akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;

int main(){
  int a,b,c,x;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  
  int counter =0,money;
  for(int i =0;i<=a;i++){
    money = x - i * 500;
    if(money <0)break;
    for(int j =0 ; j <=b;j++){
      int tmp_money = money - j*100;
      if(tmp_money <0)break;
      if(tmp_money / 50 <= c && tmp_money % 50 == 0)counter++;
    }
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int,input().split()))


import numpy as np

A_N_list = np.array([A_list[i] - (i+1)  for i in range(len(A_list))])


AN_list = sorted(A_N_list)


if len(AN_list) % 2 == 0:
    b = AN_list[int(len(AN_list)/2)-1]
else:
    b = AN_list[int((len(AN_list)+1)/2)-1]

count = 0
for id,i in enumerate(A_list):
    count += abs(i-(b+id+1)) 

print(count)

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

int main()
{
    int n;
    int g[20] = {}, p[20] = {};

    cin >> n;

    for( int i = 0; i < n; i++ )
        cin >> g[i] >> p[i];

    int max = -1;    
    for( int i = 0; i < n; i++ )
    {
        if( max < p[i] )
            max = p[i];
    }

    int min = 1000;
    for( int i = 0; i < n; i++ )
    {
        if( p[i] == max )
        {
            if( min > g[i] )
                min = g[i];
        }
    }

    cout << min << " " << max << endl;

    return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define print(x) cout << x << endl
#define ps(x,y) fixed<<setprecision(y)<<x
#define pprint cout<<"Case #"<<tt<<": ";
const int mod = 1e9+7;
const int N = 2e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}

struct Compare {
    bool operator () (pii A, pii B) {
        return A.first > B.first;
    }
};
 struct tri{
   int x,y,z;
 };
 struct cmp{
bool operator ()(tri a,tri b){
    if(a.x==b.x)
        return a.y>b.y;
    return a.x<b.x;

}};
bool comp(pii a,pii b){
    if(a.first>b.first) return true;
    else if(a.first==b.first) return a.second<b.second;
    else return false;

}
int binarySearch(vector<int>nums, int lo, int hi, int target) {
        while (lo < hi) {
            int mid = (lo + hi)/2;
            if (nums[mid] <= target) {
                lo = mid + 1;
            } else {
                hi = mid;
            }
        }
        return lo;
    }
void solve() {

    int t = 1;
    //cin >> t;
   while(t--){
      int x,a,b,c,k;
      cin>>a>>b>>c;
      cin>>k;
      while(a>=b){
        b=b*2;
        k--;
      }
      while(b>=c){
        c=c*2;
        k--;
      }
      if(k>=0)
        cout<<"Yes";
      else
        cout<<"No";
    }
}

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

   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    solve();

    return 0;
}


Measured memory_bytes: 3648
Printf.printf "%d\n" @@
Scanf.scanf "%d %d\n" @@ fun n k ->
    let a = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun i -> i in
    Array.sort (-) a;
    let ans = ref 0 in
    for i = 0 to k-1 do
        ans := !ans + a.(i)
    done;
    !ans;;


Measured memory_bytes: 4132
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

	int n, cnt = 1;
	vector<int> v;

	cin >> n;
	v.resize(n);
	for (int i = 0;i < n;i++) cin >> v[i];

	for (int i = 0;i < v.size();i++){
		if (v[i] == cnt) {
			cnt++;
		}
	}

	if (cnt == 1) cout << "-1" << endl;
	else cout<< n-cnt+1 << endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,n,t,C;
int main(){
#ifdef LOCAL
	freopen("A.in","r",stdin);//freopen("A.out","w",stdout);
#endif
	scanf("%d",&n);
	printf("%d\n",(2000-n-1)/200+1);
	return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
#include <iostream>
#include<string>
#define ll long long int
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin>>n;
	n--;
	//for(n=1;n<100;n++)
	//{
	ll cnt=0;
	for(ll i=1;i<=n;i++)
	{
		cnt+=(n/i);
	}
	
	cout<<cnt<<"\n";
	
	
	
	
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3007;
const int MOD = 998244353;

int sum(int a, int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int sub(int a, int b) {
    return a - b < 0 ? a - b + MOD : a - b;
}
int mul(int a, int b) {
    return (1LL*a*b)%MOD;
}
int pw(int a, int b) {
	if (!b) return 1;
	int r = pw(a, b/2);
	r = mul(r, r);
	if (b%2) r = mul(r, a);
	return r;
}

vector< int >v;
int dp[309][309][309];
int k;

int solve(int ps, int used, int travelling) {
    if (used > k) return 0;
    if (ps==v.size()) return 1;
    if (dp[ps][used][travelling] != -1) return dp[ps][used][travelling];

    int here = v[ps];
    int ans = solve(ps+1, used, travelling); ///change nothing

    for (int j = 1; j <= travelling; j++) {
        ans = sum(ans, solve(ps+1, used, travelling-j));
    }

    for (int j = 1; j <= here && used+j <= k; j++) {
        ans = sum(ans, solve(ps+1, used+j, travelling+j));
    }
    return dp[ps][used][travelling] = ans;
}

//int upore(int ps, int used, int travelling) {
//    if (used > k) return 0;
//    int ans = upore(ps, used+1, travelling+1);
//    ans = sum(ans, solve(ps+1, used, travelling));
//    return ans;
//}
//
//int niche(int ps, int used, int travelling) {
//    if (travelling < 0) return 0;
//    int ans = niche(ps, used, travelling-1);
//    ans = sum(ans, solve(ps+1, used, travelling));
//    return ans;
//}

int main() {
    string s;
    cin >> s >> k;

    int n = s.size();
    int ones = 0;
    for (int i = n-1; i >= 0; i--) {
        if (s[i]=='1') ones++;
        else {
            v.push_back(ones);
            ones = 0;
        }
    }

    memset(dp, -1, sizeof dp);
    cout << solve(0, 0, 0) << endl;

    return 0;
}


Measured memory_bytes: 118888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x);
int main(){
    ll n, k;
    sc(n) sc(k)
    ll y, x = abs(n-k);
    if (n < x) cout << n << endl;
    else {
        y = n % k;
        y = min(y, k - y);
        cout << y << endl;
    }
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':

	input()
	A = list(map(int,input().split()))
	B = list(map(int,input().split()))
	C = list(map(int,input().split()))

	gokei = 0
	for i in range(1,len(A)):
		if A[i] - A[i-1] == 1:
			gokei += C[A[i-1]-1]

	gokei += sum(B)
	print(gokei)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    auto p = minmax_element(v.begin(), v.end());
    int mi = *p.first;
    int ma = *p.second;

    int d = ma - mi;
    if (ma - mi >= 2) {
        cout << "No" << endl;
        ret();
    }
    if (d == 1) {
        ll x = count(v.begin(), v.end(), mi);
        ll y = count(v.begin(), v.end(), ma);
        if (x < ma && 2 * (ma - x) <= y) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        ret();
    }

    if (ma == n - 1 || 2 * ma <= n) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}


Measured memory_bytes: 4048
#include<stdio.h>


int main(void)
{
    int i,a,b;

    scanf("%d",&i);

    if(i==1)
        printf("Hello World\n");
        
    else if(i==2){
        scanf("%d%d",&a,&b);
        printf("%d\n",a+b);
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		if(N<=111) System.out.println(111);

		else if(N<=222) System.out.println(222);

		else if(N<=333) System.out.println(333);

		else if(N<=444) System.out.println(444);

		else if(N<=555) System.out.println(555);

		else if(N<=666) System.out.println(666);

		else if(N<=777) System.out.println(777);

		else if(N<=888) System.out.println(888);

		else if(N<=999) System.out.println(999);


	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using pint = pair<int,int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

int n;
vector<vector<pint>> v;

bool judge(int bit) {
    for (int i = 0; i < n; i++){
        if(!(bit & (1<<i))) continue;

        for(pint xy : v[i]){
            int x=xy.first;
            int y=xy.second;

            if(y == 1 && !(bit & (1<<x))) return false;

            if(y == 0 && (bit & (1<<x))) return false;
        }
    }
    return true;
}

int main() {
    cin >> n;
    v.resize(n);
    for(int i =0; i<n; i++){
        int a; cin >>a;
        v[i].resize(a);
        for(int j=0; j<a; j++){
            cin>>v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }

    int res =0;
    for (int bit = 0; bit < (1<< n); bit++){
        if (judge(bit)){
            int count = 0;
            rep(i, n){
                if(bit & (1<<i)) ++count;
            }
            res = max(res, count);
        }
    }
    cout <<res <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<functional>
#include<map>

using namespace std;

int N;

int main() {
	cin >> N;
	map<string, int> cnt;
	vector<priority_queue<string, vector<string>, greater<string> > > ans(N + 1);
	int m = 0;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		bool flag = false;
		
		if (cnt.find(S) == cnt.end()) {
			cnt.insert(make_pair(S, 0));
			ans[0].push(S);
		}
		else {
			cnt[S]++;
			m = max(m, cnt[S]);
			ans[cnt[S]].push(S);
		}
	}
	while (!ans[m].empty()) {
		cout << ans[m].top() << endl;
		ans[m].pop();
	}

}

Measured memory_bytes: 33008
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static int[] nm;
    static void Solve()
    {
        nm = Input.ar;
        var adj = Enumerable.Repeat(0, nm[0]).Select(v => new List<int>()).ToArray();
        for(var i=0;i<nm[1];i++)
        {
            var inp = Input.ar;
            adj[inp[0] - 1].Add(inp[1] - 1);
            adj[inp[1] - 1].Add(inp[0] - 1);
        }
        WriteLine(dfs(adj, 0, 0) ? "POSSIBLE" : "IMPOSSIBLE");
    }
    static bool dfs(List<int>[] adj,int index,int depth)
    {
        if (depth == 2)
            return index == nm[0] - 1;
        var r = false;
        foreach (var ad in adj[index])
            if (!r) r = dfs(adj, ad, depth + 1);
            else break;
        return r;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Measured memory_bytes: 36632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

int a, b;

signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> a >> b;

	cout << a + (b - a) * 2;


	return 0;

}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int X,Y,Z;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>Y>>Z;
	
	cout<<(X-Z)/(Y+Z)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16

ll N,K,mod;
ll dp[2][101][(1<<10)];

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

  cin>>N>>K>>mod;
  ll T=(1<<K);
  ll crt=0,nxt=1;
  dp[crt][0][0]=1;
  rep(i,2*N){
    rep(j,N+1)rep(S,T)dp[nxt][j][S]=0;
    rep(j,N+1){
      rep(S,T){
        if(dp[crt][j][S]==0)continue;
        ll k=i-j;
        if(j-k<0||bcnt(S)<j-k)continue;

        vector<ll> us,ls;
        if(j==0)us.push_back(INF);
        if(k==0)ls.push_back(INF);
        repl(v,max(0LL,i-K),i){
          if((S>>(i-v-1))&1LL) us.push_back(v);
          else ls.push_back(v);
        }

        if(us.size()>0&&i-us.back()<=K&&j<N){
          (dp[nxt][j+1][((S<<1LL)&(T-1))|1LL]+=dp[crt][j][S])%=mod;
        }
        if(ls.size()>0&&i-ls.back()<=K&&j>k&&i-us[us.size()-(j-k)]<=K&&k<N){
          (dp[nxt][j][(S<<1LL)&(T-1)]+=dp[crt][j][S])%=mod;
        }
      }
    }
    swap(crt,nxt);
  }

  ll res=0;
  rep(S,T)(res+=dp[crt][N][S])%=mod;
  cout<<res<<endl;

  return 0;
}



Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n, k;
  cin >> n >> k;

  cout << ((n + 1) / 2 >= k ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define int long long
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n,m,r;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
ll a[105],b[105];
string s;
signed main()
{

    //ios_base::sync_with_stdio(0),cin.tie(0);
    while(cin>>s)
    {
        ll ans=0;
        string tmp="";
        rep(i,s.size())
        {
            string t;
            t.pb(s[i]);
            if(t!=tmp)
            {
                ans++;
                tmp=t;
            }
            else
            {
                if(i==s.size()-1) break;
                t.pb(s[i+1]);i++;
                ans++;
                tmp=t;
            }
        }
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define l long long
int main()
{
  int n;
  l k;
  int q;
  cin>>n>>k>>q;
  int a[q];
  for(int i=0;i<q;i++)
  {
    cin>>a[i];
  }
  l x[n];
  /*for(int i=0;i<n;i++)
  {
    x[i]=k;
  }*/
  int y[n]={0};
  for(int i=0;i<q;i++)
  {
    y[a[i]-1]++;
  }
  for(int i=0;i<n;i++)
  {
    x[i]=k-q+y[i];
  }
  for(int i=0;i<n;i++)
  {
    if(x[i]>0)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll bik[1010][1010];

ll modinv(ll a) {
    ll m=Mod;
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(){
  ll i,j,k;
  ll n,x;
  bik[0][1]=1;
  bik[1][1]=1;
  for(i=2;i<1010;i++) bik[i][1]=(bik[i-1][1]*i)%Mod;
  for(i=0;i<1010;i++){
    for(j=2;j<1010;j++){
      bik[i][j]=(bik[i][j-1]*bik[i][1])%Mod;
    }
  }
  cin>>n;
  ll a,b,c,d;
  cin>>a>>b>>c>>d;

  VVI dp(n+2,VI(n+2,0));

  dp[b+1][0]=1;
  for(i=b;i>=a;i--){
    for(j=0;j<=n;j++){
      dp[i][j]+=dp[i+1][j];
      for(k=c;k<=d;k++){
        if(j-k*i>=0) {
          ll s=n-j+k*i;
           dp[i][j]+=((dp[i+1][j-k*i]* bik[s][1])%Mod) * modinv((((bik[s-i*k][1] * bik[i][k])%Mod)*bik[k][1])%Mod);
           dp[i][j]%=Mod;
        }
      }
    }
  }
  cout<<dp[a][n]<<endl;

  return 0;
}

Measured memory_bytes: 16128
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K=1,A,B,C;
ll T,a,b;
double v[55],D[55],Q,l,r;
ll ans;
//bool D[100005];
ll S[100005]={};
string str1,str2;
map<string,int> m;

int main(){
	cin>>str1>>str2;
	for(int i=0;i<str2.size();++i){
		cout<<str1[i]<<str2[i];
	}
	if(str1.size()>str2.size()){
		cout<<str1[str1.size()-1]<<endl;
	}else{
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int n;
    char retu[1001],tada[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ",hikaku[27]="DEFGHIJKLMNOPQRSTUVWXYZABC";
    scanf("%s",retu);
    n=strlen(retu);
    for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            if(retu[i]==hikaku[j])cout<<tada[j];
        }
    }
    cout<<"\n";
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

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

const ll mod = 1000000007;

ll x;

struct BSearch {
	ll solve(ll left, ll right, function<ll(ll)> pred) {
		while (right - left > 1) {
			ll middle = left + right;
			middle /= 2;
			if (pred(middle)) {
				right = middle;
			}
			else {
				left = middle;
			}
		}
		return right;
	}
};

int main(void)
{
	cin >> x;
	for (int i = 0; i <= 1010; i++) {
		ll lower = i * 100;
		ll upper = i * 105;
		if (x >= lower && x <= upper)
		{
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <numeric>
#define ll long long
#define MODD 998244353
#define MAXA 1000000
using namespace std;

int dists[222];
int BFS[2][222];

string S[222];

int Solve(int u, int N) {
    
    BFS[0][0]=u;
    int sz=1;
    for(int i=0;i<N;i++)
        dists[i]=-1;
    dists[u]=0;
    int ans=0;
    for(int iters=0;sz>0;iters++) {
        int nsz=0;
        for(int i=0;i<sz;i++) {
            int v = BFS[iters&1][i];
            for(int w=0;w<N;w++) {
                if (S[v][w]=='1' && dists[w]==-1) {
                    BFS[(iters+1)&1][nsz++]=w;
                    dists[w]=iters+1;
                }
            }
        }
        sz=nsz;
        ans++;
    }
    
    for(int i=0;i<N;i++)
        for(int j=i+1;j<N;j++) {
            if (dists[i]%2==dists[j]%2 && S[i][j]=='1')
                return -1;
        }
    
    return ans;
}



int main() {
    int N;
    cin>>N;
    for(int i=0;i<N;i++) {
        cin>>S[i];
    }
    
    int ans=-1;
    for(int u=0;u<N;u++) {
        ans = max(ans, Solve(u,N));
    }
    
    cout << ans << endl;
    
    
}


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

int main(){
  int n;cin>>n;
  int ans=0;ll temp;
  for(int i=0;i<n;i++){
    cin>>temp;
    if(temp%2==0){
      ans+=__builtin_ffs(temp)-1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3,"inline,Ofast")
#include<cstdio>
#include<bitset>
#define P pair<int,int>
const int N=2e3+5,p=1e9+7;
inline int read(){
    int x=0;char ch=getchar();
    for(;ch<48||ch>57;ch=getchar());
    for(;ch>47&&ch<58;ch=getchar())
    x=(x<<1)+(x<<3)+(ch^48);return x;
}
using namespace std;
bitset<4000005>vis(1);
signed main()
{
    int n=read(),sum=0;
    for(int i=1,x;i<=n;++i)
        sum+=x=read(),vis|=vis<<x;
    for(int i=sum/2;~i;--i)
        if(vis[i])
            return printf("%d\n",sum-i),0;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main()
{
    int r, D;
    int x[11];
    cin >> r >> D >> x[0];

    for (int i = 0; i < 10; i++)
    {
        x[i + 1] = r * x[i] - D;
        cout << x[i + 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<cstring>
using namespace std;
typedef long long int ll;

int main()
{
	string s;cin>>s;
	while(s.length()>0)
	{
		if(s.length()>6&&s.substr(s.length()-7,7)=="dreamer")s=s.substr(0,s.length()-7);
		else if(s.length()>5&&s.substr(s.length()-6,6)=="eraser")s=s.substr(0,s.length()-6);
		else if(s.length()>4&&s.substr(s.length()-5,5)=="erase")s=s.substr(0,s.length()-5);
		else if(s.length()>4&&s.substr(s.length()-5,5)=="dream")s=s.substr(0,s.length()-5);
		else
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 512
/* 
 * Author: aps
 * Time: 19-06-2019 18:05:00
**/
#include<bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll inf = 1e18;
const ll mod = 1e9+7;

inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int n,m; cin >> n >> m;
    
    vi dp(n+1,0); 
    for(int i=0;i<m;i++){
        int x; cin >> x;
        dp[x] = -1;
    }

    dp[0] = 1;
    if(dp[1] != -1) dp[1] = 1;
    for(int i=2;i<=n;i++){
        if(dp[i] != -1){
            if(dp[i-1] != -1) dp[i] = add(dp[i],dp[i-1]);
            if(dp[i-2] != -1) dp[i] = add(dp[i],dp[i-2]);
        }
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	string last="";
	int n=s.size(),ans=0;
	for(int i=0;i<n;) {
		bool ok=0;
		for(int j=1;j<=n-i;j++) {
			string tmp=s.substr(i,j);
			if(tmp!=last) {
				ans++;
				last=tmp;
				i+=j;
				ok=1;
				break;
			}
		}
		if(!ok) break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 720
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }

}

use std::collections::BinaryHeap;


fn main() {
    let n: usize = read();
    let m: usize = read();
    let a: Vec<i64> = read_n(n);
    let mut bh: BinaryHeap<i64> = BinaryHeap::new();

    for i in a {
        bh.push(i)
    }

    for _ in 0..m {
        let item = bh.pop().unwrap();
        let ni = item / 2;
        bh.push(ni)
    }

    let mut ans = 0;

    for i in bh {
        ans += i;
    }

    println!("{}", ans);
}


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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
		string s;
		cin >> s;
		vector<int> a;
		vector<int> z;
		for(int i=0;i<s.length();i++){
				if(s[i] == 'A') a.push_back(i);
				else if(s[i] == 'Z') z.push_back(i);
		}
		cout << z[z.size()-1] - a[0] + 1 << endl;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n,a,b,c;cin>>n>>a>>b>>c;
  vector<string> s(n);
  rep(i,n){
    cin>>s[i];
  }
  vector<char> d(n);
  rep(i,n){
    if(s[i]=="AB"){
      if(a==0&&b==0){
        cout<<"No";return 0;
      }
      if(a==1&&b==1){
        if(i<n-1){
          if(s[i+1]=="AC"){
            a++;b--;d[i]='A';
          }else{
            b++;a--;d[i]='B';
          }
        }else{
          b++;a--;d[i]='B';
        }
      }else{
        if(a>=b){
          b++;a--;d[i]='B';
        }else{
          a++;b--;d[i]='A';
        }
      }
    }else if(s[i]=="AC"){
      if(a==0&&c==0){
        cout<<"No";return 0;
      }
      if(a==1&&c==1){
        if(i<n-1){
          if(s[i+1]=="AB"){
            a++;c--;d[i]='A';
          }else{
            c++;a--;d[i]='C';
          }
        }else{
          c++;a--;d[i]='C';
        }
      }else{
        if(a>=c){
          c++;a--;d[i]='C';
        }else{
          a++;c--;d[i]='A';
        }
      }
    }else{
      if(b==0&&c==0){
        cout<<"No";return 0;
      }
      if(b==1&&c==1){
        if(i<n-1){
          if(s[i+1]=="AB"){
            b++;c--;d[i]='B';
          }else{
            c++;b--;d[i]='C';
          }
        }else{
          c++;b--;d[i]='C';
        }
      }else{
        if(b>=c){
          c++;b--;d[i]='C';
        }else{
          b++;c--;d[i]='B';
        }
      }
    }
  }
  cout<<"Yes"<<endl;
  rep(i,n)cout<<d[i]<<endl;
}

Measured memory_bytes: 6428
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""

N,M=map(int,input().split())
A=input().split()
A=[int(i) for i in A]
A.sort(reverse=True)

ans="Yes"
if A[M-1] < sum(A)/4/M:
    ans="No"

print(ans)

Measured memory_bytes: 3060
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nmq = input.front.split.to!( long[] );
	auto lrs = new long[ 2 ][ nmq[ 1 ] ];
	foreach( ref lr; lrs )
	{
		input.popFront;
		lr = input.front.split.to!( long[] );
	}
	auto pqs = new long[ 2 ][ nmq[ 2 ] ];
	foreach( ref pq; pqs )
	{
		input.popFront;
		pq = input.front.split.to!( long[] );
	}
	return tuple( nmq[ 0 ], lrs, pqs );
}

auto solve( in long n, in long[ 2 ][] lrs, in long[ 2 ][] pqs )
{
	// LとRを軸にした表に列車をプロット（0行目と0列目は全て0にすると後が楽）
	auto sss = new long[][]( n + 1, n + 1 );
	foreach( lr; lrs )
	{
		sss[ lr[ 0 ] ][ lr[ 1 ] ]++;
	}
	
	// プロット表を二次元累積和表に変換
	foreach( l; 1 .. sss.length )
	{
		foreach( r; 1 .. sss[ l ].length )
		{
			sss[ l ][ r ] += sss[ l ][ r - 1 ] + sss[ l - 1 ][ r ] - sss[ l - 1 ][ r - 1 ];		// 二重に加算しないように重複部分を引く
		}
	}
	
	// 表を使って条件に一致する列車の数を計算
	auto cs = new string[ pqs.length ];
	foreach( ref c, pq; lockstep( cs, pqs ) )
	{
		auto p = pq[ 0 ] - 1;
		auto q = pq[ 1 ];
		c = ( sss[ q ][ q ] - sss[ p ][ q ] - sss[ q ][ p ] + sss[ p ][ p ] ).to!( string );		// 二重に減算しないように重複部分を足す
	}
	
	return cs.join( "\n" );
}


Measured memory_bytes: 13436
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

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

int getInt() {
    int s;
    scanf("%d", &s);
    return s;
}

typedef long long ll;
const ll mod = 1000000007;

ll x[100000];
ll f[100000 + 10];
ll rf[100000 + 10];

ll mpow(ll b, ll e) {
    ll ans = 1;
    while(e){
        if(e % 2 == 1) ans = (ans * b) % mod;
        b = (b * b) % mod;
        e = e / 2;
    }
    return ans;
}

int main(){
    const int n = getInt();
    REP(i,n) x[i] = getInt();

    f[0] = 1;
    REP(i,n) f[i + 1] = f[i] * (i + 1) % mod;
    REP(i,n+1) rf[i] = mpow(f[i], mod - 2);

    // REP(i,n+1) printf("%lld %lld\n", f[i], rf[i]);
    
    ll ans = 0;

    /*
    REP(i,n-1) {
        for(int j = i + 1; j < n; j++) {
            const int k = j - i + 1;
            const ll d = x[j] - x[j - 1];
            ans = (ans + d * mpow(k - 1, mod - 2) % mod) % mod;
        }
    }
    */

    ll acc = 0;
    for(int i = 1; i < n; i++) {
        acc = (acc + mpow(i, mod - 2)) % mod;
        ans = (ans + (x[i] - x[i - 1]) * acc % mod) % mod;
    }

    ans = ans * f[n - 1] % mod;

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,int> pli;
typedef pair<long long, long long> pll;

const int MOD = 1e9 + 7;

ll fact(int k) {
  ll ans = 1;
  for(int i=1; i<=k; i++) {
    ans = (ans * i) % MOD;
  }
  return ans;
}

int main (int argc, char*argv[]) {
  int n, m;
  cin >> n >> m;
  if(abs(n - m) > 1) {
    cout << 0 << endl;
    return 0;
  }

  if(n > m || m > n) {
    ll sum = fact(n);
    sum = (sum * fact(m) ) % MOD;
    cout << sum << endl;
    return 0;
  } else {
    ll sum = fact(n);
    sum = (sum * fact(m) * 2 ) % MOD;
    cout << sum << endl;
    return 0;
  }
}


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

using namespace std;

#define MAX 100

#define WHITE 0
#define GRAY 1
#define BLACK 2

int T;
int N;

int M[MAX][MAX];
int C[MAX],D[MAX];

void bfs(int s)
{
    queue<int> *q = new queue<int>;

    q->push(s);
    D[s] = 0;
    C[s] = GRAY;

    while(!q->empty())
    {
        int u = q->front();
        q->pop();

        for (int v = 0; v < N; v++)
        {
            if (M[u][v] && D[v] == -1)
            {
                C[u] = GRAY;
                D[v] = D[u] + 1;
                q->push(v);
            }
        }

        C[u] = BLACK;
    }
}

int main ()
{
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        C[i] = WHITE;
        D[i] = -1;

        for (int j = 0; j < N; j++)
        {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        int u, k;
        cin >> u >> k;
        u--;

        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

/*
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (j > 0)
                cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
*/
    bfs(0);

    for (int i = 0; i < N; i++)
    {
        cout << i+1 << " " << D[i] << endl;
    }

    return 0;
}





Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

typedef long long ll;

const int MAX = 1000000;
  
struct segtree {
  int N, dat[2*MAX];
  segtree() {}
  segtree(int n) {
	N = 1;
	while(N < n) N *= 2;
	for(int i = 0; i < 2*N-1; i++)
	  dat[i] = 0;
  }
  // update k th element
  void update(int k, int a) {
	k += N-1; // leaf
	dat[k] = a; 
	while(k > 0) {
	  k = (k - 1) / 2;
	  dat[k] = dat[k*2+1] + dat[k*2+2];
	}
  }
  // min [a, b)
  int query(int a, int b) {
	return query(a, b, 0, 0, N);
  }
  
  int query(int a, int b, int k, int l, int r) {
	if(r <= a or b <= l) return 0;
	if(a <= l and r <= b) return dat[k];
	int m = (l + r) / 2;
	return query(a, b, k*2+1, l, m) + query(a, b, k*2+2, m, r);
  }
};

segtree s(200001);

int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> as(n);
  for(int i = 0; i < n; i++)
  {
	cin >> as[i];
	as[i] -= k;
  }

  for(int i = 1; i < n; i++)
  {
	as[i] += as[i - 1];
  }

  vector<pair<ll, ll>> vs;
  for(int i = 0; i < n; i++)
  {
	vs.push_back(make_pair(as[i], i));
  }
  sort(vs.begin(), vs.end());

  ll sum = 0;
  
  for(auto v : vs)
  {
	ll height, index;
	tie(height, index) = v;
	
	s.update(index, 1);
	sum += s.query(0, index);
	if(height >= 0) sum++;
  }
  cout << sum << endl;  
}


Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

const int INF = 1001001001;

int main() {
  double l;
  cin >> l;

  double ans = pow(l/(double)3.0, 3);
  // cout << ans << endl;
  printf("%lf20\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int temp=0,temp1=0;
int main()
 {  string a;cin>>a;
    temp=a[0]-'0'-1;
    temp+=a.size()*9-9;
    for(int i=0;i<a.size();i++)
    temp1+=a[i]-'0';
    int final=max(temp1,temp);
    printf("%d\n",final);
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	long long n, w;
	cin >> n >> w;
	vector<long long> wt(n), val(n);
	vector<vector<long long>> dp(n + 1, vector<long long> (w + 1, 0));

	for (long long i = 0; i < n; i++)
		cin >> wt[i] >> val[i];
	for (long long i = 0; i <= n; i++)
		for (long long j = 0; j <= w; j++) {
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else if (wt[i - 1] <= j)
				dp[i][j] = max(val[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	cout << dp[n][w] << endl;
}

Measured memory_bytes: 83020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);


    int r;
    cin >> r;

    cout << fixed << setprecision(10) << 2 * PI * r << endl;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX =510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2; i<MAX; i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll COM(int n, int k){
  if(n<k)
    return 0;
  if(n<0 || k<0)
    return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
//重複組み合わせ系な気がする
//5 3 xbx xbrbx xbrbrbx
//2個と3個のくみあわせ
//xbxについて。bは3 rは02/11/20  2-0=2 2H2=3C2
//xbrbxについて。bは12/21 rは011/020/010 2-1=1,3H1
//xbrbrbxについてbは111 rは0110 2-2=0 4C0

//7 4
//xbx b:4 1箇所に3個　1H3=3C3/ r:03,12,21,30 2箇所に3個 2H3=4 4C3=3
//xbxbx b:2箇所に2個を自由 2H2=3C2/ r:3箇所に2個自由  3H2=4C2 200 110 101 020 011 002
int main(){
  COMinit();
  ll N,K,MOD=1e9+7; cin>>N>>K;
  for(int i=1; i<=K; i++){
    ll B=K,R=N-K, ans=0;
    B-=i;
    R-=i-1;
    (ans=COM(i+B-1,B))%=MOD;
    (ans*=COM(2+(i-1)+R-1,R))%=MOD;
    cout<<ans<<endl;
  }
}


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

long long calc(string S){
  long long sum=0;
//cout << "S=" << S << endl;
  sum += stoll(S);
  
  for (int i=1; i<S.size(); i++){
    string Sl = S.substr(0,i);
    string Sr = S.substr(i);
//cout << "Sl=" << Sl << endl;
//cout << "Sr=" << Sr << endl;
    
    sum += stoll(Sl) * pow(2,floor(log10(stoll(Sr))));
    sum += calc(Sr);
//cout << "floor(log10(atoi(Sr.c_str()))=" << floor(log10(atoi(Sr.c_str()))) << endl;
  }
//cout << "S=" << S << "; sum=" << sum << endl;
  return sum;

  /*
  if(S.size() == 2){
    sum += calc(S.substr(0,1));
    sum += calc(S.substr(1,1));
  }else if(S.size() > 2){
    sum += calc(S.substr(0,1));
    sum += calc(S.substr(1));
    sum += calc(S.substr(1,1));
    sum += calc(S.substr(0,S.size()-1));   
  }
  return sum;
  */
}

int main(){
  string S;
  cin >> S;
//cout << S.size();
  long long sum;
  sum = calc(S);
  
  cout << sum;
}

Measured memory_bytes: 4016
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100];

int main(int argc, char* argv[])
{
    scanf("%s", str);

    long len=strlen(str);
    long curr=0;
    while(curr<len) {
        if(str[curr]=='0' || str[curr]=='1') {
            curr++;
        }
        else {
            if(curr>0) {
                curr--;
                long k;
                for(k=curr; k<len-2; k++) {
                    str[k]=str[k+2];
                }
                len-=2;
            }
            else {
                long k;
                for(k=curr; k<len-1; k++) {
                    str[k]=str[k+1];
                }
                len--;
            }
        }
    }
    str[len]='\0';
    printf("%s\n", str);

    return 0;
}


Measured memory_bytes: 128
K = int(input())

def gcd(p, q):
    while q:
        p, q = q, p % q
    return p

S = 0


#すべて違う
for a in range(1,K+1):
    for b in range(a+1,K+1):
        for c in range(b+1,K+1):
            S += gcd(a,gcd(b,c)) * 6


#3つとも一緒
S += (1+K)*K/2


#2つ一緒
for i in range(1,K+1):
    for j in range(i+1,K+1):
        S += gcd(i,j)*6

print(int(S))


Measured memory_bytes: 9200
#include<iostream>
#include<algorithm>
using namespace std;
int jg(int a,int b,int c,int x) {
    int ans = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                int d = 500 *i + 100 * j + 50 * k;
                if (x == d)ans++;
            }
        }
    }
    return ans;
}
int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    cout << jg(a, b, c, x) << endl;
   

}

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

int main(){
int a,b;
cin >>a >>b;
    if(a>=b){
        for(int i=0; i<a; i++){
            cout <<b;
        }
    }
    else{
        for(int i=0; i<b; i++){
            cout <<a;
        }
    }
return 0;
}

Measured memory_bytes: 256