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

int main() {
    long w, h, x, y;
    cin >> w >> h >> x >> y;

    if (x == w / 2 && w % 2 == 0 && y == h / 2 && h % 2 == 0) {
        cout << (h * w / 2) << " 1" << endl;
        return 0;
    }

    /*
    if ((x == w / 2 && w % 2 == 0) || (y == h / 2 && h % 2 == 0)) {
        cout << (h * w / 2) << " 0" << endl;
        return 0;
    }

    if (x == 0 || x == w || y == 0 || y == h) {
        cout << setprecision(12) << (h * w / 2.0) << " 0" << endl;
        return 0;
    }
    */

    cout << setprecision(12) << (h * w / 2.0) << " 0" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm> //sort
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  vector<int> vcnt;
  int j=0;
  while(j<n){
    int cnt=1;
    while(a[j]==a[j+1]){
      j++;
      cnt++;
    }
    vcnt.push_back(cnt);
    j++;
  }
  sort(vcnt.begin(),vcnt.end());
  int ans = 0;
  if(k<vcnt.size()){
    for(int i=0;i<vcnt.size()-k;i++){
      ans += vcnt[i];
    }
    cout << ans << "\n";
  }
  else{
    cout << 0 << "\n";
  }

  return 0;
}

	


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

int main(){
	char b[4];
	for(int i=0; i<4; i++) cin >> b[i];
	int a[4];
	for(int i=0; i<4; i++) a[i] = b[i] - '0';
	int p = a[0] * 10 + a[1];
	int q = a[2] * 10 + a[3];
	if(1 <= p && p <= 12){
		if(1 <= q && q <= 12){
			cout << "AMBIGUOUS" << endl;
		}else{
			cout << "MMYY" << endl;
		}
	}else{
		if(1 <= q && q <= 12){
			cout << "YYMM" << endl;
		}else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
int N;
void dfs(string S,char a) {
    if(S.size() == N) {
        cout << S << endl;
        return;
    }
    for(char i = 'a'; i <= a; i++) {
        if(i == a) {
            dfs(S+i,i+1);
        }
        else {
            dfs(S+i,a);
        }
    }
    return;
}
signed main() {
    cin >> N;
    dfs("",'a');
}


Measured memory_bytes: 3604
import java.util.*;
public class Main{
	static ArrayList<Integer>[] map;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] costv=new int[n];
		int[] costu=new int[n];
		int u=sc.nextInt()-1;
		int v=sc.nextInt()-1;
		map=new ArrayList[n];
		for(int i=0; i<n; i++){
			map[i]=new ArrayList<>();
		}
		for(int i=1; i<n; i++){
			int a=sc.nextInt()-1;
			int b=sc.nextInt()-1;
			map[a].add(b);
			map[b].add(a);
		}
		dfs(-1,v,0,costv);
		dfs(-1,u,0,costu);
		int ans=0;
		for(int i=0; i<n; i++){
			if(costu[i]<costv[i]){
				ans=Math.max(costv[i]-1,ans);
			}
		}
		System.out.println(ans);
	}
	static void dfs(int front,int now,int c,int[] cm){
		cm[now]=c;
		for(int i:map[now]){
			if(front!=i){
				dfs(now,i,c+1,cm);
			}
		}
	}
}


Measured memory_bytes: 113916
#include <stdio.h>

int main(void)
{
  int n, t, i, j, k, h, tmp, tnp;

  scanf("%d %d", &n, &t);

  int c[n], s[n];

  for(h=0;h<n;h++){
    scanf("%d %d", &c[h], &s[h]);
  }

  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(c[i]>c[j]){
        tmp = c[i];
        c[i] = c[j];
        c[j] = tmp;

        tnp = s[i];
        s[i] = s[j];
        s[j] = tnp;
      }
    }
  }
int p;
  for(k=0;k<n;k++){
    if(s[k]<=t){
      p = k;
      break;}
      p = 100;
  }

  if(p == 100)
    printf("TLE");
  else
    printf("%d", c[p]);

  return 0;


}


Measured memory_bytes: 128
K, A, B = map(int,input().split(' '))

max_n = (K-A-1)//2
mod = (K-A-1)%2

if A+2 >= B:
  print(K+1)
elif K < A+1:
  print(K+1)
else:
  print(B+max_n*(B-A)+mod)

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> a(n+2);
    ll sum=0;
    repi(i,1,n+1){
        cin>>a[i];
        sum+=abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n+1]-a[n]);
    repi(i,1,n+1){
        cout<<sum-(abs(a[i+1]-a[i])+abs(a[i]-a[i-1]))+abs(a[i+1]-a[i-1])<<endl;
    }
}

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

using namespace std;

int main(){
	cin.tie(0); ios::sync_with_stdio(0);
	
	int n;
	cin >> n;
	ll v[n];
	ll mx = 0;
	ll mxt = 0;

	for(int  i = 0; i < n; i++)
		cin >> v[i];
	for(int i = 1; i < n; i++){
		if(v[i] <= v[i-1]) {
			mxt++;
			mx = max(mxt, mx);
		}
		else{
			mxt = 0;
		}
	}
	cout << mx << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include <cmath>
using namespace std;
int main(){
  int N,i,min,max,ans;
  cin >> N;
  i = 0;
  max = 1;
  min = 1000000000;
  int A[N];
  for(int i = 0;i<N;i++){
      cin>>A[i];
  }
  for(i = 0;i<N;i++){
      if(min > A[i])
      min = A[i];
      if(max < A[i])
        max = A[i];
  }
  ans = max - min;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int n,m,A[1100000],sum = 0;
  cin >> n >> m;
  for(int i = 0; i <m; i++) {
    cin >> A[i];
    sum += A[i];
  }
  if(sum <= n) cout << n-sum << endl;
  else cout << "-1" << endl;
}

Measured memory_bytes: 3668
K = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[K-1])

Measured memory_bytes: 38256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
 
 
using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+7,M=3e5+5,MOD=1e9+7;

int n;
ll a[N];
int cnt[2][62];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	scanf("%d",&n);

	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	
	ll ans = 0;
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<60;j++){
			ll wa = (1LL<<j)%MOD;
			if(a[i]&(1LL<<j)){
				ans+=(wa*cnt[0][j])%MOD;
				ans%=MOD;
			}
			else{
				ans+=(wa*cnt[1][j])%MOD;
				ans%=MOD;
			}
		}
		for(int j=0;j<60;j++){
			if(a[i]&(1LL<<j))cnt[1][j]++;
			else	cnt[0][j]++;
		}
	}
	printf("%lld\n",ans );
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint h,w;std::cin>>h>>w;
    std::vector<std::vector<std::vector<lint>>>
        g(2,std::vector<std::vector<lint>>(h,std::vector<lint>(w)));
    for(lint i=0;i<h;i++){
        for(lint j=0;j<w;j++){
            char c;std::cin>>c;
            g.at(0).at(i).at(j)=c=='#';
            g.at(1).at(i).at(j)=!g.at(0).at(i).at(j);
        }
    }
    std::vector<std::vector<std::vector<lint>>>
        dist(2,std::vector<std::vector<lint>>(h,std::vector<lint>(w,-1)));
    using node_t=std::tuple<lint,lint,lint>;
    std::deque<node_t>que;
    if(g.at(0).at(0).at(0)){
        dist.at(1).at(0).at(0)=1;
        que.emplace_back(1,0,0);
    }else{
        dist.at(0).at(0).at(0)=0;
        que.emplace_back(0,0,0);
    }
    std::vector<lint>di={0,0,1,1,-1,-1};
    std::vector<lint>dj={1,0,1,0,1,0};
    std::vector<lint>dk={0,1,0,1,0,1};
    while(!que.empty()){
        lint i,j,k;std::tie(i,j,k)=que.front();que.pop_front();
        for(lint l=0;l<6;l++){
            lint ni=i+di.at(l);
            lint nj=j+dj.at(l);
            lint nk=k+dk.at(l);
            if(ni<0||2<=ni||h<=nj||w<=nk||g.at(ni).at(nj).at(nk)
                ||dist.at(ni).at(nj).at(nk)!=-1)continue;
            if(i!=ni){
                dist.at(ni).at(nj).at(nk)=dist.at(i).at(j).at(k)+1;
                que.emplace_back(ni,nj,nk);
            }else{
                dist.at(ni).at(nj).at(nk)=dist.at(i).at(j).at(k);
                que.emplace_front(ni,nj,nk);
            }
        }
    }
    std::cout<<(std::max(dist.at(0).at(h-1).at(w-1),dist.at(1).at(h-1).at(w-1))+1)/2<<'\n';
}


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


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

  if (s.length() <= k) {
    cout << s << endl;
    return 0;
  }

  rep(i, k) {
    cout << s[i];
  }
  cout << "..." << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

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

    
    int n,m;cin>>n>>m;
    vector<int> a(n);
    int sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }

    int cnt=0;
    rep(i,n){
        if(sum<=a[i]*4*m) cnt++;
    }
    if(cnt>=m){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

#define ll long long 
#define d  double 
#define endl "\n"

const ll int MOD=1e9+7;

void solve()
{
	int n,x;
	cin >> n;
	x = n%10;
	if(x==2 or x==4 or x==5 or x==7 or x==9)
		cout << "hon\n";
	else if(x==0 or x==1 or x==6 or x==8)
		cout <<"pon\n";
	else
		cout <<"bon\n";
}

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

	solve();
	return 0;
}

Measured memory_bytes: 3640
//Aizu 0033
//DinnerHunt
#include <cstdio>
#include <stack>
using namespace std;
int n,k,flag;
int main(){
	scanf("%d",&n);
	while(n--){
		stack<int> stk1,stk2;
		stk1.push(0);
		stk2.push(0);
		flag=1;
		for(int i=0;i<10;i++){			
			scanf("%d",&k);
			int a=k-stk1.top();
			int b=k-stk2.top();
			if (a<0&&b<0) flag=0;
			else if((0<a&&a<b)||(b<0)) stk1.push(k);
			else stk2.push(k);
		}
		if(flag)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 2588
N,M,X=map(int,input().split())

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

countA=0
countB=0

for i in range(X,N+1):
    if i in A :
        countA+=1

for i in range(0,X+1):
    if i in A :
        countB+=1

print(min(countA,countB))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll A,V,B,W,T;
  cin >> A >> V >> B >> W >> T;

  ll dis=abs(B-A);
  ll s=V-W;
  if(dis<=s*T)  cout << "YES" << endl;
  else  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 3688
import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
a,b,c,d = MI()
m = max(a*c,a*d,b*c,b*d)
print(m)


Measured memory_bytes: 9172
import numpy as np
N, M, K = map(int, input().split())
A = np.cumsum([0] + list(map(int, input().split())))
B = np.cumsum([0] + list(map(int, input().split())))

def nibu(data, value):
  left = 0
  right = len(data) - 1
  while right - left > 1:
    mid = (left + right)//2
    if data[mid] == value:
      return mid - 1
    elif value < data[mid]:
      right = mid
    else:
      left = mid
  if value >= data[right]:
    return right
  else:
    return left
  
ans = 0
for i in range(N+1):
  sa = K - A[i]
  if sa < 0:
    break
  j = nibu(B, sa)
  ans = max(ans,i+j)
print(ans)

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
      if(n%2==0)Cout(n);
      else Cout(n*2);
     

       
return 0;
}


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

from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


ans = 1
C = Counter(prime_factorize(P))
#print(C)
for item in C.items():
    i = item[0]
    v = item[1]
    if v >= N:
        ans *= i**(v//N)
print(ans)

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

#define f(i,n) for(auto i=0;i<n;i++)
#define fr(i,n) for(auto i=n-1;i>=0;i--)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define nl cout<<"\n";
#define ll long long int
#define vl vector<ll>
#define mid(a,b) ((a+b)/2)
#define pb push_back

class triplet{ll f, s, t;};

vl in(ll n){vl v;ll x;
    f(i,n)
    cin>>x, v.pb(x);
    return v;}
void out(vl v){fl(i,v)cout<<i;}
void out(vl v, char ch){
    fl(i,v)
    cout<<i<<ch;}

ll attack(ll ar[10000][10000], ll i, ll j, ll k){
    return ((i+2 < k) && (j+1 < k)) + ((i+2 < k) && (j-1 >= 0)) + ((i-2 >= 0) && (j+1 < k)) + ((i-2 >= 0) && (j-1 >= 0));
}

void solve(){
    char ch;
    cin>>ch;
    cout<<(char)(ch+1);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
   return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		int X = sc.nextInt();

		System.out.println((double) T / X);

	}

	private static class Pair {
		private int A;
		private int B;
		private long index;

		private static long count = 0;

		public Pair(int A, int B) {
			this.A = A;
			this.B = B;
			this.index = count++;
		}

		public int getA() {
			return A;
		}

		public int getB() {
			return B;
		}

		public int getDiffA() {
			return Math.min(0, A - B);
		}

		public int getDiffB() {
			return Math.min(0, B - A);
		}

		public long getIndex() {
			return index;
		}

		@Override
		public String toString() {
			return "[A=" + A + ", B=" + B + "]";
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 22996
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int m;

pii fit(const int window[][100], const int pic[][50], int y, int x)
{
	pii ans(-1, -1);
	rep(i, m) rep(j, m){
		if(pic[i][j] == -1)
			continue;
		
		if(window[y+i][x+j] != pic[i][j]){
			return pii(-1, -1);
		}else if(ans.first == -1)
			ans = pii(y+i, x+j);
	}
	return ans;
}

void rotate(int p[][50])
{
	int next[50][50];
	rep(i, m) rep(j, m)
		next[i][j] = p[m-j-1][i];
	
	rep(i, m) rep(j, m)
		p[i][j] = next[i][j];
}

int main()
{
	int n;
	while(scanf("%d%d", &n, &m), n){
		int window[100][100];
		rep(i, n) rep(j, n)
			scanf("%d", &window[i][j]);
		
		int pic[50][50];
		rep(i, m) rep(j, m)
			scanf("%d", &pic[i][j]);
		
		pii ans(-1, -1);
		rep(i, n-m+1) rep(j, n-m+1){
			rep(k, 4){
				ans = fit(window, pic, i, j);
				if(ans.first != -1){
					i=n-m+1;
					j=n-m+1;
					break;
				}
				rotate(pic);
			}
		}
		
		if(ans.first == -1)
			puts("NA");
		else
			printf("%d %d\n", ans.second+1, ans.first+1);
	}
	
	return 0;
}

Measured memory_bytes: 828
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.lang.Math;

class Main{
	public static void main(String args[]){
    	String reg = "[+-]?\\d+\\.0";
    	List<List<Integer>> hoge = new ArrayList<>();
      	
      	Scanner sc = new Scanner(System.in);
      	String str = sc.nextLine();
      	int n = Integer.parseInt(str.split(" ")[0]);
      	int d = Integer.parseInt(str.split(" ")[1]);
      	
      	for(int i = 0; i < n; i++) {
      		List<Integer> zahyo = new ArrayList<>();
      		str = sc.nextLine();
      		for(int j = 0; j < d; j++) {
      			zahyo.add(Integer.parseInt(str.split(" ")[j]));
      		}
      		hoge.add(zahyo);
      	}
      	Pattern p = Pattern.compile(reg);
      	int count = 0;
      	for(int i = 0; i < n; i++) {
      		for(int j = i+1; j < n; j++) {
      			//System.out.println(Math.sqrt(distance(hoge.get(i), hoge.get(j))));
      			Matcher matcher = p.matcher(String.valueOf(Math.sqrt(distance(hoge.get(i), hoge.get(j)))));
      			if(matcher.matches()) count++;
      		}
      	}
      	System.out.println(count);
    }
	
	public static double distance(List<Integer> p1, List<Integer> p2) {
		//int distance = 0;
		double sum = 0;
		for(int i = 0; i < p1.size(); i++) {
			sum += Math.pow(p1.get(i) - p2.get(i), 2);
		}
		return sum;
	}
}

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

int main(){
    using namespace std;
    int N; cin >> N;
    set<int> A;
    for(int i=0; i<10; i++){
        for (int j = 0; j < 10; j++)
        {   
            A.insert(i*j);
        }
    }

    if(A.count(N)!=0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
use std::cmp::{max, min};
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, k: usize, mut a: [usize;n]);
    let mut cum = vec![0; n + 1];
    for _ in 0..k {
        for i in 0..n {
            let l = i.saturating_sub(a[i]);
            let r = min(n - 1, i + a[i]) + 1;
            cum[l] += 1;
            cum[r] -= 1;
        }
        a = cum
            .iter()
            .scan(0, |b, x| {
                let c = *b as i64 + x;
                *b = c as usize;
                Some(*b)
            })
            .take(n)
            .collect::<Vec<usize>>();
        if a.iter().all(|ai| *ai == n) {
            break;
        }
        for i in 0..n + 1 {
            cum[i] = 0;
        }
    }
    println!(
        "{}",
        a.iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 18548
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    int e = c - (d - b), f = d + (c - a), g = a - (d - b), h = b + (c - a);
    cout << e << " " << f << " " << g << " " << h << endl;
}


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

using namespace std;

int lcs(string s, string t)
{
    int m = s.length();
    int n = t.length();

    vector<vector<int> > dp(m+1, vector<int> (n+1, 0));

    for(int i=0; i<=m; i++) dp[i][0] = 0;
    for(int i=0; i<=n; i++) dp[0][i] = 0;

    for(int i=1; i<=m; i++)
    {
        for(int j=1; j<=n; j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j] = 1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
            
        }
    }

    int ans = dp[m][n];

    vector<char> lcs_actual;

    int i=m, j=n;

    while(i>0 && j>0)
    {
        if(dp[i][j] > max(dp[i-1][j], dp[i][j-1]))
        {
            lcs_actual.push_back(s[i-1]); i--; j--;
        }
        else
        {
            if(dp[i][j-1]==dp[i][j]) j--;
            else i--;
        }
    } 
    
    reverse(lcs_actual.begin(), lcs_actual.end());

    for(auto x:lcs_actual) cout<<x;
    cout<<endl;

    return ans;
}

int main()
{
    string s, t; cin>>s>>t;

    int ans = lcs(s, t);

    return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
	return a * b / my_gcd(a, b);	
}

struct UF {
    vector<int> par, sz;

    UF(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b / a) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#r = int(input())
n, m = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

x = sum(a)

print(max(n-x, -1))




    


Measured memory_bytes: 10308
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){

    int N;
    cin >> N;
    string S[N];
    map<string, int> mp;

    for(int i = 0; i < N; i++){
        cin >> S[i];
        mp[S[i]]++;
    }

    char lastc = '0';
    for(int i = 0; i < N; i++){

        // // Cond 1
        for(auto m:mp){
            if(m.second > 1){
                cout << "No" << endl;        
                return 0;
            }
        }

        // Cond 2
        for(int j = 0; j < N; j++){
            if(j == 0){
                lastc = S[j][S[j].length() - 1];
                continue;
            }

            if(lastc != S[j][0]){
                cout << "No" << endl;        
                return 0;
            }
            lastc = S[j][S[j].length() - 1];
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int mx = max(max(a,b),c);
  int k;
  cin >> k;
  int ans = a + b + c - mx;
  for(int i=0;i<k;i++) mx *= 2;
  cout << ans+mx << endl;

  return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;

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

	ll cnt = 0;
	rep(i, n - 1) {
		ll x = m[i + 1] - m[i];
		if (x <= t) {
			cnt += x;
		}
		else {
			cnt += t;
		}
	}
	cout << cnt + t<< endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    rep(h, H) {
        rep(w, W) {
            if((h < B) ^ (w < A)) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

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

    if (b < a) swap(a, b);
    if (c < b) swap(b, c);
    if (b < a) swap(a, b);

    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 1164
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
//#define int unsigned long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

string S;
int num[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> S;
	int N = S.size();
	int LMR = 0;
	REP(i, N) {
		if (S[i] == 'R') {
			LMR = i;
		}
		else {
			if ((i - LMR) % 2 == 0) {
				num[LMR]++;
			}
			else num[LMR + 1]++;
		}
	}
	int RML = N - 1;
	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == 'L')RML = i;
		else {
			if ((RML - i) % 2 == 0) {
				num[RML]++;
			}
			else num[RML - 1]++;
		}
	}
	REP(i, N) {
		pe(num[i]);
	}cout << endl;
}



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

using namespace std;

typedef long long lint;
const lint N = 2e5+100, INF = 1e9+7;
lint n, a[N], dl, dr;
map<lint, lint> cntl, cntr;
set<lint> possible;

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%lld", &n);

	lint minx = N+INF, maxx = -INF;

	for (lint i = 1; i <= n; i++){
		scanf("%lld", &a[i]);
		dl = i - a[i];
		dr = a[i] + i;

		if (cntl.find(dl) == cntl.end())
			cntl[dl] = 1;
		else
			cntl[dl] = cntl[dl] + 1;
		
		if (cntr.find(dr) == cntr.end())
			cntr[dr] = 1;
		else
			cntr[dr] = cntr[dr] + 1;

		possible.insert(i - a[i]);
		possible.insert(a[i] + 1);
		minx = min(minx, min(i - a[i], a[i] + 1));
		maxx = max(maxx, max(i - a[i], a[i] + 1));
	}

	lint ans = 0;

	set<lint>::iterator it = possible.begin();

	for (it = possible.begin(); it != possible.end(); it++){
		lint x = *it;
		if (cntl.count(x) && cntr.count(x))
			ans += cntl[x] * cntr[x];
	}

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

	return 0;
}

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

using namespace std;
#define mod 1000000007
long long length , width;
long long ans[1000][1000];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
//    cin >> N;
//    vec=vector<long long>(N);
//    vector<long long>ans(N);
//    for(int i=0; i<N; i++){
//        cin >> vec[i];
//    }
//    ans[N-1] = 0;
//    for(int i=N-2; i>=0; i--){
//        if(i+2<N){
//           ans[i] = min(abs(vec[i]-vec[i+1])+ans[i+1],abs(vec[i]-vec[i+2])+ans[i+2]);
//        }
//        if(i+1<N && i+2>=N){
//            ans[i] = abs(vec[i]-vec[i+1])+ans[i+1];
//        }
//        //cout << ans[i] << endl;
//    }
//    cout << ans[0] << endl;

    cin >> length >> width;
    char grid[length][width];
    for(int i=0; i<length; i++){
        for(int j=0; j<width; j++){
            cin >> grid[i][j];
        }
    }

    ans[0][0] = 1;
    for(int i=0; i<length; i++){
        for(int j=0; j<width; j++){
            if(i>=1 && grid[i][j]!='#'){
                ans[i][j] += ans[i-1][j];
            }
            if(j>=1&& grid[i][j]!='#'){
                ans[i][j] += ans[i][j-1];
            }
            ans[i][j]%=mod;
        }
    }
    cout << ans[length-1][width-1] << endl;


    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
	x = 0; int f = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

typedef pair <int, int> pii;
typedef long long ll;
const int maxn = 2e5 + 50;
int siz[maxn], son[maxn], mrk[maxn], cnt[maxn];
int a[maxn];
char s[maxn];
int n, rt, mid;
int st[maxn], top;
pii in[maxn], ot[maxn];
ll ans;

vector <int> e[maxn];

int getpoint(int u, int f, int s){
	siz[u] = 1;
	son[u] = 0;
	for(int i = 0; i < e[u].size(); ++ i){
		int v = e[u][i]; if(mrk[v] || v == f) continue;
		getpoint(v, u, s);
		siz[u] += siz[v];
		son[u] = max(son[u], siz[v]);
	}
	son[u] = max(son[u], s - siz[u]);
	if(!rt || son[u] < son[rt]) rt = u;
}

void rebuild(int u, int f){
	siz[u] = 1;
	for(int i = 0; i < e[u].size(); ++ i){
		int v = e[u][i]; if(mrk[v] || v == f) continue;
		rebuild(v, u);
		siz[u] += siz[v];
	}
}

void dfs(int u, int f, int op){
	if(op == 0){
		if(a[u] == -1) in[u] = pii(in[f].first + 1, in[f].second);
		else{
			if(in[f].first) in[u] = pii(in[f].first - 1, in[f].second);
			else in[u] = pii(0, in[f].second + 1); 
		}
		if(in[u].first == 0) ans += cnt[in[u].second];
	}
	else{
		if(a[u] == 1) ot[u] = pii(ot[f].first, ot[f].second + 1);
		else{
			if(ot[f].second) ot[u] = pii(ot[f].first, ot[f].second - 1);
			else ot[u] = pii(ot[f].first + 1, 0);
		}
		if(ot[u].second == 0) cnt[ot[u].first] ++;
	}
	for(int i = 0; i < e[u].size(); ++ i){
		int v = e[u][i]; if(v == f || mrk[v]) continue;
		dfs(v, u, op);
	}
}

void divide(int u){
	mrk[u] = 1;
	rebuild(u, 0);
	rep(i, 0, siz[u]) cnt[i] = 0;
	if(a[u] == -1) cnt[1] = 1;
	in[u] = pii(0, 0);
	ot[u] = a[u] == 1 ? pii(0, 1) : pii(1, 0);
	for(int i = 0; i < e[u].size(); ++ i){
		int v = e[u][i]; if(mrk[v]) continue;
		dfs(v, u, 0);
		dfs(v, u, 1);
	}
	reverse(e[u].begin(), e[u].end());
	rep(i, 0, siz[u]) cnt[i] = 0;
	in[u] = pii(0, 0);
	ot[u] = a[u] == 1 ? pii(0, 1) : pii(1, 0);
	for(int i = 0; i < e[u].size(); ++ i){
		int v = e[u][i]; if(mrk[v]) continue;
		dfs(v, u, 0);
		dfs(v, u, 1);
	}
	ans += cnt[0];
	for(int i = 0; i < e[u].size(); ++ i){
		int v = e[u][i]; if(mrk[v]) continue;
		getpoint(v, rt = 0, siz[v]);
		divide(rt);
	}
}

int main(){
	rd(n);
	scanf("%s", s + 1);
	rep(i, 1, n) a[i] = s[i] == '(' ? 1 : -1;
	rep(i, 1, n - 1){
		int u, v; rd(u), rd(v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	getpoint(1, rt = 0, n);
	divide(rt);
	printf("%lld\n", ans);
	return 0;
}
/*
4
(())
1 2
2 3
3 4
*/


Measured memory_bytes: 24048
x, y, a, b, c = map(int, input().split())
red = [int(x) for x in input().split()]
green = [int(x) for x in input().split()]
red.sort()
green.sort()
candidates = [int(x) for x in input().split()] + red[-x:] + green[-y:]
candidates.sort()
print(sum(candidates[-x-y:]))

Measured memory_bytes: 23200
import math
import itertools

n = int(input())
l = list(range(n))

pos_list =[list(map(int, input().split())) for _ in range(n)]

ans = 0 
def clc_distandce(a,b):
    [x1, y1] = a
    [x2, y2] = b
    dist = math.sqrt((a[0] - b[0])**2 + (a[1]-b[1])**2)
    return dist


for i in itertools.permutations(l,n):
    #print(i)
    #print(list(i)[0])
    for k in range(1,n):
        dist = clc_distandce(pos_list[list(i)[k]],pos_list[list(i)[k-1]])
        ans += dist
    #print(ans)
    #print()
    
print(ans/math.factorial(n))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define pr printf
#define sc scanf
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef long double ld;
int a,b ;
int main () {
    sc("%d %d", &a, &b);
    for(int i = -1000000; i<= 1000000; i++) {
        //cout << i << "\n";
        
        if(abs(b-i) < a) {
            pr("%d ", i);
        }
        
    }pr("\n");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
 
using namespace std;
 
#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
 
const int N_MAX = 50;
const int DP0 = 2500;
 
typedef long long ll;
 
int N, A;
int x[N_MAX];
 
ll dp[DP0 * 2 + 1];
 
void solve() {
  dp[DP0] = 1;
  REP(i, N) {
    x[i] -= A;
    if (x[i] < 0) {
      for (int j = -DP0; j <= DP0 + x[i]; j++) {
        dp[DP0 + j] += dp[DP0 + j - x[i]];
      }
    } else {
      for(int j = DP0; j >= -DP0 + x[i]; j--) {
        dp[DP0 + j] += dp[DP0 + j - x[i]];
      }
    }
  }
  printf("%lld\n", dp[DP0] - 1);
}
 
void input() {
  scanf("%d%d", &N, &A);
  REP(i, N) scanf("%d", x + i);
}
 
int main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{

	private void solve() {
		int n=gInt(),a[]=ints(n).toArray();
		{
			int[]b=Arrays.stream(a).sorted().toArray();
			Arrays.setAll(a,i->Arrays.binarySearch(b,a[i]));
		}
		System.out.println(REPS(n).map(i->Math.abs(a[i]-i)%2).sum()/2);
	}


	public static void main(String[]$){
		new Main().solve();
	}

	static Scanner s=new Scanner(System.in);


	static int gInt(){
		return s.nextInt();
	}
	static long gLong(){
		return s.nextLong();
	}
	static long gDouble(){
		return s.nextLong();
	}


	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{

		int to,cur,d;

		Range(int from,int to,int d){
			this.cur=from-d;
			this.to=to;
			this.d=d;
		}

		Range(int n){
			this(0,n-1,1);
		}

		@Override
		public Iterator<Integer> iterator(){
			return this;
		}

		@Override
		public boolean hasNext(){
			return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
		}

		@Override
		public int nextInt(){
			return cur+=d;
		}
	}


	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}

	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}


	static IntStream ints(int n){
		return REPS(n).map(i->gInt());
	}

	static Stream<String> strs(int n){
		return REPS(n).mapToObj(i->s.next());
	}

}


Measured memory_bytes: 52836
//
// Created by 10034 on 2020/7/29.
//

#include <iostream>
#include <vector>
using namespace std;
vector<int> v;
int main(){

    long long n;
    cin>>n;
//    while(n){
//        v.push_back((n-1)%26);
//        n--;
//        n/=26;
//    }
    while(n){
        int t=n%26;
        if(t==0) {
            v.push_back(26);
            n--;
        }
        else v.push_back(n%26);
        n/=26;
    }
    for(int i=v.size()-1;i>=0;--i){
        printf("%c",v[i]+'a'-1);
    }



    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    string s; cin >> s;
    int K; cin >> K;
    set<string> ans;
    int used[26]; REP(i,26) used[i] = 0; REP(i,s.size()) used[s[i]-'a'] = 1;
    
    REP(i,26){
        if(used[i]){
            REP(j,s.size()){
                if(s[j] == i+'a'){
                    string sub = s.substr(j);
                    REP(k,min((int)sub.size(),K)){
                        ans.insert(sub.substr(0,k+1));
                        if(ans.size() > K) ans.erase(*ans.rbegin());
                    }
                }
            }
        }
        if(ans.size() == K) break;
    }
    cout << *ans.rbegin() << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	final int ROW = 0;
	final int COL = 1;
	final int QUEEN = 1;
	final int X = 2;

	boolean[] row, col, rDia, lDia; // -, |, /, \
	boolean[][] board;
	void run() {
		Scanner scan = new Scanner(System.in);
		board = new boolean[8][8];
		row = new boolean[8];
		col = new boolean[8];
		rDia = new boolean[2 * 8 - 1];
		lDia = new boolean[2 * 8 - 1];

		int k = scan.nextInt();
		for (int i = 0; i < k; i++) {
			int r = scan.nextInt();
			int c = scan.nextInt();
			board[r][c] = true;
			row[r] = true;
			col[c] = true;
			rDia[(c + (8 - 1)) - r] = true;
			lDia[r + c] = true;
		}
		dfs(0);
	}
	void dfs(int r) {
		if (r == 8) {
			for (int i = 0; i < 8; i++) {
				for (int j = 0; j < 8; j++)
					System.out.print(board[i][j] == true ? "Q" : ".");
				System.out.println();
			}
			return;
		}
		if (row[r])
			dfs(r + 1);
		for (int i = 0; i < 8; i++) {
			if (!row[r] && !col[i] && !rDia[(i + (8 - 1)) - r] && !lDia[r + i]) {
				board[r][i] = true;
				row[r] = true;
				col[i] = true;
				rDia[(i + (8 - 1)) - r] = true;
				lDia[r + i] = true;
				dfs(r + 1);
				board[r][i] = false;
				row[r] = false;
				col[i] = false;
				rDia[(i + (8 - 1)) - r] = false;
				lDia[r + i] = false;
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 26180
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	cin >> N;
	vector<ll> A(N);
	for(int i=0;i<N;i++) cin >> A[i];
	
	int sig = 0;
	int cnt = 0;
	for(int i=1;i<N;i++){
		int s0 = A[i] - A[i-1];
		if(s0 != 0) s0 /= abs(s0);
		if(sig == 0){
			sig = s0;
			continue;
		}
		if(sig == s0){
			continue;
		}
		if(s0 == 0){
			continue;
		}
		sig = 0;
		cnt++;
	}
	
	cout << (cnt + 1) << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, l = rm()
s = sorted([rr() for _ in range(n)])
print(*s, sep='')


















Measured memory_bytes: 26804
#ABC125C
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
l,r=[0]*(n+1),[0]*(n+1)
for i in range(n):
    l[i+1]=gcd(l[i],a[i])
for i in range(n,0,-1):
    r[i-1]=gcd(r[i],a[i-1])
ans=0
for i in range(n):
    ans=max(ans,gcd(l[i],r[i+1]))
print(ans)

Measured memory_bytes: 16140
a=int(input())
dic={}
dic['AC']=0
dic['WA']=0
dic['TLE']=0
dic['RE']=0
for i in range(a):
  s=input()
  dic[s]=dic[s]+1
print("AC x "+str(dic['AC']))
print("WA x "+str(dic['WA']))
print("TLE x "+str(dic['TLE']))
print("RE x "+str(dic['RE']))

Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>
#include <cstring>
#include <unordered_map>

using namespace std;

#define ll long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int main(){
    int A, P;
    cin >> A >> P;

    cout << (A * 3 + P) / 2 << endl;

}

Measured memory_bytes: 256