akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]++;
    }

    vl v(n+1);  // v[i] : i番目(iは0-index)の山の一番上の数
    v[n] = INF;
    rep(i, n) {
        // vの中でa[i]未満のものの最大値の位置posを二分探索で高速に求める
        auto pos0 = lower_bound(all(v), a[i]);  // vの中でa[i]以上の値が現れる最初の位置のイテレータ
        pos0--;  // vの中でa[i]未満の値が現れる最後の位置のイテレータ
        auto pos = pos0 - v.begin();
        v[pos] = a[i];  // pos番目の山にa[i]を置く
    }

    ll ans = 0;
    rep(i, n) {
        if(v[i] > 0) {
            ans++;
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1920
# -*- coding: utf-8 -*-

def maximum_profit_1(n, R):
    maxv = R[1] - R[0]
    for j in range(1, n):
        for i in range(j):
            maxv = max(maxv, R[j]-R[i])

    return maxv

def maximum_profit_2(n, R):
    minv = R[0]
    maxv = R[1] - R[0]
    for j in range(1, n):
        maxv = max(maxv, R[j]-minv)
        minv = min(minv, R[j])

    return maxv

if __name__ == '__main__':

    n = int(input())
    R = [ int(input()) for i in range(n)]

    ans = maximum_profit_2(n ,R)
    print(ans)


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

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



int main()
{
    int n;
    sf(n);
    int a=0 ,b=0,c=0,d=0;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="AC")c++;
        else if(s=="TLE")a++;
        else if(s=="WA")b++;
        else d++;
    }
    pf("AC x %d\n",c);
    pf("WA x %d\n",b);
    pf("TLE x %d\n",a);
    pf("RE x %d\n",d);
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#include<cmath>
#define ll long long int
#define ld double
#define pb push_back
#define ii pair<int,int>
#define setin set.insert
using namespace std;
vector<int>v;
set<int>set;
vector<ii>vp;
int main()
{
    ld a,b,h,m;
    cin >> a >> b >> h >> m;
    ld k=h*30.0 + m/2.0;
    ld l=m*6.0;
    ld ang=abs(l-k);
    if(ang>180.0)
        ang=360.0-ang;
        ang*=M_PI/180.0;
    ld f=cos(ang);
    ld p= a*a + b*b - 2.0*a*b*f;
    p=sqrt(p);
    cout << fixed << setprecision(20) << p << endl;
    return 0;
}


Measured memory_bytes: 4188
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 200002;

int n;
char a[MAX];

int main(void) {
	// in = fopen("B.in", "rt");
	
	fscanf(in, "%s", a);
	n = (int)strlen(a);
	
	for (int i = 0; i < n; i++) {
	    if (a[i] == '?')
	       a[i] = 'D';
    }
    fprintf(out, "%s\n", a);
	
	return 0;
}

Measured memory_bytes: 1924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    rep(i, 0, 61) {
        int sum1 = 0;
        rep(j, 0, n) {
            if (a[j] & (1LL << i)) sum1++;
        }
        ans += (((1LL << i) % MOD) * (((ll)sum1 * (n - sum1)) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2688
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
vector<ll> fact;
vector<ll> ifact;
ll add(ll a,ll b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
ll mult(ll a,ll b)
{
	ll res = a*b%MOD;
	if(res < 0)res+=MOD;
	return res;
}
ll binpow(ll a, ll b)
{
	ll r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
ll choose(ll a, ll b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	ll r = mult(ifact[b],ifact[a-b]);
	r = mult(r,fact[a]);
	return r;
}
ll inv(int a){return binpow(a,MOD-2);}
void init(ll n)
{
	fact.clear(); ifact.clear();
	fact.resize(n+1);
	ifact.resize(n+1);
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=n;i++){fact[i]=mult(fact[i-1],i);}
	ifact[n] = inv(fact[n]);
	for(int i=n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
}
ll rchoose(ll n,ll r){
	ll res = 1;
	for(int i=0;i<r;i++)res = mult(res,n-i);
	res = mult(res,ifact[fact[r]]);
	return res;
}
ll pchoose(ll a,ll b)
{
	if(a<b)return 0;
	if(b == 0)return 1;
	return mult(fact[a],ifact[a-b]);
}
int main()
{
	ll n,m;
	cin>>n>>m;
	init(500005);
	ll ans = pchoose(m,n);
	ll b = ans;
	for(int i=1;i<=n;i++)
	{
		b=add(b,mult((i&1?-1:1)*choose(n,i),pchoose(m-i,n-i)));
		if(b<0)b+=MOD;
	}
    cout<<mult(ans,b);
}


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

#define si(v) v.size()
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (n); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  int x = 800 * n;
  int y = n / 15 * 200;

  cout << x - y << endl;
  
  return (0);
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin>>n;
	priority_queue<int,vector<int>,greater<int> > q;
	for(int i = 0; i < n; i++) {
		int v;
		cin>>v;
		q.push(v);
	}
	double ans = q.top();q.pop();
	while(!q.empty()) {
		double nx = q.top();q.pop();
		ans = (ans+nx)/2.0;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
while True:
    ( m, f, r) = [ int(i) for i in input().split()]
    if ( m == f == r == -1): break

    total = m + f
    achieve = ''
    if m == -1 or f == -1 or total < 30: achieve = 'F'
    elif total < 50 and r < 50: achieve = 'D'
    elif total < 65: achieve = 'C'
    elif total < 80: achieve = 'B'
    else: achieve = 'A'

    print(achieve)

Measured memory_bytes: 6724
import math
import copy
from collections import defaultdict

N,P= map( int , raw_input().split() )
Po=copy.deepcopy(P)

if P==1:
	print 1
	quit()

p=int( math.sqrt(P)) +2

D=defaultdict(lambda: 0)
 
L=range(2,p)
 
for l in L:
	while P%l==0:
		P/=l
		D[l]+=1
else:
	D[P]+=1


if len(D)==0:
	print Po	
else:
	ans=1
	for x,y in D.items():
		if y>=N:
			ans*= x**(y/N)
	print ans

Measured memory_bytes: 29164
package main

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

var sc = bufio.NewScanner(os.Stdin)

func contains(target string, list []string) bool {
	for _, r := range list {
		if target == r {
			return true
		}
	}
	return false
}

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

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

func Ave(s []int) int {
	val := 0
	for _, i := range s {
		val += i
	}
	return int(val / len(s))
}
func cal(i int) (sum int) {
	for i != 0 {
		sum += i % 10
		i /= 10
	}
	return
}
func max(a []int) (idx int, val int) {
	max := a[0]
	idx = 0
	for j, i := range a {
		if max < i {
			max = i
			idx = j
		}
	}
	return idx, max
}

func draw(i int, a []int) (l []int) {
	// p = a[i]
	for j := i; j < len(a); j++ {
		if j != len(a)-1 {
			a[j] = a[j+1]
		} else if j == len(a)-1 {
			a = a[:len(a)-1]
		}
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer([]byte{}, math.MaxInt64)
	// a := make([][]int, 3)
	// for i := 0; i < 3; i++ {
	// 	a[i] = make([]int, 3)
	// }
	// for i := 0; i < 3; i++ {
	// 	for j := 0; j < 3; j++ {
	// 		a[i][j] = nextInt()
	// 	}
	// }

	n := nextInt()
	k := nextInt()
	var x []int

	for i := 0; i < n; i++ {
		x = append(x, nextInt())
	}

	sum := 0
	for _, v := range x {
		if v < k-v {
			sum += v * 2
		} else {
			sum += (k - v) * 2
		}
	}

	fmt.Println(sum)

}


Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
using namespace std;
bool d[33554432];
char k[128];

int c(char str[12]){
	int ans = str[0];
	for(int i = 1;str[i] != '\0';i++){
		ans <<= 2;
		ans += k[str[i]];
	}
	return ans;
}

int main(){
	k['A'] = 0;k['C'] = 1;k['G'] = 2;k['T'] = 3;
	int n;scanf("%d", &n);
	char s[7], str[12];
	while(n--){
		scanf("%s %s", s, str);
		if(s[0] == 'i')d[c(str)] = true;
		else puts(d[c(str)] ? "yes" : "no");
	}
	return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <cctype>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cstring>
#include <fstream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <queue>
#include <iterator>
#include <limits>

using namespace std;

int main()
    {
          char str[16];
          int N,i,win=0;
          cin>>str;
          N=strlen(str);
          for(i = 0;i < N;i++)
          {
               if(str[i] == 'o')
               win++;
          }
          if(((15 - N) + win) >= 8)
          cout<<"YES";
          else
          cout<<"NO";
          //system("pause");
          return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD (ll)(1e9 + 7)
using namespace std;
class UF
{
private:
public:
    UF *root;
    int value;
    UF(int n = 0)
    {
        root = this;
        value = 1;
    }
    void showInfo(void)
    {
        cout << "rootNode:" << root << ",value:" << value << endl;
    }
};

void connectNode(UF *a, UF *b)
{
    while (b->root != b)
        b = b->root;
    while (a->root != a)
        a = a->root;

    if (a > b)
    {
        a->root = b;
    }
    if (a < b)
    {
        b->root = a;
    }
    return;
}
bool hasSameRoot(UF *a, UF *b)
{

    UF *pa = a;
    UF *pb = b;
    while (a->root != a)
        a = a->root;
    while (b->root != b)
        b = b->root;
    pa->root = a;
    pb->root = b;

    return a == b;
}
int main()
{
    int h, w;
    cin >> h >> w;
    char g[h + 20][w + 20];
    int x[h + 20][w + 20], y[h + 20][w + 20];
    rep(i, h + 20) rep(j, w + 20)
    {
        x[i][j] = 0;
        y[i][j] = 0;
        g[i][j] = 0;
    }

    rep(i, h) rep(j, w)
    {
        x[i][j] = 0;
        y[i][j] = 0;
        cin >> g[i][j];
    }
    rep(i, h)
    {
        int st = 0;
        int num = 0;
        rep(j, w + 1)
        {
            if (g[i][j] == '.' && j != w)
            {
                num++;
            }
            else
            {
                rep(k, st, j)
                {
                    x[i][k] = num;
                }
                num = 0;
                st = j + 1;
            }
        }
    }
    rep(j, w)
    {
        int st = 0;
        int num = 0;
        rep(i, h + 1)
        {
            if (g[i][j] == '.' && i != h)
            {
                num++;
            }
            else
            {
                rep(k, st, i)
                {
                    y[k][j] = num;
                }
                num = 0;
                st = i + 1;
            }
        }
    }

    int ans = -1;
    rep(i, h) rep(j, w)
    {
        ans = max(ans, x[i][j] + y[i][j] - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 36096
N = gets.to_i
T, A = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)

ans_h_i = nil
min_diff = Float::INFINITY
H.each.with_index(1) do |h, i|
  t = T - h * 0.006
  diff = (A - t).abs
  if min_diff > diff
    min_diff = diff
    ans_h_i = i
  end
end

puts ans_h_i


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();
  vector<int> a(n);

  cin >> a;

  vector<int> cnt[5];
  for (int i = 0; i < n; ++i) {
    cnt[a[i] + 2].push_back(i);
  }

  vector<int> ans;

  bool f = false;
  if (cnt[0].size() & 1 && cnt[1].size() > 0) {
    ans.push_back(cnt[1][0]);
    f = true;
  }
  for (int i = 0; i < cnt[0].size() / 2 * 2 + f; ++i) {
    ans.push_back(cnt[0][i]);
  }
  for (int i = 0; i < cnt[4].size(); ++i) {
    ans.push_back(cnt[4][i]);
  }

  sort(all(ans));
  cout << ans.size() << endl;
  for (auto &i : ans) cout << i + 1 << endl;
}



Measured memory_bytes: 3224
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 4e+18;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N, K; cin >> N >> K;
    int x[55], y[55];
    vector<int> xs, ys;
    rep(i, N) {
        cin >> x[i] >> y[i];
        xs.pb(x[i]);
        ys.pb(y[i]);
    }
    sort(all(xs));
    sort(all(ys));
    map<int, int> mpx, mpy;
    rep(i, N) {
        mpx[xs[i]] = i;
        mpy[ys[i]] = i;
    }
    int res[55][55];
    memset(res, 0, sizeof(res));
    rep(i, N) {
        res[mpx[x[i]]][mpy[y[i]]] ++;
    }
    int cnt[55][55];
    memset(cnt, 0, sizeof(cnt));
    rep(i, N) {
        rep(j, N) {
            cnt[i + 1][j + 1] = cnt[i][j + 1] + cnt[i + 1][j] - cnt[i][j] + res[i][j];
        }
    }
    int ans = INF;
    rep(xmin, N) {
        Rep(xmax, xmin + 1, N) {
            rep(ymin, N) {
                Rep(ymax, ymin + 1, N) {
                    int ret = (xs[xmax] - xs[xmin]) * (ys[ymax] - ys[ymin]);
                    if(cnt[xmax + 1][ymax + 1] - cnt[xmin][ymax + 1] - cnt[xmax + 1][ymin] + cnt[xmin][ymin] >= K) {
                        ans = min(ans, ret);
                    }
                }
            }
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char ch;

    
  
    scanf("%c", &ch);


    if(ch >= 'A' && ch <= 'Z')
    {
        printf("A");
    }
    else if(ch >= 'a' && ch <= 'z')
    {
        printf("a");
    }
   

    return 0;
}

Measured memory_bytes: 1600
def sum(s,k)
  first=s[0]
  if s.split('').all?{|c| c==s[0] }
    puts s.length*k/2
  else
    top=0
    bot=0
    cnt=0
    i=0
    while i < s.length
      n=1
      for j in (i+1)..s.length
        if s[i] == s[j]
          n+=1
        else
          break
        end
      end
      if i.zero?
        top = n
        i+=n
        next
      end
      if i + n >= s.length
        bot = n
        i+=n
        next
      end
      i+=n
      cnt += n/2
    end
    all=cnt*k
    if first == s[s.length-1]
      a=(top+bot)/2*(k-1)
      b=top/2+(bot/2)
      all+=a+b
      puts all
    else
      all+=k*(top/2+(bot/2))
      puts all
    end
  end
end

sum(gets.chomp, gets.chomp.to_i)

Measured memory_bytes: 1916
# https://atcoder.jp/contests/agc002/tasks/agc002_b
import sys
input = sys.stdin.buffer.readline

n, m = [int(i) for i in input().split()]

count = [1] * (n + 1)  # 1-indexed
have_red = [0] * (n + 1)  # 1-indexed
have_red[1] = 1
for _ in range(m):
    x, y = [int(i) for i in input().split()]
    if have_red[x]:
        have_red[y] = 1
    count[x] -= 1
    count[y] += 1
    if count[x] == 0:
        have_red[x] = 0

ans = sum(have_red)

print(ans)


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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define boost ios::sync_with_stdio(0);cin.tie(0);
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)

const int N = 200002;
ll dp[N];
int last[N];
int val[N];

int main()
{
    boost
    //code
    memset(last,-1,sizeof(last));
    memset(val,-1,sizeof(val));
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin >> v[i];
    ll ans = 0;
	for(int i=n-1;i>=0;i--){
		if(last[v[i]]!=-1) val[i] = last[v[i]];
		last[v[i]] = i; 
	}
	dp[n] = 1;
	for(int i=n-1;i>=0;i--){
		if(val[i]==-1){
			dp[i] = dp[i+1];
		}
		else{
			if(val[i]==i+1) dp[i] = dp[i+1];
			else dp[i] = dp[val[i]]+dp[i+1];
		}
		dp[i] %= mod;
		// debug2(i,dp[i]);
	}
	cout << dp[0] << endl;
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 10000000;
static const ll MOD = 1000000007;

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

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



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

int main(){
  int64_t N,M;
  cin >> N >> M;
  int64_t ans;
  if(N<=M/2){
    ans=N;
    M-=N*2;
    ans+=M/4;
    cout << ans << endl;
  }else{
    ans=M/2;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
#define R(i,n) for(int i = 1; i<n; i++)
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  vector<int> v(26,0);
  r(i,s.length())v.at(s.at(i)-'a')++;
  r(i,27){
    if(i==26)cout << "None"<<endl;
    else{
      if(v.at(i)==0){
        cout << char('a'+i)<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 512
import numpy as np
def f(n, b, c):
    return np.sum(np.abs(c-b))

def solve(n, a):
    c = np.asarray([(a[i]-i-1) for i in range(n)], dtype=int)
    b = np.median(c)
    return int(f(n, b, c))

assert solve(5, [2, 2, 3, 5, 5]) == 2
assert solve(9, [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0
assert solve(6, [6, 5, 4, 3, 2, 1]) == 18
assert solve(7, [1, 1, 1, 1, 2, 3, 4]) == 6
n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Measured memory_bytes: 34208
def main():
    n = int(input())
    a, b, c = [0] * n, [0] * n, [0] * n
    for i in range(n):
        x, y, z = map(int, input().split())
        a[i] = x
        b[i] = y
        c[i] = z
    dp = [[0 for _ in range(3)] for _ in range(n)]
    dp[0][0] = a[0]
    dp[0][1] = b[0]
    dp[0][2] = c[0]
    for i in range(1, n):
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i]
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i]
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i]
    return max(dp[n - 1])
print(main())

Measured memory_bytes: 63996
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// #define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define MOD(x, y) ((((x) % (y)) + (y)) % (y))
#define DIV(x, y) ((x) < 0 ? (x) / (y) - 1: (x) / (y))
#define FST first
#define SND second

const int MAX_H = 500;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

string COLOR = "RGBY";

int H, W, D;
char MAP[MAX_H][MAX_H + 1];

void solve() {
  for (int i = 0; i < H; i++)
    for (int j = 0; j <= W; j++) MAP[i][j] = '\0';

  for (int r = 0; r < H; r++) {
    for (int c = 0; c < W; c++) {
      int x = r + c, y = r - c + W;
      int z = DIV((2 * x + D - 1), (2 * D));
      int w = DIV((2 * y + D - 1), (2 * D));
      z = z % 2;
      w = w % 2;
      #ifdef DEBUG
      cout << r << " " << c << endl;
      cout << x << " " << y << endl;
      cout << z << " " << w << endl;
      cout << endl;
      #endif
      int k = 2 * z + w;
      MAP[r][c] = COLOR[k];
    }
  }

  for (int i = 0; i < H; i++)
    cout << MAP[i] << endl;
}

int main() {
  cin >> H >> W >> D;

  solve();

  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

struct da{
    int a,b;
};

bool comp(da x, da y){
    if(x.b != y.b) return x.b < y.b;
    else return x.a < y.a;
}

signed main(){
    int n;
    cin >> n;
    da dat[n + 1];
    REP(i,n){
        cin >> dat[i].a;
    }
    REP(i,n) cin >> dat[i].b;

    sort(dat,dat + n, comp);
    dat[n].a = INF;
    dat[n].b = INF;
    vector<int> hoge[n];

    REP(i,n){
        int tmp = dat[i].a;
        int l = -1;
        int r = n;
        while(l + 1 < r){
            int mid = (l + r ) / 2;
            if(tmp <= dat[mid].b) r = mid; 
            else l = mid;
        }
        if(r == n){
            cout << "No" << endl;
            return 0;
        }
        hoge[r].push_back(i);
        dat[i].a = r;
    }
    priority_queue<int> Q;
    int cnt = 0;
    REP(i,n){
        itrfor(itr,hoge[i]){
            Q.push(*itr);
        }
        if(dat[i].a <= i) continue;
        else{
            if(Q.size() ==0 or Q.top() <= i){
                cout<< "No" << endl;
                return 0;
            }
            cnt ++;
            int huga = Q.top();
            Q.pop();
            swap(dat[i].a,dat[huga].a);
            hoge[dat[huga].a].push_back(huga);
        }

    }
    if(cnt <= n - 2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }



}

Measured memory_bytes: 9208
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	string s;
	cin >> s;
	bool found = false;
	for (auto x : s)
		if (x == '7')
			found = true;
	cout << (found ? "Yes" : "No");
	return 0;
}

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

const int mod = 1e9 + 7;

int main()
{
    std::string s;
    std::cin >> s;

    if (!!std::count(s.begin(), s.end(), 'N') ^ !!std::count(s.begin(), s.end(), 'S')) {
        std::cout << "No" << std::endl;
        return 0;
    }

    if (!!std::count(s.begin(), s.end(), 'W') ^ !!std::count(s.begin(), s.end(), 'E')) {
        std::cout << "No" << std::endl;
        return 0;
    }

    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<vector<int>> graph(N);
  REP(i, M){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
  }
  
  vector<int> par(N, -1);

  vector<bool> visited(N, false);
  visited[0] = true;

  queue<int> q;
  q.push(0);

  while(!q.empty()){
    int v = q.front(); q.pop();
    for(auto u : graph[v]){
      if(visited[u]) continue;
      visited[u] = true;
      par[u] = v;
      q.push(u);
    }
  }

  Yes;
  FOR(i, 1, N){
    cout << par[i]+1 << "\n";
  }

  return 0;
}

Measured memory_bytes: 12920
#include<bits/stdc++.h>
using namespace std;
const int N=50;
long long c[N+10][N+10];
void init(){
	c[0][0]=1;
	for(int i=1;i<=N;i++){
		c[i][0]=c[i][i]=1;
		for(int j=1;j<i;j++)
			c[i][j]=c[i-1][j]+c[i-1][j-1];
	}
}
int main(){
	int n,p;scanf("%d%d",&n,&p);
	int a=0,b=0;
	init();
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		if(x&1)b++;
		else a++;
	}
	long long ans=1LL<<a;
	long long ret=0; 
	if(p&1)for(int i=1;i<=b;i+=2)ret+=c[b][i];
	else for(int i=0;i<=b;i+=2)ret+=c[b][i];
	cout<<ans*ret<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long num;
    double frac;
    while(cin>>num>>frac)
    {
        long long con=(frac*100)+0.5;
       // unsigned long long sol=(frac*num);
       unsigned long long sol=(num*con)/100;
        cout<<sol<<endl;
        
    }
}

Measured memory_bytes: 3700
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll dp[55][3005];
// dp[i][j] means i length and sum j
int a[55];
int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int n,av;
    scanf("%d%d",&n,&av);
    int i;
    for(i=1;i<=n;i++)scanf("%d",&a[i]);
    dp[0][0] = 1;
    int j,k;
    for(i=1;i<=n;i++)
        {
        for(j=i-1;j>=0;j--)
            {
            for(k=0;k<=2500;k++)
                {
                int cur = k + a[i];
                dp[j+1][cur] += dp[j][k];
            }
        }
    }
    ll ans = 0;
   for(int len = 1; len<=n;len++)
       {
       ans += dp[len][av*len];
   }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
    int n,x;
    while(scanf("%d %d",&n,&x)!=EOF)
    {
        int a[100002];
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        long long int sum=0;
        if(a[0]>x)
        {
            sum+=a[0]-x;
            a[0]=x;
        }

        for(int i=1;i<n;i++)
        {
            if(a[i]+a[i-1]>x)
            {
                sum+=a[i]+a[i-1]-x;
                a[i]=x-a[i-1];
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
    int h,w;
    while (1) {
        cin>>h>>w;
        if(h==0 && w==0)break;

        for (int i = 1; i <= h; ++i) {
            if(i%2==1) {
                for (int j = 1; j <= w; ++j) {

                    if(j%2==0)cout<<'.';
                    else cout<<'#';

                    if(j==w)cout<<endl;
                }
            }
            else {
                for (int j = 1; j <= w; ++j) {

                    if(j%2==1)cout<<'.';
                    else cout<<'#';

                    if(j==w)cout<<endl;
                }

            }
        }
        cout<<endl;
    }
    return 0;

}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 240000;
LL h[maxn], dp[maxn];
set<pair<LL, int>, greater<pair<LL, LL>>> ch;
int main(){
	LL N, C;
	cin >> N >> C;
	for(int i = 1; i <= N; i += 1) cin >> h[i];
	ch.insert(make_pair(h[1], 1));
	for(int i = 2; i <= N; i += 1){
		int j = ch.upper_bound(make_pair(h[i], N + 1))->second;
		dp[i] = dp[j] + (h[i] - h[j]) * (h[i] - h[j]) + C;
		LL p = 0;
		for(auto it = ch.begin(); it != ch.end(); it = ch.erase(it)){
			j = it->second;
			//(dp[i] + (p - h[i])^2
			p = (dp[i] + h[i] * h[i] - dp[j] - h[j] * h[j]
				+ 2 * (h[i] - h[j]) - 1) / (2 * (h[i] - h[j]));
			if(p > it->first) break;
		}
		ch.insert(make_pair(max(p, h[i]), i));
	}
	cout << dp[N];
}

Measured memory_bytes: 15872
A = gets.chomp.to_i
B = gets.chomp.to_i
C = gets.chomp.to_i
X = gets.chomp.to_i

aaa = [ X / 500, A ].min
bbb = [ X / 100, B ].min
ccc = [ X / 50, C ].min

count = 0
(aaa+1).times do |a|
  (bbb+1).times do |b|
    (ccc+1).times do |c|
      if (500 * a) + (100 * b) + (50 * c) == X
        count += 1
      end
    end
  end
end

p count

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S[3];
    REP(i, 3)
    {
        cin >> S[i];
    }
    REP(i, 3)
    {
        cout << S[i][i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

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


def is_ok(last4):
    for j in range(4):
        t = list(last4)
        if j != 3:
            t[j], t[j + 1] = t[j + 1], t[j]
        if 'AGC' in ''.join(t):
            return False
    return True


def rec(length, last3):
    if last3 in m[length]:
        return m[length][last3]

    if length == n:
        return 1

    res = 0
    for c in 'ACGT':
        if is_ok(last3 + c):
            res += rec(length + 1, last3[1:] + c)
            res %= mod

    m[length][last3] = res
    return res


n = int(input())
m = [dict() for _ in range(n + 1)]
print(rec(0, 'zzz'))


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


int main() {
	int N,H,ans;
	cin >> N;
	vector<int> vec(N);
	H = N / 2;
	for (int i = 0; i < N ; i++)
	{
		cin >> vec.at(i);
	}

	sort(vec.begin(), vec.end());
	ans = vec.at(H) - vec.at(H-1);
	cout << ans << endl;
}

Measured memory_bytes: 3764
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string button[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

    int d;
    cin >> d;

    while(--d >= 0){
        string s;
        cin >> s;
        int n = s.size();

        string ret;
        int i = 0;
        while(i < n){
            char c = s[i];
            if(c == '0'){
                ++ i;
                continue;
            }

            int m = -1;
            while(i < n && c == s[i]){
                ++ m;
                ++ i;
            }
            ret += button[c-'1'][m%button[c-'1'].size()];
        }

        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define int long long
#define v(T) vector<T>
#define vb vector<bool>
#define pi pair<int,int>
#define ppi pair<pair,int,int>, int>
#define vpi vector<pair<int,int>>
#define w(t) int t; cin>>t; while(t--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
void init() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int power(int x, unsigned int y)
{
	int res = 1;
	while (y > 0) {
		if (y & 1)
			res = res * x;

		y = y >> 1;
		x = x * x;
	}
	return res;
}
int gcd(int a, int b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
int32_t main() {
	FIO;
	int s = 0;
	v(int) a(5); for (int &i : a) {cin >> i; s += i;}
	cout << (15 - s) << endl;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
	public static class Burger {
		int level;
		long meatNum = 1; // level0の初期値
		long breadNum = 0; // level0の初期値
		long layerNum = 1; // level0の初期値

		public Burger(int level) {
			this.level = level;
		}
	}

	int N;
	long X;
	List<Burger> burgers;
	long result;

	Main() {
		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		X = in.nextLong();
		in.close();

		this.burgers = new ArrayList<>(N + 1);
		for (int i = 0; i <= N; ++i) {
			this.burgers.add(new Burger(i));
		}

		// 各層のmeat, breadの枚数を記入する
		for (int i = 1; i <= N; ++i) {
			Burger prev = this.burgers.get(i - 1);
			// meatの値セット
			this.burgers.get(i).meatNum = prev.meatNum * 2L + 1L;
			// breadの値セット
			this.burgers.get(i).breadNum = prev.breadNum * 2L + 2L;
			// 総layerの値セット
			this.burgers.get(i).layerNum = prev.layerNum * 2L + 3L;
		}
	}

	void calc() {
		result = calcMeatNum(X, N);
	}

	long calcMeatNum(long remainLayerNum, int level) {

		Burger current = burgers.get(level);
		if (remainLayerNum == current.layerNum) {
			// 一致 -> そのまま返す
			return current.meatNum;
		} else if (remainLayerNum == 0L) {
			// 何も食べない
			return 0L;
		} else if (remainLayerNum <= (current.layerNum - 1) / 2) {
			// currentの下半分の中で食べる範囲は収まる
			return calcMeatNum(remainLayerNum - 1, level - 1);
		} else if (remainLayerNum == (current.layerNum + 1) / 2) {
			// ちょうど半分まで
			return burgers.get(level - 1).meatNum + 1;
		} else {
			// 上半分まで食べる
			long result = 1; // 真ん中
			result += burgers.get(level - 1).meatNum; // 下半分
			result += calcMeatNum(remainLayerNum - (current.layerNum + 1) / 2, level - 1);
			return result;
		}
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		System.out.println(ins.result);
	}

}

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

main() {
  int n,ans=100;
  cin >> n;
  
  for(;n--;) {
    int a,s=0;
    cin >>a;
    while(a%2 == 0) {
      a /=2;    
      s++;
    }
    if(s < ans) ans = s;
  }
  cout << ans <<endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
    int h, w, c[10][10], a[200][200];
    cin >> h >> w;
    rep(i, 10)rep(j, 10)cin >> c[i][j];
    rep(i, h)rep(j, w)cin >> a[i][j];
    rep(k, 10){
        rep(i, 10){
            rep(j, 10){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    int ans = 0;
    rep(i, h){
        rep(j, w){
            if(a[i][j] != 1 && a[i][j] != -1)ans += c[a[i][j]][1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s;
		int i,j,t;
		int[] c = new int[10];
		try {
			for(i=0;i<10;i++){
				s = r.readLine();
				c[i] = Integer.parseInt(s);
			}
			for(i=0;i<9;i++){
				for(j=0;j<9-i;j++){
					if (c[j]<c[j+1]){
							t=c[j];c[j]=c[j+1];c[j+1]=t;
					}
				}
			}
			for(i=0;i<3;i++)System.out.println(c[i]);
		} catch (NoSuchElementException e) {
			System.exit(0);
		}
	}
}

Measured memory_bytes: 9352
void main()
{
    string[] n = readln.split;
    n.sort!"a < b";

    writeln(n.join == "1479" ? "YES" : "NO");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define maxn 1000001
#define gc getchar()
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair 
#define ll long long
#define ull unsigned ll 
#define pb push_back
#define db double
 int mod=-99999;
int read()
{
	int x=0,f=1;char ch=gc;
	while(!isdigit(ch)){ch=gc;if(ch=='-')f=-1;}
	while(isdigit(ch))x=x*10+ch-48,ch=gc;
	return x*f;
}
void print(int x)
{
	if(x>9)print(x/10);
	putchar(x%10+48);
}
ll n,m,s;
int main()
{  
   scanf("%lld %lld",&n,&m);
   s=m*pow((m-1),(n-1));
   printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 2000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl

//ifstream in("Text.txt");cin.rdbuf(in.rdbuf());



int main() {
    int N;
    cin >> N;
    map<int, int>mp;
    rep(i, N) {
        int X;
        cin >> X;
        mp[X]++;
    }
    int ans = 0;
    for (auto itr : mp) {
        int x = itr.first;
        int n = itr.second;
        if (n < x)ans += n;
        else ans += n - x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    S = SI()
    T = SI()

    count = 0
    for s_, t_ in zip(S, T):
        if s_ == t_:
            count += 1

    print(count)


main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	char ch[10005];
	scanf("%s",ch+1);
	long long k;
	scanf("%lld",&k);
	int n=strlen(ch+1);
	for (int i=1;i<=n;i++){
		if (ch[i]=='1') {k--; continue; }
		if (k==0) {printf("1\n");  return 0;}
		printf("%d\n",ch[i]-'0'); 
		return 0;
	}
	printf("1\n");
	return 0;
} 

Measured memory_bytes: 256