akhauriyash/Code-Regression huggingface dataset:
t[9],i=4,j;k(d){return d>10?8:d>5?7:d>1?6:5;}main(a,b){for(;~scanf("%d.%d",&a,&b)&&++t[k(a*10+b)-4*(j++%2)]||printf("%d %d\n",t[i+4],t[i])&&--i;);}

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

typedef long long ll;

ll ans = 0;

void gcd(ll a, ll b){
	if (!b){
		ans -= a;
		return;
	}
	ans += a / b * b << 1;
	gcd(b, a % b);
}

int main(){
	ll n, x;
	scanf("%lld%lld", &n, &x);
	ll y = n - x;
	if (y > x){
		std::swap(x, y);
	}
	gcd(x, y);
	ans += n;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int n_max=100001;
long long int a[n_max],b[n_max];

int main(){
    int n;
    long long int pile=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i];
    }
    for(int i=n-1; i>=0; i--){
        if(b[i]==1||(a[i]+pile)==0)continue;
        if((a[i]+pile)%b[i]==0)continue;
        pile=pile+b[i]-((a[i]+pile)%b[i]);
    }
    cout<<pile<<endl;

    return 0;
}


Measured memory_bytes: 1792
def main():
    import math
    n = int(input())
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    hakobu = min(a, b, c, d, e)
    kaisuu = math.ceil( n / hakobu)

    print(kaisuu + 4)



if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
def lcs(a, b):
    n = len(a)
    m = len(b)
    dp = [[0] * (m + 1) for _ in range(n + 1)]
 
    for i in range(n):
        for j in range(m):
            if a[i] == b[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])
 
    lcs_str = ''
    i, j = n, m
    while i >= 1 and j >= 1:
        if a[i - 1] == b[j - 1]:
            lcs_str += a[i - 1] #or b[j - 1]
            i -= 1
            j -= 1
        else:
            if dp[i - 1][j] > dp[i][j - 1]:
                i -= 1
            else:
                j -= 1
 
    return lcs_str[::-1]
 
 
s = input()
t = input()
print(lcs(s, t))

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	int N;
	cin >> N;
	bool flag = false;
	for (int i = 0; i < 30; i++) {
		for (int j = 0; j < 30; j++) {
			if (4 * i + 7 * j == N)flag = true;
		}
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
from math import sqrt

def yakusuu8(n):
    lst = []
    m = int(sqrt(n)) + 2
    for i in range(2, m):
        if n % i == 0:
            j = 1
            while True:
                if n % i == 0:
                    n //= i
                    j += 1
                else:
                    lst.append(j)    
                    break
    if n != 1:
        lst.append(2)
        
    yakusuu = 1
    for i in range(len(lst)):
        yakusuu *= lst[i]
    
    if yakusuu == 8:
        return True
    else:
        return False

n = int(input())

if n < 105:
    print(0)
    exit()

else:
    ans = 0
    for i in range(105, n + 1)[::2]:
        ans += yakusuu8(i)
    print(ans)



                
                    
        

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

int main(){
    int c[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++)
            cin >> c[i][j];
    }
    bool flg = false;
    for(int i=0; i<=c[0][0]; i++){
        int a_1 = i;
        int b_1 = c[0][0] - i;
        int a_2 = c[1][0] - b_1;
        int a_3 = c[2][0] - b_1;
        int b_2 = c[0][1] - a_1;
        int b_3 = c[0][2] - a_1;
        if(a_2<0 || a_3<0 || b_2<0 || b_3<0){
            flg = false; continue;
        }
        if((a_2+b_2==c[1][1] && a_2+b_3==c[1][2]) && (a_3+b_2==c[2][1] && a_3+b_3==c[2][2])){
            flg = true; break;
        }
    }
    if(flg) cout << "Yes" << endl;
    else    cout << "No"  << endl;
    return 0;
}

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

using namespace std;


const int MAX_N = 1000000;
int par[MAX_N];

//syokika
void init(int n){
  for(int i = 0; i < n; i++) par[i] = i;
}

//kinonewomotomeru
int root(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = root(par[x]);
  }
}

//hanntei
bool same(int x, int y){
  return root(x) == root(y);
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y) return;

  par[x] = y;
}

int main(void){

  int n, m;
  cin >> n >> m;

  vector<int> adj[n];

  //syokika
  init(n);

  //heigou
  for(int i = 0; i < m; i++){
    int s, t; cin >> s >> t;
    unite(s, t);
  }

  int q; cin >> q;

  for(int i = 0; i < q; i++){
    int s, t; cin >> s >> t;
    if(same(s, t)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  


  return 0;

}

Measured memory_bytes: 6440
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
string in;

int calc(int l,int r)
{
	int pa=0;
	for(int i = r; i >= l; --i)
	{
		if(in[i]==')') pa++;
		else if(in[i]=='(') pa--;
		else if(!pa)
		{
			if(in[i]=='+') return calc(l,i-1)+calc(i+1,r);
			if(in[i]=='-') return calc(l,i-1)-calc(i+1,r);
		}
	}
	pa=0;
	for(int i = r; i >= l; --i)
	{
		if(in[i]==')') pa++;
		else if(in[i]=='(') pa--;
		else if(!pa)
		{
			if(in[i]=='*') return calc(l,i-1)*calc(i+1,r);
			if(in[i]=='/') return calc(l,i-1)/calc(i+1,r);
		}
	}
	
	if(in[l]=='('&&in[r]==')') return calc(l+1,r-1);

	stringstream ss(in.substr(l,r-l+1));
	int res; ss>>res;
	return res;
}


int main()
{
	int n;
	cin>>n;
	while(n--) 
	{
		cin>>in;
		cout<<calc(0,in.size()-2)<<endl;
	}
  return 0;
}

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

int main(){
	int N,K;
	cin>>N>>K;
	vector<long>xp;
	vector<long>xn;
	long x;
	for(int i=0;i<N;++i){
		cin>>x;
		if(x>=0)xp.push_back(x);
		else xn.push_back(abs(x));
	}
	sort(xn.begin(),xn.end());
	long ans=400000000;
	for(int i=0;i<xn.size();++i){
		long tmp=0;
		tmp=xn[i];
		if(i==K-1){
			if(ans>tmp)ans=tmp;
			break;
		}
		else{
			tmp*=2;
			if(xp.size()>=K-i-1){
				tmp+=xp[K-i-2];
				if(ans>tmp)ans=tmp;
			}
		}
	}
	for(int i=0;i<xp.size();++i){
		long tmp=0;
		tmp=xp[i];
		if(i==K-1){
			if(ans>tmp)ans=tmp;
			break;
		}
		else{
			tmp*=2;
			if(xn.size()>=K-i-1){
				tmp+=xn[K-i-2];
				if(ans>tmp)ans=tmp;
			}
		}
	}
	cout<<ans<<endl;
}


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

int main(){
  int N, M;
  int cnt = 0;
  cin >> N >> M;

  bool h[N+1];
  long long H[N+1];
  for(int i = 1; i <= N; i++){
    cin >> H[i];
    h[i] = true;
  }


  pair<int,int> j[M+1];
  for(int i = 1; i <= M; i++){
    cin >> j[i].first >> j[i].second;
  }

  for(int i = 1; i <= M; i++){
    if(H[j[i].first] - H[j[i].second] > 0){
      h[j[i].second] = false;
    }else if(H[j[i].first] - H[j[i].second] < 0){
      h[j[i].first] = false;
    }else if(H[j[i].first] - H[j[i].second] == 0){
      h[j[i].first] = false;
      h[j[i].second] = false;
    }
  }

  for(int i = 1; i <= N; i++){
    if(h[i] == true) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 5280
N,Y = map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
        x = 10000*i + 5000*j + 1000*(N-i-j)
        if x==Y:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, y;
  cin >> N;
  y = 0;
  
  for (int i = 0; i < N; i++){
    string S; 
    cin >> S;  // P W G Y
    
    if (S == "Y") {
      y++;
    }
  }
  if (y == 0) {
    cout << "Three" << endl;
  }
  else {
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 11:36:51 2020

@author: shinba
"""

n = list(input())

if (n[0] == n[1] and n[1] == n[2]) or (n[1] == n[2] and n[2] == n[3]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define fast std::ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;

void solve(){
    int x;
    cin>>x;
    if(x==25)
    cout<<"Christmas";
    else if(x==24)
      cout<<"Christmas Eve";
    else if(x==23)
       cout<<"Christmas Eve Eve";
    else 
    cout<<"Christmas Eve Eve Eve";
}
int main()
{
    fast
    solve();
    return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    stack<char> S;
    for (int i = 0; i < s.size(); ++i) {
        if (!S.empty() && s[i] == 'T' && S.top() == 'S') S.pop();
        else S.push(s[i]);
    }
    printf("%d\n", S.size());
    return 0;
}


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

struct Point{bool high;double x,y;};
bool comp(Point a,Point b) {return (a.x==b.x ? a.y<b.y : a.x<b.x);}

Point* Intersection(Point p1,Point p2,Point p3,Point p4){
    double d = (p2.x-p1.x)*(p4.y-p3.y)-(p2.y-p1.y)*(p4.x-p3.x);
    double u = ((p3.x-p1.x)*(p4.y-p3.y)-(p3.y-p1.y)*(p4.x-p3.x))/d;
    double v = ((p3.x-p1.x)*(p2.y-p1.y)-(p3.y-p1.y)*(p2.x-p1.x))/d;
    if(d==0 || u<0 || u>1 || v<0 || v>1)return NULL;
    Point *ret = new Point();
    ret->x = p1.x+u*(p2.x-p1.x);
    ret->y = p1.y+u*(p2.y-p1.y);
    return ret;
}

int main(void){
    int N,n,o,l;
    cin>>N;
    while(N--){
        Point a,b;
        vector<Point> cross;
        cin>>a.x>>a.y>>b.x>>b.y>>n;
        rep(i,n){
            Point s,t;
            cin>>s.x>>s.y>>t.x>>t.y>>o>>l;
            Point *ret = Intersection(a,b,s,t);
            if(ret!=NULL){
                ret->high = o==l;
                cross.push_back(*ret);
            }
        }

        sort(cross.begin(),cross.end(),comp);
        int cnt=0;
        for(int i=0;i+1<(int)cross.size();i++){
            cnt+=(cross[i].high!=cross[i+1].high);
        }
        cout<<cnt<<endl;
    }

    return 0;
}

Measured memory_bytes: 1620
#include <stdio.h>
#include <string.h>

#define MAX 200001

int main()
{
	char s[MAX];
	int i, k;
	int next;

	scanf("%s", s);
	k = strlen(s);
	s[k] = '\0';


	i = 0;
	while (i<k) {
		next = i + 1;
		if (s[i] == '?') {
			s[i] = 'D';
			/*if (i + 1 == k || i == 0) {
				if (s[i - 1] == 'D')
					s[i] = 'P';
			}*/
		}
		i++;
	}

	printf("%s\n", s);

	return 0;
}

Measured memory_bytes: 1808
# coding: utf-8

N = int(input())
A = list(map(int,input().split()))
ans = float('inf')

mean = int(sum(A)/N)

for i in range(-100,101):
    cost = 0
    for j in range(N):
        cost += (i - A[j]) ** 2
    ans = min(ans, cost)

if ans == float('inf'):
    ans = 0
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
bool Prime(int x){
	for(int i=2;i*i<=x;i++)if(!(x%i))return 0;
	return 1;
}
int main(){
	int x,i;
	cin>>x;
	for(i=x;!Prime(i);i++);
	cout<<i<<endl;
}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n; cin >> n;
  ll march[5] = {};
  for(int i=0; i<n; i++){
    string a;
    cin >> a;
    if(a[0]=='M') march[0]++;
    if(a[0]=='A') march[1]++;
    if(a[0]=='R') march[2]++;
    if(a[0]=='C') march[3]++;
    if(a[0]=='H') march[4]++;
  }
  ll ans = 0;
  for(int i=0; i<3; i++){
    for(int j=i+1; j<4; j++){
      for(int k=j+1; k<5; k++){
        ans += march[i]*march[j]*march[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = defaultdict(lambda : 0)
    ans = 0
    for i, ai in enumerate(a, 1):
        num = str(ai+i)
        d[num] += 1
        ans += d[str(i-ai)]
    print(ans)
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 72660
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() 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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007




n = I()
L = LI()
left = sorted(L)[n // 2 - 1]
right = sorted(L)[n // 2]
for i in range(n):
    if L[i] <= left:
        print(right)
    else:
        print(left)


Measured memory_bytes: 86840
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    ll L;
    cin >> N;
    vector<ll> x(N);
    REP(i,N) cin >> x[i];
    vector<vector<ll>> to(40, vector<ll>(N));
    cin >> L >> Q;
    x.push_back(LINF);
    REP(i,N){
        auto itr = lower_bound(x.begin(), x.end(), x[i]+L);
        if(*itr - x[i] > L) itr--;
        to[0][i] = itr - x.begin();
    }
    REP(i,39) REP(j,N) to[i+1][j] = to[i][to[i][j]];
    while(Q--){
        int a, b;
        cin >> a >> b;
        if(a > b) swap(a,b);
        --a, --b;
        ll ans = 0;
        for(int i=39;i>=0;i--) if(to[i][a] < b){
            a = to[i][a];
            ans += 1LL << i;
        }
        cout << ans+1 << endl;
    }
}

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

ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
    stri = str(input())

    if stri == "AC":
        ac += 1
    elif stri == "WA":
        wa += 1
    elif stri == "TLE":
        tle += 1
    else:
        re += 1

print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))


Measured memory_bytes: 9200
import java.io.*;
import java.math.BigInteger;
import java.util.*;



public class Main {
	

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (2e5);
    static List<Integer>[] edges;
    
	public static void main(String[] args) throws IOException {
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		double k = Math.abs(((11*m)/2 - 30*h));
		
		if(k > 180) k = 360-k;
		//out.println(k);
		//out.print(Math.cos());
		double ans = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(k*(Math.PI/180)));
		out.print(ans);
		out.close();
	}

   
}





Measured memory_bytes: 33380
n = int(input())
s = input()
right = 0
for i in range(1, n):
    if s[i] == 'E':
        right += 1
ans = right
for i in range(1, n):
    if s[i-1] == 'W':
        right += 1
    if s[i] == 'E':
        right -= 1
    if ans > right:
        ans = right
print(ans)


Measured memory_bytes: 40816
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import GHC.Magic (oneShot)

main ::  IO ()
main = do
  Just (n,_) <- BS.readInt <$> BS.getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (<'-')) <$> BS.getLine
  print $ query as

query :: VU.Vector Int -> Int
query as = VU.minimum totalWork
  where
    totalWork = VU.zipWith (+) incWork decWork
    incWork :: VU.Vector Int
    incWork = VU.reverse $ VU.cons 0 $ VU.scanl' (+) 0 $ (`evalState` Nil)
      $ (`VU.imapM` VU.reverse incDiff) $ \i x -> state $ \ !ls ->
      if x < 0 then (0,) $! Cons (i+1) (-x) ls else consume x (i+1) ls
    decWork = VU.cons 0 $ VU.scanl' (+) 1 $ VU.map (+1) $ (`evalState` Nil)
      $ (`VU.imapM` decDiff) $ \i x -> state $ \ !ls ->
      if x < 0 then (0,) $! Cons (i+1) (-x) ls else consume x (i+1) ls
    incDiff = VU.map (*2) $ VU.zipWith surpassExp4 as (VU.tail as)
    decDiff = VU.map (*2) $ VU.zipWith surpassExp4 (VU.tail as) as

data Stack = Nil | Cons {-# UNPACK #-} !Int {-# UNPACK #-} !Int !Stack

{-# INLINE consume #-}
consume :: Int -> Int -> Stack -> (Int, Stack)
consume = loop 0
  where
    loop !acc !consumed !i0 (Cons i1 power rest)
      | consumed < power
        = (acc + consumed * (i0-i1),) $! Cons i1 (power-consumed) rest
      | otherwise = loop (acc + consumed * (i0-i1)) (consumed-power) i1 rest
    loop !acc !consumed !i0 Nil
      = (acc + consumed * i0,) $! Nil

-- minimum e with x <= 4^e * y. Assumes x,y > 0.
surpassExp4 x y = (surpassExponent x y + 1) `shiftR` 1

-- minimum e with x <= 2^e * y. Assumes 0 < x,y < 2^62.
surpassExponent :: Int -> Int -> Int
surpassExponent x y
  | xShifted <= yShifted = bitDiff
  | otherwise            = bitDiff + 1
  where
    !xlz = countLeadingZeros x
    !ylz = countLeadingZeros y
    !bitDiff = ylz - xlz
    !xShifted = x `shiftL` (xlz - 2)
    !yShifted = y `shiftL` (ylz - 2)


Measured memory_bytes: 32124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 100 + 9, M = 1e5 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7, INF = 1e18 + 9;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}

int n, s, k, x, dp[M], fake[M], temp, L, R;


int main() {
//	INPUT();
	OUTPUT();
	cin >> n >> k;
	dp[0] = 1;
	for (int child = 0; child < n; child++) {
		cin >> x;
		clr(fake, 0);
		for (int used = k; used >= 0; --used) {
			temp = dp[used];
			L = used + 1;
			R = used + min(x, k - used);
			if (L <= R) {
				fake[L] = (fake[L] + temp) % MOD;
				if (R + 1 <= k) {
					fake[R + 1] = ((fake[R + 1] - temp) + MOD) % MOD;
				}
			}
		}
//		cout << child << " " << s << endl;
		s = 0;

		for (int i = 0; i <= k; ++i) {
			s = (s + fake[i]) % MOD;
			dp[i] = (dp[i] + s) % MOD;
		}

	}
	cout << dp[k];

	return 0;

}


Measured memory_bytes: 1148
#include<stdio.h>
#include<string.h>
int main(void)
{
	char o[51],e[51],s[200];
	int i,j,x,y,z;
	scanf("%s %s",o,e);
	x=strlen(o);
	y=strlen(e);
	if(x>y)	z=x;
	else	z=y;
	for(i=0;i<=z;i++){
		s[j]=o[i];
		j++;
		s[j]=e[i];
		j++;
	}
	printf("%s\n",s);
	return 0;
}
		
		
	
	

Measured memory_bytes: 128
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    N = int(readline())
    a = Counter(prime_factorize(N))

    ans = 0
    for power in a.values():
        ans += int(((1 + 8 * power) ** 0.5 - 1) / 2)

    print(ans)
    return


if __name__ == '__main__':
    main()


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	int a[n+5];
	rep(i,1,n)
	{
		cin  >> a[i];
	}
	int best = 0;
	int cur=0;
	rep(i,1,n-1)
	{
		if(a[i]>=a[i+1])
		{
			cur++;
		}
		else
		{
			best = max(cur,best);
			cur = 0;
		}
	}
	best = max(cur,best);
	cout << best << endl;
}


Measured memory_bytes: 1024
x, y, z, k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse=True)
abc = []
for i in range(min(k, x*y)):
    for j in range(z):
        abc.append(ab[i] + c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])


Measured memory_bytes: 151384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int n, k;
	cin >> n >> k;
	vi l(n);
	rep(i, n)cin >> l.at(i);
	sort(all(l));
	int ans = 0;
	reverse(all(l));
	rep(i, k) {
		ans += l.at(i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm.*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//typedef long long ll;
#define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
const int inf = 2e9;
int max(int a,int b){	if(a > b)return a; else return b; }
int min(int a, int b){	if(a < b)return a; else return b; }
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}
/*		1. Take all the inputs
		4. Whenever you do multiplication and division in the same line, beware.
*/
void solve(){
	// int main  or  int32_t main ...
	int n;
	cin >> n;
	string s;
	cin >> s;
	int rr=0,gg=0,bb=0;
	FO(i,0,n){
		if(s[i]=='R')rr++;
		else if(s[i]=='G')gg++;
		else if(s[i]=='B')bb++;
	}
	int ans = rr*gg*bb;
	int subb = 0;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;j++){
			if(i<j && i%2!=0 && j%2!=0){
				int k = (i+j)/2;
				if(s[i-1]!=s[j-1] && s[j-1]!=s[k-1] && s[k-1]!=s[i-1]){
					subb++;
					//cout << i << " " << j << " " << k << endl;
				}
			}
			else if(i<j && i%2==0 && j%2==0){
				int p = (i+j)/2;
				if(s[i-1]!=s[j-1] && s[j-1]!=s[p-1] && s[p-1]!=s[i-1]){
					subb++;
					//cout << i << " " << j << " " << p << endl;
				}
			}
		}
	}
	//cout << ans << " " << subb << endl;
	cout << ans - subb << endl;
}
/*	memset() can be used to set all values as 0 or -1 for integer data types.*/

int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(15); std::cout << std::fixed;
	int t; t = 1;
	// cin >> t;
	while(t--){ solve(); }
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

struct yku {
  int k, m;
  char t;

  bool operator<(const yku& right) const {
    return k == right.k ? m < right.m : k > right.k;
  }
};

int main() {
  int n;
  while(cin >> n) {
    if(!n) return 0;
    yku a[10] = {};
    rep(i, 0, n) {
      cin >> a[i].t;
      rep(j, 0, n - 1) {
        int b;
        cin >> b;
        if(!b) a[i].k++;
        else if(b == 1) a[i].m++;
      }
    }

    sort(a, a + n);
    rep(i, 0, n) cout << a[i].t << endl;
  }
}

Measured memory_bytes: 3168
<?php
  list($N) = explode(" ", trim(fgets(STDIN)));

  $A = explode(" ", trim(fgets(STDIN)));

  $ans = 0;
  $gcdL=[];
  $gcdL[0] = $A[0];
  for($i=0; $i<$N-2; $i++){
    $gcdL[$i+1] = gcd($gcdL[$i], $A[$i+1]);
  }

  $gcdR=[];
  $gcdR[$N-1] = $A[$N-1];
  for($i=$N-1; $i>0; $i--){
    $gcdR[$i-1] = gcd($A[$i-1], $gcdR[$i]);
  }

  $max = $gcdR[1];
  for($i=0; $i<$N-2; $i++){
    $max = max($max, gcd($gcdL[$i], $gcdR[$i+2]));
  }
  $max = max($max, $gcdL[$N-2]);

  echo $max;
  
  function gcd($a, $b){
  if($b===0){
    return $a;
  }
  return gcd($b, $a%$b);
}

Measured memory_bytes: 32056
#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);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 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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 lcm(int a,int b){return a/gcd(a, b)*b;}

ll N, M, R, r[10], g[250][250];

int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> N >> M >> R;
    rep(i, 0, R) {
        cin >> r[i];
        r[i]--;
    }
    rep(i, 0, N) rep(j, 0, N) {
        if (i != j) g[i][j] = INF;
        else g[i][j] = 0;
    }
    rep(i, 0, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        if (g[a-1][b-1] > c) {
            a--, b--;
            g[a][b] = g[b][a] = c;
        }
    }

    rep(k, 0, N) {
        rep(i, 0, N) {
            rep(j, 0, N) {
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
    ll ans = INF;
    sort(r, r+R);
    do {
        ll cur = r[0], dist = 0;
        rep(i, 1, R) {
            dist += g[cur][r[i]];
            cur = r[i];
        }
        ans = min(ans, dist);
    } while (next_permutation(r, r+R));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
A,B,C = map(int,input().split())
if A == B:
    if A != C:
        print('Yes')
    else:
        print('No')
elif A == C:
    if A != B:
        print('Yes')
    else:
        print('No')
elif B == C:
    if A != B:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc158/abc158_e.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

void insert_or_cntup(map<int, ll>& m, int key) {
  auto it = m.find(key);
  if (it != m.end()) {
    ll cnt = it->second;
    m.erase(key);
    m.emplace(key, cnt + 1);
  } else {
    m.emplace(key, 1);
  }
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, P;
  cin >> N >> P;

  string S;
  cin >> S;

  int dig = 1;
  int cur = 0;
  ll ans = 0;
  map<int, ll> modP;
  rep(i, P) { modP.emplace(i, 0); }
  modP[0] = 1;

  if (P == 2 || P == 5) {
    rep(i, N) {
      if ((S[i] - '0') % P == 0) {
        ans += i + 1;
      }
    }
  } else {
    for (int i = N - 1; i >= 0; i--) {
      int tmp = (S[i] - '0') * dig;
      cur += tmp;
      cur %= P;
      dig *= 10;
      dig %= P;

      int mod = cur % P;
      ans += modP.at(mod);
      insert_or_cntup(modP, mod);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1044
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
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)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
name = [s() for i in range(n)]
m = [i for i in name if i.startswith("M")]
a = [i for i in name if i.startswith("A")]
r = [i for i in name if i.startswith("R")]
c = [i for i in name if i.startswith("C")]
h = [i for i in name if i.startswith("H")]
ml,al,rl,cl,hl = len(m),len(a),len(r),len(c),len(h)

ans = ml*al*rl + ml*al*cl + ml*al*hl +ml*rl*cl + ml*rl*hl + ml*cl*hl + al*cl*hl + al*rl*cl + al*rl*hl + rl*cl*hl

print(ans)


Measured memory_bytes: 17872
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

def main():
    N = int(input())
    S = input()

    ans = 1
    for i in range(N-1):
        if S[i+1] != S[i]:
            ans += 1

    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9336
#include  <iostream>
#include  <vector>
#include  <algorithm>
#include  <cstdlib>


int main(void)
{
	int N;
	std::cin >> N;

	long long v[N];
	for(int i = 0; i < N; ++i)
		std::cin >> v[i];

	int ans = 0;

	for(int k = 0; k < N; ++k) {
		for(int j = 0; j < k; ++j) {
			for(int i = 0; i < j; ++i) {
				if(v[i] == v[j] || v[j] == v[k] || v[k] == v[i])
					continue;

				std::vector<long long> L{v[i], v[j], v[k]};
				std::sort(L.begin(), L.end());

				if(L[0] + L[1] > L[2])
					ans++;
			}
		}
	}

	std::cout << ans << std::endl;


	return EXIT_SUCCESS;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll  long long int
#define pb push_back
#define IO ios::sync_with_stdio(false);
typedef vector<int> vi;
#define H return 0;
#define C continue;
#define B break;
#define sec second

int main()
{

ll a;
cin>>a;
if(a<1200)
    cout<<"ABC";
else if(a<2800)
    cout<<"ARC";
else
    cout<<"AGC";

}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	string s;
	cin >> s;
	int value = 700;
	if (s[0] == 'o') {
		value = value + 100;
	}
	if (s[1] == 'o') {
		value = value + 100;
	}
	if (s[2] == 'o') {
		value = value + 100;
	}
	cout << value;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
using namespace std;
const int num = 2;
int main() {
  int n,m;
  cin >> n >>m;
  vector<vector<int>> jobs(m);

  for(int i=0; i<n; i++){ 
      int a,b;
      cin >> a>>b;
      if(a>m){
          continue;
      }
      jobs[m-a].push_back(b);
  }
  
  priority_queue<int> que;
  long long ans=0;
  for(int i=m-1; i>=0; i--){ 
      for(auto& p: jobs[i]){
          que.push(p);
      }
      if(!que.empty()){
          ans +=que.top();
          que.pop();
      }
  }

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


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

using ll = long long;
int N, M;
vector<int> Sh, St;
int sumH;
int sumT;

bool solve()
{
    for (int i = 0; i < M; ++i)
    {
        int xH = sumH - Sh[i];
        for (int j = 0; j < N; ++j)
        {
            int xT = sumT - St[j] + Sh[i];
            xH += St[j];
            if (xH == xT)
            {
                cout << St[j] << " " << Sh[i] << endl;
                return true;
            }
            xH -= St[j];
        }
    }
    return false;
}
int main(void)
{
    while (1)
    {
        cin >> N >> M;
        if (N == 0 && M == 0)
            break;
        St.resize(N);
        Sh.resize(M);

        for (int i = 0; i < N; ++i)
        {
            cin >> St[i];
        }
        for (int i = 0; i < M; ++i)
        {
            cin >> Sh[i];
        }
        sumH = accumulate(Sh.begin(), Sh.end(), 0);
        sumT = accumulate(St.begin(), St.end(), 0);
        if (!solve())
        {
            cout << "-1" << endl;
        }
    }

    return 0;
}


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

int main(){
  string str;
  int num[10][10];
  while(cin >> str){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
	num[i][j] = -1;
      }
      string tmp="";
      tmp += str[i];
      istringstream iss(tmp);
      int t = 0;
      iss >> t;
      num[0][i] = t;
    }
    for(int i=0;i<9;i++){
      for(int j=0;j<9-i;j++){
	num[i+1][j] = num[i][j]+num[i][j+1];
	if(num[i+1][j] >= 10) num[i+1][j] -= 10;
      }
    }
    cout << num[9][0] << endl;
  }
}

      

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a) (a).begin(),(a).end()
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
#define LINEY "YES\n"
#define Liney "Yes\n"
#define LINEN "NO\n"
#define Linen "No\n"

int main(){
  int N,K; cin>>N>>K;
  int r = N-K+1;
  printf("%d\n",r);
}

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

void print(set<char> S){
  for(set<char>::iterator p = S.begin(); p != S.end(); p++){
    cout << *p << " ";
  }
  cout << endl;
}

int main(){

  int N;
  cin >> N;
  int count = 0,ans = 0;

  vector<char> V;
  for(int i = 0; i < N; i++){
    char c;
    cin >> c;
    V.push_back(c);
  }

  set<char> s1;
  set<char> :: iterator p1;
  set<char> s2;
  set<char> :: iterator p2;

  for(int i = 1; i < N; i++){
    for(int j = 0; j < i; j++){
      s1.insert(V[j]);
    }
    for(int j = i; j < N; j++){
      s2.insert(V[j]);
    }
    //print(s1);
    //print(s2);

    for(p1 = s1.begin(); p1 != s1.end(); p1++){
      for(p2 = s2.begin(); p2 != s2.end(); p2++){
        if(*p1 == *p2) count++;
        //cout << *p1 << " " << *p2 << endl;
      }
    }
    ans = max(ans,count);
    count = 0;
    s1.clear();
    s2.clear();
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> vec;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin >> a >> b;
        vec.push_back(make_pair(b,a));
    }
    sort(vec.begin(),vec.end());
    ll count=0;
    bool ok=true;
    for(auto v:vec){
        count+=v.second;
        if(count>v.first){
            ok=false;
            break;
        }
    }
    cout << (ok?"Yes":"No") << endl;
    return 0;
}


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


int main() {
  
  int H, W;


  while(true){
    cin >> H >> W;
    if (H == 0 && W == 0)break;

    for (int j = 0; j < H;j++){

      if (j == 0 || j == H-1){
        for(int i = 0; i < W;i++){
          cout << "#";
        }
      } else {
        for(int k = 0; k < W;k++){
          if(k == 0 || k == W-1){
            cout << "#";
          } else {
            cout << ".";
          }
        }
      }
      
        cout << endl;
    }

    cout << endl;
}  
  


}




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

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  
  vector<vector<char>> c(H, vector<char>(W));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> c.at(i).at(j);
    }
  }
  int ans = 0;
  
  for(int tmp = 0; tmp < (1 << 6); tmp++){
    bitset<6> s(tmp);
    for(int tnp = 0; tnp < (1 << 6); tnp++){
      bitset<6> t(tnp);
      int black = 0;
      for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
          if(c.at(i).at(j) == '#' && s.test(i) && t.test(j)){
            black++;
          }
        }
      }
      
      if(black == K){
        ans++;
      }
      
      if(t.count() == W){
        break;
      }
    }
    if(s.count() == H){
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3592
import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		int sx=sc.nextInt(),sy=sc.nextInt(),tx=sc.nextInt(),ty=sc.nextInt();
		int uc=0,rc=0,sx1=sx,sy1=sy;List<Character> list=new ArrayList<Character>();
		while(sy1<ty)
		{
			list.add('U');uc++;sy1++;
		}
		while(sx1<tx)
		{
			list.add('R');rc++;sx1++;
		}
		int tx1=tx,ty1=ty;int dc=0;
		while(ty1>sy)
		{
			list.add('D');dc++;ty1--;
		}
		while(tx1>sx)
		{
			list.add('L');tx1--;
		}
		int curr_x=sx;curr_x--;int curr_y=sy+uc+1;sx1=sx;sy1=sy;
		while(sx1>curr_x)
		{
			list.add('L');sx1--;
		}
		while(sy1<curr_y)
		{
			list.add('U');sy1++;
		}
		while(curr_x<tx)
		{
			list.add('R');curr_x++;
		}
		while(curr_y>ty)
		{
			list.add('D');curr_y--;
		}
		curr_x=tx+1;
		while(tx<curr_x)
		{
			list.add('R');tx++;
		}
		curr_y=ty-dc-1;
		while(ty>curr_y)
		{
			list.add('D');ty--;
		}
		while(curr_x>sx)
		{
			list.add('L');curr_x--;
		}
		while(curr_y<sy)
		{
			list.add('U');curr_y++;
		}
		for(char ch:list)
		{
			out.print(ch);
		}
		out.println("");out.close();
    }
}
class Pair
{
	int x,y;
	public Pair(int x,int y)
	{
		this.x=x;this.y=y;
	}
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 9428
#include <algorithm>
#include <cstring>
#include <cstdio>
#define pb push_back
struct BIT
{
	int n, seg[200005], idx[4000005], orig[4000005], cnt;
	inline void init(int _n, int val = -0x3f)
	{
		n = _n;
		cnt = 0;
		memset(seg, val, n + 1 << 2);
	}
	inline void modify(int pos, int val)
	{
		for (; pos <= n; pos += pos & -pos)
		{
			idx[cnt] = pos;
			orig[cnt++] = seg[pos];
			seg[pos] = std::max(seg[pos], val);
		}
	}
	inline int query(int pos)
	{
		int res = -1e9;
		for (pos = std::min(pos, n); pos; pos -= pos & -pos)
			res = std::max(res, seg[pos]);
		return res;
	}
	inline void reset(int sz)
	{
		while (cnt > sz)
		{
			cnt--;
			seg[idx[cnt]] = orig[cnt];
		}
	}
} seg[2];
int arr[200005], suf[200005], val[200005], pos[200005][2];
int mn[2], len[2], nxt_mn[2], nxt_len[2], res[2];
char ans[200005];
int main()
{
	// freopen("AGC028-E.in", "r", stdin);
	// freopen("AGC028-E.out", "wt", stdout);
	int n, cur = 1e9;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		arr[i] = n - arr[i] + 1;
		if (arr[i] < cur)
		{
			cur = arr[i];
			val[i] = 2;
		}
		else
			val[i] = 1;
	}
	seg[0].init(n, 0);
	seg[1].init(n);
	for (int i = n - 1; i >= 0; i--)
		suf[i] = suf[i + 1] + (val[i] == 2);
	for (int i = n - 1; i >= 0; i--)
	{
		for (int j = 0; j < 2; j++)
			res[j] = std::max(0, seg[j].query(arr[i]));
		for (int j = 0; j < 2; j++)
		{
			int x = res[j] + val[i] & 1;
			seg[x].modify(arr[i], res[j] + val[i]);
		}
		for (int j = 0; j < 2; j++)
			pos[i][j] = seg[j].cnt;
	}
	mn[0] = mn[1] = 1e9;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 2; j++)
			seg[j].reset(pos[i + 1][j]);
		for (int j = 0; j < 2; j++)
		{
			memcpy(nxt_len, len, sizeof(len));
			memcpy(nxt_mn, mn, sizeof(mn));
			if (arr[i] < nxt_mn[j])
			{
				nxt_mn[j] = arr[i];
				nxt_len[j]++;
			}
			bool flg = false;
			if (i == n - 1)
				flg = nxt_len[0] == nxt_len[1];
			else
			{
				for (int k = 0; k < 2; k++)
				{
					int need = nxt_len[k] - nxt_len[k ^ 1] + suf[i + 1];
					if (need >= 0 && need <= seg[need & 1].query(nxt_mn[k ^ 1]))
						flg = true;
				}
			}
			if (flg)
			{
				ans[i] = j + '0';
				memcpy(mn, nxt_mn, sizeof(mn));
				memcpy(len, nxt_len, sizeof(len));
				break;
			}
		}
		if (!ans[i])
		{
			puts("-1");
			return 0;
		}
	}
	puts(ans);
	return 0;
}


Measured memory_bytes: 43392
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=100005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int pos[N];
int32_t main()
{
    IOS;
    fill(pos, -1);
    int n, x, m;
    cin>>n>>x>>m;
    vi v;
    v.pb(x);
    pos[x]=0;
    int temp=x, cur=1;
    while(cur<n)
    {
        x*=x;
        x%=m;
        if(pos[x]!=-1)
        {
            int s=v.size();
            for(int i=pos[x]+1;i<s;i++)
            v[i]+=v[i-1];
            int cyc=cur-pos[x];
            n-=cur;
            temp+=((n/cyc)*v[s-1]);
            n%=cyc;
            if(n)
            temp+=v[pos[x]+n-1];
            cout<<temp;
            return 0;
        }
        temp+=x;
        pos[x]=cur;
        cur++;
        v.pb(x);
    }
    cout<<temp;
}

Measured memory_bytes: 4668
def price():
    a, b = map(int, input().split())

    x = int(a / 0.08)

    if x * 8 < 100 * a:
        x += 1
    while 100*a <= x*8 < 100*a + 100:
        if 100*b <= x*10 < 100*b + 100:
            return x
        x += 1
    return -1

print(price())

Measured memory_bytes: 3060