akhauriyash/Code-Regression huggingface dataset:
def main():
  import sys
  input=sys.stdin.buffer.readline
  N,M=map(int,input().split())
  A=[list(map(int,input().split())) for i in range(N)]
  ans=N
  s=set()
  for i in range(M-1):
    d=[0]*M
    for j in range(N):
      for k in range(M):
        if A[j][k]-1 in s:
          continue
        else:
          d[A[j][k]-1]+=1
          break
    ans=min(ans,max(d))
    s.add(d.index(max(d)))
  print(ans)
main()
  


Measured memory_bytes: 9980
S = input()
flag = True

while True:
  if S.count('a') == 0:
    ans = 'a'
    break
  elif S.count('b') == 0:
    ans = 'b'
    break
  elif S.count('c') == 0:
    ans = 'c'
    break
  elif S.count('d') == 0:
    ans = 'd'
    break
  elif S.count('e') == 0:
    ans = 'e'
    break
  elif S.count('f') == 0:
    ans = 'f'
    break 
  elif S.count('g') == 0:
    ans = 'g'
    break
  elif S.count('h') == 0:
    ans = 'h'
    break
  elif S.count('i') == 0:
    ans = 'i'
    break
  elif S.count('j') == 0:
    ans = 'j'
    break
  elif S.count('k') == 0:
    ans = 'k'
    break
  elif S.count('l') == 0:
    ans = 'm'
    break
  elif S.count('n') == 0:
    ans = 'n'
    break
  elif S.count('o') == 0:
    ans = 'o'
    break
  elif S.count('p') == 0:
    ans = 'p'
    break
  elif S.count('q') == 0:
    ans = 'q'
    break
  elif S.count('r') == 0:
    ans = 'r'
    break
  elif S.count('s') == 0:
    ans = 's'
    break
  elif S.count('t') == 0:
    ans = 't'
    break
  elif S.count('u') == 0:
    ans = 'u'
    break
  elif S.count('v') == 0:
    ans = 'v'
    break
  elif S.count('w') == 0:
    ans = 'w'
    break
  elif S.count('x') == 0:
    ans = 'x'
    break
  elif S.count('y') == 0:
    ans = 'y'
    break
  elif S.count('z') == 0:
    ans = 'z'
    break
  else:
    ans = 'None'
    break
print(ans)

Measured memory_bytes: 9216
data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]

count = int(input())
for c in range(count):
    b, f, r, v = [int(i) for i in input().split()]
    data[b-1][f-1][r-1] += v
    
for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()

    if bi < 3:
        print('#' * 20)

Measured memory_bytes: 7740
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<vector<int> > c(N);
  REP(i,N-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    c[a].push_back(b);
    c[b].push_back(a);
  }
  bool v[N];
  REP(i,N)v[i]=false;
  v[0]=true;
  v[N-1]=true;
  queue<int> qf,qs;
  qf.push(0);
  qs.push(N-1);
  int nf=1;
  int ns=1;
  while(!qf.empty() or !qs.empty()){
    int mf=qf.size();
    REP(i,mf){
      for(auto e:c[qf.front()])if(!v[e]){
        qf.push(e);
        v[e]=true;
        nf++;
      }
      qf.pop();
    }
    int ms=qs.size();
    REP(i,ms){
      for(auto e:c[qs.front()])if(!v[e]){
        qs.push(e);
        v[e]=true;
        ns++;
      }
      qs.pop();
    }
  }
  // cerr<<nf<<" "<<ns<<endl;
  cout<<(nf>ns?"Fennec":"Snuke")<<endl;
  return 0;
}


Measured memory_bytes: 5888
#include <cstdio>
#include <queue>
enum{W=17,Z=100};
main(){
	std::queue<int>q;
	std::vector<int>r,sheet(W);
	int t=0,i,j,l;
	for(;r.size()<Z;t++){
		if(t%5==0)q.push(t/5);
		for(i=0;i<W;i++)if(sheet[i])sheet[i]--;
		for(;!q.empty();q.pop()){
			l=q.front()%5==1 ? 5 : 2;
			for(i=0;i<=W-l;i++){
				for(j=0;j<l;j++)if(sheet[i+j])break;
				if(j==l)break;
			}
			if(i>W-l)break;
			for(j=0;j<l;j++)sheet[i+j]=17*(q.front()%2)+3*(q.front()%3)+19;
			r.push_back(t-q.front()*5);

		}
	}
	for(;~scanf("%d",&l);)printf("%d\n",r[l]);
}

Measured memory_bytes: 1052
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
typedef long long ll;
ll c[N],f[N],res;int h[N],a[N],n;
inline void upd(R int x,R ll y){for(;x<=n;x+=x&-x)cmax(c[x],y);}
inline ll query(R int x){R ll res=0;for(;x;x-=x&-x)cmax(res,c[x]);return res;}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&h[i]);
	fp(i,1,n)scanf("%d",&a[i]);
	fp(i,1,n)f[i]=query(h[i])+a[i],upd(h[i],f[i]),cmax(res,f[i]);
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 100000007;

int main() {
    ll A,B,C,K;cin >> A >> B >> C >> K;
    if (K < A) cout << K << endl;
    else if (K < A + B) cout << A << endl;
    else cout << A - (K - A - B) << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
int main(){
	int i=0;
	int j=0;
	
	int A=0;
	int B=0;
	int X=0;
	
	int ans=0;
	
	int MIN=999999;
	
	scanf("%d %d %d",&A,&B,&X);
	
	for(i=0;i<=20000/1000;i++){
		for(j=0;j<=20000/500;j++){
			//合計金額
			ans=A*i+B*j;
			if(ans<MIN&&1000*i+500*j>=X){
				MIN=ans;
			}
		}
	}
	printf("%d\n",MIN);
	return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    REP(i, m) cin >> a[i];

    vector<LL> dp(n+5, 0);
    map<int, bool> mp;
    REP(i, m) mp[a[i]] = true;
    dp[0] = 1;
    REP(i, n)
    {
        if(!mp[i+1]) dp[i+1] = (dp[i] + (i >= 1 ? dp[i-1] : 0)) % MOD;
        //cout << dp[i] << " " << dp[i-1] << " " << dp[i+1] << endl;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    int N;
    cin>>N;
    int a[N];
    rep(i, N){
        a[i]=0;
    }
    int b;
    rep(i, N-1){
        cin>>b;
        a[b-1]++;
    }
    rep(i, N){
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 4280
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[10000000];
		boolean jud = true;
		int i = 1;
		int tmp = n;
		a[tmp] ++;
		int ans = 1;
		while(jud) {
			if(tmp%2 == 0) {
				tmp /= 2;
			}else {
				tmp = 3 * tmp + 1;
			}
			i++;
			
			if(a[tmp] == 1) {
				ans = i;
				jud = false;
			}else {
				a[tmp] ++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 64468
#include <iostream>
#include <algorithm>
using namespace std;
long long panoj(long long N,long long X){
    long long i,pan[51],sum[51];
    pan[0]=0;sum[0]=1;
    for(i=0;i<51;i++){
        pan[i+1]=pan[i]*2+2;
        sum[i+1]=sum[i]*2+3;
    }
    if(X==sum[N]){
        return pan[N];
    }else if(X>sum[N-1]+1){
        return pan[N-1]+1+panoj(N-1,X-sum[N-1]-2);
    }else if(X>0){
        return 1+panoj(N-1,X-1);
    }else{
        return 0;
    }
}
int main(void){
    long long N,X;
    cin>>N>>X;
    cout<<X-panoj(N,X)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}

signed _main(){
  int N,K,ans=0; cin >> N >> K;
  while(N!=0){
    N/=K;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N; cin >> N;
  vector<vector<int>> R(N), B(N);
  for (int i = 0; i < N; i++) {
    int a, b; cin >> a >> b;
    R.at(i) = { a, b, 1 };
  }
  sort(R.begin(), R.end(), greater<vector<int>>());
  for (int i = 0; i < N; i++) {
    int c, d; cin >> c >> d;
    B.at(i) = { c, d };
  }
  sort(B.begin(), B.end());
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int c = B.at(i).at(0);
    int d = B.at(i).at(1);
    int idx = -1;
    int tmp = -1;
    for (int j = 0; j < N; j++) {
      int a = R.at(j).at(0);
      int b = R.at(j).at(1);
      int flag = R.at(j).at(2);
      if ((a > c) || (b > d) || flag == 0) continue;
      if (b > tmp) {
        idx = j;
        tmp = b;
      }
    }
    if (idx != -1) {
      cnt++;
      R.at(idx).at(2) = 0;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int k;
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
	cin >> k;
	string pom = "ACL";
	string rez = "";
	for(int i=1;i<=k;i++)rez += pom;
	cout << rez << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#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++)


int main(){
    string a, b;
    cin >> a >> b;
    int la = a.length(), lb = b.length();
    vector<vector<int> > dp(la+1, vector<int>(lb+1, 0));
    rep2(i, 1, la+1) dp[i][0] = i;
    rep2(j, 1, lb+1) dp[0][j] = j;
    rep2(i,1, la+1){
        rep2(j,1, lb+1){
            if((char)a.at(i-1) == (char)b.at(j-1)) {
                dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j] + 1, dp[i][j-1] + 1));
            }
            else dp[i][j] = min(dp[i-1][j-1]+1, min(dp[i-1][j] + 1, dp[i][j-1] + 1));
        }
    }
    cout << dp[la][lb] << endl;
}


Measured memory_bytes: 6932
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    printf("%s%d\n", "ABC", n);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>

using namespace std;

bool solve(string s) {
    stack<char> st;
    for (string::iterator i = s.begin(); i != s.end(); i++) {
        switch (*i) {
            case '(':
                st.push('(');
                break;
            case ')':
                if (!st.empty() && st.top() == '(') {
                    st.pop();
                } else {
                    return false;
                }
                break;
            case '[':
                st.push('[');
                break;
            case ']':
                if (!st.empty() && st.top() == '[') {
                    st.pop();
                } else {
                    return false;
                }
                break;
        }
    }
    if (st.empty()) return true;
    else return false;
}

int main() {
    string s;
    while (getline(cin, s)) {
        if (s == ".") break;
        if (solve(s)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    
    int a;
    cin >> a;
    int total_num;
    if(a %2 == 0){
        total_num = a;
    int    permutacoes = total_num/2 ;

    cout << permutacoes * permutacoes  <<endl;
    }
    else{
        total_num = a + 1;
        int    permutacoes = total_num/2 ;

    cout << permutacoes * permutacoes  -permutacoes<<endl;
    }
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,i,Count;
	Count=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++)
	{
		
		if(c%i==0)Count++;
		
		}
		printf("%d\n",Count);
	
return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  vector<int>o(n), p(n), q(n);
  rep(i, n)cin>>p[i];
  rep(i, n)cin>>q[i];
  rep(i, n)o[i]=i+1;

  int counter = 0;
  int a=0, b=0;
  while(true){
    bool fa=true;
    rep(i, n)if(o[i] != p[i])fa=false;
    if(fa)a=counter;

    bool fb = true;
    rep(i, n)if(o[i] != q[i])fb=false;
    if(fb)b=counter;

    if( !next_permutation(o.begin(), o.end()) )break;
    counter++;
  }

  cout<<abs(a-b);

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  double ans = 0.0, a;
  for(int i = 0; i < n; i++){
    cin >> a;
    a = 1.0 / a;
    ans += a;
  }
  
  cout << 1.0 / ans << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    var i = 1
    while(true){
      val in = StdIn.readLine().split(" ").map(s => s.toInt)
      if(in(0) == 0 && in(1) == 0){
        return
      } else {
        val answer = in.toSeq.sorted
        println(answer(0) + " " + answer(1))}
      i += 1
    }
 }
}

Measured memory_bytes: 46912
#include<bits/stdc++.h>
using namespace std;
int main()
{
 ios::sync_with_stdio(false);
 cin.tie(0);
 int t; cin>>t;
 string s; cin>>s;
 if(s.size()>t)
 {
	 for(int i=0;i<t;i++)
	 cout<<s[i];
	 cout<<"..."<<'\n';
 }
 else
 cout<<s<<'\n';
 
 return 0;
}




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

#define PB push_back
#define MP make_pair
#define LL long long
#define LLU usinged long long
#define SZ(a) ((int)a.size())

using namespace std;

LL gcd(LL a, LL b) {
	if(a > b) return gcd(b,a);
	if(a == 0) return b;
	return gcd(b%a, a);
}

int main() {
	
	LL A, B;
	
	cin >> A >> B;
	
	LL g = gcd(A,B);
	
	vector<LL> primes;
	vector<bool> hit(1000000);
	
	primes.push_back(2);
	
	for(LL i = 3; i < SZ(hit); i+=2) {
		if(hit[i]) continue;
		primes.push_back(i);
		for(LL j = 3*i; j < SZ(hit); j += 2*i)
			hit[j] = true;
	}
	
	int ans = 1;
	
	for(LL p : primes) {
		if(g % p == 0) {
			ans++;
			while(g % p == 0) g /= p;
		}
	}
	
	if(g != 1) ans++;
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int N, K;

vector<int> A;
vector<int> cnt;

int main() {
	cin >> N >> K;
	int x;
	A.clear();
	FOR (i, N) {
		cin >> x;
		A.pb(x);
	}
	sort(all(A));
	cnt.clear();
	int j, i = 0;
	while (i < A.sz) {
		j = i;
		while (j < A.sz && A[j] == A[i])
			j++;
		cnt.pb(j - i);
		i = j;
	}
	sort(all(cnt));
	int ret = 0;
	FOR (i, cnt.sz - K)
		ret += cnt[i];
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2548
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		int[] n = new int[number];
		int[] m = new int[number];

		for (int i = 0; i < number; i++) {
			n[i] = sc.nextInt();
			m[i] = sc.nextInt();
		}
		int cnt = 0;
		for (int i = 0; i < number; i++) {
			if (n[i] == m[i]) {
				cnt++;
			}else if(n[i] != m[i]) {
				cnt = 0;
			}
			if (cnt == 3) {
				System.out.println("Yes");
				return;
			}

		}
		
			System.out.println("No");
		

	}
}


Measured memory_bytes: 36216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <vector>

// Binary Indexed Tree
// ?????¨????????? 0-indexed ??¨????????±??????
template <typename T = int>
class BIT {
	std::vector<T> vec;

public:
	BIT() = default;

	explicit BIT(int size) {
		vec.resize(size + 1);
	}

	// [0, i] ??????????¨??????????
	T sum(int i) const {
		++i;

		int s = 0;
		while (i > 0) {
			s += vec[i];
			i -= i & -i;
		}
		return s;
	}

	// ?????? i ?????? x ???????????????
	void add(int i, const T& x) {
		++i;

		while (i <= static_cast<int>(vec.size())) {
			vec[i] += x;
			i += i & -i;
		}
	}
};

std::vector<int> data[26];
std::vector<bool> charUsed;
int unusableData[26];

int main() {
	std::string str, ans;
	int k;
	std::cin >> str >> k;
	charUsed.resize(str.size());
	ans.reserve(str.size());

	BIT<> bit(str.size());

	for (auto&& e : data)
		e.reserve(200000);

	for (int i = 0; i < str.size(); ++i)
		data[str[i] - 'a'].push_back(i);

	for (auto&& e : data)
		std::sort(e.begin(), e.end());

	for (int i = 0; i < str.size(); ++i) {
		if (charUsed[i])
			continue;

		const int cur = str[i] - 'a';
		[&]() {
			for (int j = 0; j < cur; ++j) {
				if (unusableData[j] >= data[j].size() || k <= 0)
					continue;

				const auto it = std::lower_bound(data[j].begin() + unusableData[j], data[j].end(), i);

				if (it == data[j].end()) {
					unusableData[j] = data[j].size();
					continue;
				}

				const int next = *it, tmp = next - i - (bit.sum(next) - bit.sum(i));
				if (tmp <= k) {
					unusableData[j] = it - data[j].begin() + 1;

					k -= tmp;
					bit.add(next, 1);

					--i;
					charUsed[next] = true;
					ans += 'a' + j;

					return;
				}
			}

			ans += 'a' + cur;
		}();
	}

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

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

int main() {
  int N, A,B;
  cin >> N >> A;
  B = N % 500 ;
  if (B <= A  ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No"<< endl;  
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;

#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }

#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
//#define endl "\n"
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
       int ans=0;
       foo(i,1,n+1){
           if(i%5!=0&&i%3!=0){
               ans+=i;
           }
       }
       cout << ans;
    }
}


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

int main() {
    int N, a[100000];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];

    long long sum1 = 0;
    long long sum2 = 0;
    long long ans1 = 0;
    long long ans2 = 0;
    for (int i = 0; i < N; ++i) {
        sum1 += a[i];
        sum2 += a[i];
        if (i % 2 == 0) {
            if (sum1 <= 0) {
                ans1 += 1 - sum1;
                sum1 = 1;
            }
            if (sum2 >= 0) {
                ans2 += sum2 + 1;
                sum2 = -1;
            }
        }
        else {
            if (sum1 >= 0) {
                ans1 += sum1 + 1;
                sum1 = -1;
            }
            if (sum2 <= 0) {
                ans2 += 1 - sum2;
                sum2 = 1;
            }
        }
    }

    if (ans1 > ans2) cout << ans2 << endl;
    else cout << ans1 << endl;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



int main()
{
  string S;

  cin >> S;

  string r = "NA";

  if( S.at(2) == '0' && S.at(3) != '0' || S.at(2) == '1' && S.at(3) < '3' )
  {
    r = "YYMM";
    if( S.at(0) == '0' && S.at(1) != '0' || S.at(0) == '1' && S.at(1) < '3' )
    {
      r = "AMBIGUOUS";
      cout << r << endl;
      return 0;
    }
    cout << r << endl;
    return 0;
  }
  
  if( S.at(0) == '0' && S.at(1) != '0' || S.at(0) == '1' && S.at(1) < '3' )
  {
    r = "MMYY";
    cout << r << endl;
    return 0;
  }

  cout << r << endl;


}

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

int main(){
    int n, l;
    std::cin >> n >> l;

    std::vector<std::string> str(n, "");
    for(int i = 0; i < n; ++i){
        std::cin >> str.at(i);
    }

    std::sort(str.begin(), str.end());

    std::string ans = "";
    for(int i = 0; i < n; ++i){
        ans += str.at(i);
    }
    
    std::cout << ans << std::endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ll<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	ll n,l;cin>>n>>l;
	ll sum = (n+2*l-1)*n/2;
	if( (n+l-1)*(l) <= 0 )
	{}
	else if( l > 0 )
		sum -= l;
	else sum -= (n+l-1);

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
/* typedef struct [label] {
     [type name;]
} [label]; */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define CX_MAX (100)
#define CY_MAX (100)

typedef struct {
    int height;
    int active;
} pyramidst;


pyramidst pyramid[CX_MAX + 1][CY_MAX + 1];

int c[100][3];

int main(void)
{
    int nonzero;
    int i, j, k;
    int h_i, cx_i, cy_i;
    int h_d;
    int n;

    memset(pyramid, 0x00, sizeof(pyramid));

    /* 一つ目の情報読み込み */
    scanf("%d", &n);
    for (k = 0; k < n; k++)
    {
        scanf("%d %d %d", &c[k][0], &c[k][1], &c[k][2]);
        if (c[k][2] != 0)
        {
            nonzero = k;
        }
    }

    /* 一つ目の情報から可能なピラミッドを全て生成する。 */
    cx_i = c[nonzero][0];
    cy_i = c[nonzero][1];
    h_i  = c[nonzero][2];
    for (i = 0; i <= CX_MAX ; i++)
    {
        for (j = 0; j <= CY_MAX; j++)
        {
            pyramid[i][j].height = h_i + abs(i - cx_i) + abs(j - cy_i);
            pyramid[i][j].active = 1;
        }
    }

    /* 一意に定まるまでループ */
    for (k = 0; k < n; k++)
    {
        /* 読み込み */
        if (k == nonzero)
        {
            continue;
        }
        cx_i = c[k][0];
        cy_i = c[k][1];
        h_i  = c[k][2];
    
        for (i = 0; i <= CX_MAX; i ++)
        {
            for (j = 0; j <= CY_MAX; j++)
            {
                if (pyramid[i][j].active == 0)
                {
                    continue;
                }
                h_d = pyramid[i][j].height - abs(i - cx_i) - abs(j - cy_i);
                if (h_d <= 0) h_d = 0;
                if (h_i != h_d)
                {
                    pyramid[i][j].active = 0;
                }
            }
        }
    }

    /* active なやつを探して出力 */
    for (i = 0; i <= CX_MAX; i++)
    {
        for (j = 0; j <= CY_MAX; j++)
        {
            if (pyramid[i][j].active == 1)
            {
                printf("%d %d %d\n", i, j, pyramid[i][j].height);
            }
        }
    }

    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
int n,m,k;
int a[N],b[N];
int c[N],d[N];
int f[N],s[N];
int ans[N];
int getf(int u)
{
	return f[u]?f[u]=getf(f[u]):u;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=n;i++)
		s[i]=1;
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if (getf(a[i])!=getf(b[i]))
		{
			s[getf(a[i])]+=s[getf(b[i])];
			f[getf(b[i])]=getf(a[i]);
		}
	}
	for (int i=1;i<=k;i++)
		scanf("%d%d",&c[i],&d[i]);
	for (int i=1;i<=n;i++)
		ans[i]=s[getf(i)]-1;
	for (int i=1;i<=m;i++)
		if (getf(a[i])==getf(b[i]))
		{
			ans[a[i]]--;
			ans[b[i]]--;
		}
	for (int i=1;i<=k;i++)
		if (getf(c[i])==getf(d[i]))
		{
			ans[c[i]]--;
			ans[d[i]]--;
		}
	for (int i=1;i<=n;i++)
		printf("%d%c",ans[i]," \n"[i==n]);
	return 0;
}

Measured memory_bytes: 5608
n = gets.to_i
peoples = []
n.times do
  a = gets.to_i
  tms = []
  a.times do
    tms.push(gets.split.map(&:to_i))
  end
  peoples.push(tms)
end

max = 0

[0, 1].repeated_permutation(n) do |bits|
  i = 0
  everyoneHonest = true
  bits.each do |bit|
    if bit == 1
      tms = peoples[i]
      tms.each do |tm|
        if bits[tm[0] - 1] != tm[1]
          everyoneHonest = false
        end
      end
    end
    i += 1
  end
  if everyoneHonest
    max = [max, bits.count(1)].max
  end
end

print max

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    cin>>B.at(i);
  }
  vector<pair<int,int>> drink;
  for(int i=0;i<N;i++){
    drink.push_back(make_pair(A.at(i),B.at(i)));
  }
  
  sort(drink.begin(),drink.end());
  long long ans=0LL;
  
  int j=0;
  while(M!=0){
    if(drink.at(j).second==0)
      j++;
    else{
      drink.at(j).second--;
      ans+=drink.at(j).first;
      M--;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5048
using System;
using System.Collections.Generic;

class Program
{
  static void Main()
  {
    string _str = Console.ReadLine();
    var message = (IsUpperString(_str)) ? "A" : "a";
    Console.WriteLine(message);
  }
  
  static bool IsUpperString(string s)
{
    // 指定した文字列が大文字かどうかを判定します。
    if (string.IsNullOrEmpty(s)) { return false; }

    foreach (char c in s)
    {
        if (!Char.IsUpper(c))
        {
            return false;
        }
    }
    return true;
}
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    string s, t; cin >> s >> t;
    t.pop_back();
    if(s == t) cout << "Yes";
    else cout << "No";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i > b; i--)
#define repll(i, a, b) for (ll i = a; i < b; i++)

ll gcd3(int a, int b, int c) {
  rrep(p, min(a, min(b, c)),
       0) if (a % p == 0 && b % p == 0 && c % p == 0) return p;
}

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

  int k;
  cin >> k;

  ll sum = 0;
  rep(a, 1, k + 1) rep(b, 1, k + 1) rep(c, 1, k + 1) { sum += gcd3(a, b, c); }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int h;
int memo[11][5];
int bf,ans;


int main(){
  int i,j,k;
  while(1){
    scanf("%d",&h);
    if(h==0)break;
    bf=-1;
    ans=0;
    for(i=0;i<h;i++)for(j=0;j<5;j++)scanf("%d",&memo[i][j]);
    while(ans!=bf){
      bf = ans;
      //消す作業
      for(i=0;i<h;i++)for(j=0;j<3;j++){
	  int now=j;
	  while(memo[i][now]==memo[i][j]&&j<5)j++;
	  if(j-now>=3&&memo[i][now]!=-1){
	    ans+=(j-now)*memo[i][now];
	    for(k=now;k<j;k++)memo[i][k]=-1;
	  }
	  j--;
	}
      //落とす作業
      for(j=0;j<5;j++)for(i=h-1;i>=0;i--){
	  int now=i;
	  while(memo[i][j]==-1&&i>=0)i--;
	  if(i>=0&&now!=i){
	    memo[now][j]=memo[i][j];
	    memo[i][j]=-1;
	    i=now;
	  }
	}
      /*for(i=0;i<h;i++){
	for(j=0;j<5;j++)printf("%d ",memo[i][j]);
	printf("\n");
      }
      printf("\n");*/
    }
    printf("%d\n",ans);
    
  }
  return 0;
}



Measured memory_bytes: 2040
#include <stdio.h>
#include <math.h>
#define PI 3.1415926535898 
int main()
{
	double a=0,b=0,x=0,v=0;
	double y,angle;
	scanf("%lf%lf%lf",&a,&b,&x);
	v=a*a*b-x;
	if(v<=a*a*b/2)
	{
		y=v*2/(a*a);
		angle=atan(a/y)*180/PI;
	}
	else{
		y=2*x/(a*b);
		angle=atan(y/b)*180/PI;
	}
	
	printf("%.10f",90-angle);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>

using namespace std;
long long n,a[101010],tot = 0,m;
struct Node {
	long long st,ed,lazy,gx;
	Node *l,*r;
}*root,pool[404040];
inline void buildt (Node *&now,long long st,long long ed) {
	now = &pool[++tot];
	now->st = st;
	now->ed = ed;
	now->gx = now->lazy = 0;
	if (st == ed)
		return ;
	buildt(now->l,st,(st+ed)/2);
	buildt(now->r,(st+ed)/2+1,ed);
}
inline void down(Node *now) {
	if (now->st == now->ed)
		return ;
	if (!now->lazy)
		return ;
	now->l->lazy += now->lazy-(now->ed-now->l->ed)*now->gx;
	now->l->gx += now->gx;
	now->r->lazy += now->lazy;
	now->r->gx += now->gx;
	now->gx = now->lazy = 0;
}
inline void Add(Node *now,long long pos,long long v) {
	if (now->st > pos || now->ed <= pos-v)
		return ;
	if (now->st > pos-v && now->ed <= pos) {
		now->lazy += v+now->ed-pos;
		now->gx++;
		return ;
	}
	down(now);
	Add(now->l,pos,v);
	Add(now->r,pos,v);
}
inline long long getmax(Node *now) {
	if (now->st == now->ed)
		return now->lazy;
	down(now);
	return max(getmax(now->l),getmax(now->r));
}
int main() {
	scanf("%lld%lld",&n,&m);
	for (int i = 1;i <= n; i++)
		scanf("%lld",&a[i]);
	buildt(root,1,m);
	long long dis,ans = 0;
	for (int i = 1;i < n; i++) {
		dis = a[i+1]-a[i];
		if (dis < 0)
			dis += m;
		ans += dis;
		dis--;
		Add(root,a[i+1],dis);
		if (dis > a[i+1])
			Add(root,m,dis-a[i+1]);
		//getmax(root);
	}
	ans -= getmax(root);
	printf("%lld",ans);
	return 0;
}

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

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

    int  p[M+1];
    string S[M+1];
    
    for (int i = 0; i < M; i++) {
        cin >> p[i] >> S[i];
    }

    int AC[N] = {};
    int WA[N] = {};

    int p_i;
    for (int i = 0; i < M; i++) {
        p_i = p[i]-1;
        if (S[i] == "AC") {
            AC[p_i] = 1;
        } else if ((S[i] == "WA") && (AC[p_i] == 0)) {
            WA[p_i]++;
        }
    }

    int num_AC = 0;
    int num_WA = 0;
    for (int i = 0; i < N; i++) {
        if (AC[i] == 1) {
            num_AC++;
            num_WA = num_WA + WA[i];
        }
    }

    cout << num_AC << " " << num_WA << endl;

}

Measured memory_bytes: 6912
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      long x = sc.nextLong();
      if(x%11==0)System.out.println((x/11)*2);
      else if(x%11 <= 6)System.out.println((x/11)*2+1);
      else if(x%11 >= 7)System.out.println((x/11)*2+2);
    }
}


Measured memory_bytes: 21844
while True:
    d, e = map(int, input().split())
    if d == 0:
        break

    ans = abs(d - e)
    for x in range(1, d):
        y = d - x
        ans = min(ans, abs((x ** 2 + y ** 2) ** 0.5 - e))
    print("{:.4f}".format(ans))


Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,d,x,y,s,t,i,f,r;
    double a;
    scanf("%lld %lld",&n,&d);
    f = 0;
    for(i = 1;i <= n;i++){
        scanf("%lld %lld",&x,&y);
        if(x < 0){
            x = x * -1;
        }
        if(y < 0){
            y = y * -1;
        }
        s = x * x;
        t = y * y;
        r = s + t;
        a = sqrt((double)r);
        if(a <= d){
            f = f + 1;
        }
        //printf("%lld %0.2lf\n",i,a);
    }
    printf("%lld\n",f);
    return 0;
}


Measured memory_bytes: 3800
k = int(input())

if k%2 == 0 or k%5 == 0:
    print(-1)

else:
    ans = -1
    a = 7
    
    if k == 7 or k==1:
        print(1)
    
    else:
        for i in range(2,10**7):
            a = (10*a + 7)%k
            if a==0:
                ans =i
                break
        
        print(ans)

Measured memory_bytes: 9068
#include<iostream>
using namespace std;
typedef long long ll;
#define MAX_N 200000

int main(){
    ll N, K;
    cin >> N >> K;
    ll m, n, ans, zero, ans_add;
    ans = 0;
    zero = 0;
    for(ll b=1; b<=N; b++){
        m = (N+1)/b;
        n = (N+1)%b;
        ans_add = max(zero, m*(b-K)) + max(zero, n-K); 
        ans_add = max(zero, ans_add);
        ans += ans_add;
        //cout << "b = " << b << " : " << ans_add << endl;
    }
    if(K==0){
        ans = ans - N;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	vector<ll> X(N);
	ll ans = 0;
	rep(i, N)
	{
		cin >> X[i];
	}
	rep(i, N-1)
	{
		ll dis = X[i + 1] - X[i];
		ans += min(A * dis, B);
	}
	cout << ans;
}


Measured memory_bytes: 1024
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  int ans = MIN(b, d) - MAX(a, c);
  if (ans > 0)
  {
    printf("%d\n", ans);
  }
  else
  {
    printf("%d\n", 0);
  }
  return 0;
}

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

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

	
	if((b-a)==(c-b)){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}
	


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-11;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}


ll N, K;
ll dp[55][55][3000];
void solve(){
  cin >> N >> K;
  dp[0][0][0] = 1;
  rep(i, N)rep(j, N+1)rep(l, K+1){
    dp[i+1][j][l+j*2] += dp[i][j][l];
    dp[i+1][j][l+j*2] %= MOD;
    dp[i+1][j+1][l+(j+1)*2] += dp[i][j][l];
    dp[i+1][j+1][l+(j+1)*2] %= MOD;
    dp[i+1][j][l+j*2] += dp[i][j][l] * j % MOD * 2 % MOD;
    dp[i+1][j][l+j*2] %= MOD;
    if(j){
      dp[i+1][j-1][l+(j-1)*2] += dp[i][j][l] * j % MOD * j % MOD;
      dp[i+1][j-1][l+(j-1)*2] %= MOD;
    }
  }
  cout << dp[N][0][K] << endl;
}



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


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

int main(){
    int A,B,C,X,Y;
    int price=0,temp=0;
    cin>>A>>B>>C>>X>>Y;
    
    if(A+B>=C*2){
        if(X>Y){
            temp=Y*C*2;
            if(A<2*C)price=(X-Y)*A+temp;
            else price=(X-Y)*C*2+temp;
            }
        else{
            temp=X*C*2;
            if(B<2*C)price=(Y-X)*B+temp;
            else price=(Y-X)*C*2+temp;
            
        } 
    }else{
        price=A*X+B*Y;
    }
    cout<<price<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

bool f[1001];
int n;

int main(){
  f[1] = 1;
  FOR(i,2,1001){
    if(f[i])continue;
    for(int j = i*i;j <= 1000;j *= i)f[j] = 1;
  }
  cin >> n;
  for(int i = n;i >= 0;i--){
    if(f[i]){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static double dps(int deep, final int M, int prev, final int N, LinkedList<Integer> list, double[][] dist) {
		if (deep == M) {
			double ret = 0;
			
			if(M == 1){
				return 0.0;
			}

			for (int from : list) {
				for (int to : list) {
					if (from > to) {
						continue;
					}

					ret += dist[from][to];
				}
			}
			
			return ret;

		} else {
			double max = -Double.MAX_VALUE;
			for (int i = prev + 1; i < N - (M - deep - 1); i++) {
				list.addLast(i);
				max = Math.max(max, dps(deep + 1, M, i, N, list, dist));
				list.removeLast();
			}

			return max;
		}
	}

	public static void main(String[] args) {

		final Scanner sc = new Scanner(System.in);

		final int N = sc.nextInt();
		final int M = sc.nextInt();

		double[][] data = new double[N][3];

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				data[i][j] = sc.nextDouble();
			}
		}

		double[][] dist = new double[N][N];

		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				double sum = 0;

				for (int k = 0; k < 3; k++) {
					sum += (data[i][k] - data[j][k])
							* (data[i][k] - data[j][k]);
				}

				dist[i][j] = dist[j][i] = sum;
			}
		}

		System.out.println(dps(0, M, -1, N, new LinkedList<Integer>(), dist));

	}

}

Measured memory_bytes: 41004
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)   for(signed i=0; i<n; i++)
#define FOR(i, k, n)    for(signed i=k; i<n; i++)
#define yn(b)   cout << ((b)?"Yes":"No") << endl
#define YN(b)   cout << ((b)?"YES":"No") << endl
#define pr(r)   cout << r << endl
#define min(x,y)    (x<y)?x:y
#define max(x,y)    (x>y)?x:y
#define ll  long long
int main(void){
    ll n, a[5], i;
    cin >> n;
    rep(i, 5) cin >> a[i];
    sort(a, a+5);
    ll r = 5 + n/a[0];
    if(n%a[0]==0) r--;
    pr(r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
   int n, m;
   cin >> n >> m;
   priority_queue<int> pq;
   rep(i,n) {
       int v;
       cin >> v;
       pq.push(v);
   }
   for(int i = 0; i < m; i++) {
       int save = pq.top() / 2;
       pq.pop();
       pq.push(save);
   }
   ll sum = 0;
   while(!pq.empty()) {
       sum += pq.top();
       pq.pop();
   }
   cout << sum << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector> 
#include <climits> 
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	long n;
	cin >> n;
	vector<ll> data(n);
	for(long i = 0; i < n; i++){
		cin >> data[i];
	}
	ll border = pow(10,18);
	long long  ans = 1;
	for(long i = 0; i < n; i++) {
		if(data[i] == 0) {
			ans = 0;
			cout << ans << endl;
			return 0;
			// break;
		}
	}
	for(long i = 0; i < n; i++) {
		if(border / ans < data[i]) {
			// cout << ans << endl;
			ans = -1;
			// cout << "c" << endl;
			break;
		}
		ans *= data[i];
		// cout << "ans: " << ans << endl;

	}
	// cout << LLONG_MAX << endl;
	if(ans <= border) {
		cout << ans << endl;
	} else {
		cout << -1 << endl;
	}
	// cout << setprecision(20) << pow(10,18) << endl;

    return 0;
}


Measured memory_bytes: 4048
main = do
  [a,b]<- (map read.words)<$>getLine :: IO[Float]
  print $ floor $ loop a b 0

  where
   loop :: Float -> Float -> Float -> Float
   loop a b 10001 = -1
   loop a b n
     | floor (n * 0.08) == (floor a)
        && floor (n * 0.1) == (floor b)
        = n
     | otherwise
        = loop a b (n+1)


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int k;
  cin >> s >> k;
  int n = int(s.size());
  rep(i, n){
    int t = s[i] - 'a';
    t = 26 - t;
    if(k >= t && s[i] != 'a'){
      s[i] = 'a';
      k -= t;
    }
  }
  k %= 26;

  s[n-1] += k;
  if(s[n-1] > 'z') s[n-1] -= 26;

  cout << s << endl;
}


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

#define ll long long
#define watch(x) cout << (#x) << " = " << (x) << endl

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	/*---- Continue Coding ;----*/

	string s;
	cin >> s;
	int count =0;
	char ch = 'R';
	for (int i=0; i<3; i++){
		if(s[i] == 'R'){
			count++;
		}
	}
	if(count == 2){
		if(s[0] == 'R' && s[1] == 'R'){
			cout<<2<<"\n";
		}else if (s[1] == 'R' && s[2] == 'R'){
			cout<< 2 <<"\n";
		}else{
			cout<<1<<"\n";
		}
	}else{
		cout<<count<<"\n";
	}

	/*---- Break ;----*/

	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, p;
    cin >> n >> p;
    ll a[2] = { 1, 0 }, b[2] = { 0, 0 };
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        b[0] = b[1] = 0;
        if (t % 2) {
            b[0] = b[1] = a[0] + a[1];
        } else {
            b[0] = a[0] << 1;
            b[1] = a[1] << 1;
        }
        a[0] = b[0];
        a[1] = b[1];
    }
    cout << a[p];
    return 0;
}

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

int main(){
    long long n;
    cin >> n;
    long long a[n],b[n];
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    long long count=0;
    for(int i=n-1;i>=0;i--){
        a[i]+=count;
        if(a[i]%b[i]!=0) count+=b[i]-a[i]%b[i];
    }
    cout << count << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#define int long 
using namespace std;

signed main() {
	int N,Y;
	cin >> N >> Y;
	int S = Y - N * 1000;
	bool A = false;
	for(int i = 0;i <= N;i++) {
		bool B = false;
		for(int j = 0;j <= N;j++) {
			if(4000 * i + 9000 * j == S && i + j <= N) {
				A = true;
				cout << j << " " << i << " " << N - j - i << endl;
				B = true;
				break;
			}
		}
		if(B == true) {
			break;
		}
	}
	if(A == false) {
		cout << -1 << " " << -1 << " " << -1 << endl;
	}
}


Measured memory_bytes: 256