akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = INT_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

ll primes[N * 10];

void sieve() {
	primes[1] = 1;

	for (int i = 2; i * i <= N * 10; i++) {
		if (primes[i] == 0) {
			for (int j = 2 * i; j <= N * 10; j += i) {
				primes[j] = 1;
			}
		}
	}
}


int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;
	sieve();
	// cout << primes[7] << endl;
	while (tc--) {

		ll n, m, l, r;
		ll i, j;
		ll  y;

		ll x;

		cin >> n;

		ll A[n];

		for (i = 0; i < n; i++) cin >> A[i];

		map<ll, ll> mp;

		ll mx = 0;
		for (i = 0; i < n; i++) {
			mp[A[i]]++;
			mx = max(mx, A[i]);
		}
		// cout << mx << endl;
		ll ans = 0;
		for (auto i : mp) {
			ll num = i.F;
			if (mp[num] > 1) {
				mp[num] = 0;
			}

			for (j = 2 * num; j <= mx; j += num) {

				if (mp.count(j) == 1) {
					mp[j] = 0;
				}
			}
			// cout << i.S << endl;
		}


		for (auto i : mp) {
			// cout << i.S << endl;
			ans += i.S;
		}

		cout << ans << endl;




	}
}


Measured memory_bytes: 33192
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int N = 1e5+10;

using namespace std;

main()
{
    fast;
    int h,w,i;
    cin>>h>>w;
    string s;
    for (i=0;i<w+2;i++)
        cout<<'#';
    cout<<endl;
    for (i=0;i<h;i++)
    {
        cin>>s;
        s='#'+s+'#';
        cout<<s<<endl;
    }
    for (i=0;i<w+2;i++)
        cout<<'#';
    cout<<endl;
}

Measured memory_bytes: 256
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')


n = int(input())
ans = 0
p = 2
while n > 1:
    cnt = 0
    cntcnt = 1
    while n % p == 0 and n > 0:
        n  = n // p
        cnt += 1
        if cnt == cntcnt:
            ans += 1
            cnt = 0
            cntcnt += 1
    if n <= 1:
        break
    # next prime
    if p == 2:
        p = 3
    else:
        p += 2
        
        is_prime = False
        while not is_prime:
            if n % p != 0:
                p += 2
                if p*p > n:
                    p = n
                    break
                continue
            i = 5
            is_prime = True
            while (i * i <= p):
                if (p % i == 0) or (p % (i+2) == 0):
                    is_prime = False
                    break
                i += 6
            if not is_prime:
                p += 2
                

    
print(ans)


Measured memory_bytes: 85644
#include <bits/stdc++.h>
using namespace std;
const int N=1005;
int sx,sy;
int dx,dy;
int n,m;
string s[N];
bool vis[N][N];
int Dx[]={1,-1,0,0};
int Dy[]={0,0,1,-1};
bool valid(int x,int y)
{
    return x>=0&&x<n&&y>=0&&y<m&&s[x][y]=='.';
}
int bfs()
{
    deque< pair<int, pair<int,int> > >q;
    q.push_back({0,{sx,sy}});
    while(!q.empty()) {
        int d = q.front().first, x = q.front().second.first, y = q.front().second.second;
        q.pop_front();
        if (vis[x][y]) continue;;
        vis[x][y] = 1;
        //cout<<x<<" "<<y<<endl;
        if(x==dx&&y==dy) return d;
        for (int i = 0; i < 4; i++)
            if (valid(x + Dx[i], y + Dy[i]))
                q.push_front({d, {x + Dx[i], y + Dy[i]}});

        for(int i=-2;i<=2;i++)
            for(int j=-2;j<=2;j++)
                if(valid(x+i,y+j))
                    q.push_back({d + 1, {x + i, y + j}});

    }
    return -1;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m;
    cin>>sx>>sy;
    cin>>dx>>dy;
    sx--;sy--;dx--;dy--;
    for(int i=0;i<n;i++)
        cin>>s[i];
    cout<<bfs()<<endl;

    return 0;
}


Measured memory_bytes: 7124
#include<iostream>
#include<stdio.h>
#include<cmath>

using namespace std;

#define EPS 1e-5

struct point{
	double x;
	double y;
};
struct line{
	double a; // 傾き
	double b; // 切片
};

int recog_point_place( const point& a , const point&b , const point& c );
bool get_line( const point& a , const point& b , line *a_b );

int main(void)
{
	point a, b, c, p;
	int input;

	while(1)
	{
		cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> p.x >> p.y;
		if( cin.eof() ) break;

		int result_ab_c = recog_point_place( a , b , c );
		int result_ab_p = recog_point_place( a , b , p );
		int result_bc_a = recog_point_place( b , c , a );
		int result_bc_p = recog_point_place( b , c , p );
		int result_ca_b = recog_point_place( c , a , b );
		int result_ca_p = recog_point_place( c , a , p );

		if( result_ab_c == result_ab_p && result_bc_a == result_bc_p && result_ca_b == result_ca_p ) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

int recog_point_place( const point& a , const point& b , const point& c )
{
	line a_b;

	bool result = get_line( a , b , &a_b );
	if( result == false )
	{
		if( (a.x + b.x)/2 < c.x ) return 1; // 点が直線より右にある場合に1をリターン
		else return 0;
	}
	else if( result == true )
	{
		if( c.y > a_b.a * c.x + a_b.b ) return 1; // 点が直線より上にある場合に1をリターン
		else return 0;
	}

}

bool get_line( const point& a , const point& b , line *a_b )
{
	if( fabs(a.x - b.x) < EPS )
	{
		return false;
	}
	else
	{
		a_b->a = (a.y - b.y) / (a.x - b.x);
		a_b->b = a.y - a_b->a * a.x;

		return true;
	}
}

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

int h, w;
char field[100][100];
string used[100][100];

string ans;

int vx[2] = {0, 1}, vy[2] = {1, 0};

bool comp(string s1, string s2){
	if(s1 == s2)return false;
	if(s1.size() < s2.size())return true;
	else if(s1.size() > s2.size())return false;
	else{
		//今のと比較
		for(int i = 0; i < s1.size(); i++){
			if(s2[i] > s1[i]){
				return true;
			}else if(s2[i] < s1[i]){
				return false;	
			}
		}
	}
}

int main(){
	while(1){
		cin >> w >> h;
		if(h + w == 0)break;
		
		for(int i = 0; i < h; i++)for(int j = 0; j < w; j++)used[i][j] = "";


		for(int i = 0; i < h; i++)for(int j = 0; j < w; j++)
			cin >> field[i][j];

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(field[i][j] >= '0' && field[i][j] <= '9'){
					if(used[i][j] == ""){
						if(field[i][j] == '0')continue;
						used[i][j] += field[i][j];
						if(comp(ans, used[i][j]))ans = used[i][j];

					}
					for(int k = 0; k < 2; k++){
						int nx = i + vx[k], ny = j + vy[k];

						if(nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
						if(field[nx][ny] >= '0' && field[nx][ny] <= '9'){
						if(comp(used[nx][ny], used[i][j] + field[nx][ny])){
							used[nx][ny] = used[i][j] + field[nx][ny];
							if(comp(ans, used[nx][ny]))ans = used[nx][ny];
						}
					}
					}
				}
			}
		}

		cout << ans << endl;

		ans = "";
		

	}
	return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> num(N);
  int road;
  while(cin >> road) num.at(road-1)++;
  rep(i, N) cout << num.at(i) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;  
ll MOD = 1e9 + 7;

int main() 
{ 
    FIO
    int t;
    t = 1;
    while(t--)
    {
        ll a,b;
        cin >> a >> b;

        cout << a*b << endl;
    }
    return 0; 
}

Measured memory_bytes: 3636
#include<iostream>
    using namespace std;
    int main(){
     int m,n,f=0;
     char a[51][51],b[51][51];
     cin>>n>>m;
     for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)cin>>a[i][j];
     for(int i=0;i<m;i++)
      for(int j=0;j<m;j++)cin>>b[i][j];
                      
     for(int i=0;i<n;i++){/*bの左上と一致する場所を調べる*/
      if(f==1)break;
      for(int j=0;j<n;j++){
       if(f==1)break;
       if(a[i][j]==b[0][0]){/*一致した*/
        int f2=0;
        if(i+m<=n&&j+m<=n)
         for(int l=0;l<m;l++){/*ｂの画像と一致するかどうか*/
          if(f2==1)break;
          for(int k=0;k<m;k++)
           if(a[i+l][j+k]==b[l][k])f=1;
           else if(a[i+l][j+k]!=b[l][k]){f=0;f2=1;break;}
          }
        }
      }
     }   
     if(f==1)cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
     return 0;
    }

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

using namespace std;
typedef long long ll;

const int N = 200'010;
int a[N], b[N];
int n, m, k;

int main() {
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < m; i++) scanf("%d", &b[i]);
    ll r = 0;
    int j = 0;
    while (j < m && r + b[j] <= k) {
        r += b[j], j++;
    }
    int ans = j;
    ll l = 0;
    j--;
    for (int i = 0; i < n; i++) {
        l += a[i];
        while (j >= 0 && r + l > k) {
            r -= b[j], j--;
        }
        if (r + l <= k) ans = max(ans, i + j + 2);
        else break;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 5384
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
X = l()
x = sorted(X)
l = x[N//2-1]
u = x[N//2]
for i in range(N):
    if X[i] >= u:
        print(l)
    else:
        print(u)

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  ll N;
  cin>>N;
  ll ans(0);
  for(int i(1);i<=N;i++){
    ll n = N/i;
    ll tmp = n*(2*i+(n-1)*i)/2;
    //cout << tmp << endl;
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
typedef long long ll;
using namespace std;

int main(){
    int n;cin>>n;
    ll ans=0;
    vector<ll> a(n+1);
    for(int i=1;i<n+1;i++){
        ll b;cin>>b;
        a[i]=i-b;
    }
    vector<ll> aa(n+1);
    aa=a;
    sort(aa.begin(),aa.end());
    for(int i=1;i<n+1;i++){
        ll c=i-a[i]+i;
        if(lower_bound(aa.begin(),aa.end(),c)!=aa.end()){
            ans+=upper_bound(aa.begin(),aa.end(),c)-lower_bound(aa.begin(),aa.end(),c);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6416
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp3
{

    class Program
    {
        static void Main(string[] args)
        {
            string s = (Console.ReadLine());
            bool bad = false;

            for (int i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (s[i] == 'L')
                    {
                        Console.WriteLine("No");
                        bad = true;
                        return;
                    }
                }
                if (i % 2 == 1)
                {
                    if (s[i] == 'R')
                    {
                        Console.WriteLine("No");
                        bad = true;
                        return;
                    }
                }
            }
            if (bad == false)
            {
                Console.WriteLine("Yes");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    // int T;
    // cin >> T;
    // while(T){
    //     int n;
    //     cin >> n;
        
    //     T--;
    // }
    int a,b,c,k;
    cin >>a>>b>>c>>k;
    int sum = 0;
    if(k > a)
    sum += a;
    else{
    sum += k;
    cout << sum;
    return 0;
    }
    k = k - a;
    if(k>b)
    sum += 0;
    else{
    cout << sum;
    return 0;
    }
    k = k - b;
    sum -= k;
    cout << sum;
    return 0;
}









Measured memory_bytes: 3616
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Vector as V


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> [Int] -> Int
solve n bs = let
    bV = V.fromList bs
    getA 1 = bV V.! 0
    getA i = if i == n then  bV V.! (n - 2) else min (bV V.! (i -1)) (bV V.! (i - 2))
    as = getA <$> [1..n]
    in
        sum as

main = do
    n <- readInt
    bs <- readInts
    print $ solve n bs

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

int main()
{
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    if((s1[s1.size() - 1] == s2[0]) && (s2[s2.size() - 1] == s3[0])){
        cout << "YES";
    }else{
        cout << "NO";
    }
}

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

ll A, B;

void input(){
  cin >> A >> B;
}

void solve(){
  input();
  ll ans;
  if(A > 9 || B > 9){
    ans = -1;
  } else {
    ans = A*B;
  }
  cout << ans << endl;
}

int main(){
  solve();
  return 0;
}

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

int n;
int A[100];

int solve(int i,int m){
        if(m==0)return 1;

    if(i>=n)return 0;

    int res ;
    if(solve(i+1,m) || solve(i+1,m-A[i]))res=1;
    else res=0;
    return res;
    
    
}



int main(){
    int q,m;
    cin>>n;
    for(int i=0;i<n;i++)cin>>A[i];
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>m;
        if(solve(0,m))cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    
    return 0;
    
}





Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define MOD 1'000'000'007

#define N 512345
int n; 
int a[N];
int b[N]={};
map<int, vector<int>> mp;
vi v;
ll dp[N][2];

ll chk(int x, int y){
	v.clear();
	vi u = mp[x];
	REP(i, (int)u.size()-1){
		v.EB(b[u[i+1]]-b[u[i]]);
	}
	dp[v.size()][0]=0;
	dp[v.size()][1]=1;
	for(int i=v.size()-1; i>=0; i--){
		dp[i][0] = dp[i+1][0] + dp[i+1][1]*v[i];
		dp[i][0] %= MOD;
		dp[i][1] = y + dp[i+1][0] + dp[i+1][1]*(v[i]+1);
		dp[i][1] %= MOD;
	}
	DEBUG("chk(%d)\n", x);
	REP(i, (int)v.size()+1) DEBUG("%2d ", i); DEBUG("\n");
	REP(i, (int)v.size())   DEBUG("%2d ", v[i]); DEBUG("\n");
	REP(i, (int)v.size()+1) DEBUG("%2lld ", dp[i][0]); DEBUG("\n");
	REP(i, (int)v.size()+1) DEBUG("%2lld ", dp[i][1]); DEBUG("\n");
	return dp[0][1];
}

int main(){
	scanf("%d", &n);
	REP(i, n) scanf("%d", a+i);
	FOR(i, 1, n) a[i]^=a[i-1];
	REP(i, n) b[i+1]=b[i]+(a[i]==0?1:0);
	REP(i, n) if(a[i]) mp[a[i]].EB(i);

	REP(i, n) DEBUG("%2d ", i); DEBUG("\n");
	REP(i, n) DEBUG("%2d ", a[i]); DEBUG("\n");

	ll ans = 0;
	if(a[n-1]){
		ans+=chk(a[n-1], 0);
		ans%=MOD;
	}else{
		for(auto p:mp){
			ans+=chk(p.first, 1);
			ans%=MOD;
		}
		ll pw = 1;
		REP(i, b[n]-1) pw*=2, pw%=MOD;
		ans+=pw;
		ans%=MOD;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 37504
#include<iostream>  
#include<cstdlib>  
#include<string>  
#include<ctime>  
#include<cstdio>
#include<algorithm>
using namespace std;
long long a[100005] = { 0 };
long long b[100005] = { 0 };
long long x[100005] = { 0 };
long long v[100005] = { 0 };
 int main()
{
	 long long n, c,ans=0;
	 cin >> n >> c;
	 for (int i = 1; i <= n; i++)
	 {
		 cin >> x[i] >> v[i];
	 }
	 x[n + 1] = c;
	 b[n + 1] = 0;
	 for (int i = 1; i <= n; i++)
	 {
		 a[i] = a[i - 1] + v[i] - (x[i] - x[i - 1]);
	 }
	 for (int i = n; i > 0; i--)
	 {
		 b[i] = b[i + 1] + v[i] - (x[i + 1] - x[i]);
	 }
	 for (int i = 2; i <= n; i++)
	 {
		 a[i] = max(a[i - 1], a[i]);
	 }
	 for (int i = n-1; i > 0; i--)
	 {
		 b[i] = max(b[i + 1], b[i]);
	 }
	 for (int i = 1; i <= n; i++)
	 {
		 ans = max(ans, a[i]);
		 ans = max(ans, b[i]);
		 ans = max(ans,a[i]+ b[i + 1]-x[i]);
		 ans = max(ans, a[i - 1] + b[i] - (c - x[i]));
	 }
	 cout << ans << endl;
	return 0;
}

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

typedef long long ll;

const int mod = 1e9 + 7;
const int MN = 100010;

int N;
ll A, B;
ll S[MN];
int psum[MN], dp[MN];

int calc(int l, int r) {
    if(l > r) return 0;
    return psum[r] - (l? psum[l - 1] : 0);
}

struct Fenwick {
    vector<int> tree;
    void init() {
        tree = vector<int>(MN + 1, 0);
    }
    void upd(int idx, int val) {
        for(int i = idx + 1; i <= MN; i += (i & -i)) tree[i] += val, tree[i] %= mod;
    }
    int quer(int a) {
        int ret = 0;
        for(int i = a + 1; i >= 1; i -= (i & -i)) ret += tree[i], ret %= mod;
        return ret;
    }
    int quer(int a, int b) {
        if(a > b) return 0;
        return (quer(b) + mod - quer(a - 1)) % mod;
    }
} fw;

int main() {
    scanf("%d %lld %lld", &N, &A, &B);
    if(A > B) swap(A, B);

    for(int i = 0; i < N; i++) {
        scanf("%lld", &S[i]);
    }

    for(int i = 0; i < N - 2; i++) {
        if(S[i + 2] - S[i] < A) {
            printf("0");
            return 0;
        }
    }

    for(int i = 1; i < N; i++) {
        psum[i] = S[i] - S[i - 1] < A;
        psum[i] += psum[i - 1];
    }

    fw.init();
    dp[N] = 1;
    fw.upd(N, dp[N]);

    int pos1 = N;
    int pos2 = N;
    for(int i = N - 1; i >= 0; i--) {
        while(pos1 >= 1 && S[pos1 - 1] - S[i] >= B) pos1--;
        while(pos2 >= 0 && calc(i + 2, pos2 - 1)) pos2--;
        dp[i] = fw.quer(pos1, pos2);
        fw.upd(i, dp[i]);
    }
    int ans = 0;
    for(int i = 0; i <= N; i++) {
        if(!calc(0, i - 1)) ans += dp[i], ans %= mod;
    }
    printf("%d", ans);
}


Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

using namespace std;

map<string, int> cnt;
map<string, int>::iterator it;

int n, maxm = 0;

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    cnt[s]++;
    maxm = max(maxm, cnt[s]);
  }
  for (it = cnt.begin(); it != cnt.end(); it++) {
    if (it->second == maxm) {
      cout << (*it).first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 25216
n = int(input())
s = "E"+input()+"W"
lw = [0]*n
re = [0]*n
for i in range(1,n):
    if s[i] == "W":
        lw[i] = lw[i-1] + 1
    else:
        lw[i] = lw[i-1]
    if s[-i-1] == "E":
        re[-i-1] = re[-i]+1
    else:
        re[-i-1] = re[-i]
ans = [lw[i]+re[i] for i in range(n)]
print(min(ans))


Measured memory_bytes: 29716
officalhouse = Array.new( 4*3*10, 0 )

n = gets.to_i
n.times {
	b, f, r, v = gets.split( " " ).map { | val | val.to_i }
	bfr = (b-1)*30+(f-1)*10+(r-1)
	officalhouse[bfr] = officalhouse[bfr] + v;
}

for b in ( 0 .. 3 )
	for f in ( 0 .. 2 )
		for r in ( 0 .. 9 )
			print( " #{officalhouse[ b*30 + f*10 + r ]}" )
		end
		print( "\n" )
	end
	print( "####################\n" ) if b < 3
end

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, i = 0, j, a[9], x[n];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8] >> n;

  while(i < n){
    cin >> x[i];
    j = 0;
    
    while(j < 9){
      if(x[i] == a[j]){
        a[j] = 101;
      }
      j++;
    }    
    i++;
    }
  if((a[0] == 101 && a[1] == 101 && a[2] == 101) || (a[3] == 101 && a[4] == 101 && a[5] == 101) || (a[6] == 101 && a[7] == 101 && a[8] == 101) || (a[0] == 101 && a[3] == 101 && a[6] == 101) || (a[1] == 101 && a[4] == 101 && a[7] == 101) || (a[2] == 101 && a[5] == 101 && a[8] == 101) || (a[0] == 101 && a[4] == 101 && a[8] == 101) || (a[2] == 101 && a[4] == 101 && a[6] == 101)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdint>
#include<cstdio>

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

template<int BUFSIZE>
struct ans_buf {
  char buf[BUFSIZE];
  int i;
  ans_buf(): i(0) {}
  void putZ(uint64_t v, char delim='\n') {
    uint64_t k = 1;
    while(k <= v/10) k*=10;
    for(; k>0; v%=k, k/=10) buf[i++] = (v/k)+'0';
    buf[i++] = delim;
  }
  void out() { std::fwrite(buf, 1, i, stdout); }
};

int const MAXN = 1e5;
int const MAXA = 6.8e5;
int B[MAXN];

int main() {
  int N = getZ();
  for(int i = 0; i < N; ++i) B[getZ()-1] = i+1;
  ans_buf<MAXA> buf;
  for(int i = 0; i < N-1; ++i) buf.putZ(B[i], ' ');
  buf.putZ(B[N-1]);
  buf.out();
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
ll dp[maxn] , a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n ; cin >> n;
    for (int i = 1 ; i <= n ; i++) cin >> a[i];
    for (int i = 1 ; i <= n ; i++){
        dp[i] = max (dp[i - 1] , a[i]);
    }
    ll ans = 0;
    for (int i = 1 ; i <= n ; i++) {
        ans += max (0ll , dp[i - 1] - a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6716
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long[] a = new long[5];
        for (int i = 0; i < 5; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a);
        long min = a[0];
        long ans = (long) (Math.ceil(n / (min + 0.0)) + 4);
        System.out.println(ans);
    }
}

Measured memory_bytes: 35920
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int a,b;
	cin>>a>>b;
	if(a%2==0||b%2==0){
		cout<<"No";
	}else{
		cout<<"Yes";
	}
}

Measured memory_bytes: 256
R,G,B,N = list(map(int,input().rstrip().split()))

ans = 0
for r in range(0,N+1,R):
    for g in range(0,N+1,G):
        if r+g > N:
            break
        if (N-r-g)%B == 0:
            ans += 1
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,m;
    cin>>n>>m;
    vector<int> p(m+5,0);
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int a;
            cin>>a;
            p[a]++;
        }
    }
    int ans=0;
    rep(i,m+5){
        if(p[i]==n) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int h1, h2, k1, k2, a, b, c, d;
    cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
    string ans;
    int hp = h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d;
    int kp = k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d;
    if (hp > kp) ans = "hiroshi";
    else if (hp < kp) ans = "kenjiro";
    else ans = "even";
    cout << ans << endl;
}


Measured memory_bytes: 3228
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            //var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();

            var c = new StringBuilder(ReadLine());

            var left = 0;
            var right = n - 1;
            var count = 0;
            while(left < right)
            {
                if(c[left] == 'W' && c[right] == 'R')
                {
                    c[left] = 'R';
                    c[right] = 'W';
                    left++;
                    right--;
                    count++;
                }
                else
                {
                    if(c[left] == 'R')
                    {
                        left++;
                    }
                    if(c[right] == 'W')
                    {
                        right--;
                    }
                }
            }

            for(var i = 1; i < n; i++)
            {
                if(c[i - 1] == 'W' && c[i] == 'R')
                {
                    c[i - 1] = 'R';
                    count++;
                }
            }

            WriteLine(count);
        }
    }
}


Measured memory_bytes: 28672
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

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

	if (A + B + 1 >= C) {
		cout << B + C << endl;
	}
	else {
		cout << A + B + 1 + B << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>

const static int MAX = 100;
const static int INF = 1001001001;
int A[MAX][MAX];
int d[MAX];
int p[MAX];
int color[MAX];

int main(void){
    int n, tmp, u, mincost, sum;
    std::cin >> n;
    for(int i = 0; i < n; i++){
	for(int j = 0; j < n; j++){
	    std::cin >> tmp;
	    if(tmp == -1) A[i][j] = INF;
	    else A[i][j] = tmp;
	}
    }

    d[0] = 0;
    for(int i = 1; i < n; i++){
	d[i] = INF;
    }
    p[0] = -1;
    for(int i = 0; i < n; i++){
	color[i] = 0;
    }

    while(true){
	mincost = INF;
	for(int i = 0; i < n; i++){
	    if(mincost > d[i] && color[i] == 0){
		mincost = d[i];
		u = i;
	    }
	}
	color[u] = 1;

	if(mincost == INF) break;

	for(int i = 0; i < n; i++){
	    if(d[i] > A[u][i] && color[i] == 0){
		d[i] = A[u][i];
		p[i] = u;
	    }
	}
    }

    sum = 0;
    for(int i = 0; i < n; i++){
	color[i] = 0;
    }
    for(int i = 0; i < n; i++){
	int cur = i;
	while(p[cur] != -1 && color[cur] == 0){
	    sum += A[p[cur]][cur];
	    color[cur] = 1;
	    cur = p[cur];
	}
    }
    std::cout << sum << std::endl;



    return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )
#define SORT(x) sort(x.begin(), x.end())

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    int N; cin >> N;
    int a[100001] = {0};
    int cnt = 0;
    rep (i, N) {
        int b; cin >> b;
        if (b > N) {
            cnt++;
        } else {
            a[b]++;
        }
    }

    int ans = 0;
    REP (i, 1, N + 1) {
        if (i < a[i]) {
            ans += a[i] - i;
        } else if (i > a[i]) {
            ans += a[i];
        }
    }
    ans += cnt;
    COUT(ans);
}

Measured memory_bytes: 640
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  int tmp;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      int cnt = 0;
      for (int j = s.size() - 1; j > i; j--) {
        if (s[j] == 'Z') {
          cnt = j - i + 1;
          break;
        }
      }
      if (cnt > ans) ans = cnt;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
typedef pair<ll,ll> pll;
pll pmin[4],v[NMAX];
ll c[4]={INT_MIN,INT_MIN,INT_MIN,INT_MIN},mul[2]={1,-1};
ll manhattan(pll a, pll b){
    return abs(a.first-b.first)+abs(a.second-b.second);
}
int main()
{
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
        for(ll j=0;j<4;j++){
            ll d=v[i].first*mul[j&1]+v[i].second*mul[j<2];
            if(d>c[j]){
                c[j]=d;
                pmin[j]=v[i];
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<4;j++){
            ans=max(ans,manhattan(v[i],pmin[j]));
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6676
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n, m, matrix[110][110];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    rep(i, 0, n) rep(j, 0, m) cin >> matrix[i][j];
    rep(i, 0, n) {
        int sum = 0;
        rep(j, 0, m) {
            sum += matrix[i][j];
        }
        matrix[i][m] = sum;
    }
    erep(i, 0, m) {
        int sum = 0;
        erep(j, 0, n) {
            sum += matrix[j][i];
            // cout << sum << endl;
        }
        matrix[n][i] = sum;
    }
    erep(i, 0, n) {
        erep(j, 0, m) {
            printf("%d", matrix[i][j]);
            if (j != m) printf(" "); 
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3212
/**
 *   
 *   Date: 01 September 2019
 *   Time: 17:45:06
**/
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1000000007;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n,mx=1;
	cin>>n;
	ll br[n+2],ar[n+2];
	for(ll i=1;i<=n;i++)
	{
		cin>>ar[i];
	}
	br[1]=1;
	for(ll i=2;i<=n;i++)
	{
		if(ar[i]<=ar[i-1])
			br[i]=br[i-1]+1;
		else
			br[i]=1;
		mx=max(mx,br[i]);
	}
	mx-=1;
	cout<<mx<<endl;

return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int N, A, B, C;
vector<int> l;

int ref(int depth, int a, int b, int c){
    if(depth==N){
        if(!a || !b || !c){
            return 99999;
        }
        return abs(a-A)+abs(b-B)+abs(c-C);
    }
    
    int ref1 = ref(depth+1, a, b, c);
    int ref2 = ref(depth+1, a+l[depth], b, c)+(a==0 ? 0: 10);
    int ref3 = ref(depth+1, a, b+l[depth], c)+(b==0 ? 0: 10);
    int ref4 = ref(depth+1, a, b, c+l[depth])+(c==0 ? 0: 10);
    
    return min({ref1, ref2, ref3, ref4});
}

int main(){
    cin >> N >> A >> B >> C;
    l.resize(N);
    for(int i=0; i<N; i++){
        cin >> l[i];
    }
    cout << ref(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

int n;
long long X, Y;
int mod = 1e9 + 7;

int main() {
    cin >> X >> Y;
    cout << (max(X, Y) - min(X, Y) > 1? "Alice": "Brown") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

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

int main(void)
{
  int a, b;

  while (scanf("%d%d", &a, &b) != EOF){
    if (a < b){
      a ^= b;
      b ^= a;
      a ^= b;
   }
   printf("%d %d\n", gcd(a, b), (a / gcd(a, b)) * b);
 }

 return (0);
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

const MaxBufferSize = 2*100000000 + 1

func NextStr() string {
	scanner.Scan()
	return scanner.Text()
}

func NextInt() int {
	i, _ := strconv.Atoi(NextStr())
	return i
}

func main() {
	buf := make([]byte, 10000)
	scanner.Buffer(buf, MaxBufferSize)
	scanner.Split(bufio.ScanWords)
	n := NextInt()

	var ans int

	pre := -1
	for i := 0; i < n; i++ {
		next := NextInt()
		step := 0
		if pre > next {
			step = pre - next
		}
		ans += step
		pre = next + step
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5056
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    if (n == m) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <cstdio>

using namespace std;

int key[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int M1, D1, M2, D2;

int main()
{
    scanf("%d%d%d%d", &M1, &D1, &M2, &D2);
    if (key[M1] == D1)
    {
        printf("1\n");
    }
    else
    {
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 128
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#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(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;

signed main() {
int A,B,C=6;
cin >> A >> B;
C = C - A - B;
answer(C);
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <list>
#include <math.h>
#include <string>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 // 1e9+7(prime number)
#define INF 1000000000 // 1e9

using namespace std;
typedef long long ll;

int main() {
	while (1) {
		int h, r, score, count, num;
		bool erased;
		vector<list<int> > mp(5);
		vector<list<int>::iterator> itrs(5);

		score = 0;
		count = 0;
		cin >> h;
		if (h==0) break;
		vector<vector<int>> input(h);
		REP(j, h) {
			REP(k, 5) {
				cin >> r;
				input[j].push_back(r);
			}
		}

		REP(k, 5) {
			REP(j, h) { mp[k].push_front(input[j][k]); }
		}

		while (1) {
			// 各行を見て点数を計算
			REP(i, 5) itrs[i] = mp[i].begin();
			REP(j, h) {
				num = -1;
				REP(k, 5) {
					/*debug(j);
					debug(k);
					debug(*itrs[k]);*/
					if (j < mp[k].size()) {
						if (*itrs[k] == num && num>0)
							count++;
						else {
							num = *itrs[k];
							count = 1;
						}
						if (count >= 3) {
							*itrs[k] = -1;
							if (count == 3) {
								score += 3 * num;
								itrs[k - 1]--;
								itrs[k - 2]--;
								*itrs[k - 1] = -1;
								*itrs[k - 2] = -1;
								itrs[k - 1]++;
								itrs[k - 2]++;
							} else {
								score += num;
							}
							/*debug(j);
							debug(num);
							debug(count);
							debug(score);*/
						}
						if (itrs[k] != mp[k].end()) itrs[k]++;
					}
				}
			}

			erased = false;
			REP(i, 5) itrs[i] = mp[i].begin();
			REP(j, h) {
				REP(k, 5) {
					//debug(j);
					//debug(k);
					if (itrs[k] != mp[k].end()) {
						if (*itrs[k] < 0) {
							erased = true;
							//debug(*itrs[k]);
							itrs[k] = mp[k].erase(itrs[k]);
							mp[k].push_back(0);
						} else {
							//debug(*itrs[k]);
							++itrs[k];
						}
					}
					//				if (*itrs[k] != NULL)debug(*itrs[k]);
				}
				//cout << "--------------------------" << endl;
			}
			//cout << score << endl;
			//cout << "--------------------------" << endl;
			if (!erased) break;
			REP(i, 5) if (mp[i].empty()) break;
		}

		cout << score << endl;
		/*if (score==90){
			debug(po);
			debug(score);
			cout << h << endl;
			REP(j,h){
				REP(k,5) printf("%d ", input[j][k]);
				cout << endl;
			}
		}
		po++;*/
		
	}
	return 0;
}



Measured memory_bytes: 3120
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

void in(){} template<typename Head,typename... Tail> void in(Head&& head,Tail&&... tail){cin>>head;in(forward<Tail>(tail)...);}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  ll a,b,c,d;
  in(a,b,c,d);
  cout<<max(max(a*d,b*c),max(a*c,b*d))<<endl;
}

Measured memory_bytes: 3640
#pragma GCC optimize "O3"

#define F first
#define S second

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

constexpr int N = 100000;

int n, luc, ldc, ruc, rdc, lc, rc;
map<LL, set<LL>> pts;
unordered_map<int, LL> lans, rans;
LL lux[N], luy[N], rux[N], ruy[N];
LL ldx[N], ldy[N], rdx[N], rdy[N];
LL larea, rarea;
vector<pair<LL, LL>> v;

inline LL crss(LL x0, LL y0, LL x1, LL y1, LL x2, LL y2) {
  return (x1-x0) * (y2-y0) - (x2-x0) * (y1-y0);
}
void build(LL x, LL y, int &cc, LL *xx, LL *yy, int f) {
  while(cc >= 2 && crss(xx[cc-2], yy[cc-2], xx[cc-1], yy[cc-1], x, y) * f >= 0) {
    --cc;
    v.emplace_back(xx[cc], yy[cc]);
  }
  v.emplace_back(xx[cc-1], yy[cc-1]);
  xx[cc] = x;
  yy[cc] = y;
  ++cc;
}
LL calc_area() {
  if(v.size() <= 2)
    return 0;
  v.push_back(v[0]);
  LL rtn = 0;
  for(size_t i = 1; i < v.size(); ++i)
    rtn += crss(0, 0, v[i-1].F, v[i-1].S, v[i].F, v[i].S);
  return abs(rtn);
}
int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    LL x, y; scanf("%lld %lld", &x, &y);
    pts[x].insert(y);
  }
  lans[lc] = 0;
  for(auto it = pts.begin(); it != pts.end(); ++it) {
    const LL &x = it->F;
    for(LL y : it->S) {
      v.clear();
      build(x, y, luc, lux, luy,  1);
      reverse(v.begin(), v.end());
      v.pop_back();
      build(x, y, ldc, ldx, ldy, -1);
      v.emplace_back(x, y);
      larea += calc_area();
    }
    lc += (it->S).size();
    lans[lc] = larea;
  }
  rans[rc] = 0;
  for(auto it = pts.rbegin(); it != pts.rend(); ++it) {
    const LL &x = it->F;
    for(LL y : it->S) {
      v.clear();
      build(x, y, ruc, rux, ruy,  1);
      reverse(v.begin(), v.end());
      v.pop_back();
      build(x, y, rdc, rdx, rdy, -1);
      v.emplace_back(x, y);
      rarea += calc_area();
    }
    rc += (it->S).size();
    rans[rc] = rarea;
  }
  LL ans = LLONG_MAX;
  for(auto &it : lans)
    ans = min(ans, it.S + rans[n - it.F]);
  ans = ((ans&1) ? (ans+1)/2 : ans/2);
  printf("%lld\n", ans);
}

Measured memory_bytes: 28260
n,m = map(int,input().split())
ACcount = 0
WAcount = 0
WA = []
AC = []
for i in range(n):
  WA.append(0)
  AC.append(1)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if s == "WA":
    if WA[p-1] >= 0:
      WA[p-1] += 1
  if s == "AC":
    ACcount += AC[p-1]
    AC[p-1] = 0
    if WA[p-1] >= 0:
       WAcount += WA[p-1]
       WA[p-1] = -1
print(ACcount,WAcount)

Measured memory_bytes: 4748
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main() {
    int n, m; cin >> n >> m;
    vector<pair<int, int>> key;
    for (int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;
        int able = 0;
        for (int i = 0; i < b; i++)
        {
            int c; cin >> c;
            c--;
            able |= (1<<c);
        }
        key.emplace_back(able, a);
    }
    
    vector<int> dp(1<<n, INF);
    dp[0] = 0;
    for (int before = 0; before < (1<<n); before++)
    {
        for (int i = 0; i < m; i++)
        {
            int after = before | key[i].first;
            dp[after] = min(dp[after], dp[before]+key[i].second);
        }
        
    }
    int ans = dp.back();
    if (ans == INF) ans = -1;
    cout << ans << endl;
    
    return 0;
}

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

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

using namespace std;
using lint = long long;

int main(void)
{
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++){
        int N_x = (int)(i * 1.08);
        if(N_x == N){
            cout << i << endl;
            break;
        }
        else if(N_x > N){
            cout << ":(" << endl;
            break;
        }
    }
    return 0;
}

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

int main(){
  long long a, b, c;
  cin >> a >> b >> c;
  
  long long d = c - a - b;
  if( d > 0 ){
  	if( 4 * a * b < d * d) {
    	cout << "Yes" << endl;
 	 }else{
   		 cout << "No" << endl;
 	 }
  }else{
    cout << "No" << endl;
  }
  
}

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

int main()
{
	int N;
	int A[100005];
	int sum = 0, now = 0;
	cin >> N;

	for ( int i = 1; i <= N; i++ ) {
		cin >> A[i];
		sum += abs(A[i] - now);
		now = A[i];
	}
	sum += abs(now);

	A[0] = 0, A[N + 1] = 0;
	for ( int i = 1; i <= N; i++ ) {
		cout << sum + abs(A[i - 1] - A[i + 1]) - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) << endl;
	}
	return ( 0 );
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0;i<N;i++) cin >> H.at(i);
    int ans=0;
    int i=0;
    for(int i=0;i<N-1;i++){
        int len=0;
        while(i!=N-1){
            if(H.at(i)>=H.at(i+1)){
                i++;
                len++;
            }
            else break;
        }
        ans = max(ans,len);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))

(defun f(s)
  (loop for i from 1 to (length s) collect #\x))

(let* ((line0 (read-line nil nil)))
  (format t "~{~A~}~%" (f line0)))


Measured memory_bytes: 13284
a = [input() for i in range(2)]

n = a[0]
s = a[1]

find = "ABC"

pos = 0
count = 0

for i in range(int(n)):
    pos = s.find(find)
    if(pos == -1):
        print(str(count))
        break
    else:
        count = count + 1
        s = s[pos+1:]

Measured memory_bytes: 3064
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())

lines = defaultdict(set)
for i in range(N-1):
    u,v,w = inpl()
    u,v = u-1,v-1
    lines[u].add((v,w))
    lines[v].add((u,w))

ans = [0]*N

def dfs(s,c):
    global ans
    for t,d in list(lines[s]):
        if ans[t] == 0:
            if d%2 == 0:
                ans[t] = c
                dfs(t,c)
            else:
                ans[t] = -c
                dfs(t,-c)


dfs(0,1)
for a in ans:
    if a == -1:
        print(0)
    else:
        print(1)


Measured memory_bytes: 101808
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B>C+D){
    cout<<"Left"<<endl;
  }
  else if(A+B<C+D){
    cout<<"Right"<<endl;
  }
  else{
    cout<<"Balanced"<<endl;
  }
}
  
    
    


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

int main(){
    string keyword;
    string sentence;
    int cnt=0;
    bool check=false;
    cin>>keyword;
    while(1){
        cin>>sentence;
        if(sentence=="END_OF_TEXT"){
            break;
        }
        if(tolower(sentence[0])==keyword[0]&&sentence.length()==keyword.length()){
            for(int j=0;j<keyword.length();j++){
                if(tolower(sentence[j])==keyword[j]){
                    check=true;
                }else{
                    check=false;
                    break;
                }
            }
        }
        if(check){
            cnt++;
            check=false;
        }    
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3200