akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"sort"
)

type Sord struct {
	a int64
	b int64
}

type Sords []Sord

func (a Sords) Len() int {
	return len(a)
}

func (a Sords) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a Sords) Less(i, j int) bool {
	return a[i].b > a[j].b
}

func main() {
	var N int
	var H int64

	fmt.Scanf("%d %d", &N, &H)

	sords := make(Sords, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d", &sords[i].a, &sords[i].b)
	}

	sort.Sort(sords)

	max := 0
	for i := 0; i < N; i++ {
		if sords[i].a > sords[max].a {
			max = i
		}
	}

	attack := 0
	damage := int64(0)

	for i := 0; i < N; i++ {
		if sords[i].b < sords[max].a {
			break
		}

		if i != max {
			damage += sords[i].b
			attack++
		} else if sords[i].b > sords[i].a {
			damage += sords[i].b
			attack++
		}

		if damage >= H {
			break
		}
	}

	if damage < H {
		more := int((H - damage) / sords[max].a)
		if (H-damage)%sords[max].a != 0 {
			more++
		}
		attack += more
		damage += sords[max].a * int64(more)
	}

	// if sords[max].b > sords[max].a {
	// 	damage -= sords[max].a
	// 	damage += sords[max].b

	// 	attack -= int((damage - H) / sords[max].a)
	// } else if damage >= H {

	// }

	if attack <= 0 {
		fmt.Println(1)
	} else {
		fmt.Println(attack)
	}
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>

void rotate(char pat[8][9]) {
	char buf[8][9]={0};
	int x,y;
	for(y=0;y<8;y++) {
		for(x=0;x<8;x++) {
			buf[x][7-y]=pat[y][x];
		}
	}
	memcpy(pat,buf,sizeof(buf));
}

int main(void) {
	char buf[8][9];
	int i;
	for(i=0;i<8;i++)scanf("%s",buf[i]);
	rotate(buf);
	puts("90");
	for(i=0;i<8;i++)puts(buf[i]);
	rotate(buf);
	puts("180");
	for(i=0;i<8;i++)puts(buf[i]);
	rotate(buf);
	puts("270");
	for(i=0;i<8;i++)puts(buf[i]);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std; void solve(); int main(){cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); solve();}
using ll=int_fast64_t; using ld=long double; using pll=pair<ll,ll>; using pld=pair<ld,ld>;
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> void vecout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}

template <std::uint_fast64_t Modulus> class modint {
public:
  ll a;
  constexpr modint(const ll x = 0) noexcept : a(x % Modulus) {}
  constexpr ll &value() noexcept { return a; }
  constexpr const ll &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    ll exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

void solve(){
  const ll MOD=1000000007;
  string k; cin>>k;
  ll d; cin>>d;
  ll n=k.size();
  auto dp=make_v(n+1,d,2,modint<MOD>(0));
  dp[0][0][0]=modint<MOD>(1);
  rep(i,n){
    ll a=k[i]-'0';
    rep(j,d)rep(o,10){
      dp[i+1][(j+o)%d][1]+=dp[i][j][1];
      if(o<a) dp[i+1][(j+o)%d][1]+=dp[i][j][0];
      else if(o==a) dp[i+1][(j+o)%d][0]+=dp[i][j][0];
    }
  }
  cout<<(dp[n][0][0]+dp[n][0][1]-1).a<<"\n";
}

Measured memory_bytes: 55424
#include<stdio.h>
#include<stdlib.h>
void push(int);
int pop(void);
int s[100];
int top=0;
int main(){
  int ch,x,y;
  char c[100];
  while(scanf("%s",c)!=EOF){
    if(48<=c[0] && c[0]<=57){
      ch=atoi(c);
      push(ch);
      continue;
    }
    y=pop();
    x=pop();
    if(c[0]=='+')push(x+y);
    else if(c[0]=='-')push(x-y);
    else if(c[0]=='*')push(x*y);
  }
  printf("%d\n",pop());
  return 0;
}

void push(int x){
  s[top++]=x;
}

int pop(){
  return s[--top];
}



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


int main(){
  int N,K,a;
  cin >> N >> K;
  int count = 0;
  for( int i = 0; i < N; i++){
    cin >> a;
    if( a >= K ){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
A = [list(map(int,input().split())) for _ in range(3)]
ans = [[0]*3 for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]


for num in b:
    for i in range(3):
      for j in range(3):
          if A[i][j] == num:
             ans[i][j] = -1
             break

def f(ans):
    if yoko(ans) or tate(ans) or naname(ans):
        return True
    else:
        return False

def yoko(ans):
    tmp = []
    for i in ans:
        tmp.append(sum(i))
    if -3 in tmp:
        return True
    else:
        return False

def tate(ans):
    tmp = [0]*3
    for i in range(3):
        for j in range(3):
            tmp[j] += ans[i][j]
    if -3 in tmp:
        return True
    else:
        return False

def naname(ans):
    tmp = [0]*2
    tmp[0] = ans[0][0] + ans[1][1] + ans[2][2]
    tmp[1] = ans[0][2] + ans[1][1] + ans[2][0]
    if -3 in tmp:
        return True
    else:
        return False


if f(ans):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3192
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(K):
        b = [0] * (N+1)
        for j in range(N):
            a = A[j]
            b[max(j-a, 0)] += 1
            b[min(j+a+1, N)] -= 1
        for k in range(1,N+1):
            b[k] += b[k-1]
        b = b[:N]
        if b == A:
            break
        else:
            A = b
    print(*A)

if __name__ == '__main__':
    main()

Measured memory_bytes: 168392
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e6; int n;
char ss[maxN + 1];
string s[maxN];
struct Node
{
  int diff, left, right, index;
  bool operator<(const Node &other) const
  {
    return diff > other.diff;
  }
};

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    vector<Node> mid;
    string lefts = "", rights = "";
    for (int i = 0; i < n; i++)
    {
      scanf(" %s", ss);
      s[i] = string(ss);
      int left = 0, right = 0, start = 0;
      int open = 0, close = 0;
      for (int j = 0; j < s[i].size(); j++)
      {
        open += s[i][j] == '(', close += s[i][j] == ')';
        start += s[i][j] == '(' ? 1 : -1;
        if (start < 0)
          left++, start = 0;
      }
      for (int j = s[i].size() - 1; j >= 0; j--)
      {
        start += s[i][j] == '(' ? -1 : 1;
        if (start < 0)
          right++, start = 0;
      }
      if (close == 0) lefts += s[i];
      else if (open == 0) rights += s[i];
      else mid.push_back(Node{open - close, left, right, i});
    }
    sort(mid.begin(), mid.end());
    string mids = "";
    for (int i = 0; i < mid.size(); i++)
      mids += s[mid[i].index];
    string ans = lefts + mids + rights;

    bool can = true;
    int open = 0;
    for (int i = 0; i < ans.size(); i++)
    {
      open += ans[i] == '(' ? 1 : -1;
      if (open < 0) can = false;
    }
    if (open) can = false;
    DEBUG printf("\t%s - %s %s %s\n", ans.c_str(), lefts.c_str(), mids.c_str(), rights.c_str());

    printf("%s\n", can ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 44116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class D
{
    public static void Main(string[] args)
    {
        var first = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        int N = first[0], W = first[1];
        var dp = new long[N + 1, W + 1];
        for (int i = 0; i < N; i++)
        {
            var line = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
            long w = line[0], v = line[1];
            for (int j = 0; j <= W; j++)
            {
                if (dp[i, j] == 0)
                {
                    continue;
                }

                update(dp, i + 1, j, dp[i, j]);
                if (j + w <= W)
                {
                    update(dp, i + 1, j + w, dp[i, j] + v);
                }
            }
            update(dp, i + 1, w, v);
        }

        long ans = long.MinValue;
        for (int i = 0; i <= W; i++)
        {
            ans = Math.Max(ans, dp[N, i]);
        }
        Console.WriteLine(ans);
    }

    private static void update(long[,] dp, long a, long b, long v)
    {
        dp[a, b] = Math.Max(dp[a, b], v);
    }
}

Measured memory_bytes: 88928
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
using pii =pair<int,int>;
int n;
string s;

void input(){
    cin>>n>>s;
}
void src(){
    cout<<(n>=3200 ? s:"red");
    return;
}

int main(int argc,char* argv[]){
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M;
void input()
{
    cin >> N >> M;
}
//=========FUNCTIONS==========

vector<pair<long long, long long>> prime_factorize(long long n)
{
    vector<pair<long long, long long>> res;
    for (long long p = 2; p * p <= n; ++p)
    {
        if (n % p != 0)
            continue;
        int num = 0;
        while (n % p == 0)
        {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1)
        res.push_back(make_pair(n, 1));
    return res;
}
const int MAX = 1000111;
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit()
{ // O(N)
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; ++i)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve()
{
    vector<pii> pf = prime_factorize(M);
    COMinit();

    int ans = 1;
    for (auto x : pf) {
        ans *= COM(x.second + N - 1, x.second);
        ans %= MOD;
    }
    cout<<ans<<endl;




}

//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 23680
N = gets.to_i
as = gets.split.map(&:to_i)
ans = 0
l = 0
xor = 0
plus = 0
(0...N).each do |r|
    xor ^= as[r]
    plus += as[r]
    while xor != plus && l < r
        xor ^= as[l]
        plus -= as[l]
        l += 1
    end
    ans += r - l + 1
end
puts ans

Measured memory_bytes: 15364
n,l = map(int,input().split())
s = []
for i in range(n):
    a = list(input())
    a = [ord(i) for i in a]
    s.append(a)
#
s.sort()
ans = []
for i in s:
    ans1 = [chr(j) for j in i]
    ans2 = ''.join(ans1)
    ans.append(ans2)

ans3 = ''.join(ans)
print(ans3)

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

int main(){
   int n;
   cin>>n;
   int a=0,last,sum;
   cin>>last;
   sum=last;
   for(int i=0;i<n-2;i++){
	   cin>>a;
	   if(a>last){
		   sum+=last;
	   }else{
		sum+=a;
	   }
	   last=a;
   }
   sum+=last;
   
   cout<<sum<<endl;
   return 0;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

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

  int cont[101010];
  m0(cont);

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    cont[a]++;
    cont[b]++;
  }

  for (int i = 0; i < N; i++) {
    if (cont[i] % 2) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1024
import itertools
S = input()
N = len(S)
A = [0,1]
ans = 0
plus = []
for i in itertools.product(A, repeat = N-1):
    plus.append(i)
for op in plus:
    eq = S
    for index in range(N-1):
        if op[index] == 1:
            eq = eq[:N-index-1] + ',' +eq[N-index-1:]
    eq = eq.split(',')
    le = len(eq)
    for i in range(le):
        ans += int(eq[i])
print(ans)

Measured memory_bytes: 3064
/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public final class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int ans =0;
		for(int i=0;i<n;i++){
		    int x = s.nextInt();
		    if(x>=k){
		        ans++;
		    }
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 58796
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl


typedef long long ll;

ll solve(vector<string> &s,int n,int &y,int x){
    if(isdigit(s[y][x])) return s[y][x] - '0';
    if(s[y][x] == '+'){
        ll term = 0;
        while(y+1 < n && (int)s[y+1].size() > x+1){
            y++;
            term += solve(s,n,y,x+1);
        }
        return term;
    }else{
        ll term = 1;
        while(y+1 < n && (int)s[y+1].size() > x+1){
            y++;
            term *= solve(s,n,y,x+1);
        }
        return term;
    }
}

int main(void){
    int n;
    while(cin>>n,n){
        vector<string> s(n);
        rep(i,n) cin>>s[i];
        int y = 0;
        cout<<solve(s,n,y,0)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		sc.close();
		if(n>=10){
			System.out.println(r);
		}else{
			int h = 100*(10-n);
			System.out.println(r+h);
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g){
  for(int i = g; i < n; i++){
    int v = A[i];
    int j = i - g;
    while(j >= 0 && A[j] > v){
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n){
  for(int h = 1;;){
    if(h > n) break;
    G.push_back(h);
    h = 3 * h + 1;
  }

  for(int i = G.size() - 1; i >= 0; i--){
    insertionSort(A, n, G[i]);
  }
}

int main(){
  cin >> n;
  for(int i = 0; i < n; i++) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  cout << G.size() << endl;
  for(int i = G.size() - 1; i >= 0; i--){
    printf("%d", G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for(int i = 0; i < n; i++) printf("%d\n", A[i]);

  return 0;
}

Measured memory_bytes: 5196
F,*q='First';$<.map{|l|l.split.permutation{|a,b|b&&(q[a.to_i]||=[])<<b.to_i}};h=->i,r{c=0;q[i].map{|j|j!=r&&c+=h[j,i]};c^1};puts h[1,1]<1?:Second: :First

Measured memory_bytes: 29436
import Numeric (showFFloat)

ab :: [Integer] -> String
ab [a, b] = unwords [show d,show r, showFFloat Nothing f' ""]
  where
    (d, r) = quotRem a b
    f' :: Double
    f'     = fromIntegral a / fromIntegral b

main :: IO ()
main = do
  s <- getLine
  putStrLn $ ab $ (map read . words) s

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

int calc_neg(int a) { return 2 - a; }
int calc_plus(int a, int b) { return max(a, b); }
int calc_mult(int a, int b) { return min(a, b); }

int calc_op(int l, int r, char op) {
	if(op == '+') return calc_plus(l, r);
	if(op == '*') return calc_mult(l, r);
	assert(false);
}

int parse(const string &s, int &idx, map<char, int> mp) {
	if(s[idx] == '-') {
		idx++;
		return calc_neg(parse(s, idx, mp));
	} else if(s[idx] == '(') {
		idx++;
		int left = parse(s, idx, mp);
		char op = s[idx];
		idx++;
		int right = parse(s, idx, mp);
		assert(s[idx] == ')');
		idx++;
		return calc_op(left, right, op);
	} else if('0' <= s[idx] && s[idx] <= '2') {
		int n = s[idx] - '0';
		idx++;
		return n;
	} else {
		int n = mp[s[idx]];
		idx++;
		return n;
	}
}

bool solve() {
	string s;
	cin >> s;
	if(s == ".") return false;
	map<char, int> mp;
	int ans = 0;
	for(int i = 0; i < 3 * 3 * 3; i++) {
		int cpy = i;
		for(int j = 0; j < 3; j++) {
			mp['P' + j] = cpy % 3;
			cpy /= 3;
		}
		int idx = 0;
		int res = parse(s, idx, mp);
		ans += res == 2;
	}
	cout << ans << endl;
	return true;
}

int main() {
	while(solve());
	return 0;
}



Measured memory_bytes: 3036
#include <iostream>

using namespace std;
const int N = 2e3 + 5;
const int mod = 1e9 + 7;
typedef long long LL;

LL fastpow(LL a, LL b) {
    if (!b) return 1;
    LL t = fastpow(a, b / 2);
    if (b & 1) return t * t % mod * a % mod;
    else return t * t % mod;
}

LL fact[N * N], invf[N * N];
void prework(int n) {
    fact[0] = 1ll;
    for (int i = 1; i <= n; i++)
        fact[i] = fact[i - 1] * i % mod;
    invf[n] = fastpow(fact[n], mod - 2ll);
    for (int i = n - 1; ~i; i--)
        invf[i] = invf[i + 1] * (i + 1) % mod;
}

LL comb(int n, int m) {
    return fact[n]
         * invf[m] % mod
         * invf[n - m] % mod;
}

int k, n;
LL f[N][N];

signed main() {
    prework(4e6);
    cin >> n >> k;

    if (k == 1) {
        cout << 1 << endl;
        return 0;
    }

    for (int i = 0; i <= n; i++)
        f[i][0] = 1ll;
    
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= i; j++) {
            f[i][j] += (f[i][j - 1] * (n - j + 1) % mod
                     * comb(n - i + (n - j + 1) * (k - 1) - 1, k - 2) % mod
                     + f[i - 1][j]) % mod;
        }
    
    cout << f[n][n] << endl;
    return 0;
}//233

Measured memory_bytes: 88248
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<queue>
using namespace std;
long long N,M,s,a;
priority_queue<int> q;
int main()
{
    int i,t;
    scanf("%d%d",&N,&M);
    for(i=0; i<N; i++)
    {
        scanf("%d",&a);
        q.push(a);
    }
    while(M>0)
    {
       t=q.top();
       q.pop();
       q.push(t/2);
       M--;
    }
    while(!q.empty())
    {
        s+=q.top();
        q.pop();
    }
    printf("%lld\n",s);
}


Measured memory_bytes: 892
#include <iostream>
using namespace std;
const int INF = 1 << 30;

int main() {
  int n;
  cin >> n;
  int min_div = INF;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    int tmp_div = 0;
    while (x % 2 == 0 && x > 0) {
      tmp_div++;
      x /= 2;
    }
    min_div = min(min_div, tmp_div);
  }
  cout << min_div << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1200000
using namespace std;
int main()
{
    int a[110001],b[110001],c[110001];
    int n;
    int dp[110001][3];
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i]>>b[i]>>c[i];

    }


    for(int i=0; i<n; i++)
    {
        for(int j=0; j<3; j++)
        {
            if(i==0)
            {
                if(j==0)
                    dp[i][j]=a[i];
                else if(j==1)
                    dp[i][j]=b[i];
                else
                    dp[i][j]=c[i];
            }
            else
            {
                for(int k=0; k<3; k++)
                {
                    if(j==k)
                        continue;
                     if(j==0)
                    {
                        dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i]);

                    }

                    else if(j==1)
                        dp[i][j]=max(dp[i][j],dp[i-1][k]+b[i]);
                    else
                        dp[i][j]=max(dp[i][j],dp[i-1][k]+c[i]);

                }
            }
        }
    }

   int r=0;
   r=max(r,dp[n-1][0]);

   r=max(r,dp[n-1][1]);

   r=max(r,dp[n-1][2]);

   cout<<r;

}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 200010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int n;
int arr[maxn];
int b[maxn][25], cum[maxn][25];

bool check(int l, int r) {
  for (int i = 0; i <= 22; ++i) {
    if (cum[r][i] - cum[l - 1][i] > 1) return false;
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= 22; ++j) {
      if (arr[i] & (1 << j)) b[i][j] = 1;
    }
  }
  for (int j = 0; j <= 22; ++j) {
    for (int i = 1; i <= n; ++i) cum[i][j] = cum[i - 1][j] + b[i][j];
  }
  ll ans = n;
  for (int i = 1; i <= n; ++i) {
    ll lo = 0, hi = n - i, res = 0;
    while (lo <= hi) {
      int mid = (lo + hi) >> 1;
      if (check(i, i + mid)) {
        res = mid;
        lo = mid + 1;
      }
      else hi = mid - 1;
    }
    ans += res;
  }
  cout << ans << endl;
}


Measured memory_bytes: 40064
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = [0] + LI()

from itertools import accumulate

B = [[0]*(N+1) for _ in range(20)]
for i in range(20):
    for j in range(N+1):
        B[i][j] = (A[j] >> i) & 1
for i in range(20):
    B[i] = list(accumulate(B[i]))

# B[i] = Aの2**iの位の累積和
# 尺取り法

ans = 0
left = 0
right = 1
# (left,right]
while right < N+1:
    for i in range(20):
        if B[i][right] - B[i][left] <= 1:
            continue
        else:
            ans += right - left - 1
            left += 1
            break
    else:
        right += 1

ans += ((right - left)*(right - left - 1))//2

print(ans)

Measured memory_bytes: 136540
#include<iostream>

int conbination(int n, int x){
  int count = 0;
  for(int a = 1; a <= n - 2; a++){
    for(int b = a + 1; b <= n - 1; b++){
      for(int c = b + 1; c <= n; c++){
	if(a + b + c == x) count++;
      }
    }
  }
  return count;
}

int main(){
  while(true){
    int n, x;
    std::cin >> n;
    std::cin >> x;

    if(n == 0 && x == 0){
      break;
    }

    std::cout << conbination(n, x) << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int num[10];
int main(){
	int i;
	for(i=0;i<5;i++)
		scanf("%d",&num[i]);
	for(i=0;i<5;i++){
		if(!num[i]){
			printf("%d\n",i+1);
			return 0;
		}
	}
}


Measured memory_bytes: 1712
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,m,n,ans=0;
	cin>>n>>m;
	int x[m];
	for(i=0;i<m;i++)cin>>x[i];
	sort(x,x+m);
	int diff[m-1];
	for(i=0;i<m-1;i++)diff[i]=x[i+1]-x[i];
	sort(diff,diff+m-1);
	for(i=0;i<m-n;i++)ans+=diff[i];
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
import math
a, b, h, m = map(int, input().split(' '))
rh = h * 30 + m * 0.5
rm = m * 6
rr = 360 - abs(rh - rm) if abs(rh - rm) > 180 else abs(rh - rm)
ans = math.sqrt(a*a + b*b - 2 * a * b * math.cos(math.radians(rr)))
print(ans)

Measured memory_bytes: 9408
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  if (4 * M * A.at(M - 1) < sum) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}
    

Measured memory_bytes: 3604
// fahadmd16
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define pdb pair<db, db>
#define ALL(a) (a).begin(),(a).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define fornab(i,a,b) for(int i=a;i<b;i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define eps 1e-12
#define nedl endl
const ll size = 805;
const ll mod = 1e9 + 7;


ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    return ans;
}

ll BIT[26][500002]={0};

void update(ll letter,ll i,ll inc,ll n){
    while(i<=n){
        BIT[letter][i]+=inc;
        i+=(i&(-i));
    }
}

ll query(ll letter,ll i){
    ll sum=0;
    while(i>0){
        sum+=BIT[letter][i];
        i-=(i&(-i));

    }
    return sum;
}

 
int main() {
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ll t=1;//cin>>t;
    while(t--){
        ll n;cin>>n;
        string s;cin>>s;

        forn(i,n){
            update(s[i]-'a',i+1,1,n);
        }

        ll q;cin>>q;
        //trace1(q);

        while(q--){
            ll x1;cin>>x1;
            if(x1==1){
                //trace1(x1);
                 ll x2;char x3;cin>>x2>>x3;
                int letter=s[x2-1]-'a';
                s[x2-1]=x3;
                update(letter,x2,-1,n);
                update(x3-'a',x2,1,n);
            }
            else{
                //trace1(x1);
                 ll l,r;cin>>l>>r;
                ll c=0;
                forn(i,26){
                    ll gg=query(i,r)-query(i,l-1);
                    if(gg)c++;
                }
                cout<<c<<endl;
            }
        }

    }

    return 0;
}


Measured memory_bytes: 102556
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


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

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

    sort(ALL(A));
    for(ll i = 0; i < n-1;i++){
        a[i] = A[i+1]-A[i];
    }
    a[n-1] = A[0] + (k-A[n-1]);
    VSORT(a);
    cout << k - a[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

template<typename T>
struct BIT {
  int n;
  vector<T> bit;
  BIT() {}
  BIT(int n, T e = 0) : n(n), bit(n+1,e){}
  T sum(int i) {
    T s = bit[0];
    for(int x = i;x > 0; x -= (x & -x))
      s += bit[x];
    return s;
  }
  void add(int i, T a){
    if(i == 0) return;
    for(int x = i; x <= n; x += (x & -x))
      bit[x] += a;
  }
  int lower_bound(T w){
    if(w <= 0) return 0;
    int x = 0,r = 1;
    while(r < n) r <<= 1;
    for(int k = r; k > 0; k >>= 1){
      if(x+k <= n && bit[x+k] < w){
        w -= bit[x+k];
        x += k;
      }
    }
    return x+1;
  }
};

int Q;
int a[200010],b[200010],c[200010];
map<int,int> mp;
int imp[200010];

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

  BIT<int> cnt(200010),cum(200010);
  cin >> Q;
  REP(i,Q) {
    cin >> c[i];
    if (c[i] == 1) {
      cin >> a[i] >> b[i];
      mp[a[i]]++;
    }
  }
  int id = 1;
  for (auto p : mp) {
    mp[p.first] = id;
    imp[id++] = p.first;
  }
  int suma = 0, sumb = 0;
  int num = 0;
  REP(i,Q) {
    if (c[i] == 1) {
      cnt.add(mp[a[i]],1);
      cum.add(mp[a[i]],a[i]);
      suma += a[i];
      sumb += b[i];
      num++;
    } else {
      int pos = cnt.lower_bound((num+1)/2);
      int ans = sumb;
      ans += cnt.sum(pos)*imp[pos]-cum.sum(pos);
      ans += (suma-cum.sum(pos))-(num-cnt.sum(pos))*imp[pos];
      cout << imp[pos] << " " << ans << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40;
#define INF 1 << 31;
#define MOD 1000000007;
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vector<int>> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
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;
}
struct edge {
    int to, cost;
};

bool dp[2][8001][16001];

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    x += 8000;
    y += 8000;
    vi xy[2];
    int tmp = 0, cnt = 0;
    rep(i, s.size()) {
        if(s[i] == 'T') {
            xy[cnt % 2].push_back(tmp);
            tmp = 0;
            cnt++;
        } else {
            tmp++;
        }
    }
    xy[cnt % 2].push_back(tmp);
    x -= xy[0][0];
    rep(k, 2) rep(i, 8001) rep(j, 16001) { dp[k][i][j] = false; }
    dp[0][1][8000] = true;
    dp[1][0][8000] = true;
    rep(k, 2) REP(i, k == 0 ? 1 : 0, xy[k].size()) {
        rep(j, 16001) {
            if(0 <= j + xy[k][i] <= 16000)
                dp[k][i + 1][j + xy[k][i]] |= dp[k][i][j];
            if(0 <= j - xy[k][i] <= 16000)
                dp[k][i + 1][j - xy[k][i]] |= dp[k][i][j];
        }
    }
    if(dp[0][xy[0].size()][x] & dp[1][xy[1].size()][y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    // rep(i, 2) {
    //     rep(j, xy[i].size()) { cout << xy[i][j] << " "; }
    //     cout << endl;
    // }
}


Measured memory_bytes: 250368
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vi x(n);
	for (auto &i : x) cin >> i;
	ll ans = 1;
	int p = 1;
	REP(i, n)
	{
		while (p < n && p++)
		{
			int emp = x[p - 1] + i - p;
			if (emp < p - i - 1) break;
		}
		//cout << p << endl;
		ans *= p - i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	bool num[1000000] = {0};
	for(int i=2; i<1000; i++){
		if(!num[i]){
			for(int j=i*2; j<1000000; j+=i){num[j] = true;}
		}
	}
	int n;
	while(cin >>n){
		int f = 0;
		for(int i=2; i<=n; i++){
			if(!num[i]){f++;}
		}
		cout <<f<<endl;
	}
}

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

int main(){
    int N,K,a,count=0;
    cin>>N>>K;
    count += (N-K+K-2)/(K-1) + 1;
    for (int i=1;i<N+1;++i){
        cin >> a;}
    //     if(a==1){
    //         count+=(i-1-1)/(K-1)+1+(N-i-1)/(K-1)+1;
    //     }
    // }
  cout << count << endl;
}

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

#define ll long long int
#define Mod 1000000007

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    int arr[2];
    arr[0]=0;
    arr[1]=0;
    for(int i=0;i<s.size();i++)
    {
        arr[s[i]-'0']++;
    }
    cout<<s.size()-abs(arr[0]-arr[1])<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main () {
  int N;
  scanf("%d", &N); N %= 10;
  if (N == 3)
    puts("bon");
  else if (N == 0 || N == 1 || N == 6 || N == 8)
    puts("pon");
  else
    puts("hon");
  return 0;
}

Measured memory_bytes: 1648
abacus = ["* = ****", "* =* ***", "* =** **", "* =*** *", "* =**** ",
          " *= ****", " *=* ***", " *=** **", " *=*** *", " *=**** "]
flag=0
while 1:
    try:N=input()
    except:break
    if flag:print()
    else:flag=1
    N=list(N.zfill(5))
    answer=[]
    for i in N:answer.append(list(abacus[int(i)]))
    answer=[list(x) for x in zip(*answer)]
    for i in range(8):print("".join(answer[i]))


Measured memory_bytes: 5608
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
cost = 0
for i in range(x):
    if i in a:
        cost += 1
cost2 = 0
for i in range(x, n+1):
    if i in a:
        cost2 += 1
print(min(cost, cost2))

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
ifstream ifs("in.txt");
ofstream ofs("out.txt");
#define cin ifs
#define cout ofs
//*/
int N;
int P[220000];
int inv[220000];

signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> P[i];
        inv[P[i]] = i;
    }
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    int cur = 1, ans = 0;
    for (int i = 2; i <= N; i++) {
        if (inv[i] > inv[i - 1]) {
            cur++;
        } else {
            cur = 1;
        }
        ans = max(ans, cur);
    }
    cout << N - ans << endl;
}


Measured memory_bytes: 3328
N, Y = map(int, input().split())
for a in range(min(N, Y // 1000) + 1):
    for b in range(min(N - a, Y // 5000) + 1):
        c = N - a - b
        if 1000 * a + 5000 * b + 10000 * c == Y:
            print(c, b, a)
            exit()
print(-1, -1, -1)


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

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,q = LI()
        if n == 0:
            break
        a = [LI() for _ in range(n)]
        d = collections.defaultdict(int)
        for c in a:
            for cc in c[1:]:
                d[cc] += 1
        t = sorted([[-v,k] for k,v in d.items() if v >= q])
        if len(t) == 0:
            rr.append(0)
        else:
            rr.append(t[0][1])

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;



int main()
{
    fastInp;

    ll x;
    cin >> x;
    if (x >= 10000) {
        cout << "1";
    } else {
        ll vl = x / 100, vl2 = x % 100;
        if (vl >= (vl2 - 1) / 5 + 1) {
            cout << "1";
        } else {
            cout << "0";
        }
    }

    return 0;
}

Measured memory_bytes: 3632
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    A = LI()
    B = LI()
    ans = 0
    for i in range(n):
        b = B[i]
        a = A[i]
        A[i] = max(0, a-b)
        b = max(0, b-a)
        a = A[i+1]
        A[i+1] = max(0, a-b)
        b = max(0, b-a)
        ans += B[i]-b
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24252
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string s,t;
  cin >> s >> t;
  int ans = 0;
  REP(i,3){
    if (s[i] == t[i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 764
#define ll long long int

#include <bits/stdc++.h>

using namespace std;
const int N = 1E5 + 8;

vector<int> vc[N];
bool b[N];
int used[N];

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    fill(used, used + N, 1);
  //  cout <<used[1] <<" " ;
    b[1] = true;
    while (k--) {
        int x, y;
        cin >> x >> y;
        used[x]--;

        used[y]++;
        if (b[x]) {
            b[y] = true;
        }
        if(used[x] == 0)b[x] = false;
    }
    int cnt = 0;
    for (int i = 1; i <= N; ++i) {
        if (b[i] && used[i] > 0 )cnt++;
    }
    cout << cnt << "\n";


    return 0;
}


Measured memory_bytes: 6420
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define pp(a, b) pair <a, b>
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pi pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define itr iterator
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
 
 
using namespace __gnu_pbds;
using namespace std;
 
template <class T> T printr(T p){ cout << p << '\n'; return 0; }
template <class T> T printe(T p){ cout << p << '\n'; exit(0); }
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
 
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif
 
ll power(ll x, ll y, ll p){ 
   ll res = 1;
   x = x % p;  
   while (y > 0) {
      if (y & 1) 
         res = (res * x) % p; 
      y = y >> 1;
      x = (x * x) % p; 
   }
   return res;
}
 
const ll INF = (ll)(8e18);
const ll MOD = 1e9 + 7;
 
const int maxn = 300010;

ll a[maxn], bit[64];

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ll n; cin >> n;
    for(ll i = 1; i <= n; i++) cin >> a[i];
    for(ll i = 1; i <= n; i++){
        for(ll j = 0; j < 62; j++){
            if((a[i] & (1LL << j))) bit[j] += 1;
        }
    }
    ll ans = 0;
    for(ll i = 0; i < 62; i++){
        ll remaining = n - bit[i];
        ll val = (1LL << i) % MOD;
        val %= MOD;
        val *= bit[i];
        val %= MOD;
        val *= remaining;
        val %= MOD;
        ans += val; 
        ans %= MOD;
    }
    cout << ans << '\n';
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
             
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> Pi;
typedef map<ll,ll> mi;
             
template<class T> T nrem(T x,T y){return ((x%y)+y)%y;}
             
#define For(i,a,n) for(int i=a;i<n;++i)
#define For0(i,n) for(int i=0;i<n;++i)
#define For1(i,n) for(int i=1;i<=n;++i)
#define Forl0(i,n) for(ll i=0;i<n;++i)
#define Forl1(i,n) for(ll i=1;i<=n;++i)
#define fi freopen("input.txt","r",stdin);
#define fo freopen("output.txt","w",stdout);
#define pb push_back
#define mp make_pair
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cs 200005
#define pi acos(-1)
#define INF (int)INFINITY
void in()
    {
         #ifndef ONLINE_JUDGE
         freopen("input.txt", "r", stdin);
         freopen("output.txt", "w", stdout);
        #endif
    }

int a[505][505];
int vis[505][505];

int main()
{  
    IOS
    in();
    
    int h,w;
    cin>>h>>w;
    
    vector<pair<pair<int,int>,pair<int,int>>>ans;

    For1(i,h)
    For1(j,w)    
    cin>>a[i][j];


    For1(i,h)
    For1(j,w)
    {
       if(a[i][j]%2==1&&vis[i][j]==0)
       {
          vis[i][j]=1;
          a[i][j]-=1;

          if(a[i-1][j]%2&&i-1>=1)
          {
              a[i-1][j]+=1;
              ans.pb(mp(mp(i,j),mp(i-1,j)));
          }
          else if(a[i][j-1]%2&&j-1>=1)
          {
             a[i][j-1]+=1;
              ans.pb(mp(mp(i,j),mp(i,j-1)));    
          }
          
          else if(a[i+1][j]%2&&i+1<=h)
          {
             a[i+1][j]+=1;
              ans.pb(mp(mp(i,j),mp(i+1,j)));    
          }
          
          else if(a[i][j+1]%2&&j+1<=w)
          {
             a[i][j+1]+=1;
              ans.pb(mp(mp(i,j),mp(i,j+1)));    
          }
          else if(i+1<=h)
          {
               a[i+1][j]+=1;
              ans.pb(mp(mp(i,j),mp(i+1,j)));   
          }
          else if(j+1<=w)
          {
              a[i][j+1]+=1;
              ans.pb(mp(mp(i,j),mp(i,j+1)));  
          }
       }   
    }
    
   cout<<ans.size()<<endl;
    For0(i,ans.size())
    cout<<ans[i].first.first<<" "<<ans[i].first.second<<" "<<ans[i].second.first<<" "<<ans[i].second.second<<endl;
}

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

using namespace std;

int main() {
	int N,K,prod,add;
  	cin >> N >> K;
	int min = 1;
  
  	for (int i = 0; i < N; i++){
    	prod = min * 2;
      	add = min + K;
      	if (prod <= add){
        	min = prod;
        }
      	else {
        	min = add;
        }
    }
	cout << min << endl;
}

Measured memory_bytes: 256