akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}

int a[123456*2+10];

signed main()
{
	//IOS();
	vector<int>ans;
	while(1){
		string s;
		getline(cin,s);
		if(s==".")break;
		stack<int>a,b;
		int flg = 1;
		rep(i,0,s.size()){
			if(s[i]=='(')a.push(b.size());
			else if(s[i]=='[')b.push(a.size());
			else if(s[i]==')'){
				if(a.size()==0||b.size()!=a.top()){
					flg = 0;
					break;
				}
				a.pop();
			}else if(s[i]==']'){
				if(b.size()==0||a.size()!=b.top()){
					flg = 0;
					break;
				}
				b.pop();
			}
		}
		if(a.size()||b.size())flg = 0;
		ans.push_back(flg);
	}
	for(auto e:ans){
		if(e)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
}



Measured memory_bytes: 3268
#include<cstdio>
#include<cstring>
typedef long long ll;
const int N=100010;

int ls,lt,cnt[26],v[26][N]; ll ans; char s[N],t[N];
int main() {
	scanf("%s%s",s+1,t+1); ls=strlen(s+1); lt=strlen(t+1);
	for (int i=1; i<=ls; ++i) { int x=s[i]-'a'; v[x][++cnt[x]]=i; } 
	for (int i=1; i<=lt; ++i)
		if (!cnt[t[i]-'a']) return puts("-1"),0;
	int j=0,k;
	for (int i=1; i<=lt; ++i) {
		int x=t[i]-'a';
		if (j>=v[x][cnt[x]]) { 
			ans+=ls-j+v[x][1];
			j=v[x][1]; continue;
		}
		int l=1,r=cnt[x];
		while (l<r) { int m=l+r>>1; v[x][m]>j?(r=m):(l=m+1); }
		ans+=1ll*v[x][r]-j; j=v[x][r];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8960
from collections import deque

N, K = map(int, input().split())
p = list(map(int, input().split()))

queue = deque()
currentSum = 0
maxSum = 0
for i in range(len(p)):
    currentSum = currentSum + p[i] + 1
    queue.append(p[i] + 1)
    if i >= K:
        currentSum = currentSum - queue.popleft()

    if i >= K - 1:
        maxSum = max(maxSum, currentSum)

print("{:.12f}".format(maxSum / 2))


Measured memory_bytes: 25572
import java.util.*;

class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		
		Integer[] array = new Integer[n];
		for(int i = 0; i < n; ++i) {
		    int tmp = sc.nextInt();
		    array[i] = tmp;
		}
		
		Integer[] array_pon = new Integer[n+1];
		array_pon[0] = 0;
		int sum = 0;
		for(int i = 1; i < n+1; ++i) {
		    sum += array[i-1];
		    array_pon[i] = sum;
		}
		
		int counter = 0;
		for(int i = 0; i < n+1; ++i) {
		    if(array_pon[i] <= x) ++counter;
		    else continue;
		}
		
		System.out.println(counter);	
	}
}

Measured memory_bytes: 21972
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def make4(initial, L, M, N, O):
    return [[[[initial for i in range(O)]
                for n in range(N)]
                for m in range(M)]
                for l in range(L)]


def make3(initial, L, M, N):
    return [[[initial for n in range(N)]
                for m in range(M)]
                for l in range(L)]


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    n, m = MI()
    c = LI()
    dp = [[IINF] * (n+1) for i in range(m+1)]
    dp[0][0] = 0

    for i in range(m):
        for j in range(n+1):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            if j + c[i] <= n:
                dp[i][j+c[i]] = min(dp[i][j+c[i]], dp[i][j] + 1)
                dp[i+1][j+c[i]] = min(dp[i+1][j+c[i]], dp[i][j] + 1)
    print(dp[m][n])

if __name__ == '__main__':
    main()



Measured memory_bytes: 46356
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
vector <int> basyo[30];


signed main(){
  string s,t;
  cin >> s >> t;
  REP(i,s.size()){
    basyo[s[i]-'a'].pb(i);
  }
  REP(i,29){
    basyo[i].pb(INF);
  }
  int now = -1;
  int cnt = 0;
  REP(i,t.size()){
    int n2 = *lower_bound(basyo[t[i]-'a'].begin(),basyo[t[i]-'a'].end(),now+1);
    if(n2 == INF){
      if(basyo[t[i]-'a'].size()==1){
        cout << -1 << endl;
        return 0;
      }
      cnt ++;
      now = basyo[t[i]-'a'][0];
    }
    else{
      now = n2;
    }
  }
  cout << now + cnt * s.size() + 1 << endl;
  return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int c[] = {0,2,5,5,4,5,6,3,7,6};

int main() {
    int n, m;
    cin >> n >> m;
    VI a(m);
    REP(i,m) a[i] = in();
    sort(ALL(a));

    vector<string> dp(n+1);
    dp[0] = "-";
    REP(i,n){
        if (dp[i].empty()) continue;
        if (dp[i] == "-") dp[i] = "";
        for (int x : a){
            if (i + c[x] <= n){
                string next = dp[i] + char('0' + x);
                if (next.length() > dp[i + c[x]].length() || (next.length() == dp[i + c[x]].length() && next > dp[i + c[x]])){
                    dp[i + c[x]] = next;
                }
            }
        }
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 43776
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

string L;
int n;


ll mod_pow(ll x,ll n,ll mod){
    ll res=1;
    x %= mod;
    while(n){
        if(n&1) res = (res*x)%mod;
        x = (x*x)%mod;
        n>>=1;
    }
    return res;
}

ll memo[100005][2];

ll rec(int k,bool flag){
    if(memo[k][flag] != -1){
        return memo[k][flag];
    }

    if(k == n){
        return 1;
    }

    if(flag){
        ll res = 3*rec(k+1,true) % mod;
        return memo[k][flag] = res;
    }else{
        if(L[k] == '0'){
            ll res = rec(k+1,false);
            return memo[k][flag] = res;
        }else{
            ll res = 2 * rec(k+1,false) % mod;
            res += rec(k+1,true) % mod;
            res %= mod;
            return memo[k][flag] = res;
        }
    }
}

int main(){
    cin >> L;
    n = L.size();

    rep(i,100005) rep(j,2) memo[i][j] = -1;

    cout << rec(0,false) << endl;
}


Measured memory_bytes: 6656
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int count=1;
    int sum=a;
    if(b==1){
        cout << 0 << endl;
        return 0;
    }
    while(sum<b){
        sum=sum+a-1;
        count++;
    }
    cout << count << endl;
    return 0;
}

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

int main() {
  int n, m, sum;
  cin >> n >> m;
  sum = 0;
  vector<int> A(n);
  for(int i = 0; i < n; ++i){
    cin >> A.at(i);
    sum += A.at(i);
  }

  int cnt = 0;
  double go = (double) sum / (4 * m);
  for(int i = 0; i < n; ++i){
    if(go <= A.at(i)){
      cnt++;
    }
  }

  if(cnt >= m){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   int ans = min({a+c,a+d,b+c,b+d});

   cout << ans << endl;



   return 0;
}

Measured memory_bytes: 256
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int X = Integer.parseInt(st.nextToken());
        int Y = Integer.parseInt(st.nextToken());

        int y = (Y-2*X)/2;
        int x = X-y;
        if(y<0 || x<0 || (Y-2*X)%2!=0)
            System.out.println("No");
        else
            System.out.println("Yes");

    }




}



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

int main() {
    char str[3];
    cin >> str;
    sort(str, str+3);
    if(str[0] == 'a' && str[1] == 'b' && str[2] == 'c') cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

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

from collections import defaultdict
d = defaultdict(int)

for i in input().split():
    d[int(i)] += 1

d_sorted = sorted(d.items(), key=lambda x:x[0], reverse=True)

longest=0
for length, n in d_sorted:
    if n>=2 and longest!=0:
        print(longest*length)
        exit()
    elif n>=4 and longest==0:
        print(length**2)
        exit()
    elif n>=2 and longest==0:
        longest=length
print(0)

Measured memory_bytes: 24104
#include <bits/stdc++.h>
using namespace std;
int M, K;
long computeXOR(int n){
    switch(n & 3){
        case 0: return n;
        case 1: return 1;
        case 2: return n + 1;
        case 3: return 0;
    }
}
int main(){
    cin >> M >> K;
    if(K == 0){
        for(int i = 0; i < (1 << M); i++)cout << i << " " << i << " ";
        cout << '\n';
    }
    else if(K < (1 << M) && computeXOR((1 << M) - 1) ^ K == K){
        for(int i = 0; i < (1 << M); i++)if(i != K)cout << i << " ";
        cout << K << " ";
        for(int i = (1 << M) - 1; i >= 0; i--)if(i != K)cout << i << " ";
        cout << K << '\n';
    }
    else cout << -1 << '\n';
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

int bit_count(unsigned x){
    int ret = 0;
    while(x > 0){
        ret += x & 1;
        x >>= 1;
    }
    return ret;
}

vector<int> code(int N, int A, int B){
    if(N == 1) return {A, B};
    int dif = A^B;
    dif = dif & -dif;
    int mask = dif;
    int e = 1 << (N-1);
    while(mask < e){
        mask <<= 1;
        mask |= dif;
    }
    int pA = (A & ~mask) + (((A & mask) >> 1) & mask);
    int C = pA ^ 1;
    int pB = (B & ~mask) + (((B & mask) >> 1) & mask);

    auto Q = code(N-1, pA, C);
    auto R = code(N-1, C, pB);
    for (auto &&q : Q) {
        q = (q & ~mask) + (A & dif) +((q & (mask)) << 1);
    } // end q
    for (auto &&r : R) {
        r = (r & ~mask) + (B & dif) +((r & (mask)) << 1);
        Q.push_back(r);
    } // end r

    return Q;
}

void solve(istream &cin) {
    unsigned N, A, B;
    cin >> N >> A >> B;
    if(!cin) return;
    ull n2 = 1ull << N;
    if(bit_count(A^B) % 2 == 0){
        cout << "NO" << endl;
        return;
    }

    auto ans = code(N, A, B);
    cout << "YES\n";
    for (auto &&c : ans) {
        cout << c << ' ';
    } // end c
    cout << endl;





}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}



Measured memory_bytes: 1648
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int r = int.Parse(input[0]);
            int c = int.Parse(input[1]);
            int[,] hyo = new int[r + 2, c + 2];
            for (int i = 1; i <= r; i++)
            {
                string[] data = Console.ReadLine().Split(' ');
                for (int k = 1; k <= c ; k++)
                {
                    hyo[i, k] = int.Parse(data[k - 1]);
                    hyo[i, c + 1] += hyo[i, k];
                    hyo[r + 1, k] += hyo[i, k];
                    hyo[r + 1, c + 1] += hyo[i, k];
                }

            }
            for (int i = 1; i <= r+1 ; i++)
            {
                for (int k = 1; k < c+1; k++)
                {
                    Console.Write(hyo[i,k]+" ");
                }
                Console.WriteLine(hyo[i,c+1]);
            }
        } 
    }
}

Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> C(N-1), S(N-1), F(N-1);
  rep(i,N-1)cin >> C[i] >> S[i] >> F[i];
  vector<int> ans(N);
  ans[N-1] = 0;
  rep(i,N-1){
    ans[i] = 0;
    rep(j,i+1){
      if(ans[j] <= S[i])ans[j] = S[i]+C[i];
      else{
        int t = ans[j]/F[i];
        if(ans[j]%F[i]!=0)++t;
        ans[j] = t*F[i] + C[i];
      }
    }
  }
  rep(i,N)cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i =0;i < n;i++){
		cin >> a[i];
		}
	int b[n];
		
	for(int i = 0;i < n;i++){
		b[i] = a[n - i - 1];
		cout << b[i];
		if(i < n - 1) cout << " ";
		}
	cout << endl;
	return 0;
	}		

Measured memory_bytes: 3076
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n
dp[0] = 0


for i in range(n-1):
    if i+2 <= n-1:
        dp[i+1] = min(dp[i] + abs(h[i] - h[i+1]), dp[i+1])
        dp[i+2] = min(dp[i] + abs(h[i] - h[i+2]), dp[i+2])
    elif i+1 <= n-1:
        dp[i+1] = min(dp[i] + abs(h[i] - h[i+1]), dp[i+1])

print(dp[n-1])

Measured memory_bytes: 13980
package main

import "fmt"

func main() {
	var r, d, x int
	fmt.Scan(&r)
	fmt.Scan(&d)
	fmt.Scan(&x)

	now := x
	for index := 0; index < 10; index++ {
		tmp := now*r - d
		fmt.Println(tmp)
		now = tmp
	}
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  vector<vector<char>> list(N, vector<char>(M));
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> list.at(i).at(j);
    }
  }
  
  vector<bool> one(N, false);
  vector<bool> two(M, false);
  
  int size_1 = list.size();
  int size_2 = list.at(0).size();
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (list.at(i).at(j) == '#') {
        one.at(i) = true;
        two.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < size_1; i++) {
    if (!one.at(i)) continue;
    for (int j = 0; j < size_2; j++) {
      if (!two.at(j)) continue;
      cout << list.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    vint d(n);
    d[0] = a[0];
    rep(i, n-1) d[i+1] = a[i+1] - a[i];
    ll total = 0; 
    rep(i, n) total += abs(d[i]);
    total += abs(a[n-1]);
    int a0, a1, a2;
    ll ans;
    rep(i, n) {
        if (i > 0) a0 = a[i-1];
        else a0 = 0;
        a1 = a[i];
        if (i < n-1) a2 = a[i+1];
        else a2 = 0;
        ans = total + abs(a2 - a0) - abs(a2 - a1) - abs(a1 - a0);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2048
#include<stdio.h>
#include<map>
#define INF 20000000
using namespace std;
typedef pair<int,int> P;
int d[100000];
int p[100000];
P deq[200000];
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int main(){
	int n,mh;
	int i;
	scanf("%d %d",&n,&mh);
	for(i=0;i<n-1;i++)scanf("%d %d",&d[i],&p[i]);
	long long ans=0;
	int l=0,r=0;
	int s=0,t=0;
	int lim=0;
	int h=mh;
	while(r<n-1){
		while(s<t&&deq[t-1].first<p[r])t--;
		deq[t++]=P(p[r],r);
		while(h<=d[r]){
			while(l<r&&min(lim,p[l])<deq[s].first){
				lim+=d[l++];
				while(s<t&&deq[s].second<=l)s++;
			}
			int rec=d[r]-h+1;
			int a=rec/p[l];
			int b=lim/p[l];
			int c=min(a,b);
			if(c==0)c++;
			ans+=c;
			int add=c*p[l];
			if(add>lim)add=lim;
			lim-=add;
			h+=add;
			if(h>mh)h=mh;
		}
		h-=d[r];
		r++;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265
typedef long long ll;

int main( void ) {

    while( 1 ) {
        int    sum = 0;
        string x;
        cin >> x;
        if( x == "0" ) break;

        int l = x.length();

        for( int i = 0; i < l; i++ ) {
            sum += ( x.at( i ) - '0' );
        }
        cout << sum << endl;
    }
    return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
char s[20];
int f(int x)
{
    int res=0;
    for (int i=0;i<3;++i) res=res*10+s[i+x]-'0';
    return res;
}
     
int main()
{
    while (scanf("%s",s+1)!=EOF)
    {
        int res=0x3f3f3f3f, len=strlen(s + 1);
        for (int i=1;i<=len-2;++i)res=min(res,abs(f(i)-753));
        printf("%d\n",res);
    }
    return 0;
}

Measured memory_bytes: 256
defmodule Main do
  def main do
    IO.gets("") |> String.trim |> String.split(" ") |>Enum.map(fn x->String.to_integer(x)end)
    |>List.to_tuple()
    # |>IO.puts()
    |> (fn x ->  Enum.map(0..4, fn y-> (if elem(x,y)==0 do IO.puts(y+1) end) end)end).()
  end
end


Measured memory_bytes: 30508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long 
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//typedef long long  MOD=1000000009;
ll MOD=998244353;
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll lcm(ll x, ll y) {ll res = (x * y) / __gcd(x, y); return res;}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

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


void solution()
{
    ll k,i,j,h,m,w,n;
    ll d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d)
    cout<<"Yes";
    else cout<<"No";
    
}

int main(){
    fio
    //iofoj();
    // ll t;
    // cin>>t;
    // while(t--)
    solution();
    return 0; 
}





Measured memory_bytes: 3644
#include<stdio.h>

int main (void)
{
	int input1,input2,input3;
	
	scanf("%d %d %d",&input1,&input2,&input3);
	if(input1 < input2 && input2 < input3)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2120
import heapq
x,y=list(map(int, input().split()))
z=list(map(int, input().split()))
z = list(map(lambda x: x*(-1), z))
heapq.heapify(z)
for i in range(y):
	k=heapq.heappop(z)
	heapq.heappush(z, -(-k//2))
z = list(map(lambda x: x*(-1), z))
print(sum(z))

Measured memory_bytes: 14184
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define PI 3.1415926535897932384626
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define Rep(i, a, b) for (int i=a; i<(b); i++)
#define rep(i, a) for (int i=0; i<(a); i++)
#define Dep(i,a,b) for (int i = (b)-1; i >= a; i--)
#define dep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for(auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // Random No.

const int MOD = 1000000007;
const char nl = '\n';

void sol() {

    ll n , d ;

    cin >> n  >> d;
    ll count = 0;
    rep(i , n) {
        ll x, y ;
        cin >> x >> y ;
        if ((ll)(x * x) + (ll)(y * y) <= (ll)(d * d)) {
            count++;
        }
    }

    cout << count << nl;
}


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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T = 1;
    while (T--) {
        sol();
    }

    return 0;
}



Measured memory_bytes: 3648
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int k;
    cin >> k;

    queue <ll> q;
    for (ll i = 1; i < 10; i++) q.push(i);

    while (--k) {
        ll p = q.front();
        q.pop();

        if (p % 10 != 0) q.push(p * 10 + p % 10 - 1);
        q.push(p * 10 + p % 10);
        if (p % 10 != 9) q.push(p * 10 + p % 10 + 1);
    }

    cout << q.front() << "\n";
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	vector<int> a( 3 );
	int K;
	cin >> a[0] >> a[1] >> a[2] >> K;

	sort( a.begin(), a.end() );

	while( K-- > 0 ) {
		a.back() *= 2;
	}

	cout << a[0] + a[1] + a[2] << endl;

	return 0;
}


Measured memory_bytes: 256
//初めての尺取り

#include<stdio.h>
#include<iostream>
using namespace std;

#define GOMAE (long long)50000
#define EPS (long long)4000
#define TO_OUTSIDE (long long)1500
#define IS_NOT_EVEN_HOBBY (long long)114
int N;
long long input;
long long A[300010];
long long ans;

int solve( long long X ){
	int i,j=0,k=0;
	
	if( X >= (A[N]>>1) )
		return 0;
	for( i = 0; i < N; i++ ){
		//大きさがX以上になるように切る
		for( ; j < N+i; j++ ){
			if( A[j]-A[i] >= X )
				break;
		}
		//できるだけ真ん中で切る
		for( ; k < N+i; k++ ){
			if( A[k]-A[j] >= A[N+i]-A[k] )
				break;
		}
		if( min( A[j]-A[i], min( A[k]-A[j], A[i+N]-A[k] ) ) >= X )
			break;
		k--;
		if( min( A[j]-A[i], min( A[k]-A[j], A[i+N]-A[k] ) ) >= X )
			break;
	}
	if( i < N )
		return 1;
	return 0;
}
				
int main(){
	int i,j,k;
	long long s = 0, e = GOMAE * EPS * TO_OUTSIDE * IS_NOT_EVEN_HOBBY * EPS;
	scanf("%d",&N);
	if( N > 100000 )
		return 0;
		
	for( i = 1; i < N+1; i++ ){
		scanf("%d",&input);
		A[i] = A[i-1]+input;
	}
	for( i = N+1; i < 3*N+1; i++ ){
		A[i] = A[i-N] + A[N];
	}
	
	//printf("%lld %lld\n",s,e);
	while( s <= e ){
		ans = (s+e)>>1;
		if( solve(ans) ){
			if( solve(ans+1) )
				s = ans+1;
			else
				break;
		}
		else{
			e = ans-1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3532
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[1500001], invf[1500001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int n, k; cin>>n>>k;
    fac(n);
    for(int i=1; i<=k; i++){
        cout<<comb(k-1, i-1)*comb(n-k+1, i)%MOD<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    int W, a, b;
    cin >> W >> a >> b;

    if (a + W < b) {
        cout << b - (a + W) << endl;
    } else if (b + W < a) {
        cout << a - (b + W) << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

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

int main(){
  int n,k;
  int sum=0;
  cin >> n >> k;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  for(int i=1;i<=k;i++){
    sum += l[n-i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b;
  cin >> a >> b;
//  if(a<b) swap(a,b);
  //ユークリッドの互除法
//  long long r=a%b;
  long long q;
//  long long c;
/*  while(r!=0){
    c=q;
    q=r;
    r=c%r;
  }*/
  q=__gcd(a,b);
  //cout << sqrt(q)<<endl;
  int count=1;;
  for(long long i=2;i<=sqrt(q);i++){
    //cout<<i<<endl;
    //cout<<q<<endl;
    if(q%i==0){
      count++;
      while(q%i==0){
        q /= i;
      }
    }
  }
  //cout << q << endl;
  if(q!=1) count++;
  cout << count << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = []
    for _ in range(D):
        si = list(map(int, input().split()))
        s.append(si)
    score = 0
    last_list = [0] * 26
    for i in range(D):
        t = int(input())
        last_list[t-1] = i+1
        current = s[i][t-1]
        minus = 0
        for j in range(26):
            if t - 1 != j:
                minus += c[j] * (i+1-last_list[j])
        current -= minus
        score += current
        print(score)
if __name__ == "__main__":
    main()

Measured memory_bytes: 68816
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
a = inl()
if n==k:
    p = 1
    for x in a:
        p = (p*x)%R
    print(p)
    exit()
a.sort()
b = [(abs(x),x) for x in a]
b.sort()
if a[-1]>0:
    c = [z[1] for z in b[n-k:n]]  # abs-max k elems
    neg = [x for x in c if x<0]
    if len(neg)%2 > 0:
        inmmin = BIG
        for j,y in enumerate(c):
            if y<0:
                inmmin = y
                inmminsuf = j
                break
        outpmax = BIG
        for j in range(n-1-k,-1,-1):
            if b[j][1]>0:
                outpmax = b[j][1]
                break
        inpmin = BIG
        for j,y in enumerate(c):
            if y>0:
                inpmin = y
                inpminsuf = j
                break
        outmmax = BIG
        for j in range(n-1-k,-1,-1):
            if b[j][1]<0:
                outmmax = b[j][1]
                break
        if inpmin==BIG or outmmax==BIG:
            useoutpmax = True
        elif outpmax==BIG:
            useoutpmax = False
        elif outpmax*inpmin>outmmax*inmmin:
            useoutpmax = True
        else:
            useoutpmax = False
        if useoutpmax:
            c[inmminsuf] = outpmax
        else:
            c[inpminsuf] = outmmax
elif k%2==0:
    c = [z[1] for z in b[n-k:n]]  # abs-max k elems
else:
    c = [z[1] for z in b[:k]]  # abs-min k elems
p = 1
for x in c:
    p = (p*x)%R
print(p)


Measured memory_bytes: 122324
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 998244353;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


signed main() {
	int n,s;
	std::cin >> n >> s;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::vector<mint> q(s+1,0);
	mint sum=0;
	rep(i,n) {
		q[0]+=1;
		std::vector<mint> q2(s+1,0);
		for(int j=s;j>=0;j--) {
			q2[j]+=q[j];
			if(j-a[i]>=0) q2[j]+=q[j-a[i]];
		}
		sum+=q2[s];
		q=q2;
	}
	print(sum);
	return 0;
}


Measured memory_bytes: 256
def main():
	N, L = map(int, input().split())
	apple = [L+i-1 for i in range(1, N+1)]
	original = sum(apple)

	mindiff = float('inf')
	for j in range(N):
		applepai = sum(apple[:j] + apple[j+1:])
		diff = abs(original - applepai)

		if diff < mindiff:
			mindiff = diff
			ans = applepai
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846
#ifdef LOCAL
#include <sys/types.h>
#include <sys/timeb.h>
#include <intrin.h> 
#include <thread>
#else
#include <sys/time.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main(){
	LL ret = 1;
	LL n, p;
	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	for (LL i = 2; i*i <= p; i++) {
		int cnt = 0;
		while (p % i == 0) {
			p /= i;
			cnt++;
		}
		cnt /= n;
		REP(j, cnt) {
			ret *= i;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
def solve(takoyakis):
    ans = 0

    for i, x in enumerate(takoyakis):
        for j, y in enumerate(takoyakis):
            if j <= i:
                continue
            ans += x * y

    return ans


if __name__ == "__main__":
    n = int(input())
    d_s = [int(d) for d in input().split(' ')]
    print(solve(d_s))


Measured memory_bytes: 39152
n = int(input())
al = list(map(int, input().split()))
ratel = [0,0,0,0,0,0,0,0,0]

def check(a):
    if 1 <= a <= 399:
        return 0
    elif 400 <= a <= 799:
        return 1
    elif 800 <= a <= 1199:
        return 2
    elif 1200 <= a <= 1599:
        return 3
    elif 1600 <= a <= 1999:
        return 4
    elif 2000 <= a <= 2399:
        return 5
    elif 2400 <= a <= 2799:
        return 6
    elif 2800 <= a <= 3199:
        return 7
    else:
        return 8

for a in al:
    i = check(a)
    ratel[i] += 1


zeroc = 0
ratec = 0
for i in range(8):
    if ratel[i] == 0:
        zeroc += 1
    else:
        ratec += 1

if ratel[8] == 0:
    print(ratec,ratec)
elif 1 <= ratel[8] <= 8:
    if ratec == 0:
        print(1,ratel[8])
    elif ratel[8] < zeroc:
        print(ratec, ratec+ratel[8])
    elif ratel[8] >= zeroc:
        print(ratec,ratec+ratel[8])
else:
    if ratec == 0:
        print(1,ratel[8])
    else:
        print(ratec,ratec+ratel[8])

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

int main()
{
  int N = 0, tmp_i;
  int64_t ans = 0, num, tmp_num;

  cin >> num;
  tmp_num = num;
  while (tmp_num)
  {
    N++;
    tmp_num /= 10;
  }
  for (int tmp = 0; tmp < (1 << N - 1); tmp++)
  {
    bitset<10> s(tmp);
    tmp_num = num;
    tmp_i = 0;
    for (int i = 1; i < N; i++)
    {
      if (s[i - 1])
      {
        ans += tmp_num % (int)pow(10, i - tmp_i);
        tmp_num = tmp_num / (int)pow(10, i - tmp_i);
        tmp_i = i;
      }
    }
    ans += tmp_num;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, K = map(int, input().split())

if K == 0:
    print(N * N)
else:
    ans = 0
    for i in range(K + 1, N + 1):
        cnt = N // i
        x = max(0, N - cnt * i - K + 1)
        ans += (cnt + 1) * x
        ans += cnt * (i - K - x)
        # for j in range(K, i):
        #
        #     if cnt * i + j <= N:
        #         cnt += 1
        #     ans += cnt
        # print(i, cnt, x, ans)
    print(ans)

Measured memory_bytes: 3572
#include<stdio.h>

int main()
{
	int x,a,b;
	scanf("%d %d %d", &x, &a, &b);
	a -= x; b -= x;
	if(a < 0) a *= -1;
	if(b < 0) b *= -1;
	
	if(a < b) printf("A\n");
	else printf("B\n");
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<string, int> m;
    pair<int, string> p;
    vector<pair<int, string>> v;
    rep(i, n) {
        string tmp;
        cin >> tmp;
        if(m.find(tmp) == m.end())
            m[tmp] = 1;
        else {
            m[tmp] += 1;
        }
    }
    int maxv = 0;
    for(const auto &x : m) {
        int v = x.second;
        if(v > maxv)
            maxv = v;
    }

    for(auto it = m.begin(); it != m.end(); it++) {
        if(it->second == maxv) {
            cout << it->first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 19272
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		String a=s.next();
		String b=s.next();
		int n=gInt();
		int m=gInt();
		if(a.equals(s.next()))
			System.out.println((n-1)+" "+m);
		else
			System.out.println(n+" "+(m-1));
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
int main(void)
{
	int n,k[1000],p[1000],i,x,y,z;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&k[i],&p[i]);
	}
	for(i=0;i<n;i++){
		if(k[i]>p[i]){
			if(k[i]%p[i]!=0){
				x=k[i]%p[i];
				printf("%d\n",x);
			}
			else{
				printf("%d\n",p[i]);
			}
		}
		else{
			printf("%d\n",k[i]);
		}
	}
	return 0;
}


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

typedef long long ll;

ll A,B;

ll unit(ll n)
{
    if(n <= 0)return 0;
    ll ret = 0;
    ll tmp = (n + 1) % 4;
    for(int i = 0; i < tmp; i++)ret ^= n - i;
    return ret;
}

int main()
{
    cin >> A >> B;
    printf("%lld\n",unit(A - 1) ^ unit(B));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

// int apple(const int& N, const int& L){
//     if(L >= 0)       return (L);
//     if(fabs(L) <= N) return (0);
//     return (L + N - 1);
// }

int apple(const int& N, const int& L){
    int re = L;
    for(int i = 1; i <= N; i++){
        if(fabs(L + i - 1) < fabs(re)) re = (L + i - 1);
    }
    return re;
}

int main(){
    int N, L;
    int sum = 0;

    cin >> N >> L;

    for(int i = 1; i <= N; i++) sum += (L + i - 1);

    int eat = apple(N, L);

    // cout << eat << endl;
    cout << sum - eat;
}

Measured memory_bytes: 256
from collections import Counter
n, *A = map(int, open(0).read().split())

a0 = Counter(A[::2]).most_common(2)
a1 = Counter(A[1::2]).most_common(2)

if a0[0][0] == a1[0][0]:
    l0, l1 = len(a0), len(a1)
    if l0 == l1 == 1:
        print(n//2)
    elif l0 < l1:
        print(n//2 - a1[1][1])
    elif l0 > l1:
        print(n//2 - a0[1][1])
    else:
        print(n - max(a0[1][1] + a1[0][1], a0[0][1] + a1[1][1]))
else:
    print(n - a0[0][1] - a1[0][1])

Measured memory_bytes: 15460
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n;
    cin >> n;
    int h[n];
	fr(i,n){
      cin >> h[i];
    }
    int max=h[0];
    string ans = "Yes";
    fro(i,1,n){
      if(max-1>h[i]){
        ans = "No";
        break;
      }
      if(max<h[i])max=h[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  string s;
  int k;
  cin >> k >> s;
  int n = s.size();
  if(n <= k) {
    cout << s << endl;
    return 0;
  } else {
    s = s.substr(0,k);
    cout << s << "..." << endl;
  }
}

Measured memory_bytes: 3596