akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cShaprTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var N = int.Parse(input[0]);
            var M = int.Parse(input[1]);
            var C = int.Parse(input[2]);

            var B = Console.ReadLine().Split(' ');
            int sum = 0;

            for (var i = 0; i < N; i++)
            {
                input = Console.ReadLine().Split(' ');
                int total = 0;

                for (int j = 0; j < M; j++)
                {
                    total += int.Parse(B[j]) * int.Parse(input[j]);
                }

                total += C;
                if (total > 0)
                {
                    sum++;
                }
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;


int main(){
    int n;
    cin >> n;
    int m=n;
    int s=0;
    while(m>0){
        s+=m%10;
        m/=10;
    }
    int ans=n%s;
    if(ans==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

func solution(n int, a, b []int) int {
   out := 0

   for i := 0; i < n; i++ {
        if b[i] > a[i] {
                out += a[i]
                b[i] = b[i] - a[i]

                if b[i] > a[i+1] {
                        out += a[i+1]
                        a[i+1] = 0
                } else {
                        a[i+1] = a[i+1] - b[i]
                        out += b[i]
                }
        } else {
                out += b[i]
        }

   }

   return out
}

func main() {
   r := bufio.NewReader(os.Stdin)
   var n int
   fmt.Fscan(r, &n)
   a := make([]int, n+1)
   for i := range a {
        fmt.Fscan(r, &a[i])
   }
   b := make([]int, n)
   for i := range b {
        fmt.Fscan(r, &b[i])
   }
   fmt.Println(solution(n, a, b))
}

Measured memory_bytes: 5992
let r_long () = Int64.of_int (Scanf.scanf " %d" (fun x -> x)) ;;
let r_int () = Scanf.scanf " %d" (fun x -> x) ;;
let a=r_int() in
let b=r_int() in
let c=r_int() in
if (a=7 && b=5 && c=5) || (a=5 && b=7 && c=5) || (a=5 && b=5 && c=7) then
begin
print_string "YES";
end
else
begin
print_string "NO";
end
;
print_newline();


Measured memory_bytes: 3692
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int [] a = new int[3];
		int ind = 0;
		int max = 0;
		int sum = 0;
		for(int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
			if(a[i] > max) {
				max = a[i];
				ind = i;
			}
		}
		int k = sc.nextInt();
		for(int i = 0; i < k; i++) {
			a[ind] += a[ind];
		}
		for(int i = 0; i < 3; i++) {
			sum += a[i];
		}
		System.out.println(sum);
		sc.close();
	}

}


Measured memory_bytes: 21972
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define INF 1000000000000000000
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	ll h;
	int n;
	cin >> h >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		sum += a;
	}
	if (sum >= h) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())

# 空いている空間の体積
emp = a*a*b - x
# 空いた空間の三角柱の辺のうち、傾けて長さが変動する一辺の長さ
t_length = (emp * 2) / (a*a)

# 水が入った部分が三角柱型になる時は上の処理、空いた空間が三角柱型であるうちは下の処理、
if t_length > b:
    print(90 - math.degrees(math.atan2((x*2) / (a*b), b)))
else:
    print(math.degrees(math.atan2(t_length, a)))


Measured memory_bytes: 38512
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    H = list(map(int, lines.pop(0).split(' ')))
    re = 0
    tmp = 0
    for i in range(len(H) - 1):
        a = H[i]
        b = H[i+1]
        if a >= b:
            tmp += 1
            re = max(re, tmp)
        else:
            tmp = 0
    print(re)

lines = [x.strip() for x in sys.stdin.readlines()]
solve(lines)

Measured memory_bytes: 14104
N, M = map(int,input().split())
p = []
for i in range(M):
    s = list(map(int,input().split()))
    p.append(s + [i])
p.sort()
cur = p[0][0]
cnt = 1
for i in range(M):
    if p[i][0] > cur:
        cur = p[i][0]
        cnt = 1
    p[i][1] = cnt
    cnt += 1
p.sort(key=lambda x: x[2])
for i in range(M):
    print("0" * (6 - len(str(p[i][0]))) + str(p[i][0]) + "0" * (6 - len(str(p[i][1]))) + str(p[i][1]))

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

using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<string> svec;

#define IN_LL(in) ll in; cin >> in
#define IN_STR(in) string in; cin >> in
#define IN_VEC(in, size) vec in; for(int i = 0; i < (size); ++i){int ____cur; cin >> ____cur; in.push_back(____cur); } 0
#define IN_SVEC(in, size) svec in; for(int i = 0; i < (size); ++i){int ____cur; cin >> ____cur; in.push_back(____cur); } 0

#define OUT(out) cout << (out)
#define OUT_VEC(out) for(ll i = 0; i < (out).size(); ++i) cout << (out)[i]

int main(void){
	IN_LL(s);
	IN_LL(w);
	
	string res = (w >= s) ? "unsafe" : "safe";
	
	OUT(res);
	return 0;
}


Measured memory_bytes: 3624
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Data.Char
import Data.IORef

inter it a b
    | a == 1 = VUM.write it b True
    | b == 1 = VUM.write it a True
    | otherwise = return ()

dest it ds a b n
    | a == n = VUM.write ds b True
    | b == n = VUM.write ds a True
    | otherwise = return ()

main = do
    [n, m] <- Prelude.map read . Prelude.words <$> Prelude.getLine :: IO [Int]
    it <- VUM.replicate (n+1) False
    ds <- VUM.replicate (n+1) False
    res <- newIORef False
    forM_ [1..m] $ \_ -> do
        bs <- B.getLine
        let Just (a, bs') = B.readInt bs
            Just (b, _) = B.readInt $ B.dropWhile isSpace bs'
        inter it a b
        dest it ds a b n
    forM_ [1..n] $ \i -> do
        r <- VUM.read it i
        when r $ do
            r' <- VUM.read ds i 
            when r' $ modifyIORef' res (||True)
    
    readIORef res >>= \r -> putStrLn $ if r then "POSSIBLE" else "IMPOSSIBLE"

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

y=[]
for i in range(1,10):
    for j in range(1,10):
        x=i*j
        y.append(x)

count=0
for z in y:
    if N==z:
        count+=1
    else:
        count=count
if count==0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

int siz[111111];
vector<ii> adj[111111];

void prep(int u, int p)
{
	siz[u]=1;
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i].fi;
		if(v==p) continue;
		prep(v,u);
		siz[u]+=siz[v];
	}
}
int n;
int centroid(int u, int p)
{
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i].fi;
		if(v==p) continue;
		if(siz[v]*2>n)
		{
			return centroid(v,u);
		}
	}
	return u;
}

ll ans=0;

void solve(int u, int p)
{
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i].fi; ll w=adj[u][i].se;
		if(v==p) continue;
		ans+=ll(2)*siz[v]*w;
		//cerr<<u<<' '<<v<<' '<<w<<' '<<2*siz[v]<<'\n';
		solve(v,u);
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int u,v,w;
		cin>>u>>v>>w;
		u--; v--;
		adj[u].pb(mp(v,w));
		adj[v].pb(mp(u,w));
	}
	prep(0,-1);
	int cent = centroid(0,-1);
	prep(cent,-1);
	ll mini=ll(1e18);
	for(int i=0;i<adj[cent].size();i++)
	{
		int v=adj[cent][i].fi; ll w=adj[cent][i].se;
		if(siz[v]>=(n+1)/2)
		{
			mini=w;
			break;
		}
		mini=min(mini,w);
	}
	ans-=mini;
	solve(cent,-1);
	cout<<ans<<'\n';
}


Measured memory_bytes: 15232
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  ll x;
  cin >> x;
  ll ans;
  rep(i, 1e6) {
    if (x <= i*(i+1)/2) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

int main(){
    
    int n, t, a;

    std::cin >> n >> t >> a;

    std::vector<double> temperature(n);

    for(auto &&e : temperature){
        int h;
        std::cin >> h;

        e = t - h * 0.006;
    }

    double min_temp;
    int ans;
    for(int i = 0; i < n; i++){
        if(i == 0){
            min_temp = std::abs(temperature[i] - a);
            ans = i;
        }else{
            if(min_temp > std::abs(temperature[i] - a)){
                min_temp = std::abs(temperature[i] - a);
                ans = i;
            }
        }
    }

    std::cout << ans + 1 << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
s = [0] * (N + 1)
for i in range(N):
    s[i + 1] = s[i] + a[i]
ans = float('Inf')
for i in range(1, N):
    #print(ans)
    kouho = abs(s[i] - ((s[-1]) - s[i]))
    if ans > kouho:
        ans = kouho
    #ans = min(ans, kouho)
print(ans)


Measured memory_bytes: 24832
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    ll N, M, X;
    cin >> N >> M >> X;
    
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    
    REP(i, N){
        cin >> C[i];
        REP(j, M){
            cin >> A[i][j];
        }
    }
    
    ll ans = LINF;
    for(int mask = 0; mask < 1ll << N; ++mask){
        vector<int> tapu(M);
        ll cost = 0;
        
        for(int i = 0; i < N; ++i){
            if(mask >> i & 1){
                cost += C[i];
                for(int j = 0;j < M; ++j){
                    tapu[j] += A[i][j];
                }
            }
        }
        
        bool f = true;
        for(auto e : tapu){
            if(e < X) f = false;
        }
        if(f){
            chmin(ans, cost);
        }
    }
    
    if(ans == LINF){
        cout << -1 << endl;
        return;
    }
    cout << ans << endl;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>
#include <string.h>
#include "math.h"


int main(int argc, char *argv[]){

  int i, j;
  double a, b, x;
  int y;   //volume
  double z;
  double theta;

  scanf("%lf %lf %lf", &a, &b, &x);

  if(2*x >= a*a*b){
    y = a*a*b - x;
    z = 2 * y / a / a;
    theta = atan( z / a );

  }else{
    z = 2 * x / a / b;
    theta = atan( b / z );
  }

  theta = theta / 2 / M_PI * 360;
  printf("%f\n", theta);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
    int a[3],temp,sum=0,i;
    
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    
    for(i=0;i<2;i++){
        if(a[i]>a[i+1]){
            temp=a[i];
            a[i]=a[i+1];
            a[i+1]=temp;
        }
    }
    
    sum=a[0]+a[1];
    
    printf("%d\n",sum);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include<set>
#include<math.h>
#include<string>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


int main() {
	int n=0;
	string s,str;
	cin>>s>>str;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]==str[i])
		{
			n+=1;
		}
	}
	if (n==s.size() && str.size()==(s.size()+1))
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3028
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnInts();
        var N = _[0];
        var K =_[1];
        var Hs = LnInts();
        var dp = new int[N + 1];
        //i番目にいくために
        for (int i = 0; i < dp.Length; i++) { dp[i] = int.MaxValue; }
        dp[0] = 0;
        for (int i = 0; i < N; i++)
        {
            for (int k = 1; k <= K;k++) {
                if (i < N - k) dp[i + k] = Min(dp[i + k], dp[i] + Abs(Hs[i + k] - Hs[i]));
            }
        }
        Console.WriteLine(dp[N-1]);
    }

    static bool isLunLun(int i)
    {
        var vs = i.ToString().ToCharArray();
        var lastnum = int.Parse(vs[0].ToString());
        for (int n = 0; n < vs.Length; n++)
        {
            var cur = int.Parse(vs[n].ToString());
            if (Abs(lastnum - cur) > 1) { return false; }
            lastnum = cur;
        }
        return true;
    }


    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}



Measured memory_bytes: 18912
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n;
    cin >> n;

    cout << (n-3)*180 + 180 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
typedef pair<int,int> P;
priority_queue<P,vector<P>,greater<P> > que;
int main(){
	while(true){
		int n;
		cin >> n;
		if(n==0) break;
		rep(i,n){
			string x,y;
			cin >> x >> y;
			int a=stoi(x.substr(0,2))*3600+stoi(x.substr(3,2))*60+stoi(x.substr(6,2));
			int b=stoi(y.substr(0,2))*3600+stoi(y.substr(3,2))*60+stoi(y.substr(6,2));
			que.push(P(b,0));
			que.push(P(a,1));
		}
		int now=0,ans=0;
		while(!que.empty()){
			P q=que.top();
			que.pop();
			if(q.second==0) now++;
			else{
				if(now>0) now--;
				else ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1524
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 2e5 + 10;
int digit[MAXN],a[MAXN];
map<int,int> cnt;
int MOD;

int power(int x,int y){
    int res = 1;

    while(y){
        if(y&1) res = (res*x)%MOD;
        x = (x*x)%MOD;
        y >>= 1;
    }
    return res;
}


void solve(){
    int n,p; cin>>n>>p;
    MOD = p;
    string s; cin>>s;

    for(int i=0;i<n;i++) digit[i+1] = s[i]-'0';

    if(p == 5 || p == 2){
        int ans = 0;
        FOR(i,1,n){
            if(digit[i]%p == 0){
                ans += i;
            }
        }
        cout<<ans<<endl;
        return;
    }

    int val = 1;
    for(int i=n;i>=1;i--){
        digit[i] = (digit[i+1] + (digit[i]*val)%p)%p;
        val = (val*10)%p;
    }

    FOR(i,1,n) cnt[digit[i]]++;

    int ans = 0;
    val = 1;
    int check = 0;

    RFOR(i,1,n){
        ans += cnt[check];
        cnt[digit[i]]--;
        check = digit[i];
    }

    cout<<ans<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 2580
// https://beta.atcoder.jp/contests/abc115

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;

const int MAX_LEVEL = 50;
uint64_t n_layers[MAX_LEVEL + 1];
uint64_t n_patties[MAX_LEVEL + 1];

void init() {
    n_layers[0] = 1;
    n_patties[0] = 1;
    for (int i = 1; i <= MAX_LEVEL; ++i) {
        n_layers[i] = 2 * n_layers[i - 1] + 3;
        n_patties[i] = 2 * n_patties[i - 1] + 1;
    }
}

uint64_t solve(uint64_t n, uint64_t x) {
    uint64_t ans = 0;
    while (true) {
        if (n == 0) {
            ans++;
            break;
        }
        // left bun
        if (x == 1) break;
        x--;


        // left n - 1
        // dig n - 1 level
        if (x <= n_layers[n - 1]) {
            n--;
            continue;
        }
        x -= n_layers[n - 1];
        ans += n_patties[n - 1];

        // center patty
        ans += 1;
        if (x == 1) break;
        x--;

        // right n - 1
        if (x <= n_layers[n - 1]) {
            n--;
            continue;
        }

        x -= n_layers[n - 1];
        ans += n_patties[n - 1];

        if (x == 1) break;
        cout << "error!";
        exit(1);
    }

    return ans;
}

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(50 4321098765432109
)");
#endif
    init();

    uint64_t n, x;
    in >> n >> x;

    auto ans = solve(n, x);

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

Measured memory_bytes: 384
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<time.h> 
#define debug(a) cout << "*" << a << "*" << endl
#define ls	(k << 1)
#define rs	((k << 1) | 1)
#define mid	((l + r) >> 1)
using namespace std;
typedef long long ll;
ll a[100005], n, sum;
int main()
{
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++)	
	{
		scanf("%lld", a + i);
		sum += abs(a[i] - a[i - 1]);
	}
	sum += abs(a[n]);
	for (int i = 1; i <= n; i++)
	{
		printf("%lld\n", sum + abs(a[i - 1] - a[i + 1]) - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]));
	}
}

Measured memory_bytes: 2048
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

# N = int(input())
S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

A = S.count("A")
B = S.count("B")

if 0 < A < 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9096
import bisect
n = int(input())
a = [int(_) for _ in input().split()]
a.sort()

res = 0

for i in set(a):
    tmp = bisect.bisect_right(a,i)-bisect.bisect_left(a,i)
    if tmp < i:
        res += tmp
    else:
        res += tmp - i

print(res)

Measured memory_bytes: 14428
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	a,b,c=MI()

	print(min(a+b+1,c)+b)










if __name__ == "__main__":
	main()


Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    ll n, a,b;cin>>n>>a>>b;
    if (a>b) {cout<<0<<endl;return 0;}
    if (a!= b && n<2){cout<<0<<endl; return 0;}
    cout<<1 + max(0LL,(b-a)*(n-2))<<endl;
    
    return 0;
}








Measured memory_bytes: 256
#include <iostream>
using namespace std;
int fact(int n)
{
	int f=1;
	for(int i=1;i<=n;i++)
	{
		f*=n;
	}
	return f;
}
int main() {
	int n,m; cin>>n>>m;
	int ans=0;
	int f=(n*(n-1))/2;
	int s=(m*(m-1))/2;
	cout<<f+s;
	
}

Measured memory_bytes: 256
n = input()
l = len(n)
k = int(input())
dp = [[[0] * 2 for _ in range(k + 1)] for _ in range(l + 1)]
dp[0][k][1] = 1
for i in range(l):
  for j in range(k+1):
    if n[i] != '0':
      if j >= 1:
        dp[i+1][j-1][0] += dp[i][j][0]*9 + dp[i][j][1]*(int(n[i])-1)
        dp[i+1][j-1][1] += dp[i][j][1]
      dp[i+1][j][0] += dp[i][j][1] + dp[i][j][0]
    else:
      if j >= 1:
        dp[i+1][j-1][0] += dp[i][j][0]*9 
      dp[i+1][j][0] += dp[i][j][0]
      dp[i+1][j][1] += dp[i][j][1]
      
print(dp[l][0][0]+dp[l][0][1])

Measured memory_bytes: 38384
I = gets.to_i
t = {S: [*(1..13)], H: [*(1..13)], C:[*(1..13)], D:[*(1..13)]}
I.times{
  m, n = gets.split
  t[m.to_sym].delete n.to_i
}
t.each{|m, a|
  a.each{|n|
    puts "#{m} #{n}"
  }
}

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

int main() {
    long long N, ans;
    ans = 0;
    cin >> N;
    if (N % 2 != 0) {
        ans = 0;
    }
    else {
        long long denom = 10;
        while (denom <= N) {
            ans += N/denom;
            denom = denom * 5;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, a[100005], ans=0;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        ans+=a[i];
    }
    ans-=n;
    cout << ans;
}


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

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

  string cand1,cand2;
  for(int i=0; i<N; i++){
    cand1+= '0'+ M;
  }
  for(int i=0; i<M; i++){
    cand2+= '0'+ N;
  }

  string ans= (cand1 < cand2) ? cand1
                              : cand2;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  def solve(sc: Scanner): String = {
    val n = sc.nextInt()
    val ws = Vector.fill(n)(sc.nextInt())

    val sums = ArrayBuffer.empty[Int]
    for (i <- 1 to ws.length) {
      sums += abs(ws.slice(0, i).sum - ws.slice(i, ws.length).sum)
    }
    sums.min.toString
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


Measured memory_bytes: 27448
#include<bits/stdc++.h>
#include <ctime>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
#define all(x) (x).begin(), (x).end()   // sort(all(v)) instead sort(v.begin(),v.end())
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vi vector<int>
#define vl vector<int>
#define pb push_back
#define eb empalce_back
int main()
{   fast;
    int t=1;
    //cin>>t;
    while(t--){
        string str;
        cin>>str;
        ll n=0;
        f(i,str.size()){
            n=(n%9+((int)str[i]%48)%9)%9;

        }
        if(n%9==0)cout<<"Yes";
        else cout<<"No";
}

}

Measured memory_bytes: 3756
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n;
	cin >> n;

	vector<ll> a(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	ll m;
	cin >> m;

	vector<ll> b(m);
	for (ll i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	vector<ll> res;
	set_symmetric_difference(all(a), all(b), inserter(res, end(res)));

	for (ll it : res)
	{
		println(it);
	}
}



Measured memory_bytes: 10096
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
  int n; cin >> n;
  int k = n; if(n % 2 == 0) k++;
  lli res = 0;
  for(int i = 1; i <= n; i++){
    for(int j = i + 1; j <= n; j++){
      if(i + j != k){
        res++;
      }
    }
  }
  cout << res << BR;
  for(int i = 1; i <= n; i++){
    for(int j = i + 1; j <= n; j++){
      if(i + j != k){
        cout << i << " " << j << BR;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
  ll n, m, l;
  cin >> n >> m >> l;
  ll a[n][m] = {0}, b[m][l] = {0}, c[n][l] = {0};
  REP(i, n) {
    REP(j, m) {
      cin >> a[i][j];
    }
  }
  REP(i, m) {
    REP(j, l) {
      cin >> b[i][j];
    }
  }
  REP(i, n) {
    REP(j, l) {
      ll tmp = 0;
      REP(k, m) {
        tmp += a[i][k] * b[k][j];
      }
      c[i][j] = tmp;
    }
  }

  REP(i, n) {
    REP(j, l) {
      cout << c[i][j];
      if (j != l-1) cout << " ";
    }
    cout << "\n";
  }
}



Measured memory_bytes: 3300
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AMitsui solver = new AMitsui();
        solver.solve(1, in, out);
        out.close();
    }

    static class AMitsui {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            out.println(a != c ? "1" : "0");
        }

    }
}



Measured memory_bytes: 22228
N = int(input())
P = [int(v) for v in input().split(' ')]

def is_sorted(array):
    v0 = array[0]
    for i in range(1, len(array)):
        v = array[i]
        if v0 > v:
            return False
        v0 = v
    return True
    
if is_sorted(P):
    print('YES')
    exit()

for i in range(0, N - 1):
    for j in range(i + 1, N):
        tmp = P[i]
        P[i] = P[j]
        P[j] = tmp

        if is_sorted(P):
            print("YES")
            exit()

        tmp = P[i]
        P[i] = P[j]
        P[j] = tmp

print("NO")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 998244353
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	string s;
	cin >> s;
	int n = (int) s.size();
	int c = 0;
	int ans = n;
	for (int i = 0; i < n; i++) {
		if(s[i] == '1') {
			c++;
		}
		else {
			if(c > 0) {
				int val = max(n - i, i - c);
				val = max(val, min(n - (i - c), i));
				ans = min(ans, val);
				c = 0;
			}
		}
	}
	if(c > 0) {
		int val = max(n - n, n - c);
		val = max(val, min(n - (n - c), n));
		ans = min(ans, val);
		c = 0;
	}
	cout << ans;
}


Measured memory_bytes: 512
N,K = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]

for i in range(K):
    imos = [0] * (N+1)
    for n,a in enumerate(A):
        left = max(0,n-a)
        right = min(N-1,n+a) + 1
        imos[left] += 1
        imos[right] -= 1
    cur = 0
    A = []
    for n in range(N):
        cur += imos[n]
        A.append(cur)
    if all([a==N for a in A]):
        break
print(*A)


Measured memory_bytes: 180584
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int main()
{



    for(int i=0;i<5;i++){
        int a;
        cin >> a;

        if(a==0){

            cout << i+1 << endl;
            return 0;
        }
    }


    
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;
typedef long long ll;
const int N = 1e4+4;
int n;
int a[N];
int p[1000006];
int inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void primefact(int n){

    int p1=0,p2=0;
    while(n%2 == 0){
        p1++;
        n/=2;
    }
    p[2]= max(p[2],p1);
    for(int i = 3;i <= sqrt(n); i += 2){
        p2 = 0;
        while(n%i ==0){
            p2++;
            n/=i;
        }
        p[i] = max(p[i],p2);
    }
    if(n > 2)
        p[n] = max(p[n],1);
}

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

    for(int i=0;i<n;i++)
        primefact(a[i]);

    for(int i = 2;i <= 1000000;i++)
        l = (l % mod * fp(i,p[i]) % mod) % mod;

    for(int i = 0; i<n;i++)
        inv[a[i]] = fp(a[i],mod-2);

    int sum = 0;
    for(int i = 0; i<n;i++)
        sum = (sum % mod + (l*inv[a[i]])%mod) % mod;
    cout<<sum;

    return 0;
}


Measured memory_bytes: 9992
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
	  int b = sc.nextInt();
      if(a > 8 || b > 8)
      System.out.println(":(");
      else
      System.out.println("Yay!");
  }
}

Measured memory_bytes: 21204
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;

int main(){
  int N;
  cin>>N;
  string S;
  char SS[N];
  cin>>S;
  int K;
  cin>>K;
  for(int i=0; i<N; ++i){
    if(S.at(i)!=S.at(K-1)) SS[i]='*';
    else SS[i]=S.at(i);
  }
  for(int i=0; i<N-1; ++i) cout<<SS[i];
  cout<<SS[N-1]<<endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);		
		int K = a.nextInt();
		String S = a.next();
		if(K >= S.length()) {
			System.out.println(S);
		}else {
			String SS = S.substring(0,K);
			System.out.println(SS + "...");
		}
	}
}

Measured memory_bytes: 38592
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

unsigned GetDigit(unsigned num){
    return to_string(num).length();
}

int main(){
    int N,keta,ans;
    cin >> N;
    keta=GetDigit(N);
    if(keta==1){
        ans=N;
    }else if(keta==2){
        ans=9;
    }else if(keta==3){
        ans=9+N-99;
    }else if(keta==4){
        ans=9+900;
    }else if(keta==5){
        ans=909+N-9999;
    }else if(keta==6){
        ans=9+900+90000;
    }
    P(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l;
  int sum = 0, ml = 0;

  cin >> n;

  for(int i = 0;i < n;i++){
	cin >> l;
	sum += l;
	if(ml < l){
	  ml = l;
	}
  }

  if(sum - ml > ml){
	cout << "Yes" << endl;
  }else{
	cout << "No" << endl;
  }
	  
  return 0;
}


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


int main()
{
    long long ans=1;
    int N,K;
    cin>>N>>K;

    ans=K;

    for(int i=2;i<=N;i++){
        ans*=(K-1);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static long mod = (long)1e9+7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		long ans = pow(2,n);
		long minus = comb(n,a)+comb(n,b)+1;
		while(ans < minus)ans += mod;
		ans -= minus;
		ans %= mod;
		System.out.println(ans);
		sc.close();
	}
	public static long comb(long a, long b) {
		if(a < b) return -1;
		long ans = 1;
		long inv = pow(fact(b), mod-2);
		for (int i = 0; i < b; i++) {
			ans = ans*a%mod;
			a--;
		}
		ans = ans*inv%mod;
		return ans;
	}
	public static long pow(long x, long n) {
	    long sum = 1;
	    while (n > 0) {
	        if ((n & 1) == 1) {
	            sum = sum * x % mod;
	        }
	        x = x*x%mod;
	        n >>= 1;
	    }
	    return sum;
	}
	private static long fact(long n) {
	    long a = 1;
		while(n != 0) {
			a = a*n%mod;
			n = n-1;
		}
		return a;
	}
}

Measured memory_bytes: 21844
import math

R = 10**9 + 7

def combination(n,k):
    if 2*k > n:
        k = n - k

    r = 1
    for i in range(n-k+1,n+1):
        r = (r*i)

    r = (r//math.factorial(k))

    return r

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

decomposition = []
i = 2
while i * i <= M:
    if M % i == 0:
        decomposition.append(0)
        while M % i ==0:
            decomposition[-1] = decomposition[-1] + 1
            M = M//i
    i = i + 1
if M > 1:
    decomposition.append(1)

H = [ combination(N+k-1,k) % R for k in decomposition]
r = 1
for h in H:
    r = (r*h) % R

print(r)

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,m;
    vec dist(2000);
    pvvec x(3000);
    
    cin>>n>>m;
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        x[a].eb(b,c);
    }
    rep(i,n) dist[i]=-INF;
    dist[0]=0;
    
    ll p=dist[n-1];
    rep(i,8*n){
        rep(now,n){
            for(P k:x[now]){
                int next=k.fs;
                int cost=k.sc;
                dist[next]=max(dist[next],dist[now]+cost);
            }
        }

        if(p!=dist[n-1]&&i>=5*n){
            cout<<"inf"<<endl;
            return 0;
        }
        p=dist[n-1];
    }
    cout<<dist[n-1]<<endl;
}

Measured memory_bytes: 5120
#ARC60 C
N,A=map(int,input().split())
X=[""]+list(map(int,input().split()))
for i in range(1,N+1):
    X[i]-=A

dp=[[0 for j in range(5001)] for i in range(N+1)]

dp[0][2500]=1

for i in range(1,N+1):
    for j in range(5001):
        dp[i][j]+=dp[i-1][j]
        if 0<=j+X[i]<=5000:
            dp[i][j+X[i]]+=dp[i-1][j]

print(dp[N][2500]-1)

Measured memory_bytes: 42332
#include<bits/stdc++.h>
using namespace std;
int n,a[100],sum,k,b[100],g=1;
int main()
{

		cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--)
	{
		b[g]=a[i];
		g++;
	}
	for(int i=1;i<=k;i++)
	{
		sum+=b[i];
	}
	cout<<sum<<endl;
	return 0;
}

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

int main()
{
    ll n,m,d,t;
    cin >> n >> m >> d;
    if(d) t=(n-d)*2;
    else t=n;

    ll now=(m-1)*t;
    n=n*n;
    double ans=(double)now/n;
    printf("%.12f\n", ans);
}


Measured memory_bytes: 256