akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ll long long
#define MAXN 110
#define MAXK 100010

using namespace std;

ll dp[MAXN][MAXK];
const ll mod = 1e9 + 7;

ll add(ll a, ll b) {

    a += b;
    if(a >= mod)
        a -= mod;
    return a;
}

ll sub(ll a, ll b) {

    a += mod - b;
    a %= mod;
    return a;
}

int main() {

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

    int n, k;
    cin >> n >> k;

    int arr[n];
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    
    for(int i = 0; i <= n; i++)
        dp[i][0] = 1;
    ll pre[k + 1];
    for(int i = 0; i <= k; i++)
        pre[i] = i ? pre[i - 1] : 0 + dp[0][i];
    for(int i = 1; i <= n; i++) {
        ll temp[k + 1];
        temp[0] = dp[i][0];
        for(int j = 1; j <= k; j++) {
            int mn = j - min(arr[i - 1], j);
            dp[i][j] = pre[j];
            if(mn)
                dp[i][j] = sub(dp[i][j], pre[mn - 1]);
            /*
            for(int o = min(arr[i - 1], j); o >= 0; o--)
                dp[i][j] = add(dp[i][j], dp[i - 1][j - o]);
            */
            temp[j] = add(temp[j - 1], dp[i][j]);
        }

        for(int j = 0; j <= k; j++)
            pre[j] = temp[j];
    }
    cout << dp[n][k] << endl;
    return 0;
}


Measured memory_bytes: 83352
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

int main()
{
    int n, m;
    while(1){
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        int taro[100], hanako[100];
        int taro_sum = 0, hanako_sum = 0;
        for(int i = 0; i < n; i++){
            cin >> taro[i];
            taro_sum += taro[i];
        }
        for(int i = 0; i < m; i++){
            cin >> hanako[i];
            hanako_sum += hanako[i];
        }
        if((taro_sum + hanako_sum) % 2 == 1) cout << -1 << endl;
        else{
            int new_taro_sum, new_hanako_sum;
            for(int i = 0; i < n; i++){
                for(int j = 0; j < m; j++){
                    new_taro_sum = taro_sum + hanako[j] - taro[i];
                    new_hanako_sum = hanako_sum + taro[i] - hanako[j];
                    if(new_hanako_sum == new_taro_sum){
                        cout << taro[i] << ' ' << hanako[j] << endl;
                        i = 101;
                        break;
                    }
                }
                if(i == n - 1) cout << -1 << endl;
            }
        }
    }
   return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef vector<vector<int> > Graph;
typedef pair<int, int> P; 
// MOD
//const int mod = 1000000007;
typedef long long ll;
long long INF = 1<<30;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
//int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}
 
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI=3.14159265358979323846;
bool seen[100][100];

bool memo[110];
bool flag;

int dist[100][100];

bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second< y.second;
}


struct Unionfind{
    vector<int> par;

    Unionfind(int n) : par(n, -1){}

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    } 

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x]>par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

P s(int x){
    int a = x%10;
    int b = 0;
    while(x){
        b = x;
        b/=10;
    }
    return P(a, b);
}


int main() {
  string s, t; cin >> s >> t;
  int n = s.size();
  int sum=0;
  for(int i=0; i<n; i++){
    if(s[i]!=t[i]) sum++;
  }
  cout << sum << endl;
}

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

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

  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N; y++) {
      if (N - x - y < 0) continue;
      int sum = 10000 * x + 5000 * y + 1000 * (N - x - y);
      if (sum == Y){
        cout << x << " " << y << " " << N - x - y << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std; 
int main()
{    int n; 
    cin >> n;
	if (n<1000)    
	cout << "ABC" << endl;
	else
		cout << "ABD" << endl; 
	return 0; 
}

Measured memory_bytes: 256
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<cassert>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()


using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(int argc, char const* argv[])
{
    int N;
    int ans = 0;

    cin >> N;

    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        ans += r-l+1;
    }

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













Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int buy,best,eat;
	buy=a-b;
	best=a;
	eat=buy+c;
	if(eat<=best)
	{
		cout<<"delicious"<<endl;
	}
	else if(eat<=2*best){
		cout<<"safe"<<endl;
	}
	else{
			cout<<"dangerous"<<endl;
	}
	
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
	int h, w;
	cin >> h >> w;

	string board[50];

	for (int i = 0; i < h; ++i)  cin >> board[i];

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

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (board[i][j] == '#') continue;

			int num = 0;
			for (int d = 0; d < 8; ++ d) {
				const int ni = i + dy[d];
				const int nj = j + dx[d];

				if (ni < 0 or h <= ni) continue;
				if (nj < 0 or w <= nj) continue;
				if (board[ni][nj] == '#') num++;
			}

			board[i][j] = char(num + '0');

		}
	}

	for (int i = 0; i < h; ++i)  cout << board[i] << endl;

	return 0;
}


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

int main(int argc, char *argv[])
{
    int n, a, b, c, x, y, i, num;
    const int MAX = 10001;
    while (cin >> n >> a >> b >> c >> x, n|a|b|c|x) {
        int ys[n];
        for (i = 0; i < n; ++i) {
            cin >> y;
            ys[i] = y;
        }
        for (i = 0, num = 0; i <= MAX; ++i) {
            if (ys[num] == x)
                num++;
            if (num == n)
                break;
            x = (a * x + b) % c;
        }
        if (i >= MAX)
            cout << -1 << endl;
        else
            cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N, A, B; cin >> N >> A >> B;
		A += B;
		rep(i, N){
			char c; cin >> c;
			if (c == 'a') {
				if (A) { A--; cout << "Yes" << endl; }
				else cout << "No" << endl;
			}
			if (c == 'b') {
				if (A && B) { A--; B--; cout << "Yes" << endl; }
				else cout << "No" << endl;
			}
			if (c == 'c') {
				cout << "No" << endl;
			}
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int tra = N*A;
  int tax = B;
  int ans = min(tra,tax);
  cout << ans << endl;

}

Measured memory_bytes: 256
"""
E
"""
#treeのiに1を加える
def bit_add(I,k):
    while I<=N:
        tree[k][I]+=1
        I+=I&(-I)

def bit_no_add(I,k):
    while I<=N:
        tree[k][I]-=1
        I+=I&(-I)
        
#0からiまでの合計を帰す
def bit_sum(I,k):
    s=0
    while I>0:
        s+=tree[k][I]
        I-=I&(-I)
    return s

N=int(input())
S=["a"]+list(input())
Q=int(input())
que=[list(input().split()) for i in range(Q)]

alpa=list("abcdefghijklmnopqrstuvwxyz")
tree=[[0]*(N+1) for i in range(len(alpa))]

for i in range(1,N+1):
    j=alpa.index(S[i])
    bit_add(i, j)

for iii in range(Q):
    if que[iii][0]=="1":
        i,c=int(que[iii][1]),que[iii][2]
        j=alpa.index(S[i])
        bit_no_add(i, j)
        S[i]=c
        j=alpa.index(c)
        bit_add(i, j)
    else:
        l,r=que[iii][1],que[iii][2]
        l=int(l)
        r=int(r)
        cnt=0
        for j in range(len(alpa)):
            if bit_sum(l-1, j)==bit_sum(r, j):
                continue
            cnt+=1
        print(cnt)

Measured memory_bytes: 171864
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const int INF=100000000;
// e_ÔÌ£
double dist[22][22];
// e_ÌÀW
vector<pair<int,int> > points;
int n,hx,hy,dx,dy;
bool ok=false;
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

// »ÝÌê©çßÄÂ\ÈÅ¬ÊßbðÔ·
void dfs(int s,int cp,double passedSec){
    if(ok)
        return;
    else if(s==0){
        ok=true;
        return;
    }
    for(int i = 0; i < n; i++){
        // Ü¾rbgª1ÈçÎ
        if((s>>i)&1){
            // áCªB·éOÉTõÂ\©Ç¤©ð`FbN
            double dt=dist[cp][i];
            // ¤©çÚ®æÖÌ¼aðæ¾
            double r=dist[n+1][i];
            // àµ¼aªz¦Ä¢½ç,}ëè
            if(dt+passedSec>r||EQ(dt+passedSec,r))
                return;
        }
    }

    for(int i = 0; i < n; i++){
        // Ü¾rbgª1ÈçÎ
        if((s>>i)&1){
            // áCªB·éOÉTõÂ\©Ç¤©ð`FbN
            double dt=dist[cp][i];
            // ¤©çÚ®æÖÌ¼aðæ¾
            double r=dist[n+1][i];
            dfs((s&(~(1<<i))),i,dt+passedSec);
        }
    }
}


int main(){
    while(cin>>n>>hx>>hy>>dx>>dy&&!(n==0&&hx==0&&hy==0&&dx==0&&dy==0)){
        points.clear();
        ok=false;
        // EÒÌúÊu
        for(int i = 0; i < n; i++){
            pair<int,int> p;
            cin>>p.second>>p.first;
            points.push_back(p);
        }
        points.push_back(make_pair(hy,hx));
        points.push_back(make_pair(dy,dx));
        for(int i = 0; i < points.size(); i++){
            for(int j = 0; j < points.size(); j++){
                dist[i][j]=sqrt((double)(points[i].first-points[j].first)*(points[i].first-points[j].first)
                    +(points[i].second-points[j].second)*(points[i].second-points[j].second));
            }
        }
        dfs(((1<<n)-1),n,0.0);
        if(ok)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

i64 calc_b(std::vector<i64> A) {
  const i64 N = A.size();
  for (i64 i = 0; i < N; ++i) {
    A[i] -= i + 1;
  }
  std::sort(A.begin(), A.end());
  return A[N / 2];
}

i64 calc_sadness(const std::vector<i64>& A, const i64 b) {
  const i64 N = A.size();
  i64 sadness = 0;
  for (i64 i = 0; i < N; ++i) {
    sadness += std::abs(A[i] - (b + i + 1));
  }
  return sadness;
}

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);
  std::cout << calc_sadness(A, calc_b(A)) << std::endl;
  return 0;
}

Measured memory_bytes: 3328
import java.util.*;

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

    	int n = sc.nextInt();

    	double[][] dp = new double[2][n+5];
    	int curr = 0;
    	int next = 1;
    	dp[curr][0] = 1;
    	for(int z = 0; z < n; z++) {
    		Arrays.fill(dp[next], 0);
    		double p = sc.nextDouble();
    		for(int i = 0; i < n; i++) {
    			dp[next][i+1] += dp[curr][i] * p;
    			dp[next][i] += dp[curr][i] * (1-p);
    		}
    		int tmp = curr;
    		curr = next;
    		next = tmp;
    	}

    	double ans = 0;
    	for(int i = (n+1)/2; i < n+1; i++)
			ans += dp[curr][i];

    	System.out.println(ans);
    }
}

Measured memory_bytes: 53072
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vec<string> C(H);
    rep(i, H) cin >> C[i];

    int ans = 0;
    rep(h, 1 << H) rep(w, 1 << W) {
        int black = 0;
        rep(i, H) rep(j, W) {
            if ((h & 1 << i) || (w & 1 << j)) continue;
            if (C[i][j] == '#') ++black;
        }
        if (black == K) {
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
n,k=map(int,input().split())
MOD=10**9+7
def comb(n,m,p=10**9+7):
    buf=perm[n]*inv[m]
    buf%=MOD
    buf*=inv[n-m]
    buf%=MOD
    return buf
def inv_mod(a):
  return pow(a,MOD-2,MOD)

perm=[1]*(2*n+1)
for i in range(1,2*n+1):
    perm[i]=perm[i-1]*(i)
    perm[i]%=MOD
inv=[1]*(2*n+1)
inv[-1]=inv_mod(perm[-1])
for i in range(2*n-1,-1,-1):
    inv[i]=inv[i+1]*(i+1)
    inv[i]%=MOD
#print(comb(5,2))
buf=comb(2*n-1,n)
for j in range(k+1,n):
    x=comb(n,j)*comb(n-1,j)
    x%=MOD
    buf-=x
    buf%=MOD
print(buf)

Measured memory_bytes: 45936
N ,A ,B ,C ,D = list(map(int,input().split()))
S = input()
 
def judgeArrive(S, x, y):
    flag = "Yes"
    for i in range(x-1 ,y-2):
        if S[i] ==  S[i+1] == "#":
            flag = "No"
    return flag

def judgeJumpOver(S, x , y):
    flag = "No"
    for i in range(x-1 ,y):
        if S[i-1] ==  S[i] ==  S[i+1] == ".":
            flag = "Yes"
            break
    return flag
 
result = "Yes"
if(C > D):
    result = judgeJumpOver(S, B, D)
if(result == "Yes"):
    result = judgeArrive(S, B, D)
if(result == "Yes"):
    result = judgeArrive(S, A, C)
print(result)

Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main() {
    while (1) {
        int a[4], b[4], hit = 0, blow = 0;
        for (int i = 0; i < 4; i++) {
            if (!(cin >> a[i])) {
                return 0;
            }
        }
        for (int i = 0; i < 4; i++) {
            cin >> b[i];
            if (a[i] == b[i]) {
                hit++;
            }
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if (i == j) {
                    continue;
                }
                if (a[i] == b[j]) {
                    blow++;
                }
            }
        }
        cout << hit << " " << blow << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int N;
int num;
int a[100000];


int partition(int *A,int p,int r){
    int i,j,tmp,x;
    
    x=A[r];
    i=p-1;
    
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i=i+1;
            tmp=A[i];
            A[i]=A[j];
            A[j]=tmp;
        }
    }
    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;
    
    return i+1;
    
}

int main(){
    
    int i;
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    
    num=partition(a,0,N-1);
    
    for(i=0;i<N-1;i++){
        if(i==num)printf("[%d] ",a[i]);
        else printf("%d ",a[i]);
    }
    printf("%d\n",a[N-1]);
    //printf("%d\n",num);
    
    
    return 0;
}

Measured memory_bytes: 988
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,a[55],b[55],c[55],d[55],p;
  long long count=0;
  cin>>n>>m;
  for(int i=0; i<n; i++){
    cin>>a[i]>>b[i];
  }
  for(int i=0; i<m; i++){
    cin>>c[i]>>d[i];
  }
  for(int i=0; i<n; i++){
    p=1;
    count=abs(a[i]-c[0])+abs(b[i]-d[0]);
    for(int j=1; j<m; j++){
      if(count>abs(a[i]-c[j])+abs(b[i]-d[j])){
	count=abs(a[i]-c[j])+abs(b[i]-d[j]);
	p=j+1;
      }
    }
    cout<<p<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;++i)
    #define Fdr(i,x,y) for(int i=x;i>=y;--i)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){clr(ch,0);if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 5011
#define base 2333
int n;
ull p[N],h[N];
char s[N];
ull gh(int l,int r){
	return h[r]-h[l-1]*p[r-l+1];
}
bool chk(int len){
	Fur(i,1,n-len*2+2)
		Fur(j,i+len,n-len+1)
			if(s[i]==s[j]&&gh(i,i+len-1)==gh(j,j+len-1))return 1;
	
	return 0;
}
int main(){
	scanf("%d%s",&n,s+1);
	p[0]=1;
	Fur(i,1,n){
		h[i]=h[i-1]*base+s[i];
		p[i]=p[i-1]*base;
	}
	int l=1,r=n/2+2,ans;
	while(l<=r){
		int m=(l+r)>>1;
		if(chk(m))ans=m,l=m+1;
		else r=m-1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
def resolve():
    n,m,x=map(int, input().split())
    l=list(map(int, input().split()))
    l.append(x)
    l.sort()
    if l[0]==x or l[-1]==x:
        print(0)
    else:
        for i in range(m+1):
            if l[i]==x:
                print(min(m-i,i))

resolve()

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

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const int MAXN = 1e5 + 5;
char S[MAXN],T[MAXN];
int main(){
	scanf("%s%s",S+1,T+1);
	int n = strlen(S+1);
	FOR(i,1,n){
		if(S[i] != T[i]){
			puts("No");return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;

    int ans = a * c;
    if (b >= ans) {
        cout << c << endl;
    }else if(b < ans) {
        int ans = b / a;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <cstdio> 
#include <iostream> 
#include <cmath> 
#include <string> 
#include <list> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <utility> 
#include <set> 
#include <map> 
#include <complex> 
#include <queue> 
#include <stack> 
#include <cstdlib> 
#include <ctime> 
#include <cstring> 
#include <string.h> 
#include <unordered_set>
#include <unordered_map>
#include <cassert>

using namespace std; 

typedef unsigned int uint; 
typedef long long int64; 
typedef unsigned long long uint64; 
typedef unsigned short ushort; 
typedef unsigned char uchar; 
typedef pair<int,int> ipair; 
typedef vector<int> VI; 
typedef vector<string> VS; 
typedef vector<double> VD; 
#define SIZE(A) ((int)(A.size()))
#define LENGTH(A) ((int)(A.length()))
#define MP(A,B) make_pair(A,B)
const double pi=acos(-1.0); 
const double eps=1e-11; 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(a) (a).begin(),(a).end()

template<class T> T sqr(const T &x) { return x*x; } 
template<class T> T lowbit(const T &x) { return (x^(x-1))&x; } 
template<class T> int countbit(const T &n) { return (n==0)?0:(1+countbit(n&(n-1))); } 
template<class T> void ckmin(T &a,const T &b) { if (b<a) a=b; } 
template<class T> void ckmax(T &a,const T &b) { if (b>a) a=b; } 

int c[1<<20];

int main()
{
#ifdef _MSC_VER
	freopen("input.txt","r",stdin);
#endif
	std::ios_base::sync_with_stdio(false);
	int n;
	memset(c,0,sizeof(c));
	cin>>n;
	REP(i,n)
	{
		int d;
		cin>>d;
		c[d]++;
		c[d+1]++;
		c[d+2]++;
	}
	int r=0;
	REP(i,1<<20) ckmax(r,c[i]);
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 4352
#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()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const double eps = 1e-9;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

signed main() {
  int n = in();
  vector<vi> g(n);

  rep(i, n - 1) {
    int a = in() - 1, b = in() - 1;
    g[a].pb(b);
    g[b].pb(a);
  }

  int used[101010];
  memset(used, -1, sizeof(used));
  queue<pii> q;
  q.push(mp(0, 0));
  q.push(mp(n - 1, 1));

  while (!q.empty()) {
    pii p = q.front();
    q.pop();

    int v = p.fs;

    for (int i = 0; i < g[v].size(); ++i) {
      int u = g[v][i];
      if (~used[u]) continue;
      used[u] = p.sc;
      q.push(mp(u, used[u]));
    }
  }

  int cnt = 0;
  rep(i, n) if (!used[i]) cnt++;

  cout << (cnt <= n / 2 ? "Snuke" : "Fennec") << endl;
}


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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

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

int main() {
    int K;
    cin >> K;
    ll sum = 0;
    for (int i=1; i<=K; ++i) {
        for (int j=1; j<=K; ++j) {
            for (int k=1; k<=K; ++k) {
                sum += gcd(i, gcd(j, k));
            }
        }
    }
    cout << sum << endl;
    return 0;
}   

Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int fn = 0, ln = 0;
  map<string, int> m ;
  string str, f, l;
  bool b;

  while(cin >> str) {
    b = true;
    map<string, int>::iterator it = m.begin();
    while(it != m.end()) {
      if(it->first == str) {
	it->second += 1;
	b = false;
      }
      it++;
    }
    if(b) m.insert(pair<string, int>(str, 1));
  }
  map<string, int>::iterator it = m.begin();
  while(it != m.end()) {
    if(it->second > fn) {
      fn = it->second;
      f = it->first;
    }
    if((it->first).length() > ln) {
      ln = (it->first).length();
      l = it->first;
    }
    it++;
  }
  cout << f << ' ' << l << endl;
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll A,B,C,K; cin >> A >> B >> C >> K;

  if(K <= A){
    cout << K << endl;
    return 0;
  } else if(K <= A + B ){
    cout << A << endl;
  } else {
    ll tmp = K - (A+B);
    cout << A - tmp << endl;
  }

}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	int ans = -1;
	int now = 0;
	int cnt = 0;
	rep(i, n) {
		now = a[now];
		cnt++;
		if(now == 1) {
			ans = cnt;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
function Main(input) {
    input = input.split(" ");
    var a = parseInt(input[0]);
    var b = parseInt(input[1]);
    var c = parseInt(input[2]);


    if (a <= b && b <= c && a <= c) {
        console.log(a + " " + b + " " + c);
    }else if (a <= b && c <= b && a <= c) {
        console.log(a + " " + c + " " + b);
    }else if (b <= a && b <= c && a <= c) {
        console.log(b + " " + a + " " + c);
    }else if (a <= b && c <= a && c <= b) {
        console.log(c + " " + a + " " + b);
    }else if (b <= a && c <= a && b <= c) {
        console.log(b + " " + c + " " + a);
    }else if (b <= a && c <= b && c <= a) {
        console.log(c + " " + b + " " + a);
    }
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug() {
    var input = document.getElementById("input").value;
    Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15136
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n=int(input())
l=[list(input()) for _ in range(n)]
dic_l={}
cnt=0
ans_lst=[]
for i in range(n):
  l[i].sort()
  l[i]=str(l[i])
  if l[i] not in dic_l:
    dic_l[l[i]]=1
  else:
    dic_l[l[i]]+=1
for j in dic_l.values():
  if j>=2:
    ans_lst.append(j)
    cnt += comb(j,2)
print(cnt)


Measured memory_bytes: 29072
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+10;
const double inf=1000;
typedef long long ll;
typedef pair<int,int>pr;
const int mod=1000000007;
ll _pow(ll  a,ll b) {
    ll ans=1;
    while(b) {
        if(b&1)
            ans=ans*a;
        a=a*a;
        b>>=1;
    }
    return ans;
}
ll gcd(ll a,ll b){
    if(!b) return a;
    else return gcd(b,a%b);
}


int main(){
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin>>n;

  int num = n/1000+1;
  if(n%1000==0) num--;
  cout<<(num*1000-n)<<endl;

  return 0;
}

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

int main() {
  int a ,b;
  cin >> a >> b;
  
  if (a%2 == 0 || b%2 == 0) {
    cout << "Even" << endl;
  }
  else {
  cout << "Odd" << endl;
  }
}
 


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
using namespace std;
int N;
int A[2][100];
int ans;
main()
{
	cin>>N;
	for(int i=0;i<2;i++)for(int j=0;j<N;j++)cin>>A[i][j];
	int tmp=0;
	for(int i=0;i<N;i++)tmp+=A[1][i];
	ans=tmp;
	for(int i=0;i<N;i++)
	{
		tmp+=A[0][i];
		ans=max(ans,tmp);
		tmp-=A[1][i];
	}
	cout<<ans<<endl;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  int n;
  cin >> n;
  vector<ll> va(n);
  for (int i = 0; i < n; i++) {
    cin >> va[i];
  }

  sort(va.begin(), va.end(), greater<ll>());
  auto calc_r = [](ll n, ll r) { return min(r, n - r); };
  sort(va.begin() + 1, va.end(),
       [&](ll a, ll b) { return calc_r(va[0], a) > calc_r(va[0], b); });
  cout << va[0] << ' ' << va[1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int n,y;
int main()
{
    int i,j,k;
    scanf("%d%d",&n,&y);
    for(i=0;i<=n;i++)
    for(j=0;j<=n;j++)
    for(k=0;k<=n,i+j+k<=n;k++)
    if(i+j+k==n&&i*10000+j*5000+k*1000==y)
    {printf("%d %d %d\n",i,j,k);
    return 0;}
    printf("-1 -1 -1 \n");
    return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
students = []
for _ in range(N):
    a, b = map(int, input().split())
    students.append([a, b])
checkpoints = []
for _ in range(M):
    c, d = map(int, input().split())
    checkpoints.append([c, d])

for (a, b) in students:
    best = 1e9
    ans = -1
    for i, (c, d) in enumerate(checkpoints):
        res = abs(a - c) + abs(b - d)
        if (best > res):
            best = res
            ans = i + 1
    print(ans)


Measured memory_bytes: 39408
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

///////////////////////////////////////////////////////////////////////////

int main(){
	
	char c;
	cin >> c;
	switch(c){
	    case 'a':
	    case 'i':
	    case 'u':
	    case 'e':
	    case 'o':
	        cout << "vowel" << endl;
	        return 0;
	}
	cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
list($S)=sscanf(trim(fgets(STDIN)),"%s");
$S1 = substr($S,0,2);
$S2 = substr($S,-2);
if(($S[0] == $S[1])&&($S[0] == $S[3])){
    printf("No");
    exit;
}
if(($S[0] == $S[1])&&($S[0] == $S[2])){
    printf("No");
    exit;
}
if(($S[0] == $S[1])&&($S[2] == $S[3])){
    printf("Yes");
    exit;
}

if($S1 == $S2){
    printf("Yes");
    exit;
}
if($S1 == strrev($S2)){
    printf("Yes");
    exit;
}
print("No");

Measured memory_bytes: 4728
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ x, y ] <- readInts
	print $ minimum $ map fromJust $ filter isJust $ [ solve x y, ( 1 + ) <$> solve (-x) y, ( 1 + ) <$> solve x (-y), ( 2 + ) <$> solve (-x) (-y) ]

solve x y
	| x <= y = Just $ y - x
	| otherwise = Nothing


Measured memory_bytes: 508
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
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);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

//const int mod = 1000000007;
const int mod = 998244353;

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

  //for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

#define N 310

//head

string s;
int k, n;
int cnt0;
int info[N];
mint dp[N][N], sum1[N][N], sum2[N][N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s >> k;
  n = s.size();
  rep(i, n) cnt0 += (s[i] == '0');
  chmin(k, n-cnt0);
  int now = 0;
  for(int i = 0; i < n;) {
    if(s[i] == '0') {
      i++;
      now++;
      continue;
    }
    int j = i+1;
    while(j < n and s[j] == '1') j++;
    info[now] = j-i;
    i = j;
  }
  dp[0][0] = 1;
  for(int i = 1; i <= k+1; i++) sum1[0][i] = 1;
  for(int i = 1; i <= k+1; i++) sum2[i][i] = 1;
  for(int i = cnt0; i >= 0; i--) {
    rep(j, k+1) {
      rep(u, j+1) {
        int mi = u-max(0, u-info[i]);
        dp[j][u] = sum1[j][k+1] - sum1[j][u] + sum2[j][u] - sum2[j-mi][u-mi];
      }
    }
    rep(j, k+1) for(int u = 1; u <= k+1; u++) sum1[j][u] = sum1[j][u-1] + dp[j][u-1];
    for(int j = 1; j <= k+1; j++) rep(u, j) sum2[j][j-u] = sum2[j-1][j-u-1] + dp[j-1][j-u-1];
    //rep(i, k+1) rep(j, k+1) cout << dp[i][j] << (j == k?'\n':' ');
    //cout << '\n';
  }
  mint ans;
  rep(i, k+1) ans += dp[i][0];
  cout << ans << endl;
}

Measured memory_bytes: 5852
from collections import defaultdict
d = defaultdict(int)

n = int(input())
maximum = 0
for _ in range(n):
    s = input()
    d[s] += 1
    maximum = max(maximum, d[s])
    
sorted_d = sorted(d.items())
for k, v in sorted_d:
    if v == maximum:
        print(k)

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

double getProbability(vector<double>& pHeads, int coin, int numTails, vector<vector<double> >& memo) {
    if(coin == pHeads.size()) return 1;
    if(memo[coin][numTails] != -1) return memo[coin][numTails];
    memo[coin][numTails] = pHeads[coin] * getProbability(pHeads, coin+1, numTails, memo);
    if(numTails > 0) memo[coin][numTails] += (1 - pHeads[coin]) * getProbability(pHeads, coin+1, numTails-1, memo);
    
    return memo[coin][numTails];
}

int main() {
    int numCoins;
    cin >> numCoins;
    vector<double> pHeads(numCoins);
    for(double& coin : pHeads) {
        cin >> coin;
    }

    int numTails = (numCoins - 1)/2;
    vector<vector<double> > memo(numCoins, vector<double>(numTails+1, -1));
    printf("%.15f", getProbability(pHeads, 0, numTails, memo));

    return 0;
}

Measured memory_bytes: 38492
#include <stdio.h>

int f[44];

int fibonacci(int i){
  if(i==0 || i==1) {
    return f[i]=1;   
  }
  if(f[i]){
    return f[i];
  }
  return f[i]=fibonacci(i-2) + fibonacci(i-1);
}
    

int main() {
  int n;
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
  return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int[][] n=new int[101][101];
int[] tate=new int[101];
int[] yoko=new int[101];

int sum=0;
int x=scan.nextInt();
int y=scan.nextInt();
for(int i=0;i<x;i++){
tate[i]=0;
yoko[i]=0;
}
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
n[i][j]=scan.nextInt();
tate[j]+=n[i][j];
yoko[i]+=n[i][j];
sum+=n[i][j];
}
}
for(int i=0;i<x+1;i++){
for(int j=0;j<y;j++){
if(i!=x){
System.out.print(n[i][j]);
System.out.print(" ");
if(j==y-1)
System.out.println(yoko[i]);
}
else
System.out.print(tate[j]+" ");
}
}
System.out.println(sum);

}
}

Measured memory_bytes: 41584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    ll h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];
    vector<vector<ll>> dp(h + 1, vector<ll>(w + 1, 0));
    dp[0][1] = 1;
    reps(i, 1, h + 1) {
        reps(j, 1, w + 1) {
            if (a[i - 1][j - 1] == '#') continue;
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }
    cout << dp[h][w] << endl;
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>

using namespace std;
int main()
{
	char a[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	cout << a[0][0] << a[1][1] << a[2][2] << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	var s, t string
	fmt.Scan(&n, &s, &t)

	var res string
	for i := 0; i < n; i++ {
		res = res + string(s[i]) + string(t[i])
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;

char s[10];
int main()
{
	while(scanf("%s", s + 1) != EOF)
	{
		int len = strlen(s + 1);
		bool f = 0;
		for(int i = 1; i < len; i++) {
			if(s[i] == 'A' && s[i + 1] == 'C')
				f = 1;
		}
		if(f == 1) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
program contests
  implicit none
  integer :: n, a, b, p(100) = 0, i, m(3) = 0
  read(*,*) n
  read(*,*) a, b
  read(*,*) p(1:n)
  do i = 1, n
    if (p(i) <= a) then
      m(1) = m(1)+1
    else if (p(i) <= b) then
      m(2) = m(2)+1
    else
      m(3) = m(3)+1
    end if
  end do
  write(*,'(i0)') minval(m)
end program contests

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int K,a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>K;
    cout<<a[K-1]<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,l,r) for(ll i=l;i<(ll)(r);i++) //ll
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;
const int INF = (1<<30);
int upcmpii(const void *a, const void *b){return(*(int*)a==*(int*)b?0:(*(int*)a>*(int*)b?1:-1));}
void sort_ui(int*a, int n){qsort(a,n,sizeof(int),upcmpii);}

int n;
int a[201010], cnt[101010] = {0};
ll ans = 0;

void solve(){
    int tmp = a[0];
    rep(i, n-1){
        if(a[i+1] < tmp){
            ans += tmp-a[i+1];
        }else{
            tmp = a[i+1];
        }
        
    }
}

int main(){
    scanf("%d", &n);
    rep(i, n) scanf("%d", a+i);

    solve();

    printf("%lld", ans);
}

Measured memory_bytes: 2520
#include <bits/stdc++.h>
using namespace std;
vector<int> B[100000];
 
int main() {
    int N, M; cin >> N >> M;
    for (int i=0; i<N; i++) {
        int a, b; cin >> a >> b;
        if (a <= M) B[a].push_back(b);
    }

    long long int ans = 0;
    priority_queue<int> que;
    for (int i=1; i<=M; i++) {
        if (!B[i].empty()) {
            for (auto b: B[i]) que.push(b);
        }
        if (!que.empty()) {
          ans += que.top();
          que.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<int>>;


int main()
{
  ll a;
  cin >> a;
  ll ans = a+ a*a + a*a*a;
  cout << ans << endl;
  
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define ll long long
int main(){
    int i,j,n,m,k;
    priority_queue<int>a;
    ll h=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%d",&k);
        a.push(k);
    }
    while(m>0){
        a.push(a.top()/2);
        a.pop();
        m--;
    }
    for(i=0;i<n;i++){
        h+=a.top();
        a.pop();
    }
    printf("%lld\n",h);
    return 0;
}




Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	ll n,a[100010];
	cin >> n;
	FOR(i,n)cin >> a[i];
	deque<ll> v;
	v.push_back(a[0]);
	for(int i=1;i<n;i++){
		int p=lower_bound(all(v),a[i])-v.begin();
		if(p==0)v.push_front(a[i]);
		else v[p-1]=a[i];

	}

	cout << v.size() << endl;
}

Measured memory_bytes: 1792
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long int;

const int MAX_N = 3 * 1e5;
vector<int> cost(MAX_N, 0);
vector<int> ans(MAX_N, -1);
vector<vector<int>> edge(MAX_N, vector<int>{});

int dfs(int frm, int n){
    if(ans[n] != -1){return 0;}
    if(frm == -1){
        ans[n] = cost[n];
    }
    else{
        ans[n] = ans[frm] + cost[n];
    }
    for(auto& v:edge[n]){
        dfs(n, v);
    }
    return 0;
}

int main(){
    int n, q; cin >> n >> q;
    for(int i=0; i<n-1; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for(int i=0; i<q; i++){
        int p, x; cin >> p >> x;
        p--;
        cost[p] += x;
    }
    dfs(-1, 0);
    for(int i=0; i<n; i++){
        cout << ans[i] << endl; 
    }
    return 0;
}

Measured memory_bytes: 24320