akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
ll M = 998244353;

int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	int k; cin>>k; k--;
	cout<<a[k];
	//if(k==31) cout<<s[32];


	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {

	N := oneInt()
	var count map[int]int

	count = make(map[int]int)

	for i := 1; i < N; i++ {
		count[oneInt()]++
	}

	for i := 1; i <= N; i++ {
		fmt.Println(count[i])
	}

}

func exp(val int) float64 {
	var temp float64
	for index := 1; index <= val; index++ {
		temp += float64(index)
	}
	return temp / float64(val)
}

func searchAbove(slice []int, target int, index int) int {
	for i := index + 1; i < len(slice); i++ {
		v := slice[i]
		if v >= target {
			return i
		}
	}
	return -1
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 14992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(a) cout<<#a<<":"<<a<<endl;
const ll INF=0x3f3f3f3f;
const ll N=4e6+7;
const ll mod=1e9+7;
ll maxn,minn;
ll T,n,m;
ll mp[100][100];
ll dp[N];

int main(){
	cin>>n;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			scanf("%lld",&mp[i][j]);
		}
	}
	dp[0]=1;
	for(ll i=0;i<(1<<n);i++){
		ll num=0;
		for(ll j=0;j<n;j++){
			if((i>>j)&1){
				num++;
			}
		}
		for(ll j=0;j<n;j++){
			if(mp[num][j]==1&&((1<<j)^i)!=i){
				dp[(1<<j)^i]=(dp[(1<<j)^i]+dp[i])%mod;
			}
		}
	}
	cout<<dp[(1<<n)-1]<<endl;


	return 0;
}





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


int main()
{
	int a, b, c;
	cin >>a>>b;
	if((a==0)&&(b==0))
	{
		return 0;
	}
	else
	{
		do
		{
			if(a>b)
		    {
			c=a;
			a=b;
			b=c;
		    }
		    else{}
		    cout <<a<<" "<<b<<"\n";
		    cin >>a>>b;
		}
		while((a!=0)||(b!=0));
		return 0;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <assert.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repn(a,b,c) for(int a=b;a>=c;a--)
#define ll long long 
#define sum(a,b) a=a+b
#define mem(a, b) memset(a, (b), sizeof(a))
#define ctz(x) __builtin_ctz(x)
#define clz(x) __builtin_clz(x)
#define popcount(x) __builtin_popcount(x)
#define parity(x) __builtin_parity(x)

//=======binarysearch===========
int bs(vector<string>&a,string  que){
 auto it=lower_bound(a.begin(),a.end(),que);
 if(*it==que){
    return it-a.begin();
 }
 return -1;
}
//========binarysearch=========


bool isprime(int x)
{
  if ( x == 2 ) return true;
  if ( x  < 2 ) return false;
  for ( int i = 2; i * i <= x; i++ )
    if ( x % i == 0 ) return false;


  if(x==0) return false;
  return true;
}


int main(){


string s;
cin>>s;

int x;
cin>>x;

rep(i,0,s.size()-1){
  if(i%x==0){
    cout<<s[i];
  }
}


}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();

    println!("{}", if a==b && b==c {"Yes"} else {"No"});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

struct UnionFind{
	vl par,dist;
	UnionFind(int x){par.assign(x,-1); dist.assign(x,0);}
	ll find(ll x){return par[x]<0?x:find(par[x]);}
	ll depth(ll x){return par[x]<0?0:depth(par[x])+dist[x];}
	bool same(ll x,ll y){return find(x)==find(y);}
	ll size(ll x){return -par[find(x)];}
	ll diff(ll x,ll y){return same(x,y)?depth(x)-depth(y):LINF;}
	void unite(ll x,ll y,ll k=0){
		k+=depth(y); k-=depth(x); k=-k;
		x=find(x); y=find(y);
		if(x==y)return;
		if(size(x)<size(y)){swap(x,y);k=-k;}
		par[x]+=par[y]; par[y]=x; dist[y]=k;
	}
};
ll g(ll a){
	return (a*(a-1)/2);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vector<pll> v(m);
	rrep(i,m)cin>>v[i].fs>>v[i].sc;

	UnionFind uf(n);
	vl ans(m+1,0);
	rep(i,m){
		ll a,b;
		tie(a,b)=v[i];
		a--; b--;
		if(uf.same(a,b)){
			ans[i+1]=ans[i];
			continue;
		}
		//puta(i,uf.size(a),uf.size(b));
		ll t=g(uf.size(a))+g(uf.size(b));
		uf.unite(a,b);
		//puta(i+1,"=",ans[i],"-",t,"+",g(uf.size(a)));
		ans[i+1]=ans[i]-t+g(uf.size(a));
	}
	rrep(i,m){
		puta(g(n)-ans[i]);
	}
	//puta(ans);
	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <stack>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
#define ll long long
static const int MAX = 100010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;



int main() {

  int N;
  cin >> N;
  vector<ll> H(N);
  int count = 0;
  int maxmax = 0;

  REP(i, N){
    cin >> H[i];
  }

  REP(i, N-1){
    if( H[i] >= H[i+1] ){
      count++;
    } else {
      maxmax = max( maxmax, count );
      count = 0;
    }
  }
  maxmax = max( maxmax, count );

  cout << maxmax << endl;
 
  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=1e6+5;

ll cp[60]={1},cb[60]={0};

ll dfs(int n,ll x)
{
    if(n==0)return 1;
    ll sum=cp[n-1]+cb[n-1];
    if(x==1)return 0;
    if(x<=1+sum)return dfs(n-1,x-1);
    if(x==1+sum+1)return cp[n-1]+1;
    if(x<=1+sum+1+sum)return cp[n-1]+1+dfs(n-1,x-sum-2);
    return cp[n-1]*2+1;
}
int main()
{
    for(int i=1;i<=51;i++)
    {
        cp[i]=2*cp[i-1]+1;
        cb[i]=2*cb[i-1]+2;
    }
    ll n,x;
    while(cin>>n>>x)
    {
        ll ans=dfs(n,x);
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=mod;
  ll n,m,k;
  cin>>k >>n;
  ll a[n+2] = {0};
  a[n+1] = k;
  for (ll i = 1; i <= n; ++i){		
  cin>>a[i];
  }
  for (ll i = 2; i <= n; ++i){
  		x+=(a[i]-a[i-1]);
  }
  ans =x;
  for (ll i = 2; i <= n; ++i){
  		
  ans = min(ans,x-(a[i]-a[i-1]) + k - a[n]+a[1]);
  //c( ((a[i-1]-a[i-2])+(a[i+1]-a[i])));
  }

  c(ans);
  
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int r; cin>>r;
	cout<<r*r<<endl;
	return 0;
}

Measured memory_bytes: 256
class Burg:
    def __init__(self):
        self.lv = [2**(i+1) - 1 for i in range(51)]

    def make_burg(self, n, m):
        if n == 0:
            return 1, m - 1
        num = 4 * 2**n - 3
        if num <= m:
            return self.lv[n], m - num
        if m <= 1:
            return 0, 0
        a, b = self.make_burg(n - 1, m - 1)
        if b <= 1:
            return a + b, 0
        c, d = self.make_burg(n - 1, b - 1)
        return a + c + 1, max(0, d - 1)

n, x = map(int, input().split())

gen = Burg()
print(gen.make_burg(n, x)[0])

Measured memory_bytes: 3064
import sys
from collections import Counter

input = sys.stdin.readline

n = int(input())
v = list(map(int, input().split()))
arr1 = list(Counter([v[i] for i in range(n) if i % 2 == 0]).items())
arr2 = list(Counter([v[i] for i in range(n) if i % 2 == 1]).items())

arr1.append((0, 0))
arr2.append((0, 0))

arr1.sort(key=lambda x:x[1])
arr2.sort(key=lambda x:x[1])

if arr1[-1][0] == arr2[-1][0]:
    ans = min(n - arr1[-1][1] - arr2[-2][1], n - arr1[-2][1] - arr2[-1][1])
else:
    ans = n - arr1[-1][1] - arr2[-1][1]

print(ans)

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

typedef long long ll;
typedef unsigned long long llu;

int main(int argc, char *argv[]) {
  ll n;
  cin >> n;

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

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

  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    for (ll j = i; j <= i+1; ++j) {
      ll teki = 0;
      if (a[j] > b[i]) {
        teki = b[i];
        b[i] = 0;
      } else {
        teki = a[j];
        b[i] -= a[j];
      }
      a[j] -= teki;
      ans += teki;
    }
  }

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

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

int main()
{
  int n;
  string str;
  cin >> n >> str;
  int count = n;
  rep(i, n - 1)
  {
    if(str[i] == str[i + 1])
    {
      count--;
    }
  }
  cout << count << endl;
}


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

string S;
int N;

vector<string> split(string str, string sep) {
  vector<string> result;
  int index = 0;
  while (1) {
    int pos = str.find(sep, index);
    if (pos == string::npos) {
      result.push_back(str.substr(index));
      return result;
    }
    result.push_back(str.substr(index, pos - index));
    index = pos + sep.size();
  }
}

long long func(string str, int n) {
  if (n == 0) return func(str += S.at(0), 1);
  else if (n == N) {
    vector<string> result = split(str, "+");
    long long sum = 0;
    for (string v : result) sum += stoll(v);
    return sum;
  }
  else return func(str + "+" + S.at(n), n+1) + func(str + S.at(n), n+1);
}

int main() {
  cin >> S;
  N = S.size();
  cout << func("", 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()

inline void fastin(int &num) {
  int c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

inline void fastout(int &n) {
  int N = n, rev, count = 0;
  rev = N;
  if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
  while ((rev % 10) == 0) { ++count; rev /= 10;}
  rev = 0;
  while (N != 0) { rev = (rev << 3) + (rev << 1) + N % 10; N /= 10;}
  while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
  while (count--) putchar_unlocked('0');
}

const int INF = 1e9;

int main(){
  int N, M, R; fastin(N); fastin(M); fastin(R);
  vector<int> r(R); rep(i, R) {fastin(r[i]); --r[i];}
  sort(all(r));

  int dis[N][N];
  rep(i, N){
    rep(j, N) {
      if (i == j) dis[i][j] = dis[j][i] = 0;
      else dis[i][j] = dis[j][i] = INF;
    }
  }

  rep(i, M){
    int a, b, c; fastin(a); fastin(b); fastin(c);
    --a; --b;
    dis[a][b] = dis[b][a] = c;
  }

  rep(k, N){
    rep(i, N){
      rep(j, N){
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }

  int ans = 1e9;

  do{
    int temp = 0;
    for (int i = 1; i < R; ++i){
      temp += dis[r[i - 1]][r[i]];
    }
    ans = min(ans, temp);
  } while(next_permutation(all(r)));

  fastout(ans);

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
main(){
  int x;cin >> x;
  if(x==0){
    cout << '1' << endl;
    return 0;
  } else if(x==1){
    cout << '0' << endl;
    return 0;
  }
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
using namespace std;
int main()
{
	int a, b, c, d, e, i, j, k, l, m, n, o, p, q, r;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	j = b%d;
	if (j>0)
	{
		b = b / d;
		b = b + 1;
	}
	else if (j == 0)
	{
		b = b / d;
	}
	i = c%e;
	if (i>0)
	{
		c = c / e;
		c = c + 1;
	}
	else if (i == 0)
	{
		c = c / e;
	}
	a=a-max(b, c);
	cout <<a<< endl;
	return 0;
}

Measured memory_bytes: 1160
(function main() {
  let line = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('');
  // 初めの上昇と平坦を除去
  while (line.length > 0 && line[0] !== '\\') line.shift();
  // 終わりの下降と平坦を除去
  while (line.length > 0 && line[line.length - 1] !== '/') line.pop();

  let height_list = [0];
  let current_height = 0;
  line.forEach(function(e, i){
      if (e === '\\') current_height--;
      else if (e === '/') current_height++;
      height_list.push(current_height);
  });

  let h, sum = 0;
  let holes = [];
  for (;height_list.length > 1;) {
    if (h = makeHole(height_list)) {
      sum += h;
      holes.push(h);
    }
  }

  console.log(sum);
  console.log(holes.length && holes.length + ' ' + holes.join(' '));
})();

function makeHole(list) {
    begin = list.shift();
    if (list[0] < begin && begin <= list.reduce((a, b) => Math.max(a, b), -100000)) {
    let area = 0;
      while (!(list.length === 0 || begin <= list[0])) area += begin - list.shift();
      return area;
    }
    return 0;
}



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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

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;}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
//const int mod = 1000000007;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//[mint]
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}c(200005);

struct hoge{
  ll x; // typedef long long ll;
  hoge(ll x=0):x((x%mod+mod)%mod){}
};

int main(){
  int n,m,k;cin>>n>>m>>k;
  mint ans=0;
  mint col=m;
  for(int i=n-1;i>=0;i--){
    mint now=col;
    now *=c(n-1,i);
    if(i<=k)ans+=now;
    col*=(m-1);
  }
  cout<<ans;
}


Measured memory_bytes: 6244
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();

		long mod = 1000000007;
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 2; i <= N; i++) {
			boolean flag = true;
			for(int j = 2; j < i; j++) {
				if(i % j == 0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				list.add(i);
			}
		}

		int[]p = new int[list.size()];
		for(int i = 0; i < list.size(); i++) {
			int k = list.get(i);
			for(int j = 2; j <= N; j++) {
				int t = j;
				while(t % k == 0) {
					t /= k;
					p[i]++;
				}
			}
		}
		long cnt = 1;
		for(int i : p) {
			cnt *= (i + 1);
			cnt %= mod;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin>>n;
  vector<int64_t> a(n);
 for(int i=0;i<n;i++){
   cin>>a.at(i);
 }
  int64_t count=0; 
  for(int i=0;i<n;i++){
    count+=a.at(i);
  }
  if(count%2==0){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)  a[i] = 20001*(i+1);
    for(int i = 0; i < n; i++)  b[i] = 20001*(n-i);
    vector<int> r(n);
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        r[x-1] = i+1;
    }
    for(int i = 0; i < n; i++)  cout << a[i] << " \n"[i+1==n];
    for(int i = 0; i < n; i++)  cout << b[i]+r[i] << " \n"[i+1==n];
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a,b,c;
    int k;
    cin>>a>>b>>c>>k;
    while(b<=a){
    	b*=2;
    	k--;
	}
	if(k<0){
		cout<<"No"<<endl;
		return 0;
	}
	while(c<=b){
		c*=2;
		k--;
	}
	if(k<0){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
//		Scanner s = new Scanner(System.in);
		int c,total=0,s=0;
		c=System.in.read();
		
		while(c!='\n'&&c!='\r')
		{
			total++;
			if(c=='S')
				s++;
			else
			{
				if(s>0)
				{
					s--;
					total-=2;
				}
			}
			c=System.in.read();
		}
		
		System.out.println(total);
	}

}


Measured memory_bytes: 8532
import numpy as np
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
s = np.array(s)
out = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        if i == 0 and j == 0:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif i == 0 and j == w-1:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j]
        elif i == h-1 and j == 0:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif i == h-1 and j == w-1:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j - 1]
            right = s[i][j]
        elif i == 0 and j != 0 and j != w-1:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j + 1]
        elif i == h-1 and j != 0 and j != w-1:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j - 1]
            right = s[i][j + 1]
        elif j == 0 and i !=  0 and i != h-1:
            up = s[i - 1][j]
            down = s[i + 1][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif j == w-1 and i != 0 and i!= h-1:
            up = s[i - 1][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j]
        else:
            up = s[i-1][j]
            down = s[i+1][j]
            left = s[i][j-1]
            right = s[i][j+1]
        if s[i][j] != up and s[i][j] != down and s[i][j] != left and s[i][j] != right:
            out = "No"
print(out)


Measured memory_bytes: 21536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int t,x,y;
  int bx,by,bt = 0;
  int chk = 1;
  int i;
  for(i=0;i<n;i++){
    bt = t;
    bx = x;
    by = y;
    t = 0;
    x = 0;
    y = 0;
    cin >> t >> x >> y;
    if(t%2 != (x+y)%2) chk = 0;
    if(t-bt < abs(x-bx)+abs(y-by))chk = 0;

    
  }
  if(chk==1)cout << "Yes";
  else cout << "No";
  
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int s1 = sc.nextInt();
   int s2 = sc.nextInt();
   int s3 = sc.nextInt();
   if(s1+s2<s3)System.out.println("dangerous");
   else if(s1>=s3)System.out.println("delicious");
   else System.out.println("safe");
 }
}

Measured memory_bytes: 21844
//https://atcoder.jp/contests/abc124/tasks/abc124_a

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>


using namespace std;
int main(){
	int a,b,ans;
	cin>>a>>b;
	if(a==b) ans=2*a;
	if(a!=b) ans=max(a,b)*2-1;
	cout<<ans<<endl;
}



Measured memory_bytes: 256
n, t = map(int, input().split())
a = [int(x) for x in input().split()]
c = 0
s = 0
e = 0
for k in a:
    if k >= e:
        c += e - s
        s = k
        e = k + t
    else:
        e = k + t
c += e - s
print(c)


Measured memory_bytes: 25196
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
typedef long long lint;
using namespace std;

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

int main(){
    int N,X,x[100010];
    cin>>N>>X;

    for(int t=0;t<N;t++){
        cin>>x[t];
        x[t]=abs(X-x[t]);
    }

    if(N==1){
        cout<<x[0];
        return 0;
    }

    int temp;
    for(int t=0;t<N-1;t++){
        if(t==0){
            temp=gcd(x[0],x[1]);
        }else{
            temp=gcd(temp,x[t+1]);
        } 
    }

    cout<<temp<<"\n";
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std; 

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; i++) {
        cin >> X[i];
    }

    // min_P Y,  Y = (sum (X_i - P)^2)

    int ans = 1e8;
    for(int i = 0; i < 100; i++) {
        int sum = 0;
        for(int j = 0; j < N; j++) {
            sum += (X[j] - i) * (X[j] - i);
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
 
int comp(const void *p, const void *q){
 
    return * (int*) q - * (int*) p;
 
    }
                                                                                       
  
int main(void){
                                                                                                
   
    int n, m, i;
   
    int d[200001];

    int t[200001];

    int a = 0;
   
    int  j = 0;

      
    scanf("%d", &n);

   
    for( i = 0 ; i < n ; i = i + 1 ){

         scanf("%d", &d[i]);

         }

   
    scanf("%d", &m);


    for( i = 0 ; i < m ; i = i + 1 ){

         scanf("%d", &t[i]);

         }


    qsort( d, n, sizeof(int), comp );

    qsort( t, m, sizeof(int), comp );


    for( i = 0 ; i < m ; i = i + 1 ){

         for(  ; j < n ; j = j + 1 ){

               if( t[i] == d[j] ){

               a += 1;

               j = j + 1;

               break;

               }

            }

         }


    if( a == m ) printf("YES\n");

    else printf("NO\n");


    return 0;
                                                          
}

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

typedef pair<int,int> P;
const int INF = 500000000;

int main(){
    ll x,ans=0;
    cin >> x;
    ans += x/500*1000;
    x %= 500;
    ans += x/5*5;
    cout << ans << "\n";
}

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

int main()
{
    long long int i,j,k,a,b,c,d,n;
    vector <long long int> v2;
    cin>>n;
    j=0;
    for(i=0;i<n;i++)
    {
        cin>>a;
        v2.push_back(a);
    }
    if(n%2==0)
    {
        if(n>2)
         a=2;
        else
          a=-1;
        b=n-1;
        while(b>=1)
       {
        cout<<v2[b];
        b-=2;
        cout<<" ";
       }
       cout<<v2[0]<<" ";
       while(a<n)
       {
           cout<<v2[a];
           a+=2;
           if(a!=(n-1))
            cout<<" ";
       }
       cout<<"\n";
    }
    else
    {
        a=n-1;
        if(n>1)
            b=1;
        else
            b=-1;
        while(a>=2)
        {
            cout<<v2[a];
            a-=2;
            cout<<" ";
        }
        cout<<v2[0]<<" ";
        while(b<n && b!=-1)
        {
            cout<<v2[b];
            b+=2;
            if(b!=(n-1))
                cout<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3824
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

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


#############
# Main Code #
#############

S = input()
print(S[:3])

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

int main()
{
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    ll sum = 0;
    rep(i, n) {
        sum += a[i];
        if(x >= sum) {
            ans++;
        }
        else {
            cout << ans << endl;
            return 0;
        }
    }
    if(x == sum) cout << n << endl;
    else cout << n - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int INF=1000000000000000005;
int main() 
{   
long long int n,W;
  scanf("%lld %lld",&n,&W);
long long int v[n],w[n];
long long int sum=0;
for(long long int i=0;i<n;i++)
{scanf("%lld %lld",&w[i],&v[i]);
   
}
for(long long int i=0;i<n;i++)
{sum=sum+v[i];
   
}
long long int dp[sum+1];
memset(dp,INF,sizeof(dp));
dp[0]=0;
for(long long int i=0;i<n;i++)
{


  for(long long int j=sum-v[i];j>=0;j--)
  {

dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);


  }
}
long long int ans=0;
for (long long int i = 0; i <=sum; ++i)
{


  if(dp[i]<=W)
    ans=max(ans,i);
}

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

}

Measured memory_bytes: 1024
include Math
while gets
    x,rad=1.0,0.0
    s=$_.to_i
    break if s==-1
    (s-1).times do
        r=sqrt(x**2+1)
        rad+=asin(1/r)
        x=r
    end
    printf("%.2f\n%.2f\n",x*cos(rad),x*sin(rad))
end

Measured memory_bytes: 6208
#include <iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;

int main() {
	long long n,m;cin>>n>>m;
	string s,t;cin>>s>>t;
	long long mul=1;
	long long n2,m2;
	n2=n;
	m2=m;
	int i=2;
	while((i<=n)*(i<=m)){
		if(n2%i==0){
			if(m2%i==0){
				n2/=i;
				m2/=i;
				mul*=i;
				i=1;
			}
		}
		i++;
	}
	long long minm=mul*n2*m2;
//	cout<<mul<<' '<<n2<<' '<<m2<<endl;
	map<long long,char> ans;
	for(int j=0;j<n;j++){
		ans[j*minm/n]='1';
	}
//	for(int j=0;j<minm;j++){
//		cout<<ans[j];
//	}
	for(int j=0;j<m;j++){
//		cout<<ans[j*minm/m]<<t[j]<<endl;
		ans[j*minm/m]='1';
	}
	for(int j=0;j<n;j++){
		ans[j*minm/n]=s[j];
	}
//	for(int j=0;j<minm;j++){
//		cout<<ans[j];
//	}
	for(int j=0;j<m;j++){
//		cout<<ans[j*minm/m]<<t[j]<<endl;
		if(ans[j*minm/m]!='1'){
			if(ans[j*minm/m]!=t[j]){
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	cout<<minm<<endl;
	return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k;
  cin >> n >> k;
  vector<ll> p(n);
  rep(i, 0, n) cin >> p[i];

  vector<double> acc(n + 1, 0);
  rep(i, 0, n) {
    double t = (p[i] * (p[i] + 1)) / 2.0L;
    acc[i + 1] = acc[i] + t / p[i];
  }

  double ans = 0;
  rep(i, 0, n) {
    if (i + k > n)
      break;
    chmax(ans, acc[i + k] - acc[i]);
  }

  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 6364
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int dp[1024][100001];

void dfs(int v, int L, int &ans, vector<int> &W, vector<int> &V, int now=0) {
    if(v < 1024) {
        ans = max(ans, dp[v][L] + now);
    } else {
        dfs(v/2, L, ans, W, V, now);
        if(L - W[v] >= 0) {
            dfs(v/2, L - W[v], ans, W, V, now+V[v]);
        }
    }
}

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

    int N;
    cin >> N;
    vector<int> V(N+1), W(N+1);
    for(int i=1; i<=N; i++) {
        cin >> V[i] >> W[i];
    }

    for(int i=1; i<1024; i++) {
        for(int k=100001; k>=0; k--) {
            if(k - W[i] < 0) {
                dp[i][k] = dp[i/2][k];
            } else {
                dp[i][k] = max(dp[i/2][k - W[i]] + V[i], dp[i/2][k]);
            }
        }
    }

    int Q;
    cin >> Q;
    while(Q--) {
        int v, L;
        cin >> v >> L;
        int ans = 0;
        dfs(v, L, ans, W, V);
        // printf("%d\n", ans);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 404844
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;
int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll reverse(ll num)
{
     ll n, reversedNumber = 0, remainder;
     n=num;
    while(n != 0)
    {
        remainder = n%10;
        reversedNumber = reversedNumber*10 + remainder;
        n /= 10;
    }
    return reversedNumber;
}
bool divisor(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll a;
   cin>>a;
   cout<<a+(a*a)+(a*a*a);
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> arr(n);
  for(int i = 0; i < n-1; i++){
   int t;cin>>t;
    arr[t-1]++;
  }
  for(int i : arr) cout<<i<<"\n";
}


Measured memory_bytes: 4048
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

int memo[1000010];
int dfs(int n) {
	if (n == 0) {
		return 0;
	}
	if (memo[n] != -1) {
		return memo[n];
	}
	int res = n;
	for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
		res = min(res, dfs(n - pow6) + 1);
	}
	for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
		res = min(res, dfs(n - pow9) + 1);
	}
	return memo[n] = res;
}
signed main() {
	int N;
	cin >> N;
	for (int i = 0; i < 1000010; i++) {
		memo[i] = -1;
	}
	cout << dfs(N) << endl;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

using ll    = long long;
using vll   = vector<ll>;
using pll   = pair<ll,ll>;
using ld    = long double;

const ll mod = (ll)1e9 + 7;
const ll mxN = (ll)4e5 + 3;

void solve() {
	ll n;cin>>n;
	ll ans=0,msf=-1e18;
	for(int i=0,x;i<n;i++) {
		cin>>x;
		if(x>=msf) ans++,msf=x;
	}
	cout<<ans<<"\n";
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	pre();
//	ll t;cin>>t;while (t--)
		solve();
}


Measured memory_bytes: 3644
#include <stdio.h>
typedef long long ll;
char txt[4];
int gcd(int a, int b){
	return a%b?gcd(b,a%b):b;
}
int main(){
	int SW = 2;
	if(SW == 0){
		scanf("%s",txt);
		bool f = false;
		for(int i=0;i<3;i++) f|=txt[i]=='7';
		printf("%s",f?"Yes":"No");
	}
	else if(SW==1){
		ll N;scanf("%lld",&N);
		ll ret = N*(N+1)/2;
		ret -= 3*(N/3)*(N/3+1)/2;
		ret -= 5*(N/5)*(N/5+1)/2;
		ret += 15*(N/15)*(N/15+1)/2;
		printf("%lld",ret);
	}
	else{
		ll K;scanf("%lld",&K);
		ll sum=0;
		for(ll i=1;i<=K;i++){
			for(int j=1;j<=K;j++){
				for(int k=1;k<=K;k++){
					sum+=gcd(gcd(i,j),k);
				}
			}
		}
		printf("%lld",sum);
	}
}

Measured memory_bytes: 1736
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];


int main()
{
	long long K, A, B, cnt = 0, tmp, ans = 1;
	cin >> K >> A >> B;
	bool flag = false;
	if (B > A + 2)flag = true;

	for (int i = 0; i < K; i++) {
		if (!flag || (ans < A || i == K - 1))
		{
			ans++;
		}
		else{
			ans += B - A;
			i++;
		}
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

struct punct
{
    long long val;
    int poz;
};

punct sum[200010];
int aib[200010],n;

int cmp(punct a,punct b)
{
    if(a.val==b.val) return a.poz<b.poz;
    else return a.val<b.val;
}

void aib_update(int poz,int val)
{
    for(int i=poz;i<=n;i+=i&(-i))
        aib[i]+=val;
}

int aib_query(int poz)
{
    int s=0;
    for(int i=poz;i>=1;i-=i&(-i))
        s+=aib[i];
    return s;
}

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    int k,x;
    long long sol=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        x-=k;
        sum[i].val=sum[i-1].val+x;
        sum[i].poz=i;
    }
    sort(sum+1,sum+n+1,cmp);
    for(int i=1;i<=n;i++)
    {
        aib_update(sum[i].poz,1);
        if(sum[i].val>=0) sol++;
        sol+=aib_query(sum[i].poz-1);
    }
    printf("%lld",sol);
    return 0;
}


Measured memory_bytes: 4096
# coding: utf-8
H,W=map(int,input().split())
picture=[]

for i in range(H):
    row=list(input())
    picture.append(row)

dx=[1,0,-1,0,1,-1,1,-1]
dy=[0,1,0,-1,1,1,-1,-1]

for i in range(H):
    for j in range(W):

        x=j
        y=i
        cnt=0
        if picture[y][x]=="#":
            continue
        
        for k in range(8):
            nx=x+dx[k]
            ny=y+dy[k]
            if 0<=nx<=(W-1) and 0<=ny<=(H-1):
                if picture[ny][nx]=="#":
                    cnt+=1
        picture[y][x]=str(cnt)
        
for i in range(H):
    print("".join(picture[i]))



Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
 	int a, b; cin>>a>>b;
  	for(int i = 1; i < 2000; i++){
     	if((int)(i*0.08) == a && (int)(i*0.1) == b){
        	cout<<i<<endl;
          	return 0;
        }
    }
  	cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t;
     cin>>t;
     cout<<acos(-1)*t*2<<endl;

}


Measured memory_bytes: 3752
#include<stdio.h>
int main(){
  int n,i,b,f,r,v,total[5][4][11]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    total[b][f][r]+=v;
  }
  for(b=1;b<5;b++){
    for(f=1;f<4;f++){
      for(r=1;r<11;r++){
    if(total[b][f][r]<0)total[b][f][r]=0;
    if(total[b][f][r]>9)total[b][f][r]=9;
    printf(" %d",total[b][f][r]);
      }
      printf("\n");
    }
    if(b!=4)printf("####################\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>

int main()
{
  long int w, a, b;

  scanf("%ld %ld %ld", &w, &a, &b);

  if (a + w < b)
    printf("%ld\n", b - (a + w));
  else if (b + w < a)
    printf("%ld\n", a - (b + w));
  else
    printf("0\n");
  return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  string s = readString();
  sort(ALL(s));
  if (s == "abc")
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <math.h>

#define M_PI 3.141592653589793

int main(void) {

	int i = 0, j;
	int a[10000], b[10000];
	int flag = 0;
	char op[10000];

	while (1) {
		scanf("%d %c %d", &a[i], &op[i], &b[i]);
		if (op[i] == '?') {
			break;
		}
		else {
			i++;
		}
	}


	for (j = 0; j < i; j++) {
		switch (op[j]) {
		case '+': printf("%d\n", a[j] + b[j]); break;
		case '-': printf("%d\n", a[j] - b[j]); break;
		case '*': printf("%d\n", a[j] * b[j]); break;
		case '/': printf("%d\n", a[j] / b[j]); break;
		}
	}

	return 0;
}

Measured memory_bytes: 2672
#include <iostream>

using namespace std;

int a[5];

int main(void)
{
	for(int i = 0; i < 5; i++) cin >> a[i];
	int ans = 0, mx = 0;
	for(int i = 0; i < 5; i++) ans += (a[i]+9)/10*10;
	for(int i = 0; i < 5; i++) mx = max(mx, (a[i]+9)/10*10 - a[i]);
	ans -= mx;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int X, N;
    cin >> X >> N;
    vector<bool> hist(201, 1);
    rep(i, N) {
        int p;
        cin >> p;
        hist[p] = false;
    }
    int now = INF;
    int res = X;
    for(int x = 200; x >= -100; x--) {
        if(x >= 0 && !hist[x])
            continue;
        if(abs(X - x) <= now) {
            res = x;
            now = min(now, abs(X - x));
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

int H, W;
vector<string>S;
char f(int x,int y) {
	int nx, ny, cnt = 0;
	for (int dx = -1; dx <= 1; dx++) {
		for (int dy = -1; dy <= 1; dy++) {
			if (dx == 0 && dy == 0)continue;
			nx = x + dx;
			ny = y + dy;
			if (0 <= nx && nx < H && 0 <= ny && ny < W && S[nx][ny] == '#')cnt++;
		}
	}
	char ch = '0' + cnt;
	return ch;
}
signed main() {
	cin >> H >> W;
	string s;
	rep(i, H) {
		cin >> s;
		S.push_back(s);
	}
	rep(i, H)rep(j, W) {
		if (S[i][j] == '#')continue;
		else S[i][j] = f(i, j);
	}
	rep(i, H) {
		rep(j, W)cout << S[i][j];
		cout << endl;
	}
}

Measured memory_bytes: 256
from sys import exit

x, n = map(int, input().split())
p = list(map(int, input().split()))
for d in range(x+1): #0に達した時点で0を出力して終了するので、大きい側は気にしなくてよい
    for s in [-1, 1]:
        a = x + d*s
        if not a in p:
            print(a)
            exit()

Measured memory_bytes: 9092
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

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

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

signed main() {
  string s;
  cin >> s;

  int a = 0, b = 0;
  rep(i, 0, s.length()) {
    if(s[i] == '1') a++;
    else b++;
  }

  cout << s.length() - abs(a - b) << endl;
}


Measured memory_bytes: 512