akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

#nCk
#0!~(n-1)!をmodしつつ求める
def fact_all(n,M=mod):
    f = [1]*n
    ans = 1
    for i in range(1,n):
        ans = ans*i
        ans = ans%M
        f[i] = ans
    return f


#a!をmodしつつ求める
def fact(a,M=mod):
    ans = 1
    for i in range(2,a+1):
        ans = ans*i
        ans = ans%M
    return ans


#互いに素なa,bについて、a*x+b*y=1の一つの解[x,y]を出力
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]


#aの逆元(mod M)を求める（aとMは互いに素）
def mod_inv(a,M=mod):
    x = extgcd(a,M)[0]
    return (M+x%M)%M


#nCkをmodしつつ返す
def nCk(n,k,fact_list=[],inv_list=[],M=mod):
    if fact_list and inv_list:
        return (fact_list[n]*inv_list[k]*inv_list[n-k])%M
    else:
        x = fact(n,M)
        y1 = mod_inv(fact(k,M),M)
        y2 = mod_inv(fact(n-k,M),M)
        return (x*y1*y2)%M

N,K = II()
A = III()
A.sort()

fact_list = fact_all(N+1)
inv_list = [mod_inv(f) for f in fact_list]
ans = 0
for i in range(1,N+1):
    a,b = 0,0
    if i-1>=K-1:
        a = nCk(i-1,K-1,fact_list,inv_list)
    if N-i>=K-1:
        b = nCk(N-i,K-1,fact_list,inv_list)
    ans += A[i-1]*(a-b)
    ans %= mod

print(ans)

Measured memory_bytes: 63472
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    h,w = list(map(int, input().split()))
    a = [input() for _ in range(h)]
    c = 0
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                c += 1
    if c == h + w -1:
        return 'Possible'
    return 'Impossible'


print(f())


Measured memory_bytes: 5548
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll P = 998244353, N, ans = 1;;
  std::cin >> N;
  std::vector<ll> D(N);
  for(int i=0;i<N;i++) std::cin >> D[i];
  if(D[0]!=0){
    std::cout << 0 << '\n';
    return 0;
  }else{
    std::vector<ll> data(200000, 0);
    for(int i=0;i<N;i++) data[D[i]]++;
    sort(D.begin(), D.end());
    for(int i=1;i<N;i++) {
      if(D[i]==0) ans = 0;
      else ans = (ans * data[D[i]-1])%P;
    }
    std::cout << ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define int long long
#define ull unsigned long long
#define mod 1000000007
#define vi vector<ll>
#define pb push_back
#define mp make_pair
#define str string
#define p(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define sp(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define all(v) v.begin(), v.end()
#define test cout<<"LOL_ABHISHEK"<<endl;
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//kehsihba();
	ll n,m;
	cin>>n>>m;
	vi v[n+1];
	ll vis[n+1]={0};
	ll dist[n+1]={0};
	ll a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	queue<ll>q;
	q.push(1);
	ll x=1;
	vis[1]=1;
	ll ans[n+1];memset(ans,-1,n+1);
	while(q.empty()!=1){
		ll p=q.front();
		q.pop();
		for(auto i:v[p]){
			if(vis[i]==0){
				q.push(i);
				vis[i]=1;
				dist[i]=dist[p]+1;
				ans[i]=p;
			}
		}
	}
	ll sum=0;
	for(int i=1;i<=n;i++){
		sum+=vis[i];
	}
	if(sum==n){cout<<"Yes"<<endl;
		for(int i=2;i<=n;i++){
			cout<<ans[i]<<endl;
		}
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 14596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int min = 10000, ans = 0;
		for(int i = 0; i < 2; ++i) {
			min = 10000;
			for(int j = 0; j < 2; ++j) {
		int a = sc.nextInt();
		min = Math.min(min, a);
			}
			ans += min;
		}
		sc.close();
		System.out.println(ans);
	}

}


Measured memory_bytes: 22740
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

n = max(A).bit_length()

cnt = [[0, 0] for _ in range(n)]

for x in A:
	x = "{:b}".format(x).zfill(n)
	for i in range(n):
		cnt[i][int(x[-(i+1)])] += 1

ans = 0

for i in range(n):
	bit_sum = ((cnt[i][0]*cnt[i][1])%mod) * pow(2, i, mod) % mod
	ans = (ans+bit_sum)%mod

print(ans)


Measured memory_bytes: 132112
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==1)a=14;
	if(b==1)b=14;
	if(a==b){
	cout<<"Draw";
	}
	else if(a>b){
		cout<<"Alice";
	}else{
		cout<<"Bob";
	}



}

Measured memory_bytes: 256
#include<stdio.h>
#include<stack>
#include<ctype.h>
#include<stdlib.h>
int main()
{
	char str[99],*p,*np;
	while(fgets(str,99,stdin) && !isspace(str[0]))
	{
		std::stack<double> s;
		for(p=str;*p;++p)
		{
			if(isspace(*p))continue;

			double u,v=strtod(p,&np);
			if(p!=np) s.push(v),p=np-1;
			else
			{
				u=s.top(),s.pop(),v=s.top(),s.pop();
				if(*p=='+') s.push(v+u);
				else if(*p=='-') s.push(v-u);
				else if(*p=='*') s.push(v*u);
				else if(*p=='/') s.push(v/u);
			}
		}
		printf("%f\n",s.top());
	}
	return 0;
}

//üÍ³ê½t|[hL@ðvZ¹æ
//EEEÇÌZqð·êÎ¢¢ñÅ·©ËH
//»µÄAuvÆÍÇñÈàÌðwµÄ¢éñÅ·©Ë¦

Measured memory_bytes: 0
/**
*    created: 03.07.2020 17:04:59
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    char mp[h][w];
    int ans[h][w];
    rep(i,h) rep(j,w) ans[i][j] = 0;
    rep(i,h) rep(j,w) cin >> mp[i][j];
    rep(i,h) rep(j,w) {
        if (mp[i][j] == '#') {
            ans[i][j] = -INF;
            if (0 <= j+1 && j+1 < w) ans[i][j+1]++;
            if (0 <= j-1 && j-1 < w) ans[i][j-1]++;
            if (0 <= i+1 && i+1 < h) ans[i+1][j]++;
            if (0 <= j-1 && j-1 < w && 0 <= i+1 && i+1 < h) ans[i+1][j-1]++;
            if (0 <= j+1 && j+1 < w && 0 <= i+1 && i+1 < h) ans[i+1][j+1]++;
            if (0 <= i-1 && i-1 < h) ans[i-1][j]++;
            if (0 <= j+1 && j+1 < w && 0 <= i-1 && i-1 < h) ans[i-1][j+1]++;
            if (0 <= j-1 && j-1 < w && 0 <= i-1 && i-1 < h) ans[i-1][j-1]++;
        }
    }
    rep(i,h) {
        rep(j,w) {
            if (ans[i][j] < 0) cout << '#';
            else cout << to_string(ans[i][j]);
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
<?php
$n = (int)trim(fgets(STDIN));

$comments = [];
for ($i=1; $i <= $n; $i++) { 
	$comments[$i] = [];
	$a = (int)trim(fgets(STDIN));
	for ($j=0; $j < $a; $j++) { 
		$input = explode(' ', trim(fgets(STDIN)));
		$x = (int)$input[0];
		$y = (int)$input[1];
		$comments[$i][] = [$x, $y];
	}
}
$result = 0;
// $n桁の二進数
$max = pow(2, $n) - 1;
$padding = strlen(decbin($max));
for ($i=0; $i <= $max; $i++) { 
	//ありうる組み合わせかどうか？
	$exists = true;
	$honest = 0;
	$bin = int2bin($i, $padding);
	// echo $bin . PHP_EOL;
	$b_length = strlen($bin);
	for ($j=0; $j < $b_length; $j++) { 
		//正直者は発言をチェック
		if ($bin[$j] == "1") {
			$honest += 1;
			foreach ($comments[$j+1] as $cmt) {
				if ($bin[$cmt[0]-1] != $cmt[1]) {
					$exists = false;
					break;
				}
			}
		}
		if (!$exists) {
			break;
		}
	}
	//その場合の正直者の人数は？
	if ($exists) {
		$result = max($result, $honest);
	}
}
echo $result;


function int2bin($int, $padding = 0){
	$bin = decbin($int);
	if ($padding > 0) {
		$bin = str_pad($bin, $padding, "0", STR_PAD_LEFT);
	}
	return $bin;
}

Measured memory_bytes: 4728
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const ll mod=1e9+7;
const int N=1e5+4;

int main()
{
	int n; scn(n);

	vector<int> va,vb;

	rep(i,0,n)
	{
		int x,y; scn(x); scn(y);

		va.pb(x+y); vb.pb(x-y);
	}

	sort(va.begin(),va.end()); sort(vb.begin(),vb.end());

	int ans = max(va[n-1]-va[0],vb[n-1]-vb[0]);

	pri(ans);

	return 0;
}

Measured memory_bytes: 5112
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];
  ll ans = LLONG_MAX;
  ll left = 0, right = k - 1;
  ll zerop = lower_bound(x.begin(), x.end(), 0) - x.begin();
  rep(i, n){
    if(right >= n)  break;
    ll cost;
    if(x[left] <= 0 && x[right] >= 0) cost = min(2 * abs(x[left]) + abs(x[right]), abs(x[left]) + 2 * abs(x[right]));
    else cost = max(abs(x[left]), abs(x[right]));
    ans = min(ans, cost);
    left++; right++;
  }

  cout << ans << endl;

}

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

const int N = 105;
const int K = 100005;
const int mod = 1e9 + 7;

void add(int &x,int y) {
	x += y; if (x >= mod) x -= mod;
}

void sub(int& x,int y) {
	x -= y; if (x < 0) x += mod;
}

int n, k;
int a[N];
int f[K];
int pre[K];

void build() {
	for (int i = 0; i <= k; ++i) {
		pre[i + 1] = pre[i];
		add(pre[i + 1], f[i]);
	}
}

int get(int l,int r) {
	int ans = pre[r + 1];
	sub(ans, pre[l]);
	return ans;
}

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	f[0] = 1;
	build();
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= k; ++j) {
			f[j] = get(max(0, j - a[i]), j);
		}
		build();
	} 
	printf("%d\n", f[k]);
}

Measured memory_bytes: 1024
#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 watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF 2e14
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int n,k;
string s;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n>>k>>s;
	
	int cnt=0;
	forn(i,1,n){
		if(s[i]!=s[i-1]){
			cnt++;
		}
	}
	
	cout<<n-max(1,cnt+1-2*k)<<'\n';
	
	return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long num = sc.nextLong();
		ArrayList<Integer> numList = new ArrayList<Integer>();
		while (true) {
			int digit = (int)(num % 26L);
			if (digit == 0) {
				digit = 26;
			}
			numList.add(digit + 96);
			num = (num - digit) / 26L;
			if (num == 0) {
				break;
			}
		}

		for (int i = numList.size() - 1; i >= 0; i--) {
			int let = (int)numList.get(i);
			char c = (char)let;
			System.out.print(c);
		}
	}


}


Measured memory_bytes: 35820
#include<iostream>

using namespace std;

int main(){
  int n;
  int u[100];
  int A[100][100] = {};
  
  cin >> n;
  
  for(int i = 0;i < n;i++){
    int k;
    cin >> u[i] >> k;
    int v[k];
    for(int j = 0;j < k;j++){
      cin >> v[j];
      A[i][v[j] - 1] = 1;
    }
  }
  
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      if(j > 0) cout << " ";
      cout << A[i][j];
    }
    cout << "\n";
  }
  
  return 0;
}



Measured memory_bytes: 3128
n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for j in range(n)] + [[0] * m]

sum0 = 0

for j in range(m):
    for i in range(n):
        sum0 += a[i][j]
    a[n][j] = sum0
    sum0 = 0

for k in range(n+1):

    a[k].append(sum(a[k]))
    print(' '.join([str(p) for p in a[k]]))



Measured memory_bytes: 5684
#include "bits/stdc++.h"
using namespace std ;



int main(){
	string s ;
	cin >> s ;
	
	for( int i = 1 ; i <= s.size() ; i++ ){
		if(i&1){
			if(s[i-1]== 'L'){
				puts("No");
				return 0 ;
			}
		}
		else{
			if( s[i-1] == 'R'){
				puts("No");
				return 0 ;
			}
		}
	}
	puts("Yes");

	return 0 ;
}

Measured memory_bytes: 256
/*
“Yesterday is history, tomorrow is a mystery, today is a gift of God,
which is why we call it the present.” ― Bill Keane
*/
#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGEsj
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
using namespace std;
typedef long long int lli;
constexpr int MAX=3e5;
inline lli add(lli a, lli b, int mod){
	lli x=a+b;
	if(x>=mod)
		x-=mod;
	return x; 
}
inline lli mul(lli a, lli b, int mod){
	return ((a%mod)*(b%mod))%mod;	
}
inline lli sub(lli a, lli b, int mod){
	lli x=a-b;
	if(x<0)
		x+=mod;
	return x;
}

lli powr(lli a, lli b, lli mod) {
	lli ans = 1;
	while(b) {
		if(b&1LL){
			ans=mul(ans,a,mod);
			b--;
		}
		a=mul(a,a,mod);
		b>>=1;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int bitcnt=0;
	for(char c: s) if(c=='1') bitcnt++;
	lli u, v;
	u=v=0;
	for(int i=n-1; i>=0; --i){
		if(s[i]=='1'){
			u=add(u, powr(2,n-i-1,bitcnt+1), bitcnt+1);
			u=u%(bitcnt+1);
			if(bitcnt-1==0) continue;
			v=add(v, powr(2,n-i-1,bitcnt-1), bitcnt-1);
			v=v%(bitcnt-1);
		}	
	}
	
	int dp[MAX]={0};
	dp[1]=1;
	dp[2]=1;
	for(int i=3; i<MAX; ++i){
		dp[i]=1+dp[i%__builtin_popcount(i)];
	}
	lli res;
	for(int i=0; i<n; ++i){
		if(s[i]=='1'){
			if(bitcnt-1==0){
				cout<<0<<endl;
				continue;
			}
			res=sub(v,powr(2,n-i-1,bitcnt-1),bitcnt-1);
			cout<<1+dp[res%(bitcnt-1)]<<endl;
		}
		else{
			res=add(u,powr(2,n-i-1,bitcnt+1),bitcnt+1);	
			cout<<1+dp[res%(bitcnt+1)]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4920
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    int n;
    int cmax;
    cin >> n >> cmax;
    Vec<Vec<int> > table(cmax, Vec<int>(100000, 0));
    FOR (i, 0, n) {
        int s;
        int t;
        int c;
        cin >> s >> t >> c;
        s--;
        t--;
        c--;
        EFOR (j, s, t) {
            table[c][j] = 1;
        }
    }

/*
    FOR (i, 0, cmax) {
        FOR (j, 0, 5) {
            cout << table[i][j] << " ";
        }
        cout << endl;
    }
*/

    int max_count = 0;
    FOR (i, 0, 100000) {
        int count = 0;
        FOR (j, 0, cmax) {
            if (table[j][i] == 1) {
                count++;
            }
        }
        max_count = max(max_count, count);
    }
    cout << max_count << endl;

    return 0;
}


Measured memory_bytes: 12416
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    long ans=a[0];
    for(int i=1;i<n;i++){
      ans=gcd(ans,a[i]);
    }
    System.out.println(ans);
  }
  static long gcd(long c,long d){
    while(true){
      long f=c%d;
      if(f==0){
        return d;
      }
      c=d;
      d=f;
    }
  }
}

Measured memory_bytes: 50556
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };




/******************************************************************************************/





int main() {

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

	for (int i = 0; i < n-1; i++)
	{
		if (a[i] < a[i + 1]) {
			a[i + 1]--;
		}
	}

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

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


	cout << "Yes" << endl;



	return 0;
}


Measured memory_bytes: 640
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n) :
	a = list(map(int, input().split()))
	if sum([x * y for (x, y) in zip(a, b)]) + c > 0 :
		ans += 1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a[3],n;
    cin>>a[0]>>a[1]>>a[2]>>n;
    sort(a,a+3);
    int ans=0;
    for(int i=0;i*a[2]<=n;i++){
        for(int j=0;i*a[2]+j*a[1]<=n;j++){
            if((n-i*a[2]-j*a[1])%a[0]==0) ans++;
        }
    }
    cout<<ans;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  int dp[N+1][3];
  for(int i=0; i<3; ++i) dp[0][i]=0;
  
  for(int i=0; i<N; ++i){
    int a,b,c;
    cin>>a>>b>>c;
    dp[i+1][0]=max(dp[i][1],dp[i][2])+a;
    dp[i+1][1]=max(dp[i][0],dp[i][2])+b;
    dp[i+1][2]=max(dp[i][1],dp[i][0])+c;
  }
  cout<<max(dp[N][0],max(dp[N][1],dp[N][2]))<<endl;
}


Measured memory_bytes: 1408
/**
*    author:  yuya1234
*    created: 08.07.2020 16:45:50
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  string s,ss;
  cin>>s;
  ss=s;

  string m="keyence";
  int cnt=0;

  REP(i,SZ(m))
  {
    if(m[i]==s[i])cnt++;
    else break;
  }

  if(cnt==0)
  {
    REPD(i,SZ(m))
    {
      if(m[i]==s[SZ(s)-SZ(m)+i])cnt++;
      else break;
    }
  }
  else if(cnt!=7)
  {
    REPD(i,SZ(m))
    {
      if(m[i]==s[SZ(s)-SZ(m)+i])cnt++;
      else break;
    }
  }

  if(cnt>=7)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}

Measured memory_bytes: 3640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int N=sc.nextInt();
		int K=sc.nextInt();
		if((N+1)/2>=K) {
			pw.println("YES");
		}else {
			pw.println("NO");
		}
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,n,i,sum=0;
	cin>>h>>n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n;i++)
	{
		sum=sum+a[i];
	}
	if(sum>=h)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int X[100010];
    for (int i = 1;i <= N;i++) {
    	cin >> X[i];
    }
    int sol = 0;
    int crt = 0;
    for (int i = 1;i <= N;i++) {
    	if (X[i] == i) crt++;
    	else {
    		sol += (crt + 1) / 2;
    		crt = 0;
    	}
    }
    sol += (crt + 1) / 2;
    cout << sol << endl;
    return 0;
}

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

long long MOD = 1e9 + 7;

long long mul(long long a, long long b) {
    return a * b % MOD;
}

long long fac[100010];

long long pow_mod(long long x, long long n) {
    long long res = 1;
    while (n) {
        if (n & 1) res = mul(res, x);
        x = mul(x, x);
        n /= 2;
    }
    return res;
}

long long inv(long long n) {
    return pow_mod(n, MOD - 2);
}

long long binomial(int k, int n) {
    if(n<0 || k<0 || n-k<0) return 0;
    return mul(mul(fac[n], inv(fac[n - k])), inv(fac[k]));
}

int main(int argc, char *argv[])
{
    fac[0] = 1;
    for (int i = 1; i < 100001; i++) {
        fac[i] = mul(fac[i - 1], i);
    }
    int N, K;
    cin >> N >> K;
    vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(begin(a), end(a));
    long long res = 0;
    for (int i = N - 1; i >= K - 1; i--) {
        res = (res + mul(a[i], binomial(K - 1, i))) % MOD;
    }
    for (int i = 0; i <= N - K; i++) {
        res = (res - mul(a[i], binomial(K - 1, N - i - 1)) + MOD) % MOD;
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,maxz,ans,a[10000+5];
string st;
int main()
{
	cin>>n;
	cin>>st;
	for(int i=0;i<n;i++)
	{
		if(st[i]=='D')--ans;
		else ++ans;
		a[i]=ans;
	}
	for(int i=0;i<n;i++)
	{
		maxz=max(a[i],maxz);
	}
	cout<<maxz;
}

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

E = [None] * N
for _ in range(N):
    u, k, *vs = map(int, input().split())
    E[u] = []
    for i in range(k):
        v, c = vs[i*2], vs[i*2+1]
        E[u].append((v, c))

import heapq

vis = [False] * N
inf = 1e9
d = [inf] * N
d[0] = 0
pq = [(0, 0)]
while pq:
    nv, ni = heapq.heappop(pq)
    if nv > d[ni]:
        continue
    d[ni] = nv
    vis[ni] = True
    for v, c in E[ni]:
        nc = d[ni] + c
        if not vis[v] and nc < d[v]:
            heapq.heappush(pq, (nc, v))

for v in range(N):
    print(v, d[v])


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll A;
    string S;
    cin >> A >> S;
    ll B = 0;
    B += (S[0]-'0')*100;
    B += (S[2]-'0')*10;
    B += (S[3]-'0')*1;
    cout << A * B /100 << endl;

    return 0;
}

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

int main() {
  LL A,V,B,W,T;
  cin >> A >> V >> B >> W >> T;

  if (V < W) {
    cout << "NO" << endl;
    return 0;
  }
  LL d = abs(B - A);
  LL v = (V - W) * T;
  if (d <= v) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    string S=in<string>();
    int cnt_1=0;int cnt_0;
    REP(i,S.size()){
        // debug(S[i]);
        if(S[i]=='1')cnt_1++;
    }   
    int ans;cnt_0=S.size()-cnt_1;
    ans=min(cnt_1,cnt_0);
    cout<<ans*2<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
        int b =sc.nextInt();
        int c =sc.nextInt();
        if(a>b){
            int t = a;
            a = b;
            b = t;}
        if(b>c){
            int u = c;
            c = b;
            b = u;}
        if(a>b){
            int v = a;
            a = b;
            b = v;}
            System.out.println(a+" "+b+" "+c);
    }
}


Measured memory_bytes: 26252
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
const int MAX_V = 100010;
typedef pair<int, int> P;
vector<P> G[MAX_V];
int color[MAX_V];
int N; 
void dfs(int v, int p = -1, int depth = 0) {
    color[v] = depth % 2;
    for(auto to: G[v]) {
        if(p == to.first) continue;
        int d = depth + to.second;
        dfs(to.first, v, d);
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--; w %= 2;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    dfs(0, 0);
    rep(i, N) {
        if(color[i] == 1) cout << 1 << endl;
        else cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  if (N % 2) {
    cout << "No" << endl;
    return 0;
  }

  int n = N / 2;
  if (S.substr(0, n) == S.substr(n, n)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

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

    long long int h[n];
    for (int i=0;i<n;i++){
        scanf("%lld",&h[i]);
        // printf("%lld\n",h[i]);
    }

    int flag[n];
    for (int i=0;i<n;i++)
        flag[i]=1;

    int a[m];
    int b[m];
    for (int i=0;i<m;i++){
        scanf("%d %d",&a[i],&b[i]);
        if (h[a[i]-1]<h[b[i]-1]){
            flag[a[i]-1]=0;
        }else if (h[a[i]-1]>h[b[i]-1]){
            flag[b[i]-1]=0;
        }else{
            flag[a[i]-1]=0;
            flag[b[i]-1]=0;
        }
    }

    int ans=0;
    for (int i=0;i<n;i++){
        // printf("flag[%d]=%d\n",i,flag[i]);
        if (flag[i]==1)
            ans=ans+1;
    }

    printf("%d\n",ans);


    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b;
  std::cin >> a >> b;
  if(a>0) std::cout << "Positive" << '\n';
  else if((a<=0 && b>=0)||a==0||b==0) std::cout << "Zero" << '\n';
  else std::cout << ((b - a)%2==0?"Negative":"Positive") << '\n';
  return 0;
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  ll x, k, d; cin >> x >> k >> d;
  x = abs(x);
  ll st = min(k, x/d);
  ll now = x - st*d;
  k -= st;
  if(k&1) now = abs(now-d);
  cout << now << "\n";
  return 0;
}

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

using namespace std;

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

  int n;
  cin >> n;

  int cmd, val;
  int lhd, rhd;

  set<int> s;
  set<int>::iterator it;
  for (int i = 0; i < n; i++) {
    cin >> cmd;
    switch (cmd) {
      case 0:
        cin >> val;
        s.insert(val);
        cout << s.size() << endl;
        break;

      case 1:
        cin >> val;
        it = s.find(val);

        if (it != s.end() && *it == val) {
          cout << 1 << endl;

        } else {
          cout << 0 << endl;
        }
        break;

      case 2:
        cin >> val;
        it = s.find(val);
        if (it != s.end()) {
          s.erase(it);
        }
        break;

      case 3:
        cin >> lhd >> rhd;

        for (auto itr = s.lower_bound(lhd); itr != s.end() && *itr <= rhd; itr++) {
          cout << *itr << endl;
        }
        break;
    }
  }
}




Measured memory_bytes: 12492
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	k = 0
	n = len(l)
	l = sorted(l)
	while(k < n-1):
		ans = l[0] + l[1]
		zz = ans/2
		l.pop(0)
		l.pop(0)
		l.insert(0,zz)
		k += 1
	return round(l[0],10)

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print("%10f"%ans)


Measured memory_bytes: 6244
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	long long int N, K, res = -1000000009;
	vector<long long int> P, C, score;
	cin >> N >> K ;

	P.resize(N+1);
	C.resize(N+1);
	score.resize(N+1);

	for(int i = 1; i<N+1; i++){
		cin >> P[i];
	}
	for(int i = 1; i<N+1; i++){
		cin >> C[i];
	}

	for(int i = 1; i<N+1; i++){
		int tmpIdx = i, loopL = 0;
		long long int loopS = 0, score = 0;

		do{
			loopL++;
			tmpIdx = P[tmpIdx];
			loopS += C[tmpIdx];
			score += C[tmpIdx];

			if(loopL <= K){
				res = max(res, score);
			}
		}while(tmpIdx != i);
		score = 0;
		if(K >= loopL && loopS > 0){
			for(int j=1; j<loopL+1; j++){
				tmpIdx = P[tmpIdx];
				score += C[tmpIdx];
				res = max(res, score + loopS*((K-j)/loopL));
			}
		}

	}
	
	
	cout << res;
	return 0;
}



Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   int x,y;x=y=0;
   if(a==5)x++;
   if(a==7)y++;
   if(b==5)x++;
   if(b==7)y++;
   if(c==5)x++;
   if(c==7)y++;
   if(x==2&&y==1)cout<<"YES\n";
   else cout<<"NO\n";
}


Measured memory_bytes: 256
fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}



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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  ll t[2];
  ll a[2];
  ll b[2];
  rep(i, 2) cin >> t[i];
  rep(i, 2) cin >> a[i];
  rep(i, 2) cin >> b[i];
  ll p, q;
  p = t[0] * (b[0] - a[0]);
  q = p + t[1] * (b[1] - a[1]);
  if (p > 0) {
    q = -q;
    p = -p;
  }
  if (q < 0) {
    cout << 0 << endl;
    return;
  }
  if (q == 0) {
    cout << "infinity" << endl;
    return;
  }
  ll ans = abs(p) / q * 2;
  if (abs(p) % q != 0) ans++;
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 384
count=int(input())

data=[]
for i in range(count):
    data.append(input()[0])

counts=[0,0,0,0,0]

M=0
A=0
R=0
C=0
H=0

for i in data:
    if i=='M':
        counts[0]+=1
    if i=='A':
        counts[1]+=1
    if i=='R':
        counts[2]+=1
    if i=='C':
        counts[3]+=1
    if i=='H':
        counts[4]+=1

ans=0

select=[(0,1,2),(0,1,3),(0,1,4),(0,2,3),(0,2,4),(0,3,4),(1,2,3),(1,2,4),(1,3,4),(2,3,4)]

for i in select:
    ans+=counts[i[0]]*counts[i[1]]*counts[i[2]]
    
print(ans)

Measured memory_bytes: 4012
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<int>());

    int ret = 0;
    while (a[0] >= n) {
        for (int i = 0; i < n; i++) {
            auto num = (int) ceil(1.0 * (a[i] - (n - 1)) / n);
            num = max(0LL, num);
            a[i] -= num * n;
            for (int j = 0; j < n; j++) {
                if (i == j) continue;
                a[j] += num;
            }
            ret += num;
        }
        sort(a, a + n, greater<int>());
    }

    cout << ret << endl;

    return 0;
}

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

int main( void )
{
	register int i, j;

	bool isPrime[50001 + 1];
	isPrime[2] = true;
	for ( i = 3; i < 50001; i += 2 )
	{
		isPrime[i] = true;
	}

	for ( i = 3; i < 50001; i += 2 )
	{
		for ( j = i + i; j < 50001; j += i )
		{
			isPrime[j] = false;
		}
	}

	int cnt = 1;
	int primes[5500];
	primes[0] = 2;
	for ( i = 3; i < 50001; i += 2 )
	{
		if ( isPrime[i] )
		{
			primes[cnt] = i;
			cnt++;
		}
	}

	int n;
	while ( cin >> n && n != 0 )
	{
		int kotae = 0;
		for ( i = 0; i < cnt; i++ )
		{
			if ( primes[i] <= n / 2 )
			{
				if ( isPrime[n-primes[i]] )
					kotae++;
			}
		}
		cout << kotae << endl;
	}

	return 0;
}

Measured memory_bytes: 936
N=input().split()
A=int(N[0])
B=int(N[1])
C=int(N[2])
D=int(N[3])

t=0
if(C<A):
 if(D<=A):
  t=0
 if(A<D<=B):
  t=D-A
 if(B<D):
  t=B-A

if(A<C):
 if(B<=C):
  t=0
 if(C<B<=D):
  t=B-C
 if(D<B):
  t=D-C

if(A==C):
 if(B<=D):
  t=B-A
 else:
  t=D-A
  
print(t)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const int INF = 1e+9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int MAX_N = 110000;

int memo[MAX_N];
int rec(int n) {
  if (n == 0) return 0;
  if (memo[n] != -1) return memo[n];

  int ans = n;
  for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
    ans = min(ans, rec(n-pow6)+1);
  }
  for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
    ans = min(ans, rec(n-pow9)+1);
  }

  return memo[n] = ans;
}

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

  for (int i = 0; i < MAX_N; i++) {
    memo[i] =  -1;
  }
  cout << rec(N) << endl;
}

Measured memory_bytes: 3840
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
x = input()

# N のすべての正の約数を求める
# O(sqrt(N))
def divisor_list(N): #約数のリスト
    if N == 1: return [1]
    res = []
    for i in range(1,N):
        if i*i >= N: break
        if N%i == 0:
            res.append(i)
            res.append(N//i)
    if i*i == N: res.append(i)
    return sorted(res)


div = divisor_list(n)

div = [i for i in div if i%2]


ans = []

MOD = 998244353
for i in div:
    per = n//i
    if i == 1:
        less = 0
        eq = 1
        for j in x:
            if j=="1":
                less *= 2
                less += eq
                less %= MOD
            else:
                less *= 2
                less %= MOD
        res = less+1
        #print(less,eq)
        ans.append(res)
    else:
        per = n//i
        less = 0
        eq = 1
        for j in x[:per]:
            if j=="1":
                less *= 2
                less += eq
                less %= MOD
            else:
                less *= 2
                less %= MOD
        res = less

        X = x[:per]
        Y = "".join(["1" if i=="0" else "0" for i in X])
        X = X+Y
        X = (X*i)[:n]
        if X <= x: res += 1
                
        #ans -= res*(2*(n-per))%MOD
        ans.append(res)



for j in range(len(ans)-1,-1,-1):
    for k in range(j):
        if div[j]%div[k] == 0:
            ans[k] -= ans[j]

    
res = 0    
for d,a in zip(div,ans):
    res += a*(n//d)*2%MOD

print(res%MOD)    










Measured memory_bytes: 120160