akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define maxn 32005
#define int long long
using namespace std;
typedef long long ll;
typedef long long LL;
const LL mod = 998244353;
int n, m;
const int g = 3;
LL dp[505][maxn];
ll fac[maxn];
ll invv[maxn];
LL qpower(LL, LL);
LL inline inv(LL x) {
	return qpower(x, mod - 2);
}
ll qpow(long long a,long long b) {
	ll ans=1;
	ll k=a;
	while(b) {
		if(b&1)ans=ans*k%mod;
		k=k*k%mod;
		b>>=1;
	}
	return (ans+mod)%mod;
}
void init() {
	long long it;
	fac[0]=1;
	invv[0]=1;
	fac[1]=1;
	invv[1]=1;
	for (it=2; it<maxn; it++) {
		fac[it]=((fac[it-1]*it)%mod+mod)%mod;
		invv[it]=(qpow(fac[it],mod-2)+mod)%mod;
	}
}
ll C(ll n,ll m) {
	if (n<m||m<0) return 0;
	return  (fac[n]*invv[m]%mod*invv[n-m]%mod+mod)%mod;
}
void NTT(LL *, int, int);
ll p[maxn], q[maxn];
void solve(int index) {
	for(int i=0; i<=n; i++) {
		dp[index][i]+=dp[index-1][i]*(1+C(i+1, 2))%mod;
		dp[index][i]%=mod;
	}
	memset(p,0,sizeof(p)), memset(q,0,sizeof(q));
	for(int i=1; i<=n; i++) q[i] = invv[i+2];
	for(int i=0; i<=n; i++) p[i] = dp[index-1][i]*invv[i]%mod;
	int len = 1;
	while(len<(2*(n+1))) len<<=1;
	NTT(p, len, 1);
	NTT(q, len, 1);
	for (int i = 0; i < len; ++i)
		p[i] = p[i] * q[i] % mod;
	NTT(p, len, -1);
	for(int i=1; i<=n; i++) {
		dp[index][i]+=p[i]*fac[i+2]%mod;
		dp[index][i]%=mod;
	}
}
signed main() {
	std::cin >> n >> m;
	init();
	dp[0][0] = 1;
	for(int i=1; i<=m; i++) {
		solve(i);
	}
	ll ans = 0;
	for(int i=0;i<=n;i++) {
		ans += dp[m][i]*C(n, i)%mod;
		ans%=mod;
	
	}
	cout << ans << endl;

}
LL qpower(LL x, LL y) {
	LL res = 1;
	while (y) {
		if (y & 1) (res *= x) %= mod;
		(x *= x) %= mod;
		y >>= 1;
	}
	return res;
}
void NTT(LL *arr, int size, int type) {
	int rev[100005];
	rev[0] = 0;
	for (int i = 1; i < size; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) ? (size >> 1) : 0);
	for (int i = 0; i < size; ++i)
		if (rev[i] > i) std::swap(arr[i], arr[rev[i]]);
	for (int len = 2; len <= size; len <<= 1) {
		LL wn = qpower(g, (mod - 1) / len);
		if (type == -1) wn = inv(wn);
		for (int i = 0; i < size; i += len) {
			LL w = 1;
			for (int j = 0; j < (len >> 1); ++j, w = w * wn % mod) {
				LL tmp1 = arr[i + j], tmp2 = arr[i + (len >> 1) + j] * w % mod;
				arr[i + j] = tmp1 + tmp2;
				arr[i + j + (len >> 1)] = tmp1 - tmp2;
				if (arr[i + j] >= mod) arr[i + j] -= mod;
				if (arr[i + j + (len >> 1)] < 0) arr[i + j + (len >> 1)] += mod;
			}
		}
	}
	if (type == -1) {
		LL t = inv(size);
		for (int i = 0; i < size; ++i)
			arr[i] = arr[i] * t % mod;
	}
}


Measured memory_bytes: 17932
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;


typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef vector<ii> vii; 
typedef vector<ff> vff;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,d;
    cin>>n>>d;
    int i = (2*d)+1;
    cout<<ceil(n/(double)i)<<endl;
    return 0;
}

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

int main() {
	long N,T,A;
	vector<long> H;
	cin >> N >> T >> A;
	long reg = 0;
	long dtmin = 1000000;
	for (long i=0; i<N; i++) {
		long tmp;
		cin >> tmp;
		if (dtmin>abs(1000*T-6*tmp-1000*A)) {
			reg = i+1;
			dtmin = abs(1000*T-6*tmp-1000*A);
		}
	}
	cout << reg << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
  int n;cin>>n;
  int h[20];
  for(int i=0;i<n;++i)
	cin>>h[i];

  int mx=0;
  int ans=0;
  for(int i=0;i<n;++i){
	if(mx<=h[i])ans++;
	mx=max(mx,h[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll n, m;
  cin >> n >> m;
  ll temp = n;
  ll ans = 1;
  while (temp * 2 <= m) {
    ans++, temp *= 2;
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,arr[100],i,sum=0,a=0,b=0,temp=0,j,sum1=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
 for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(arr[i]<arr[j])
			{
				temp  =arr[i];
				arr[i]=arr[j];
				arr[j]=temp;
			}
		}
	}
    for(i=0;i<n;i++)
    {
    if(i%2==0)
    {
        sum+=arr[i];
    }
    else{
        sum1+=arr[i];
    }
    }
    cout<<abs(sum-sum1)<<endl;
}


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

int main(){
	int a,b;
	while(1){
		cin>>a>>b;
		if(a==0 && b==0)break;
		int cnt=0;
		if(a<b){
			int sub=a;
			a=b;
			b=sub;
		}
		while(1){
			int alt=a%b;
			cnt++;
			a=b;
			b=alt;
			if(b==0)break;
		}
		cout<<a<<" "<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
h,w=map(int,input().split())
a=[[str(i) for i in input()] for j in range(h)]
ef=True
for y in range(h):
    for x in range(w):
        f=False
        if a[y][x]=="#":
            if y>0:
                if a[y-1][x]=="#":f=True
            if x>0:
                if a[y][x-1]=="#":f=True
            if y+1!=h:
                if a[y+1][x]=="#":f=True
            if x+1!=w:
                if a[y][x+1]=="#":f=True
            if not f:
                ef=False
                break
print("Yes" if ef else "No")

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = Integer.parseInt(scanner.nextLine());
		int[] As = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] numSOs = new int[N];
		for(int A: As) {
			numSOs[A - 1]++;
		}
		for(int numSO: numSOs) {
			System.out.println(numSO);
		}
	}
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << a * b / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

int main(){

  int a, b;
  cin >> a >> b;

  int d = b-a;
  int sum = 0;
  for(int i=0; i<1000; i++){
    sum += i;
    if( i == d ){
      break;
    }
  }
  cout << sum - b << endl;

  return 0;
}

//


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
using namespace std;

void solve() {
	int N;
	vector<int> H;
	cin >> N;
	H.resize(N);
	for (int n = 0; n < N; n++)cin >> H[n];
	int ans = 0;
	int cur = 0;
	for (int n = 1; n < N; n++) {
		if (H[n] <= H[n - 1])cur++;
		else {
			ans = max(ans, cur);
			cur = 0;
		}
	}
	ans = max(ans, cur);
	cout << ans << endl;
	return;
}

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

int main() {
#ifdef DEBUGTIME
	for (int time = 0; time < DEBUGTIME; time++) {
		solve();
		cout << "####################" << endl;
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  string a;
  cin>>a;
  rep(i,a.size()){
  if(a[i]=='?'){
  cout<<'D';
  }
    else
      cout<<a[i];
  }
}

Measured memory_bytes: 3908
N = int(input())
Ss =sorted([int(input()) for i in range(N)])
if sum(Ss)%10!=0:
    print(sum(Ss))
else:
    ans = 0
    check = False
    for s in range(0,len(Ss)):
        if Ss[s]%10!=0:
            ans = sum(Ss)-Ss[s]
            check = True
            break
    if check == True:
        print(ans)
    else:
        print(0)

Measured memory_bytes: 3064
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];
        public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] have = new int[n];
        for(int i = 0;i < k;i++){
            int d = sc.nextInt();
            for(int j = 0;j < d;j++){
                int tmp = sc.nextInt();
                have[tmp-1]++;
            }
        }
        int ans = 0;
        for(int i = 0;i < n;i++){
            if(have[i]==0)ans++;
        }
        System.out.println(ans);

        
        
    }
    
}


Measured memory_bytes: 46204
N, K = map(int, input().split())
S = input()
T = []
count = 1
for n in range(N - 1):
    s0, s1 = S[n], S[n + 1]
    if s0 == s1:
        count += 1
    else:
        T.append(count)
        count = 1
T.append(count)
if S[0] == '0':
    T = [0] + T
if S[-1] == '0':
    T = T + [0]
L = len(T)
if 2 * K + 1 >= L:
    print(N)
    exit()
# 偶数番目から始まる連続する2K+1個の和の最大値
now = sum(T[0: 2 * K + 1])
ans = now
for l in range(2, L - (2 * K + 1) + 1, 2):
    now -= T[l - 2]
    now -= T[l - 1]
    now += T[l + 2 * K - 1]
    now += T[l + 2 * K]
    if now > ans:
        ans = now
print(ans)


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    string s;
    cin>>s;
    int a=s.size(),ansA=0,ansB=0;
    if(a%2==1){
        int i=a/2+1;
        while(s[a/2]==s[i]&&i<a) ansA++,i++;
        i=a/2-1;
        while(s[a/2]==s[i]&&i>=0) ansB++,i--;
    }
    else if(s[a/2-1]==s[a/2]){
        int i=a/2;
        while(s[a/2]==s[i]&&i<a) ansA++,i++;
        i=a/2-1;
        while(s[a/2-1]==s[i]&&i>=0) ansB++,i--;
    }
    cout<<(a+1)/2+min(ansA,ansB);
}

Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def find(S, x):
    left = -1
    right = n

    while right - left > 1:
        mid = (left + right)//2

        if S[mid] == x:
            return True 

        if S[mid] < x:
            left = mid
        else:
            right = mid

    return False

n = int(input())
S = sorted(map(int,input().split()))
q = int(input())
T = map(int,input().split())

count = 0
for t in T:
    if find(S, t):
        count += 1
print(count)

Measured memory_bytes: 18664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, a;
  cin>>N;
  vector<int> dfc(100010,0);
  for(int i=0; i<N; i++){
    cin>>a;
    dfc.at(a)++;
  }
  int ans=0;
  int sum=0;
  for(int i=0; i<100000; i++){
    sum+=dfc.at(i);
    if(sum==N/2){
      ans++;
    }
    else if(sum>N/2+1){
      break;
    }
  }
  cout<<ans<<endl;
  
}
  

Measured memory_bytes: 3804
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

const int mod = 1000000007;
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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

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

int main(){
  int64_t N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  sort(all(A));
  mint ans = 0;
  mint tmp = 0;
  combination c(N-1);
  rep(i, N){
    tmp = c(N-i-1, K-1) * (A.at(N-i-1) - A.at(i));
    ans += tmp;
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=500005;
const ll INF=1LL<<30;

int V,cmp[MAX];
vector<int> G[MAX],rG[MAX],vs;//vsがトポソの逆順になってる
bool used[MAX];

void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void DFS(int v){
    used[v]=1;
    for(int i=0;i<G[v].size();i++){
        if(used[G[v][i]]==0) DFS(G[v][i]);
    }
    vs.push_back(v);
}

void rDFS(int v,int k){
    used[v]=1;
    cmp[v]=k;
    for(int i=0;i<rG[v].size();i++){
        if(used[rG[v][i]]==0) rDFS(rG[v][i],k);
    }
}

int scc(){
    memset(used,0,sizeof(used));
    vs.clear();
    for(int v=0;v<V;v++){
        if(used[v]==0) DFS(v);
    }
    
    memset(used,0,sizeof(used));
    int k=0;
    for(int i=vs.size()-1;i>=0;i--){
        if(used[vs[i]]==0) rDFS(vs[i],k++);
    }
    return k;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    V=N;
    
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        add_edge(a,b);
    }
    
    int k=scc();
    cout<<k<<endl;
    
    vector<vector<int>> G(k);
    
    for(int i=0;i<N;i++) G[cmp[i]].push_back(i);
    
    for(int i=0;i<k;i++){
        cout<<si(G[i]);
        for(int a:G[i]) cout<<" "<<a;
        cout<<"\n";
    }
}


Measured memory_bytes: 80000
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

a,b,c,d=map(int,input().split())
ans=-10**18
#x=0 or y=0
if a<=0<=b or c<=0<=d:
    ans=max(ans,0)
#x<0 and y>0
ans=max(ans,b*c)
#x>0 and y>0
ans=max(ans,b*d)
#x<0 and y<0
ans=max(ans,a*c)
#x>0 and y<0
ans=max(ans,a*d)
print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define INF (1ll<<60)
#define mod 1000000007
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll n;cin>>n;
    
    ll ans=0;
    rep(i,n){
        ll a;cin>>a;
        if(i%2==0 && a%2==1) ans++;
    }

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

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main()
{
    int x,ans;

    cin >> x;

    ans = x;
    while (true) {
        if (IsPrime(ans))
            break;
        ++ans;
    }

    std::cout << ans << endl;
}


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

int main(){
  int A, B, C, X, i, j, k, count = 0;
  cin >> A >> B >> C >> X;
  
  for (i = 0; i <= A; i++){
    for (j = 0; j <= B; j++){
      for (k = 0; k <= C; k++){
        if(500*i + 100*j + 50*k == X){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
  
  return 0;
}

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

const int MAXN = 5e3 + 7;

int n, a[MAXN], ans;
set<int> stk;

int main() {
    scanf("%d", &n);
    for(int i = 1;i <= n;i++) {
        scanf("%d", &a[i]);
        stk.insert(a[i]);
    }
    //cout << n << endl;
    sort(a+1, a+n+1);
    ans = 0;
    for(int i = 1;i <= n;i++) {
        for(int j = i+1;j <= n;j++) {
            if(n-j+2 <= ans) break;
            //if(vis[i] && vis[j]) continue;
            int val = a[j] - a[i];
            int num = 2, tmp = a[j] + val;
            //vis[i] = vis[j] = 1;
            while(tmp <= a[n]) {
                if(stk.count(tmp)) num++, tmp += val;
                else break;
            }
            ans = max(ans, num);
            if(ans == n-i+1) break;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
  char b;
  cin>>b;

   if(b=='T') cout<<'A'<<endl;
   if(b=='A')cout<<'T'<<endl;
    if(b=='G')cout<<'C'<<endl;
    if(b=='C')cout<<'G'<<endl;
  
 
}

Measured memory_bytes: 256
X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  p.sort()
  
  for i in range(52):
    if X - i not in p:
      print(X-i)
      break
    if X + i not in p:
      print(X+i)
      break


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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios:: sync_with_stdio(false);
  cin.tie();
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(max(a * c, a * d), max(b * c, b * d));
  return 0;
}




Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
int gcd(int x, int y) {
	if (y == 0)return x;
	else return gcd(y, x%y);
}
using namespace std;
signed main() {
	ll a, b;
	cin >> a >> b;
	if (b%a == 0)cout << a + b << endl;
	else cout << b - a << endl;
	getchar(); getchar(); return 0;
}


Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._

  val a = readLine.trim.toList
  val b = readLine.trim.toList
  println(
    if (isMatch(a, b)) "Yes" else "No"
  )
  def isMatch(state: List[Char], target: List[Char]): Boolean = {
    def sub(state: List[Char], target: List[Char]): Boolean = {
      target match {
        case Nil ⇒ true
        case '_' :: tt ⇒
          state match {
            case Nil ⇒ false
            case _ :: t ⇒ sub(t, tt)
          }
        case ht::tt ⇒
          state match {
            case Nil ⇒ false
            case h::t if h == ht ⇒ sub(t, tt)
            case _ ⇒ false
          }
      }
    }
    state match {
      case Nil ⇒ false
      case h::t ⇒ sub(state, target) || isMatch(t, target)
    }
  }
  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 44068
import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni();
        int cnt = 0;
        for(int i = 1; i<= n; i++)if(ni() != i)cnt++;
        pn((cnt == 0 || cnt == 2)?"YES":"NO");
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long IINF = (long)1e18, mod = (long)1e9+7;
    final int INF = (int)1e9, MX = (int)2e5+5;
    DecimalFormat df = new DecimalFormat("0.00");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-6;
    static boolean multipleTC = false, memory = false, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        if(fileIO){
            in = new FastReader("input.txt");
            out = new PrintWriter("output.txt");
        }else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}
 
    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }
 
        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }
 
        String nextLine() throws Exception{
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }  
            return str;
        }
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

const int MAXV = 11, INF = 10000;

struct edge{int to, cost;};

typedef pair<int ,int> pp;

int d[MAXV];
int n, a, b, c, t, anst, ansc, minc;

int main()
{
    while(cin >> n && n)
    {
        anst = MAXV;
        ansc = INF;
        t = 0;
        vector<edge> g[MAXV];
        

        REP(n)
        {
            cin >> a >> b >> c;
            g[a].push_back((edge){b, c});
            g[b].push_back((edge){a, c});

            t = max(t, a+1);
            t = max(t, b+1);
        }

        rep(k,t)
        {
            memset(d, INF, sizeof(d));
            d[k] = 0;
            priority_queue<pp, vector<pp>, greater<pp> > que;
            que.push(pp(0, k));

            while(!que.empty())
            {
                pp p = que.top(); que.pop();
                int v = p.second;
                if(d[v] < p.first ) continue;

                rep(i,g[v].size())
                {
                    edge e = g[v][i];
                    if(d[e.to] > d[v] + e.cost)
                    {
                        d[e.to] = d[v] + e.cost;
                        que.push(pp(d[e.to], e.to));
                    }
                }
            }
            minc = 0;
            REP(t) minc += d[i];
            if(minc < ansc) {anst = k; ansc = minc;}
        }
        cout << anst << " " << ansc << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

bool compare(vi a, vi b){

	for(int i=0;i<a.size();i++){
		if(a[i]!=b[i]) return false;
	}

	return true;
}
 
int32_t main(){

	
	int n, n1,n2;
	vector<int>aux;
	cin >> n;
	for(int i=0;i<n;i++)
		aux.push_back(i+1);
	vector<vector<int>>v;

	vi b(n);
	vi a(n);
	
	do{
		v.push_back(aux);
	}while(next_permutation(all(aux)));

	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	
	sort(all(v));

	for(int i=0;i<v.size();i++){
		if(compare(v[i],a)) n1=i;
		if(compare(v[i],b)) n2=i;
 	}

 	cout << abs(n1-n2) << endl;
	return 0;
}

Measured memory_bytes: 3256
n = int(input())
a = list(map(int, input().split()))
input()
m = list(map(int, input().split()))

n2 = 2**n
aa = [0 for _ in range(n2)]
for i in range(n):
    t = 2**i
    for j in range(n2):
        if (j//t)%2:
            aa[j] += a[i]

for k in m:
    if k in aa:
        print('yes')
    else:
        print('no')

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1000000007;

int main(void)
{
	ll n, m;
	cin >> n >> m;
	vector<ll> ss(n);
	rep(i, n) cin >> ss[i];
	vector<ll> ts(m);
	rep(i, m) cin >> ts[i];

	vector<vector<ll>> sum(n + 5, vector<ll>(m + 5, 0));
	rep(i, n) {
		rep(j, m) {
			ll ip = i + 1;
			ll jp = j + 1;
			sum[ip][jp] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j];
			if (ss[i] == ts[j]) {
				sum[ip][jp] += sum[i][j] + 1;
			}
			sum[ip][jp] += mod;
			sum[ip][jp] %= mod;
		}
	}
	cout << sum[n][m] + 1 << endl;

	return 0;
}


Measured memory_bytes: 31744
#include <iostream>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    map<int64_t,int64_t> cardcount;
    for(int i = 0; i < n; ++i)
    {
        int64_t a;
        cin >> a;
        cardcount[a]++;
    }
    for(int i = 0; i < m; ++i)
    {
        int64_t b,c;
        cin >> b >> c;
        cardcount[c] += b;
    }
    //for(auto [x,y] : cardcount) cout << x << ':' << y << '\n';
    auto itr = cardcount.end();
    int64_t sum = 0;
    int64_t count = 0;
    while(count < n)
    {
        --itr;
        int64_t u = min(itr->second, n - count);
        count += u;
        sum += u * itr->first;
        //cout << itr->first << " x " << u << '\n';
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 12800
w, h = gets.split.map(&:to_i)
p = w.times.map { gets.to_i }.sort
q = h.times.map { gets.to_i }.sort
ps = p.inject(:+)
qs = q.inject(:+)
sum = ps + qs

tsum = 0
ssq = q.map{ |i| tsum += i}
ssq.unshift(0)

p.each {|x|
  idx = (0...q.size).bsearch{|i| q[i] > x}
  if !idx
    sum += qs
  else
    ppss = x * (q.size - idx)
    qqss = ssq[idx]
    sum += ppss if ppss
    sum += qqss if qqss
  end
}
p sum



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

int main(){
	int n;
	cin>>n;
	double v[n];
	rep(i,n) cin>>v[i];
	sort(v, v+n);
	double ans=(v[0]+v[1])/2;
	for(int i=2; i<n; i++){
		ans = (ans+v[i])/2;
	}
	cout.precision(10);
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int h,w;
char c[200][200];
int main(){
    cin>>h>>w;
    for(int i=0;i<200;i++){
        for(int j=0;j<200;j++){
            c[i][j]='#';
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>c[i][j];
        }
    }
    for(int i=0;i<=h+1;i++){
        for(int j=0;j<=w+1;j++){
            cout<<c[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <string>
#include <cmath>

# define PI 3.14159265358979323846

using namespace std;

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

    cout << exp2((int) log2(n)) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int res = 0;
        
        for(char c : s.toCharArray()) res+=c=='2'?1:0;
        
        System.out.println(res);
    }
}


Measured memory_bytes: 21844
n, q = map(int, input().split())
A = []
for _ in range(n):
    name, time = input().split()
    A += [[name, int(time)]]

progress = 0

while A:
    if A[0][1] <= q:
        progress += A[0][1]
        print(A[0][0], progress)
        A.pop(0)
    else:
        progress += q
        A[0][1] -= q
        A += [A[0]]
        A.pop(0)



Measured memory_bytes: 13016
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef int64_t ll;

void solve() {
    ll n, m;
    cin >> n >> m;
    //bool a[n + 1] = {false};
    ll gap = m, fs = 1, bs = n, fe, be, flag = 1;
    for(ll i = 0; i < m; i++) {
        if(flag) {
            flag = 0;
            fe = fs + gap;
            cout << fs << " " << fe << "\n";
            fs++;
        }
        else {
            flag = 1;
            be = bs - gap;
            cout << be << " " << bs << "\n";
            bs--;
        }
        gap--;
    }
}    

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cmath>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(val) cout << "!!!" << #val << ": " << val << endl
#define mod 1000000007
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    LL n;
    cin >> n;
    string str = "";

    while (n != 0) {
        LL r = n % 2;
        if (r < 0) r += 2;

        n = (n - r) / (-2);

        str += (char)('0' + r);
    }

    reverse(str.begin(), str.end());

    if (str == "") str = "0";

    cout << str << endl;
    return 0;
}


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

def main():
    n = int(input())

    for i in range(100):
        for j in range(100):
            ans = i * 4 + j * 7
            if ans == n:
                print('Yes')
                exit()
    print('No')

if __name__ == '__main__':
    main()

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

using namespace std;

const int O = 1e6 + 5;

int n, a[O];

map <int, int> Map;

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++ i){
        cin >> a[i];
        ++ Map[a[i] + i];
    }
    int Ans = 0;
    for (int i = 1; i <= n; ++ i){
        Ans += Map[i - a[i]];
    }
    cout << Ans;
}

Measured memory_bytes: 27816
#include<iostream>
#include<vector>

#include<bits/stdc++.h>
using namespace std;

int main(){
	int x,y;
	cin >> x >> y;
	switch(x){
	case 2:
		if(x==y){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
		break;
	case 4:
	case 6:
	case 9:
	case 11:
		switch(y){
		case 4:
		case 6:
		case 9:
		case 11:
			cout << "Yes" << endl;
			break;
		default:
			cout << "No" << endl;
		}
		break;
	default:
		switch(y){
		case 2:
		case 4:
		case 6:
		case 9:
		case 11:
			cout << "No" << endl;
			break;
		default:
			cout << "Yes" << endl;
		}
	}
}


Measured memory_bytes: 256
import numpy as np
n,k=list(map(int,input().split()))
t=np.zeros(n)
for i in range(k):
  d=int(input())
  tmp=list(map(int,input().split()))
  for j in range(d):
    t[tmp[j]-1] = 1

ans=n-np.sum(t)
print(int(ans))

Measured memory_bytes: 27180
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  int ans=a*a;
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <stack>
#include <vector>
using namespace std;

int majority(int x) {
	return x / 2 + 1;
}

int majority(vector<int> vec) {
	sort(begin(vec), end(vec));
	return accumulate(begin(vec), begin(vec) + majority(vec.size()), 0);
}

int number(int l, int r, const string &str) {
	return stoi(str.substr(l, r - l));
}

int parse(int l, int r, const string &str) {
	if(isdigit(str[l])) return majority(number(l, r, str));

	vector<int> vec;
	stack<int> sta;
	for(int i = l; i < r; ++i) {
		if(str[i] == '[') {
			sta.push(i);
		}
		else if(str[i] == ']') {
			assert(!sta.empty());
			if(sta.size() > 1) {
				sta.pop();
				continue;
			}
			
			const int child_l = sta.top() + 1;
			sta.pop();
			vec.emplace_back(parse(child_l, i, str));
		}
	}
	assert(!vec.empty());
	return majority(vec);
}

void solve() {
	string str;
	cin >> str;
	cout << parse(1, str.size() - 1, str) << endl;
}

int main() {
	int T;
	cin >> T;
	while(T--) solve();
	
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1308
N, K = map(int, input().split())
S = list(input())
A = {}
if S[0] == "1":
    A[1] = 0
    c = 1
else:
    A[0] = 0
    c = 0
for i in range(N-1):
    if S[i] == "0" and S[i+1] == "1":
        c += 1
        A[c] = i+1
B = {}
c = 1
for i in range(N-1):
    if S[i] == "1" and S[i+1] == "0":
        B[c] = i
        c += 1

ans = 0
for p, v in A.items():
    t = B.get(p+K, N-1)
    ans = max(t-v+1, ans)
print(ans)

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

using namespace std;


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

  priority_queue<int, vector<int>, greater<int>> pq;
  int temp = 0;
  for (int i = 0; i < n; i++)
  {
	  cin >> temp;
	  pq.push(temp);
  }

  while (pq.size() > 1)
  {
	  int top = pq.top();
	  pq.pop();

	  int next = pq.top();
	  pq.pop();

	  if (next%top == 0)
		  pq.push(top);
	  else
	  {
		  pq.push(top);
		  pq.push(next%top);
	  }
  }

  cout << pq.top() << endl;
  return 0;
}

Measured memory_bytes: 892
INF = 1 << 29

while n = gets.to_i
  break if n == 0
  stg = n.times.map{ gets.split.map(&:to_i)
                 .map.with_index(-1) { |t, i| [t, i] }
                 .sort }

  memo = [INF] * (1<<n)
  memo[0] = 0
  (1<<n).times do |bits|
    next if memo[bits] == INF
    n.times do |i|
      next if bits | (1<<i) == bits
      nbits = bits | (1<<i)
      mint = 0
      (0..n).each do |j|
        k = stg[i][j][1]
        if k < 0 || bits | 1<<k == bits
          mint = memo[bits] + stg[i][j][0]
          break
        end
      end
      memo[nbits] = mint if memo[nbits] > mint
    end
  end
  p memo[(1<<n)-1]
end

Measured memory_bytes: 15756
#include<iostream>
using namespace std;
int main(){
  int n,t,min_c=10000;;
  cin >> n >> t;
  int cost[n],time[n];
  for(int i=0;i<n;i++){
    cin >> cost[i] >> time[i];
    if(t>=time[i]&&min_c>cost[i]){
      min_c=cost[i];
    }
  }
  if(min_c==10000){
    cout << "TLE\n";
  }else{
    cout << min_c<<"\n";

  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, T, A, H, m(1e9), t, i{}, j; cin >> N >> T >> A;
  while (++i, cin >> H) if ((t = abs(1000 * (T - A) - 6 * H)) < m) m = t, j = i;
  cout << j;}

Measured memory_bytes: 3528
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    println!(
        "{}",
        format!("{0}{1}{2}", s[0], s.len() - 2, s[s.len() - 1])
    );
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
n, m = gets.split.map(&:to_i)
image_a = []
n.times do
  image_a << gets.chomp
end
image_b = []
m.times do
  image_b << gets.chomp
end

def get_indices(line, part)
  offset = 0
  indices = []
  while index = line.index(part, offset)
    indices << index
    offset = index + part.length
  end
  indices
end

find = false
(n-m+1).times do |current_line|
  break if find
  get_indices(image_a[current_line], image_b[0]).each do |current_index|
    flag = true
    m.times do |check_line|
      next if check_line == 0
      unless image_a[current_line+check_line][current_index..current_index+m-1] == image_b[check_line]
        flag = false
        break
      end
    end
    if flag
      find = true
      break
    end
  end
end
puts find ? "Yes" : "No"


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
int main() {
  int in(N);

  vector<int> h(N), dp(N+1, 1e9);
  rep(i, N) {
    cin >> h[i];
  }
  dp[0] = 0;
  rep(i, N) {
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N;
    cin >> N;
    int X = (int)(N / 1.08);


    while (X * 1.08 < N)
    {
        X += 1;
    }
    if ((int)(X * 1.08) == N) cout << X << "\n";
    else cout << ":(\n";
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var C1, C2 string
	fmt.Scan(&C1)
	fmt.Scan(&C2)

	if C1[0] == C2[2] && C1[1] == C2[1] && C1[2] == C2[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
N=int(input())
n=[list(range(2)) for i in range(N)]
h=list(map(int,input().split()))
for i in range(N):
    n[i][0]=h[i]
    n[i][1]=i+1
std=sorted(n)
for i in range(N):
    print(std[i][1], end=' ')
    

Measured memory_bytes: 25948
def attack(H):
    #最小の要素を頭に出す
    H.sort()
    H_min = H[0]
    for i in range(1,len(H)):
        H[i]  = H[i] % H_min
    #0を削除
    new_H = [i for i in H if i != 0]
    return new_H

N = int(input())
HP_str = input().split()
HP = [0 for i in range(N)]
for j in range(N):
    HP[j] = int(HP_str[j])

while(True):
    HP = attack(HP)
    if len(HP) == 1:
        break

HP.sort()
HP.reverse()
print(HP[0])

Measured memory_bytes: 14864
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

const int MAXV = 300;
const int MAXE = MAXV * MAXV;
const int MAXF = (1<<29);
typedef int F;

struct MaxFlow {
    F cap[MAXE], flow[MAXE];
    int V, E, level[MAXV], prev[MAXE], edge[MAXV], to[MAXE];
    MaxFlow(int n) : E(0) {
        V = n;
        memset(flow, 0, sizeof(flow));
        memset(prev, -1, sizeof(prev));
        memset(edge, -1, sizeof(edge));
    }
    void add_edge(int s, int t, F f, F g = 0) {
        cap[E] = f; to[E] = t; prev[E] = edge[s]; edge[s] = E; E++;
        cap[E] = g; to[E] = s; prev[E] = edge[t]; edge[t] = E; E++;
    }
    void make_level(int s) { // make level graph (bfs)
        memset(level, -1, sizeof(level));
        queue<int> q; q.push(s); level[s] = 0;
        while(!q.empty()) {
            int v = q.front(); q.pop();
            for (int e = edge[v]; e != -1; e = prev[e]) {
                if (cap[e] - flow[e] > 0 && level[to[e]] == -1)
                    q.push(to[e]), level[to[e]] = level[v]+1;
            }
        }
    }
    int augment(int s, int t, F f) { // find augment path (dfs)
        if (s == t || f == 0) return f;
        for (int e = edge[s]; e != -1; e = prev[e]) {
            if (level[to[e]] > level[s] && cap[e] - flow[e] > 0) {
                F g = augment(to[e], t, min(f, cap[e] - flow[e]));
                if (g > 0) {
                    flow[e] += g, flow[e^1] -= g;
                    return g;
                }
            }
        }
        return 0;
    }
    int max_flow(int s, int t) {
        int f, ret = 0;
        for (bool cont = true; cont; ) {
            cont = false;
            make_level(s);
            while ((f = augment(s, t, MAXF)) > 0) {
                cont = true;
                ret += f;
            }
        }
        return ret;
    }
};

int main() {
    ios::sync_with_stdio(false);
    int x[MAXE], y[MAXE];
    int N,M,a,b;
    cin>>N>>M;
    MaxFlow mf(N);
    for (int i=0; i<M; ++i) {
        cin>>a>>b; a--, b--;
        mf.add_edge(a, b, 1, 1);
        x[i] = a, y[i] = b;
    }
    cin>>a>>b; a--, b--;
    cout<<mf.max_flow(a, b)<<endl;
    vector<int> rev;
    for (int i=0; i<M; ++i) {
        int e = mf.edge[y[i]];
        while(e != -1) {
            if (mf.to[e] == x[i] && mf.flow[e] > 0) rev.push_back(i);
            e = mf.prev[e];
        }
    }
    cout<<rev.size()<<endl;
    for (int i=0; i<rev.size(); ++i) cout<<rev[i]+1<<endl;
}

Measured memory_bytes: 1984
#include <stdio.h>


int main(void)
{
	int h[300];
	int w[300];
	int i = -1,j,k,l;
	do{
		i++;
		scanf("%d%d", &h[i], &w[i]);
	} while (h[i] != 0 || w[i] != 0);
	for (j = 0; j <= i; j++){
		for (l = 0; l < h[j]; l++){
			for (k = 0; k < w[j]; k++) {
				if(k == 0 || k == (w[j] - 1) || l == 0 || l == (h[j] - 1))printf("#");
				else printf(".");
			}
			printf("\n");
		}
		if(j != i)printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1752