akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int x[] = new int[N];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
		}
		
		long dp[][][] = new long[N + 1][N + 1][50 * 50 + 1];
		dp[0][0][0] = 1;
		
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				for(int k = 0; k <= 50 * 50; k++) {
					if(dp[i][j][k] != 0) {
						dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
						dp[i + 1][j][k] += dp[i][j][k];
					}
				}
			}
		}
		
		long ans = 0;
		for(int i = 1; i <= N; i++) {
			ans += dp[N][i][i * A];
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 84300
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
using namespace std;
int read(){
	char ch=getchar();int x=0,op=1;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10);putchar(a%10+'0');
}
#define N 100005
int n,m;ll ans[N];
int main(){
	n=read(),m=read();
	rep (i,1,n){
		int l=read()-1,r=read(),last,j;
		for (j=1;j<=l;j=last+1){
			last=min(l/(l/j),r/(r/j));//cerr<<last<<' ';
			if (r/j-l/j>0) ans[j]++,ans[last+1]--;
		}
		if (j<=r) ans[j]++,ans[r+1]--;
	}
	rep (i,1,m) ans[i]+=ans[i-1],write(ans[i]),puts("");
	return 0;
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int ans = (h2-h1)*60 + (m2-m1) - k;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3592
N,x = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
i = 0
tmp = 0
while True:
    if i == len(A):
        if  x - tmp == 0:
            print(i)
            exit()
        else:
            print(i - 1)
            exit()
    else:
        tmp += A[i]
        if tmp > x:
            print(i)
            exit()
        else:
            i += 1


Measured memory_bytes: 3060
#include <cstdio>
using namespace std;

int main(){
	const int MAX_N = 1000;
	int N, M;
	int A[MAX_N], B;
	int point[MAX_N];
	int max_p, res;
	
	for(int i = 0; i < MAX_N; i++) point[i] = 0;
	
	scanf("%d%d", &N, &M);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	
	for(int i = 0; i < M; i++){
		scanf("%d", &B);
		for(int j = 0; j < N; j++){
			if(B >= A[j]){
				point[j]++;
				break;
			}
		}
	}
	
	res = 0; max_p = point[0];
	for(int i = 1; i < N; i++){
		if(max_p < point[i]){
			res = i;
			max_p = point[i];
		}
	}
	
	printf("%d\n", res + 1);
	
	return 0;
}

Measured memory_bytes: 1032
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in= new Scanner(System.in);
		while(in.hasNext())
		{
			int y=in.nextInt(),m=in.nextInt(),d=in.nextInt();
			if(y<1868)
				System.out.println("pre-meiji");
			else if(y>=1868&&y<=1912)
			{
				if(y==1868)
				{
					if(m>=9)
					{
						if(m==9)
						{
							if(d>=8)
								System.out.println("meiji "+(y%1867)+" "+m+" "+d);
							else
								System.out.println("pre-meiji");
						}
						else
							System.out.println("meiji "+(y%1867)+" "+m+" "+d);
					}
					else System.out.println("pre-meiji");
				}
				else if(y==1912)
				{
					if(m<=7)
					{
						if(m==7)
						{
							if(d<=29)
								System.out.println("meiji "+(y%1867)+" "+m+" "+d);
							else
								System.out.println("taisho "+(y%1911)+" "+m+" "+d);
						}
						else System.out.println("meiji "+(y%1867)+" "+m+" "+d);
					}
					else System.out.println("taisho "+(y%1911)+" "+m+" "+d);
				}
				else
					System.out.println("meiji "+(y%1867)+" "+m+" "+d);
			}
			else if(y>1912&&y<=1926)
			{
				if(y>1912&&y<1926)
					System.out.println("taisho "+(y%1911)+" "+m+" "+d);
				else if(y==1926)
				{
					if(m<=12)
					{
						if(m==12)
						{
							if(d<=24)
								System.out.println("taisho "+(y%1911)+" "+m+" "+d);
							else
								System.out.println("showa "+(y%1925)+" "+m+" "+d);
						}
						else System.out.println("taisho "+(y%1911)+" "+m+" "+d);
					}
					else System.out.println("showa "+(y%1925)+" "+m+" "+d);
				}
			}
			else if(y>1926&&y<=1989)
			{
				if(y>1926&&y<1989)
					System.out.println("showa "+(y%1925)+" "+m+" "+d);
				else if(y==1989)
				{
					if(m==1)
					{
						if(d<=7)
							System.out.println("showa "+(y%1925)+" "+m+" "+d);
						else
							System.out.println("heisei "+(y%1988)+" "+m+" "+d);
					}
					else System.out.println("heisei "+(y%1988)+" "+m+" "+d);
				}
			}
			else
				System.out.println("heisei "+(y%1988)+" "+m+" "+d);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>

using namespace std;

int main()
{
  unsigned N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  unsigned happiness = 0;
  
  for (int n=0; n<N; ++n) {
    if ((n>0 && S[n]=='L' && S[n-1]=='L') ||
	(n<N-1 && S[n]=='R' && S[n+1]=='R'))
      ++happiness;
  }

  cout << min(N-1, happiness+2*K) << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin>>a;
    int l;
    cin>>l;
    int sum=0;
    int ans =0;
    for(int i=0;i<a;i++)
    {
        int n;
        cin>>n;
        int d = sum+n;
        sum=d;
        //cout<<d<<endl;
        if(d<=l)
        {
            ans++;
        }
    }
    cout<<++ans<<endl;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    auto S = sread();
    long w = lread();
    long i = 0;
    while (i < S.length)
    {
        write(S[i]);
        i += w;
    }
    writeln();
}


Measured memory_bytes: 256
my $input = <STDIN>;
my ($n, $h, $w) = split(" ", $input);
my $c = 0;
while (my $line = <STDIN>) {
    my ($a, $b) = split(" ", $line);
    if ($a>=$h && $b>=$w) { $c++; }
}
print $c."\n";


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int N;
int A[10];
int main(){
    scanf("%d", &N);
    int all = 1, bad = 1;
    for(int i = 0; i < N; ++i){
        scanf("%d", A + i);
        all *= 3;
        if(A[i] % 2 == 0) bad *= 2;
}
printf("%d\n", all - bad); return 0;
}


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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list
def summarize_list(l):
  sl=sorted(l)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res

def main():
  n=I()
  l=LI()

  l=summarize_list(l)

  ans=0
  for x in l:
    if x[0]<=x[1]:
      ans+=x[1]-x[0]
    else:
      ans+=x[1]

  return ans

# main()
print(main())


Measured memory_bytes: 20812
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	string A, B, C;
	cin>>A>>B>>C;
	if(A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

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

using namespace std;

int main()
{
    int Test;
    cin >> Test;
    map<string, int> mp;
    while(Test--)
    {
        string a;
        cin >> a;
        mp[a]++;
    }
    cout << "AC" << " x " << mp["AC"] << '\n';
    cout << "WA" << " x " << mp["WA"] << '\n';
    cout << "TLE" << " x " << mp["TLE"] << '\n';
    cout << "RE" << " x " << mp["RE"] << '\n';
}


Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(void){
  int h,m,s;
  cin >> s;
  h = s / 3600;
  s %= 3600;
  m = s / 60;
  s %= 60;
  cout << h << ':' << m << ':' << s << endl;
  return 0;
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
A = list(map(int, input().split()))

buka = [0] * N

for i in range(N - 1):
    buka[A[i]-1] += 1

print('\n'.join(map(str, buka)))


Measured memory_bytes: 33052
#include<iostream>

using namespace std;
int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int ans=0;
    int k;
    k = n/x;
    for(int i=0;i<k;i++){
        ans+=t;
    }
    k=n%x;
    if(k==0)
        cout << ans;
    else
        cout << ans+t;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll sum1(ll x)
{
    ll sum = 0;
    while (x != 0)
    {
        ll r = x % 10;
        x = x / 10;
        sum = sum + r;
    }
    return (sum);
}

int main()
{
//#ifndef ONLINE_JUDGE
  //  freopen("q1.txt", "r", stdin);
   // freopen("pelu13.txt", "w", stdout);
//#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll a1 = n / 1000;
    ll a2 = n % 1000;
    if (a2 == 0)
        cout << 0 << endl;
    else
    {
        a1 = a1 + 1;
        cout << (a1 * (1000) - n) << endl;
    }

}







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


void solve(){
    vector<int> digits;
    int n, k;
    cin >> n >> k;
    for(int i = 0, q; i < k; i++){
        cin >> q;
        digits.push_back(q);
    }
    for(int i = n;1;i++){
        bool good = true;
        for(int p : digits){
            if(!good) break;
            int t = i;
            while(t > 0){
                if(t%10 == p){
                    good = false;
                    break;
                }
                t/=10;
            }
        }
        if(good){
            cout << i << "\n";
            return;
        }
    }
}

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

    bool multitest = false;
//    multitest = true;
    if(multitest){
        int t; cin >> t;
        while(t--)
            solve();
    }
    else
        solve();
}






Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void printVec(vector<int> &v){
    vector<int>::iterator ite = v.begin();
    int i = 0;
    while(ite != v.end()){
        if (i++ != 0){
            cout << " ";
        }
        cout << *ite;
        ite++;
    }
    cout << endl;
}

void insSort(int n, vector<int> &vec){
    int i, j, x;
    for(i = 1; i < n; i++){
        printVec(vec);
        x = vec[i];
        j = i - 1;
        while(j >= 0 && vec[j] > x){
            vec[j+1] = vec[j];
            vec[j--] = x;
        }
    }
    printVec(vec);
}

int main(){
    int x, m, i;
    i = 0;
    m = 0;
    vector<int> v, rv;
    while(cin >> x){
        if(i++ == 0){
            m = x;
            continue;
        }
        v.push_back(x);
        if(i-1 == m){
            break;
        }
    }
    insSort(m, v);
}

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

using namespace std;

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int64_t res = 1LL << 60;
  for (int bit = 0; bit < (1 << N); bit++) {
    int64_t cost = 0;
    int k = 1, ma = A[0];
    for (int i = 1; i < N; i++) {
      int diff = 0;
      if ((bit >> i) & 1) {
        diff = max(0, ma - A[i] + 1);
        cost += diff;
      }
      if (chmax(ma, A[i] + diff)) k++;
    }
    if (k >= K) res = min(res, cost);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj0029/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/xxxyyyy/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		Map<String, Integer> map = new TreeMap<String, Integer>();
		String longest = "";
		while(sc.hasNext()) {
			String key = sc.next();
			int value = 0;
			if( map.containsKey(key) ) value = map.get(key);
			map.put(key, value + 1);
			
			if( longest.length() < key.length())
				longest = key;
		}
		int most = 0;
		for(int value : map.values()) {
			most = max(most, value);
		}
		for(String key : map.keySet()) {
			if( most == map.get(key))
				System.out.print(key);
		}
		System.out.println(" " + longest);
	}
	
	void debug(Object... os) {
		System.err.println(deepToString(os));
	}
}

Measured memory_bytes: 12000
#include<cstdio>
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
const int MOD=1e9+7;
struct mint{int x;mint(int x=0):x(x){}};
inline mint operator+  (mint a,mint b){return a.x+b.x<MOD?a.x+b.x:a.x+b.x-MOD;}
inline mint operator-  (mint a){return MOD-a.x;}
inline mint operator-  (mint a,mint b){return a+-b;}
inline mint operator*  (mint a,mint b){return 1LL*a.x*b.x%MOD;}
inline mint operator<< (mint x,int y){mint r=1;for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
inline mint operator~  (mint x){return x<<MOD-2;}
inline mint operator/  (mint a,mint b){return a*~b;}
inline mint&operator+= (mint&a,mint b){return a=a+b;}
inline mint&operator-= (mint&a,mint b){return a=a-b;}
inline mint&operator*= (mint&a,mint b){return a=a*b;}
inline mint&operator<<=(mint&x,int y){return x=x<<y;}
inline mint&operator/= (mint&a,mint b){return a=a/b;}
#define MN 15
int g[MN+5][MN+5],s[MN+5][1<<MN-2];
mint f[1<<MN-2][2],p[MN+5],ss;
int main()
{
	int n,m,i,j,x;
	n=read();m=read();
	for(i=1;i<=m;++i)x=read(),g[x][read()]=1;
	for(i=1;i<=n;++i)for(j=1;j<1<<n-2;++j)
		for(x=3;x<=n;++x)if(j&(1<<x-3))s[i][j]+=g[i][x];
	for(p[0]=i=1;i<=n;++i)p[i]=p[i-1]+p[i-1];
	for(f[i=0][0]=f[i][1]=1;i<1<<n-2;++i)
		for(j=((1<<n-2)-1)^i;j;(--j)&=((1<<n-2)-1)^i)
		{
			for(ss=1,x=3;x<=n;++x)
				if(i&(1<<x-3))ss*=p[s[x][j]]-1;
				else if(!(j&(1<<x-3)))ss*=p[s[x][j]];
			f[i|j][0]+=f[i][0]*ss*p[s[1][j]]*p[s[2][j]];
			f[i|j][1]+=(f[i][0]+f[i][1]*(p[s[1][j]]-1)*(p[s[2][j]]-1))*ss;
		}
	printf("%d",(mint(2)<<m)-f[(1<<n-2)-1][1]);
}

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

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
  int n, h, w;
  cin >> n >> h >> w;
  vector<p> v(n, {0, 0});

  int res = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> v[i].first >> v[i].second;
    if(v[i].first >= h && v[i].second >= w) res++;
  }
  cout << res << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.next();
            if(str.equals("-")){
                break;
            }
            int count = sc.nextInt();
            for(int i = 0; i < count; i++){
                int h = sc.nextInt();
                String temp = str.substring(0,h);
                str =str.substring(h) + temp;
            }
            System.out.println(str);
        }
    }
}


Measured memory_bytes: 26444
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << b + min(c, a+b+1) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,g;
char s[100010],t[100010]; 
int main()
{
	cin>>n>>m;
	scanf("%s",&s);
	scanf("%s",&t);
	g=__gcd(n,m);
	ll l=n*m/g;
	ll a,b;
	a=l/n;
	b=l/m;
	g=__gcd(a,b);
	ll ka=b/g,kb=a/g;
	bool f=true;
	for (int i=0,j=0;i<n && j<m;i+=ka,j+=kb)
	{
		if (s[i]!=t[j])
		{
			f=false;
			break;
		}
	}
	if (!f)
	{
		puts("-1");
	}
	else
	{
		cout<<l<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python
N = int(input())
A = list(map(int, input().split()))
cnt = 0
tmp = 0
r = 0
for l in range(N):
    while r < N and tmp & A[r] == 0:
        tmp ^= A[r]
        r += 1
    cnt += (r-l)
    tmp ^= A[l] 
print(cnt)

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


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> west(n+1),east(n+1);
  west[0]=0;
  east[0]=0;
  int ans=1000000;
  for(int i=0;i<n;++i){
    if(s[i]=='W'){
      west[i+1]=west[i]+1;
      east[i+1]=east[i];
    }else{
      east[i+1]=east[i]+1;
      west[i+1]=west[i];
    }
  }
  for(int i=0;i<n;++i){
    int cal=0;
    if(i==0){
      if(s[i]=='W'){
        cal=east[n];
      }else{
        cal=west[n];
      }
    }else if(i==n-1){
      if(s[i]=='W'){
        cal=east[n-1];
      }else{
        cal=west[n-1];
      }
    }else{
        cal=west[i];
        cal+=east[n]-east[i+1];
    }
    ans=min(cal,ans);
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>

bool debug=true;
/*
   Write In New Computer
    By XiaoGeNintendo
	     gwq2017
	Type:
*/

int a,b,c,d; 
int main(int argc,char* argv[]){
	cin>>a>>b>>c>>d;
	if(abs(c-a)<=d){
		cout<<"Yes";
		return 0;
	}
	if(abs(b-a)<=d && abs(b-c)<=d){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 764
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7

a.sort()
b = [ abs((n-1-i) - i)  for i in range(n)]
b.sort()

for ai,bi in zip(a,b):
    if(ai!=bi):
        print(0)
        exit()

ans = pow(2, n//2 ,mod)
print(ans)

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

sousu = sum(a)

eraberu = 0
for i in range(n):
    if a[i] >= sousu / (4 * m):
        eraberu += 1

if eraberu >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <priority_queue <ll>> v(n, priority_queue <ll> ());
  rep(i, m) {
    ll a, b, c;
    cin >> a >> b;
    if (a == 0) {
      cin >> c;
      v.at(b).push(c);
    } else if (a == 1) {
      if (!v.at(b).empty()) {
        cout << v.at(b).top() << endl;
      }
    } else {
      if (!v.at(b).empty()) {
        v.at(b).pop();
      }
    }
  }
}


Measured memory_bytes: 5168
n = int(input())
s = [int(input()) for _ in range(n)]
s = sorted(s)
sum = sum(s)
pivot = 0
while sum%10==0:
    if s[pivot]%10!=0:
        sum -= s[pivot]
        break
    pivot += 1
    if pivot==n:
        print(0)
        exit()
print(sum)


Measured memory_bytes: 3060
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
BoverA = [0] * N
CoverB = [0] * N
for i in range(N):
    BoverA[i] = N - bisect.bisect_right(B, A[i])
    CoverB[i] = N - bisect.bisect_right(C, B[i])
cumBC = [0] * N
cumBC[N-1] = CoverB[N-1]
for i in range(N-2, -1, -1):
    cumBC[i] = cumBC[i+1] + CoverB[i]
ans = 0
for i in range(N):
    if N - BoverA[i] >= 0 and N - BoverA[i] < N:
        ans += cumBC[N - BoverA[i]]
print(ans)

Measured memory_bytes: 28276
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int odd = 0;
		for(int i=0; i<N; i++) {
			if(sc.nextInt()%2==1)
				odd++;
		}
		
		System.out.println(odd%2==0 ? "YES" : "NO");
		sc.close();
	}
}


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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

double Distance(int x1, int x2, int y1, int y2){
    return sqrt( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) );
}

int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main (void) {
    int N;
    scanf("%d", &N);
    vector<int> X(N), Y(N);
    REP(int, i, 0, N){
        scanf("%d %d", &X.at(i), &Y.at(i));
    }
    double Average = 0;
    vector<int> v(N);
    iota( v.begin(), v.end(), 0);       // v に 0, 1, ... N-1 を設定
    do {
        // for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
        REP(int, i, 0, N - 1){
            Average += Distance(X.at(v.at(i)), X.at(v.at(i+1)),
                                Y.at(v.at(i)), Y.at(v.at(i+1)));
        }     
    } while( next_permutation( v.begin(), v.end()) );

    int FactN = facctorialMethod(N);

    printf("%f\n", Average / FactN);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <vector>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

double mdistance(int p, vector<double> vx, vector<double> vy) {
	vector<double> vd(vx.size());
	transform(vx.begin(), vx.end(), vy.begin(), vd.begin(),
		[p](double a, double b) { return pow(abs(a - b), p); });
	return pow(accumulate(vd.begin(), vd.end(), 0.0), 1.0 / p);
}

double cdistance(vector<double> vx, vector<double> vy) {
	vector<double> vd(vx.size());
	transform(vx.begin(), vx.end(), vy.begin(), vd.begin(),
		[](double a, double b) { return abs(a - b); });
	return *max_element(vd.begin(), vd.end());
}

int main() {
	cout << fixed << setprecision(10);

	int n;
	cin >> n;
	vector<double> vx, vy;
	copy_n(istream_iterator<double>(cin), n, back_inserter(vx));
	copy_n(istream_iterator<double>(cin), n, back_inserter(vy));

	cout << mdistance(1, vx, vy) << endl;
	cout << mdistance(2, vx, vy) << endl;
	cout << mdistance(3, vx, vy) << endl;
	cout << cdistance(vx, vy) << endl;

	return 0;
}



Measured memory_bytes: 3488
#include <cstdio>
int n, t;
char s[305][305];
int main(){
    scanf("%d",&n);
    for(int i = 0; i < n; i++) scanf("%s", s[i]);
    for(int i = 0; i < n; i++){
        bool ok = true;
        for(int j = 0; j < n-1; j++)
            for(int k = j+1; k < n; k++)
            if(s[(j+i)%n][k] != s[(k+i)%n][j]) ok = false;
        t += ok;
    }
    printf("%d\n", t*n);
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> c(h);
	rep(i, h)cin>>c[i];


	// bit 全探索
	int hw = h + w;
	// h + wのbit全探索
	//int all = 1 << hw;
	//debug(all);
	int ans = 0;
	for(int mask = 0; mask  < (1 << hw); mask++){
		int count = 0;
		bitset<15> tmp(mask);
		rep(i,h){
			rep(j,w){
				if(tmp.test(i) || tmp.test(h+j)) continue;
				else {
					if(c[i][j] == '#') count++;
				}
			}
		}
		if(count == k) ans++;
	}
	cout << ans << endl;
}


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

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

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

    ll N; cin >> N;
    map<string,ll> ms;
    for (int i = 0;i < N;i++){
        string s; cin >> s;
        ms[s]++;
    }

    ll ma = 0;
    for(auto&& i:ms){
        ma = max(ma,i.second);
    }

    for(auto&& i:ms){
        if(ma == i.second) cout << i.first << endl;
    }

    return 0;

}

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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  map<char,int> m;
  rep(i,0,n){
    m[s[i]]++;
  }
  int ans=inf;
  for(int i=97;i<=122;i++){
    int o=n;//o=文字列の長さ
    char c=i;
    if(m[c]==0)continue;
    int cnt=m[c];//cnt=指定文字のnagasa
   // cout<<m[c]<<endl;
    string t=s;
    int momo=0;
    while(o>cnt){
          rep(j,1,o){
                  if(t[j]==c&&t[j-1]!=c){
                     t[j-1]=t[j]; 
                    cnt++;
                  }
          }
      o--;
      if(t[o]==c)cnt--;
      momo++;
    }
    ans=min(ans,momo);
  }
         cout<<ans<<endl;
}

Measured memory_bytes: 3576
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 14:32:30 2019

@author: shinjisu
"""


# arc 072 c sequence
def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def db(x):
    global debug
    if debug:
        print(x)


def count(N, A, initSum):
    # global N, A
    sm = initSum
    cnt = abs(sm-A[0])
    db(cnt)
    for i in range(N-1):
        nextSum = sm + A[i+1]
        db((sm, nextSum))
        if sm > 0 and nextSum >= 0:
            cnt += abs(nextSum)+1
            sm = -1
        elif sm < 0 and nextSum <= 0:
            cnt += abs(nextSum)+1
            sm = 1
        else:
            sm = nextSum
        db(cnt)
    return cnt


def probC():
    N = getInt()
    A = getIntList()
    db((N, A))
    if A[0] != 0:
        initSum = A[0]
    else:
        initSum = 1
    cnt1 = count(N, A, initSum)
    db(('a[0] or +1: ', cnt1))
    if initSum > 0:
        cnt2 = count(N, A, -1)
    else:
        cnt2 = count(N, A, 1)
    db(('反対符号 or -1: ', cnt2))
    return min(cnt1, cnt2)


debug = False
print(probC())


Measured memory_bytes: 14648
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
    
    int n, m;
    cin >> n;
    map<int, int>a, b;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[x]++;
    }
    cin >> m;
    bool f = 0;
    for(int i=0;i<m;i++) {
        int x;
        cin >> x;
        a[x]--;
        if (a[x] < 0)f = 1;
    }

    if (f)cout << "NO" << endl;
    else cout << "YES" << endl;

    return 0;

}

Measured memory_bytes: 9600
#include<stdio.h>
int x,y,z,s,ans;
template<typename TYPE>
inline void read(TYPE&x){
	x=0;int w=1;register char c=getchar();for(;c<'0'||c>'9';c=getchar()) if (c=='-') w=-1;
	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+(c^48),c=getchar());x*=w;
}
int main(){
	read(x);read(y);read(z);
	for(;s+z<=x;s=s+z+y) ans++;
	return printf("%d\n",--ans),0;
}

Measured memory_bytes: 128
from bisect import bisect_left

def main():
    def eratosthenes(n):
        A = [i for i in range(2, n+1)]
        P = []
        i = 2
        while i**2 <= n:
            prime = min(A)
            P.append(prime)
            j = 0
            while j < len(A):
                if A[j] % prime == 0:
                    A.pop(j)
                    continue
                j += 1
            i += 1    
        for a in A:
            P.append(a)
        return P

    x = int(input())
    prime_table = eratosthenes(100003)
    idx = bisect_left(prime_table, x)
    ans = prime_table[idx]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 12944
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint a(n+2);
  int count=0;
  REP(i,1,n+1){
    cin>>a[i];
    if(i%2==1 && a[i]%2==1){
      count++;
    }
  }
  cout<<count<<'\n';
  return(0);
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18
 
        bool check(int n,int k){
            while(n%k==0){
                n=n/k;
            }
            return n%k==1;
        }
        
        signed main() {
 
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n;
        cin>>n;
        string s;
        cin>>s;
        int r=0,b=0,g=0;
        for(int i=0;i<s.length();i++){
            if(s[i]=='R')r++;
            if(s[i]=='B')b++;
            if(s[i]=='G')g++;
        }

        int ans=r*b*g;
        int k=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){

                if(s[i]!=s[j] && 2*j-i<n){
                    if(s[i]!=s[2*j-i]&&s[j]!=s[2*j-i])k++;
                }
            }
        }
        cout<<ans-k;


        return 0;
    }

Measured memory_bytes: 3624
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007
    
    N, W = map(int,input().split())
    wv = [tuple(map(int,input().split())) for i in range(N)]
    dp = [0]*(W+1)
    for i in range(N):
        for j in range(W, wv[i][0]-1, -1):
            dp[j] = max(dp[j], dp[j-wv[i][0]]+wv[i][1])
    print(max(dp))

if __name__ == '__main__':
    main()


Measured memory_bytes: 39792
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[100100];
void WA(){puts("No");exit(0);}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	sort(&a[1],&a[n+1]);
	if(abs(a[n]-a[1])>1){puts("No");return 0;}
	if(a[n]==a[1])
	{
		if(a[n]==1||a[n]==n-1||2*a[n]<=n)puts("Yes");
		else puts("No");
		return 0;
	}
	int cnt=0;
	for(int i=n;i;--i)if(a[i]==a[n])++cnt;
	int v=a[n]-(n-cnt);
	if(v>0&&2*v<=cnt&&a[1]==v+(n-cnt)-1)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


void solve() {
    int a, b;
    cin >> a >> b;
    if(a % 2 == 1 && b % 2 == 1){
        cout << "Odd" << "\n";
    }
    else{
        cout << "Even" << "\n";
    }
}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;
using Data = pair<long long, vector<int>>;

int main()
{
    vector<long long> xyz(3);
    int K;
    for(int i=0; i<3; i++) cin >> xyz[i]; cin >> K;

    vector<vector<long long>> v(3);
    for(int iter=0; iter<3; iter++){
        v[iter].resize(xyz[iter]);
        for(int i=0; i<xyz[iter]; i++) cin >> v[iter][i];
        sort(v[iter].begin(), v[iter].end(), greater<long long>());
    }
    priority_queue<Data> que;
    set<Data> se;
    que.push(Data(v[0][0] + v[1][0] + v[2][0], vector<int>({0, 0, 0})));
    for(int k=0; k<K; k++){
        auto c = que.top();que.pop();
        cout << c.first << endl;

        for(int iter=0; iter<3; iter++){
            if(c.second[iter] + 1 < xyz[iter]){
                long long sum = c.first - v[iter][c.second[iter]] + v[iter][c.second[iter] + 1];
                auto num = c.second; num[iter]++;
                auto d = Data(sum, num);

                if(!se.count(d)) se.insert(d), que.push(d);
            }
        }
    }
}

Measured memory_bytes: 1408
#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())

MAX = 10 ** 2


def main():
    l = [0] * (N + 1)
    for x in range(1, MAX + 1):
        for y in range(1, MAX + 1):
            for z in range(1, MAX + 1):
                v = (x + y + z) ** 2 - (x * y + y * z + z * x)
                if v <= N:
                    l[v] += 1
    for ans in l[1:]:
        print(ans)
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 9460
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val arr = LongArray(N) { readInputLine().toLong() }
    val tmp = LongArray(N)
    
    if (arr[0] != 0L) {
        println(-1)
        return
    }
    
    for (i in 1 until N) {
        if (arr[i] - arr[i - 1] > 1L) {
            println(-1)
            return
        }
    }

    var ans = 0L

    for (i in N - 1 downTo 1) {
        if (arr[i] - arr[i - 1] == 1L) {
            ans++
        } else {
            ans += arr[i]
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 43184
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64, m: u64
    }

    let divs = divisors(m);
    let mut ret = 0;
    for c in divs {
        if m / c / n >= 1 {
            ret = std::cmp::max(ret, c);
        }
    }
    println!("{}", ret);
}

#[doc = " n>=1"]
#[allow(dead_code)]
fn divisors(n: u64) -> Vec<u64> {
    let mut ret = vec![];
    for i in (1..).take_while(|i| i * i <= n) {
        if n % i == 0 {
            ret.push(i);
            if i != n / i {
                ret.push(n / i);
            }
        }
    }
    ret
}

Measured memory_bytes: 4352
from itertools import accumulate
N = int(input())
S = list(input())
W = [0]*N
R = [0]*N
ans = N

for i in range(N):
    if S[i] == "W":
        W[i] = 1
    else:
        R[i] = 1
R.reverse()
R = list(accumulate(R))
W = list(accumulate(W))
if R[N-1] == 0 or W[N-1] == 0:
    ans = 0
else:
    sakai = R[N-1]
    ans = max(W[sakai-1], R[N-sakai-1])
print(ans)


Measured memory_bytes: 27796
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>

typedef long long LL;

constexpr long long INFLL = 1e18;

using namespace std;

LL solve(LL temp)
{
    LL ans;
    LL count;
    LL x = 0;

    count = temp / 2 + 1;
    if (temp % 2)
    {
        if (count % 2)
        {
            ans = 1;
        }
        else
        {
            ans = 0;
        }
    }
    else
    {
        count--;
        ans = temp;
        if (count % 2)
        {
            ans++;
        }
        else
        {
            //処理なし
        }
    }
    return ans;
}

int main()
{
    LL A, B;
    cin >> A >> B;

    if (A > 0)
    {
        A = solve(A - 1);
    }
    // bitset<64> bsA(A);
    // bitset<64> bsB(solve(B));

    // cout << bsA.to_ullong() << endl;
    // cout << bsB.to_ullong() << endl;

    cout << (A ^ solve(B)) << endl;

    return 0;
}

Measured memory_bytes: 384
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 k = sc.nextInt();
		sc.close();

		int mod = 1000000007;
		if (n <= k + 1) {
			long ans = nCr(n + n - 1, n, mod);
			System.out.println(ans);
		} else {
			long[] p = new long[n + 1];
			long[] pi = new long[n + 1];
			p[0] = 1;
			pi[0] = 1;
			for (int i = 1; i < p.length; i++) {
				p[i] = p[i - 1] * i % mod;
				pi[i] = modinv(p[i], mod);
			}

			long ans = 0;
			for (int i = 0; i <= k; i++) {
				long val1 = nCr(n, i, mod, p, pi);
				long val2 = nCr(n - 1, i, mod, p, pi);
				ans += val1 * val2;
				ans %= mod;
			}
			System.out.println(ans);
		}
	}

	static long nCr(int n, int r, int m, long[] p, long[] pi) {
		return p[n] * pi[r] % m * pi[n - r] % m;
	}

	static long nCr(long n, long r, int m) {
		long val = 1;
		for (int i = 1; i <= r; i++) {
			val = val * (n - i + 1) % m;
			val = val * modinv(i, m) % m;
		}
		return val;
	}

	static long modinv(long a, int m) {
		long b = m;
		long u = 1;
		long v = 0;
		long tmp = 0;

		while (b > 0) {
			long t = a / b;
			a -= t * b;
			tmp = a;
			a = b;
			b = tmp;

			u -= t * v;
			tmp = u;
			u = v;
			v = tmp;
		}

		u %= m;
		if (u < 0) u += m;
		return u;
	}
}


Measured memory_bytes: 25684
#include <stdio.h>
#define MAX 2000001
#define VMAX 10000

int A[MAX], B[MAX], C[MAX];

int main(){
  int i, j, n;
  scanf("%d",&n);
  
  for(i = 0; i <= VMAX; i++) C[i] = 0;
 
  for(i = 0; i < n; i++){
    scanf("%d",&A[i+1]);
    C[A[i + 1]]++;
  }
    
  for(i = 1; i <= VMAX; i++) C[i] += C[i-1];
  
  for(j = 1; j <= n; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1; i <= n; i++){
    if(i > 1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 17896
#include<bits/stdc++.h>
using namespace std;
const int P=998244353;
int n,m,ans,A[305][305],two[605];
void up(int &x){if (x>=P) x-=P;}

int xor_guass(int m, int n) //A是异或方程组系数矩阵 返回秩
{
    int i = 0, j = 0, k, r, u;
    while(i < m && j < n){//当前正在处理第i个方程,第j个变量
        r = i;
        for(int k = i; k < m; k++) if(A[k][j]){r = k; break;}
        if(A[r][j]){
             if(r != i) for(k = 0; k <= n; k++) swap(A[r][k], A[i][k]);
             //消元完成之后第i行的第一个非0列是第j列,且第u>i行的第j列全是0
            for(u = i + 1; u < m; u++) if(A[u][j])
                for(k = i; k <= n; k++) A[u][k] ^= A[i][k];
            i++;
        }
        j++;
    }
    return i;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			int x;scanf("%d",&x);
			A[j-1][i-1]=x;
		}
	 
	two[0]=1;
	for (int i=1;i<=n+m;i++)
		two[i]=two[i-1]*2%P;
	ans=1ll*(two[n]-two[n-xor_guass(m,n)]+P)*two[m-1]%P; 
	printf("%d\n",ans);
}

Measured memory_bytes: 768
n,k= map(int, input().split())
a=[]
for i in range(k):
    s=int(input())
    t= list(map(int, input().split()))
    a.append(t)

ans=[0]*n
for i in range(k):
    for j in range(len(a[i])):
        if ans[a[i][j]-1]==0:
            ans[a[i][j] - 1]=1
cnt=0
for i in range(n):
    if ans[i]==0:
        cnt+=1

print(cnt)

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

bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    string s;
    cin >> s;
    int a[4] = {0};
    for (size_t i = 0; i < s.length(); i++)
    {
        if (s[i] == 'N')
        {
            a[0] = 1;
        }
        if (s[i] == 'S')
        {
            a[1] = 1;
        }
        if (s[i] == 'E')
        {
            a[2] = 1;
        }
        if (s[i] == 'W')
        {
            a[3] = 1;
        }
    }
    if ((a[0] ^ a[1]) == 0 && (a[2] ^ a[3]) == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {

        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
 
#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
 
 
using namespace std;
int main() {
  int n=0;
  double a[10];
  std::string t[10];
  cin >> n;
  rep(i,n){
   cin >> a[i];
   cin >> t[i];
  }
  double sum=0;
  rep(j,n){
   if (t[j] == "BTC"){
  a[j]=a[j]*380000.0;
   }
   sum += a[j];
  }
  cout << sum;
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector> 
#include<algorithm>
 
using namespace std;
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  
  vector<int> d(n);
  
  for(int i = 0; i < n; ++i){
    cin >> d[i];
  }
  
  sort(d.begin(), d.end());
  
  int res = d[n/2] - d[n/2 - 1];
    
  cout << res << "\n";
  return 0; 
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
using int64 = long long;
#define ForInt(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define ForIntInit(i, begin, end) for (int i = (begin); i < (end); ++i)
#define ForItr(it, itBegin, itEnd) for (auto (it) = (itBegin); (it) != (itEnd); ++(it))


int main()
{
	const int64 DIVISOR = 1000000007;

	string s;
	cin >> s;
	int n = s.length();
	int64 dp[100001][13];
	//int64 dp[200][13];

	if (s[n - 1] == '?')
	{
		ForInt(j, 10)
		{
			dp[0][j] = 1;
		}
		dp[0][10] = 0;
		dp[0][11] = 0;
		dp[0][12] = 0;
	}
	else
	{
		ForInt(j, 13)
		{
			dp[0][j] = 0;
		}
		int r = (int)(s[n - 1] - '0');
		dp[0][r] = 1;
	}
	int multiplier = 10;
	ForIntInit(i, 1, n)
	{
		int si = n - 1 - i;
		if (s[si] == '?')
		{
			ForInt(j, 13)
			{
				dp[i][j] = 0;
			}
			ForInt(num, 10)
			{
				int r = (num * multiplier) % 13;
				ForInt(j, 13)
				{
					dp[i][(j + r) % 13] += (dp[i - 1][j] % DIVISOR);
				}
			}
		}
		else
		{
			int num = (int)(s[si] - '0');
			int r = (num * multiplier) % 13;
			ForInt(j, 13)
			{
				dp[i][(j + r) % 13] = (dp[i - 1][j] % DIVISOR);
			}
		}
		multiplier = (10 * multiplier) % 13;
	}
	cout << (dp[n - 1][5] % DIVISOR) << endl;

	return 0;
}


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

int main(){
  int n; cin>>n;
  string s; cin>>s;
  
  if(n%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
  
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[i+n/2]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  
  cout<<"Yes"<<endl;
  return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H.at(i);
    }

    vector<bool> is_good(N, true);
    int Ai, Bi;
    for (int i = 0; i < M; i++)
    {
        cin >> Ai >> Bi;
        Ai--;
        Bi--;
        if (H.at(Ai) <= H.at(Bi))
        {
            is_good.at(Ai) = false;
        }
        if (H.at(Bi) <= H.at(Ai))
        {
            is_good.at(Bi) = false;
        }
    }
    int res = 0;
    for (int i = 0; i < N; i++)
    {
        if (is_good.at(i))
        {
            res++;
        }
    }
    cout << res << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main()
{
    ll n;cin >>n;
    ll ans=1;
    rep(i,n){
        ans*=(i+1);
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long int lld;
#define MOD 1000000007

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int count[26];
  for(int i=0;i<26;i++)count[i]=1;
  for(int i=0;i<n;i++){
    count[s.at(i)-'a']++;
  }
  lld ans=1;
  for(int i=0;i<26;i++){
    ans*=count[i];
    ans%=MOD;
  }
  ans+=MOD-1;
  ans%=MOD;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512