akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    bool flag =false;
    string s,t;
    cin >> s>> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    for(int i=0;i<min(t.size(),s.size());i++){
        if(s[i]<t[i]){
            flag =true;
            break;
        }
    }
    if(s.size()<t.size() && t.substr(0,s.size())==s){
        flag =true;
    }
    //cout << s <<t <<endl;
    if(flag ==true){
        cout << "Yes"<<endl;
    }else{
        cout << "No" <<endl;
    }
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let x = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
    let y = Array.copy x in
    Array.sort compare y;

    let mi = y.(n / 2) in
    let mx = y.(n / 2 - 1) in

    Array.iter (fun i -> Printf.printf "%d\n" @@ if i <= mx then mi else mx) x
)

Measured memory_bytes: 9172
#include<iostream>
#define MAX_N 110
#define MAX_V 100010

using namespace std;

long long dp[MAX_N][MAX_V+1];
long long w[MAX_N],v[MAX_N],W;
int N;
const long long INF = 1LL<<60;

int main(){
  cin >> N >> W;
  for(int i=0;i < N;i++) cin >> w[i] >>v[i];
  
  for(int i=0;i < MAX_N;i++)for(int j=0;j < MAX_V;j++) dp[i][j] = INF;
  
  dp[0][0] = 0;
  for(int i=0;i < N;i++){
    for(int j=0;j < MAX_V;j++){
      if(j < v[i]){
        dp[i+1][j] = dp[i][j];
      }else{
        dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
      }
    }
  }
  int ans = 0;
  for(int i=0;i < MAX_V;i++)if(dp[N][i] <= W) ans = i;
  
  cout << ans << endl;
   
  return 0;
}

Measured memory_bytes: 89568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

int n;

vector<pair<int, int>> seg;

void init() {
  seg = {{-1, inf}};
}

void solve() {
  while (n--) {
    char c;
    cin >> c;

    if (c == 'W') {
      int id, s;
      cin >> id >> s;

      int left = 0;
      rep(i, seg.size()) {
        if (seg[i].first != -1) {
          left = seg[i].second;
          continue;
        }
        if (s >= seg[i].second - left) {
          seg[i].first = id;
          s -= seg[i].second - left;
        }
        else {
          seg.insert(seg.begin() + i + 1, seg[i]);
          seg[i] = {id, left + s};
          s = 0;
        }
        left = seg[i].second;
        if (!s) break;
      }
    }
    else if (c == 'D') {
      int id;
      cin >> id;
      rep(i, seg.size()) {
        if (seg[i].first == id) seg[i].first = -1;
      }
    }
    else {
      int p;
      cin >> p;

      int left = 0;
      rep(i, seg.size()) {
        if (left <= p && p < seg[i].second) {
          cout << seg[i].first << '\n';
          break;
        }
      }
    }
  }
  //rep(i, seg.size()) cout << seg[i].first << ' ' << seg[i].second << '\n';
  cout << '\n';
}

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

  while (cin >> n, n) {
    init();
    solve();
  }

  




  
  return 0;
}


Measured memory_bytes: 3220
n=int(input())
s=input()
r=s.count('R')
g=s.count('G')
b=s.count('B')
cnt=0
for i in range(n-1):
    for j in range(1, min(i+1, n-i)):
            if (s[i] != s[i-j]) and (s[i] != s[i+j]) and (s[i-j] != s[i+j]):
                cnt += 1
print(r*g*b-cnt)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b > c+d){
    cout<<"Left"<<'\n';
  }
  else if(a+b < c+d){
    cout<<"Right"<<'\n';
  }
  else{
    cout<<"Balanced"<<'\n';
  }
  return 0;
}

Measured memory_bytes: 3644
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    rep(i,h)rep(j,w) cin >> a[i][j];
    vector<P> now, next;
    rep(i,h)rep(j,w) {
        if (a[i][j]%2 == 0) continue;
        if (i == h-1 && j == w-1) continue;
        if (i == h-1) {
            now.emplace_back(i+1,j+1);
            next.emplace_back(i+1,j+2);
            a[i][j]--;
            a[i][j+1]++;
            continue;
        }
        if (j == w-1) {
            now.emplace_back(i+1,j+1);
            next.emplace_back(i+2,j+1);
            a[i][j]--;
            a[i+1][j]++;
            continue;
        }
        now.emplace_back(i+1,j+1);
        next.emplace_back(i+2,j+1);
        a[i][j]--;
        a[i+1][j]++;
    }
    int n = now.size();
    cout << n << endl;
    rep(i,n) {
        cout << now[i].first << " " << now[i].second << " " << next[i].first << " " << next[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 6448
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	int n;
	cin>>n;
	int a[n+1];
	rep(i,n)cin>>a[i+1];
	vector<int>res;
	int b[n+1];
	b[0]=0;
	rep(i,n)b[i+1]=0;
	for(int i=n;i>0;i--){
		b[i]=a[i];
		for(int j=i*2;j<=n;j+=i){
			b[i]^=b[j];
		}
	}
	rep(i,n)if(b[i+1])res.pb(i+1);
	cout<<res.size()<<"\n";
	for(int i:res)cout<<i<<" ";
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

using namespace std;

const int maxN = 200000;
const int maxh = 28;

int N;
int a[maxN];
int b[maxN];

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

	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i];
	for (int i = 0; i < N; i++)
		cin >> b[i];

	int ans = 0;
	for (int h = 0; h <= maxh; h++) {
		int ac[2] = {0, 0};
		for (int i = 0; i < N; i++)
			ac[a[i] >> h & 1] ^= 1;
		int bc[2] = {0, 0};
		for (int i = 0; i < N; i++)
			bc[b[i] >> h & 1] ^= 1;

		vector<int> bv;
		for (int i = 0; i < N; i++)
			bv.push_back(b[i] & (1 << h) - 1);
		sort(bv.begin(), bv.end());

		int c = 0;
		for (int i = 0; i < N; i++) {
			int x = a[i] & (1 << h) - 1;
			c ^= bv.end() - lower_bound(bv.begin(), bv.end(), (1 << h) - x) & 1;
		}

		if (ac[0] * bc[1] + ac[1] * bc[0] + c & 1)
			ans |= 1 << h;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	char a; cin>>a;
	if (a==toupper(a)) cout<<"A"<<endl;
	else cout<<"a"<<endl;
	return 0;
}


Measured memory_bytes: 3512
def main():
    import sys
    input = sys.stdin.readline
    N = input().strip()
    L = len(N)
    N = int(N)
    s = ''
    ans = 0
    for _ in range(L):
        t = 9
        while int(str(t) + s) > N:
            t -= 1
        s = str(t) + s
        ans += t
    print(ans)    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
// unihernandez22
// https://atcoder.jp/contests/abc153/tasks/abc153_b
// greedy

use std::io::stdin;

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

    let words: Vec<i64> = s
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let k = words[1];

    s = String::new();
    stdin().read_line(&mut s).unwrap();

    let mut h: Vec<i64> = s
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    h.sort();
    for _ in 0..k {
        h.pop();
    }

    let mut ans = 0;
    for i in h {
        ans += i;
    }

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


Measured memory_bytes: 10492
#include<bits/stdc++.h>
#include<cstring>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define MOD 1000000007
unordered_map<int, bool> visited;
unordered_map<int, int> path_len;
vector<int> adjList[100005];





int main()
{



	ll n, m;
	cin >> n >> m;

	char arr[n][m];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> arr[i][j];

	int dp[n][m];
	dp[0][0] = 1;
	for (int i = 1; i < m; i++)
	{
		if (arr[0][i] == '#')
			dp[0][i] = 0;
		else
			dp[0][i] = dp[0][i - 1];
	}
	for (int i = 1; i < n; i++)
	{
		if (arr[i][0] == '#')
			dp[i][0] = 0;
		else
			dp[i][0] = dp[i - 1][0];
	}

	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j < m; j++)
		{
			if (arr[i][j] == '#')
				dp[i][j] = 0;

			else
				dp[i][j] = (dp[i - 1][j] % MOD) + (dp[i][j - 1] % MOD);
			dp[i][j] %= MOD;
		}
	}

	cout << dp[n - 1][m - 1] % MOD << endl;

}





Measured memory_bytes: 7424
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int x, i, j, max;
    cin >> x;

    if (x < 4)
    {
        cout << 1 << endl;
        return 0;
    }

    i = 2;
    j = 1;

    while (i <= sqrt(x))
    {
        j = i;
        while (j <= x)
        {
            j *= i;
        }
        if (max < j / i)
            max = j / i;

        i++;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end());
  int ans[A[A.size()-1]+1];
  for(int i=0;i<=A[A.size()-1];++i) ans[i] = 0;
  map<int, int> amap;
  for(int i=0;i<N;++i) {
    amap[A[i]]++;
    for(int j=2;A[i]*j<=A[A.size()-1];++j) {
      ans[A[i]*j]++;
    }
  }
  int ans1 = 0;
  for(int i=0;i<=A[A.size()-1];++i) {
    if(amap[i]==1 && ans[i]==0) ans1++;
  }
  cout<<ans1<<endl;
}



Measured memory_bytes: 54736
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

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

    int n; cin >> n;
    int a[n],b[n];

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

    bool is = false;
    for(int i=0;i<n-2;i++){
        if(a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2]) is = true;
    }

    if(is) cout << "Yes\n";
    else cout << "No\n";



    

}


Measured memory_bytes: 3608
#include <stdio.h>
/*
color=0 黒
color=1 白
*/
int main(void)
{
    int ans=0, color, i=0;
    char s[10*10*10*10*10*10];
    scanf("%s", s);

    while(s[i] != '\0'){
        if(i==0){
            if(s[i]=='B') color=0;
            else color=1;
        }
        else if(s[i]=='B' && color==1){
            ans++;
            color=0;
        }
        else if(s[i]=='W' && color==0){
            ans++;
            color=1;
        }
        i++;
    }

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


Measured memory_bytes: 256
n, m = map(int, input().split())
stores = [list(map(int, input().split())) for _ in range(n)]
sorted_sotres = sorted(stores, key=lambda x: x[0])
total = 0
ans = 0
for cost, number in sorted_sotres:
    if number > m:
        ans += cost * m
        break
    elif number == m:
        ans += cost * number
        break
    else:
        ans += cost * number
    m -= number
print(ans)


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a), end(a)

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M);
    REP(i, M) {
        int k;
        cin >> k;
        s[i] = vector<int>(k);
        REP(j, k) cin >> s[i][j];
    }
    vector<int> p(M);
    REP(i, M) cin >> p[i];
    int ans = 0;
    REP(i, 1 << N) {
        vector<bool> b(N);
        REP(j, N) b[j] = (i >> j) & 1;
        bool ok = true;
        REP(j, M) {
            int cnt = 0;
            REP(k, s[j].size()) {
                if (b[s[j][k] - 1]) cnt++;
            }
            if (cnt % 2 != p[j]) ok = false;
        }
        if (ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	while(true)
	{
	  int height, width;
	  cin >> height >> width;
	  if(width == 0 && height == 0) break;
	  else
	  {
	    for(int x = 0; x < width; x++) cout << "#";
	    cout << endl;
	    
	    for(int y = 1; y < height - 1; y++)
	    {
	      cout << "#";
	      
	      for(int x = 1; x < width - 1; x++)
	      {
	        cout << ".";
	      }
	      cout << "#" << endl;
	    }
	    
	    for(int x = 0; x < width; x++) cout << "#";
	    cout << endl << endl;
	  }
	}
	
}


Measured memory_bytes: 3080
/*********************************************
* 20.05.19 AtCoder Beginner Contest 153
* 
* 
*********************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define et "\n"

class CRun{
private:
    void IO_faster();
public:
    char problem_num;
    
    CRun(){
        problem_num = 'C';
    }; 
    ~CRun(){};
    void build();
    void solve_A(); void solve_B(); void solve_C(); 
    void solve_D(); void solve_E(); void solve_F();
};

void CRun::IO_faster(){
    ios::sync_with_stdio(0); cin.tie(NULL);
}

/*********************************************
A - Serval vs Monster
敵の体力H
味方の攻撃1回で体力をA減らせる
勝つための攻撃回数は？
*********************************************/
void CRun::solve_A(){
    int H; cin >> H;
    int A; cin >> A;
    
    int ans = 0;
    //ans += (H % A > 0 ? H / A + 1 : H / A);
    ans += (H - 1) / A + 1;
    cout << ans;
}

/*********************************************
B - Common Raccoon vs Monster
モンスターの体力H
N種類の攻撃で敵のHPをAN減らせる
同じ攻撃を使わずに敵を倒せるか？
*********************************************/
void CRun::solve_B(){
    
    int H; cin >> H;
    int N; cin >> N;
    int A[N]; rez(i,N) cin >> A[i];
    
    int sum = 0;
    for (auto &ix : A) sum += ix;
    
    string ans[] = {"Yes", "No"};
    if (sum >= H) {
        cout << ans[0];
    }
    else {
        cout << ans[1];
    }
    
}

/*********************************************
C - Fennec vs Monster
N개체의 적, H_N 만큼의 체력
공격 : 적을 1개체 골라서 체력을 1만큼 줄임
필살 : 적을 1개체 골라서 체력을 0으로 만듦
K회만큼 필살기를 쓸 수 있을 때, 승리하는 공격의 최소횟수는?
*********************************************/
void CRun::solve_C(){
    this->IO_faster();
    int enemy_num; cin >> enemy_num;
    int ultimate_cnt; cin >> ultimate_cnt;
    int enemy_hp[enemy_num]; rez(i,enemy_num) cin >> enemy_hp[i];
    
    ll ans = 0;
    sort(enemy_hp, enemy_hp + enemy_num, greater<int>());
    for (int ix = ultimate_cnt; ix < enemy_num; ix++) {
        ans += enemy_hp[ix];
    }
    cout << ans;
}

/*********************************************

*********************************************/
void CRun::solve_D(){
    
}

/*********************************************

*********************************************/
void CRun::solve_E(){
    
}

/*********************************************

*********************************************/
void CRun::solve_F(){
    
}

int main(){
    CRun run;
    switch (run.problem_num) {
        case 'A' : run.solve_A();
        case 'B' : run.solve_B();
        case 'C' : run.solve_C();
        case 'D' : run.solve_E();
        case 'E' : run.solve_D();
        case 'F' : run.solve_F();
    }
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
typedef long long llong;
using namespace std;
const llong DIV = 1000000007;

llong mod_pow(llong M, llong N, llong mod = DIV)
{
	if (N == 0)
	{
		return 1;
	}
	if (N == 1)
	{
		return M;
	}

	llong ret = mod_pow(M, N / 2, mod);
	ret = ret * ret % mod;

	if (N & 1)
	{
		ret = (ret * M) % mod;
	}

	return ret;
}

llong ncr(llong N, llong r, llong mod = DIV)
{
	r = min(r, N - r);
	llong ret = 1;
	for (int i = 1; i <= r; i++)
	{
		ret = ret * (N - i + 1) % mod;
		ret = ret * mod_pow(i, mod - 2) % mod;
	}
	return ret;
}

int main()
{
	llong N,M;
	vector<llong> Ss,Ts;
	cin>>N>>M;
	for(llong i=0;i<N;i++){
		int s;
		cin>>s;
		Ss.push_back(s);
	}
	for(llong i=0;i<M;i++){
		int t;
		cin>>t;
		Ts.push_back(t);
	}
	vector<vector<llong> > dp (N,vector<llong>(M,0));
	
	dp[0][0] = 1;
	if (Ss[0]==Ts[0]){
		dp[0][0]=2;
	}
	for(llong i=1;i<N;i++){
		dp[i][0]=dp[i-1][0];
		if(Ss[i]==Ts[0]){
			dp[i][0]+=1;
		}
	}
	for(llong i=1;i<M;i++){
		dp[0][i]=dp[0][i-1];
		if(Ss[0]==Ts[i]){
			dp[0][i]+=1;
		}
	}
	int n=1,m=1;
	for(llong n=1;n<N;n++){
		for(llong m=1;m<M;m++){
			if(Ss[n-1]==Ts[m]){

			}
			dp[n][m] = (dp[n][m-1]+dp[n-1][m]+DIV-dp[n-1][m-1])%DIV;
			if(Ss[n]==Ts[m]){
				dp[n][m] += dp[n-1][m-1];
				dp[n][m] = dp[n][m]%DIV;
			}
		}
 
	}
	cout<<dp[N-1][M-1]<<endl;
	return 0;
}

Measured memory_bytes: 31616
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

#include <bits/stdc++.h>

#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
typedef long long Long;
typedef double Double;

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

bool isSet(Long n, int b) { return (n >> b) & 1LL; }

void printRow(int x) { cout << bitset<5>(x).to_string() << endl; }

void printMat(const vector<Long>& mat) {
  for (auto& x : mat) {
    printRow(x);
  }
}

vector<Long> getRREF(const vector<Long>& mat) {
  vector<Long> res = mat;
  int rank = 0;
  for (int row = 0, col = 63; row < res.size() && col >= 0; --col) {
    for (int i = row; i < res.size(); ++i) {
      if (isSet(res[i], col)) {
        swap(res[row], res[i]);
        break;
      }
    }
    if (!isSet(res[row], col)) continue;
    ++rank;
    for (int i = 0; i < res.size(); ++i) {
      if (i == row) continue;
      if (isSet(res[i], col)) {
        res[i] ^= res[row];
      }
    }

    ++row;
  }

  return res;
}

int getRank(const vector<Long>& mat) {
  int res = 0;
  for (auto& x : mat) {
    res += (x != 0);
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int t;
  cin >> t;

  vector<Long> a;

  string s;
  while (t--) {
    int n;
    cin >> n;
    a.resize(n);
    cin >> a;
    cin >> s;
    vector<Long> zeroes;
    vector<Long> all;
    bool winner = 0;
    for (int i = sz(s) - 1; i >= 0; --i) {
      if (s[i] == '0') {
        zeroes.emplace_back(a[i]);
      }
      all.emplace_back(a[i]);
      zeroes = getRREF(zeroes);
      all = getRREF(all);
      if (getRank(zeroes) != getRank(all)) {
        winner = 1;
        break;
      }
    }
    cout << winner << endl;
  }

  return 0;
}

Measured memory_bytes: 3708
#include <iostream>

using namespace std;

int main(){
    int n, nr, ncur=1, rez=0;
    cin>>n;
    for(int i=0; i<n; ++i){
        cin>>nr;
        if(nr!=ncur) rez++;
        else ncur++;
    }
    if(rez==n) cout<<-1;
    else cout<<rez;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  int max = 0;
  int min = pow(10, 9)+1;
  
  for (int i = 0; i < N; i++) {
    if (vec.at(i) > max) {
	  max = vec.at(i);
    }
    if (vec.at(i) < min) {
      min = vec.at(i);
    }
  }
  cout << max - min << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
a = list(map(int, input().split()))
p1, p2 = a[:2], a[2:]

h1, h2 = p2[0] - p1[0], p2[1] - p1[1]
print(p2[0] - h2, p2[1] + h1, p1[0] - h2, p1[1] + h1)


Measured memory_bytes: 12508
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define re register
#define LL long long
#define N 2005
#define Maxn 4000000
using namespace std;
const int Mod=1e9+7;
int n,k;
LL f[N][N],fac[Maxn+5],inv_fac[Maxn+5];
inline LL C(int n,int m){ return (((fac[m]*inv_fac[n])%Mod)*inv_fac[m-n])%Mod; }
LL power(LL x,int P){
	LL ans=1,m=x;
	while(P){
		if(P&1) (ans*=m)%=Mod;
		P>>=1;(m*=m)%=Mod;
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&k);
	if(k==1){ printf("%d\n",1); return 0; }
	fac[0]=1; for(re int i=1;i<=Maxn;++i) fac[i]=(fac[i-1]*i)%Mod;
	inv_fac[Maxn]=power(fac[Maxn],Mod-2); for(re int i=Maxn-1;i>=0;--i) inv_fac[i]=(inv_fac[i+1]*(i+1))%Mod;
	f[0][0]=1;
	for(re int i=1;i<=n;++i){
		for(re int j=0;j<=i;++j){
			f[i][j]=f[i-1][j];
			if(!j) continue;
			(f[i][j]+=f[i][j-1]*(n-j+1)%Mod*C(k-2,n-i+(n-j+1)*(k-1)-1)%Mod)%=Mod;
		}
	}
	printf("%lld\n",f[n][n]);
	return 0;
}

Measured memory_bytes: 94080
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

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

const int MAX = 10;

int main()
{
    int n;
    while(cin >> n && n)
    {
        int ice[MAX] = {};
        int t;
        REP(n){cin >> t; ice[t]++;}

        REP(MAX){ rep(j,ice[i]) cout << "*"; if(ice[i] == 0) cout << "-"; cout << endl;}

    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    int minus = 0;
    ll sum = 0;
    ll num_s = INF;
    rep(i, N) {
        cin >> A[i];
        if (A[i] < 0) {
            minus++;
            sum -= A[i];
        }
        else {
            sum += A[i];
        }
        num_s = min(num_s, abs(A[i]));
    }

    if (minus % 2 == 1) {
        sum -= (num_s * 2);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1024
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a = int(input())
b = int(input())
if a>b:
    print("GREATER")
elif a == b:
    print("EQUAL")
else:
    print("LESS")

Measured memory_bytes: 12400
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll mt[111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n),B(n);
  ll maa=0,mab=0;
  for(auto &a:A){cin>>a;maa = max(maa,a);}
  for(auto &a:B){cin>>a;mab = max(mab,a);}
  if(maa != mab){
    cout<<0<<endl;
    return 0;
  }
  mt[0] = A[0];
  for(int i=1;i<n;i++){
    if(A[i] != A[i-1])
      mt[i] = A[i];
  }
  if(mt[n-1] && mt[n-1] != B[n-1]){
    cout<<0<<endl;
    return 0;
  }
  mt[n-1] = B[n-1];
  for(int i=n-2;i>=0;i--){
    if(mt[i]){
      if(B[i] < mt[i]){
	cout<<0<<endl;
	return 0;
      }
    }
    if(B[i]!=B[i+1]){
      if(mt[i] && mt[i] != B[i]){
	cout<<0<<endl;
	return 0;
      }
      mt[i] = B[i];
    }
  }

  ll ret = 1;
  for(int i=0;i<n;i++){
    if(mt[i])continue;
    ret *= min(A[i],B[i]);
    ret %= MOD;
  }

  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int color[202020];
vector<vector<int>> G;
int even = 0, odd = 0;
void dfs(int v, int par, int d){
    if(color[v] == -1){
        color[v] = d;
        if(d & 1) odd++;
        else even++;
    }
    for(auto nv : G[v]){
        if(nv == par) continue;
        dfs(nv, v, d^1);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    G.resize(N);
    REP(i,N-1){
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    memset(color, -1, sizeof(color));

    color[0] = 0;
    even++;
    dfs(0, -1, 0);
    vector<int> num[3];
    for(int i=1;i<=N;i++){
        num[i%3].push_back(i);
    }
    vector<int> ans(N);
    if(N/3 < odd && N/3 < even){
        REP(i,N){
            if(!num[color[i]+1].empty()){
                ans[i] = num[color[i]+1].back();
                num[color[i]+1].pop_back();
            }
            else{
                ans[i] = num[0].back();
                num[0].pop_back();
            }
        }
    }
    else if(N / 3 >= odd){
         REP(i,N){
            if(color[i]){
                ans[i] = num[0].back();
                num[0].pop_back();
            }
            else{
                if(!num[2].empty()){
                    ans[i] = num[2].back();
                    num[2].pop_back();
                }
                else if(!num[1].empty()){
                    ans[i] = num[1].back();
                    num[1].pop_back();
                }
                else{
                    ans[i] = num[0].back();
                    num[0].pop_back();
                }
            }
        }
    }
    else{
        REP(i,N){
            if(!color[i]){
                ans[i] = num[0].back();
                num[0].pop_back();
            }
            else{
                if(!num[2].empty()){
                    ans[i] = num[2].back();
                    num[2].pop_back();
                }
                else if(!num[1].empty()){
                    ans[i] = num[1].back();
                    num[1].pop_back();
                }
                else{
                    ans[i] = num[0].back();
                    num[0].pop_back();
                }
            }
        }
    }
    REP(i,N) cout << ans[i] << " ";
    cout << endl;
}


Measured memory_bytes: 18936
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int s = scan.nextInt();
        //System.out.println("k = " + k);
        //System.out.println("s = " + s);
        if(k >= s){
            System.out.println((s + 2) * (s + 1) / 2);
        }else{
            int ans = 0;
            for(int x = 0; x <= k; x++){
                for(int y = 0; y <= k; y++){
                    int z = s - x - y;
                    if(z >= 0 && z <= k){
                        ans++;
                    }
                }
            }
            System.out.println(ans);
        }
    }
}

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

int main() {
	// your code goes here
	int a,b,d,r;
	double f;
	cin>>a>>b;
	    d=a/b;
	    r=a%b;
	    f=1.0*a/b;
	
	cout<<d<<" "<<r<<" ";
	printf("%.5lf\n",f);
	
	return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;

int main() {
    string S;
    cin >> S;
    bool res = true;
    REP(i, 4) {
        int count = 0;
        REP(j, 4) {
            if(S[i] == S[j]) {
                count++;
            }
        }
        res = res && count == 2;
    }
    if(res) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    sx--; sy--; gx--; gy--;
    vector<vector<bool>> avail(H,vector<bool>(W));
    for(int i=0; i<H; i++){
        string s;
        cin >> s;
        for(int j=0; j<W; j++) avail[i][j] = (s[j] == '.');
    }

    int dx[] = {-1, 1, 0, 0};
    int dy[] = {0, 0, -1, 1};
    auto inside = [&](int i, int j){ return i>=0 && i<H && j>=0 && j<W && avail[i][j]; };

    vector<vector<int>> dist(H, vector<int>(W, 1e9));
    queue<pair<int, int>> que;
    que.emplace(sx, sy);
    dist[sx][sy] = 0;

    while(que.size()){
        auto [i, j] = que.front(); que.pop();
        for(int k=0; k<4; k++) for(int d=1; d<=K; d++){
            int x = i+d*dx[k], y = j+d*dy[k];
            if(!inside(x, y) || dist[x][y] <= dist[i][j]) break;
            if(dist[x][y] == 1e9){
                dist[x][y] = dist[i][j] + 1;
                que.emplace(x, y);
            }
        }
    }

    int ans = dist[gx][gy];
    if(ans == 1e9) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11340
from heapq import *
def dijkstra(s, n, w, cost):
    #s:始点,n:頂点数,w:辺の数,cost:辺ijの重み
    ans = [float('inf')] * n #最短距離の記録
    d = [[float('inf'), i] for i in range(n)]
    used = [False] * n #一度最短距離を確定した頂点はもう見ない
    ans[s] = 0
    d[s][0] = 0
    heapify(d)

    while d:
        D, V = heappop(d)
        if used[V]:continue
        used[V] = True

        for t, distance in cost[V]:
            ans[t] = min(ans[t], D + distance)
            heappush(d, [ans[t], t])
    return ans

v, e, r = map(int,input().split())
route_list=[[] for i in range(v)]#辺の移動の際のコスト

for i in range(e):
    s,t,d=map(int,input().split())
    route_list[s].append((t,d))
#print(route_list)

ans = dijkstra(r, v, e, route_list)

for i in ans:
    if i == float('inf'):
        print('INF')
    else:
        print(i)


Measured memory_bytes: 107980
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		long power = 1;
		int count = sc.nextInt();
		for(int i=1;i<=count;i++){
			power *= i;
			if(power > 1000000007){
				power %= 1000000007;
			}
		}
		System.out.println(power);
	}
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
}

Measured memory_bytes: 20948
#include <stdio.h>

int main(){
  int n[3],i,f=0;
  for(i=0;i<3;i++){
    scanf("%d",&n[i]);
  }
  for(i=0;i<3;i++){
    if(n[i]==n[(i+1)%3]) f++;
  }
  if(f==1){
    printf("Yes");
  }else{
    printf("No");
  }
  return(0);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int a,b;
    cin >>a>>b;
    if(a*b%2==0) cout<<"Even";
    if(a*b%2!=0) cout<<"Odd";

    return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

#define MAX 1010
signed main() {
	for (int n; cin >> n&&n;) {
		vector<tuple<int, int, int, int>> t(n);
		bool flag = true;
		rep(h, 0, n) {
			int i, p, q, r; cin >> i >> p >> q >> r;
			t[h] = make_tuple(i, p, q, r);
		}
		int P, Q, R, C; cin >> P >> Q >> R >> C;
		rep(h, 0, t.size()) {
			int i, p, q, r; tie(i, p, q, r) = t[h];
			if (p > P)continue;
			if (q > Q)continue;
			if (r > R)continue;
			if (p * 4 + q * 9 + r * 4 > C)continue;
			cout << i << endl;
			flag = false;
		}
		if (flag)cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
using namespace std;
constexpr int64_t INF = 1000000000;

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

  int32_t N, M;
  cin >> N >> M;
  if (N == M) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
$a = array();
for($i = 0;$i < 5;$i ++) {
	fscanf(STDIN, "%d", $a[$i]);
}

$ret_list = array();
for($j = 0;$j < 5;$j ++) {
	$ret = 0;
	for($i = 0;$i < 5;$i ++) {
		if($i === $j)continue;
		$ret += intval(ceil($a[$i] / 10) * 10);
	}
	$ret += $a[$j];
	$ret_list[] = $ret;
}
print(min($ret_list)."\n");

?>


Measured memory_bytes: 3828
package main

import "fmt"

func main() {
  var n, y int
  fmt.Scan(&n, &y)
  m, g, s := 10000, 5000, 1000
  for mi := 0; mi <= n; mi++ {
    o := n - mi
    for gi := 0; gi <= o; gi++ {
      si := o - gi
      if y == m*mi+g*gi+s*si {
        fmt.Println(mi, gi, si)
        return
      }
    }
  }
  fmt.Println(-1, -1, -1)
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		for (int i=A; i<=B; i++) {
			if (i<A+K || i>B-K) System.out.println(i);
		}

	}
}


Measured memory_bytes: 22612
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

lint dp[51][51][2525];

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

    int n, a;
    cin >> n >> a;

    vector<int> x(n);
    rep(i, n){
        cin >> x[i];
    }

    dp[0][0][0] = 1;

    rep(i, n){
        rep(j, i + 1){
            rep(k, 2501){
                dp[i + 1][j][k] += dp[i][j][k];
                if(k + x[i] < 2525){
                    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
                }
            }
        }
    }

    lint ans = 0;
    reps(j, n){
        ans += dp[n][j][j * a];
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 49664
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define pb push_back
typedef long long ll;
const int MAXN = 1e3 + 5;
const int MOD = 1e9 + 7;

using namespace std;
    

int main()
{
  

ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

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

int ans = (3 * a + b) / 2;
cout << ans ;

}

Measured memory_bytes: 256
use std::io::{stdin, stdout, Write};
use std::collections::HashMap;

fn main() {
    let out = stdout();
    let mut out = out.lock();
    let mut first_line = String::new();
    stdin().read_line(&mut first_line).unwrap();
    let n: usize = first_line.trim().parse().unwrap();

    let mut second_line = String::new();
    stdin().read_line(&mut second_line).unwrap();
    let v: Vec<&str> = second_line.split_whitespace().collect();
    let mut map =HashMap::new();
    for i in 0..n {

        if map.contains_key(v[i]) {
            write!(out, "NO").unwrap();
            return;
        }
        map.insert(v[i], "");
    }
    write!(out, "YES").unwrap();
}


Measured memory_bytes: 27136
N,M,L,Q;
D[301][301];
i,j,k;
a,b,c;
main()
{
	scanf("%d%d%d",&N,&M,&L);
	for(i=1;i<=N;i++)for(j=i+1;j<=N;j++)D[i][j]=D[j][i]=1000000001;
	for(i=0;i<M;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		D[a][b]=D[b][a]=c;
	}
	for(k=1;k<=N;k++)for(i=1;i<=N;i++)for(j=1;j<=N;j++)
		if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
	for(i=1;i<=N;i++)for(j=i+1;j<=N;j++)
	{
		D[i][j]=D[j][i]=D[i][j]>L?1000000000:1;
	}
	for(k=1;k<=N;k++)for(i=1;i<=N;i++)for(j=1;j<=N;j++)
		if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
	scanf("%d",&Q);
	for(i=0;i<Q;i++)
	{
		scanf("%d%d",&a,&b);
		printf("%d\n",D[a][b]<1000000000?D[a][b]-1:-1);
	}
}

Measured memory_bytes: 768
n = int(input())
b = list(map(int, input().split()))

ans = []

k = 0
# try:
while True:
    a = -1
    for k in range(len(b)):
        if b[k] == k+1:
            a = k
#     print(a, b, ans)
    if a == -1:
        ans = [-1]
        break
    else:
        b.pop(a)
        ans.append(a+1)
        if len(b) == 0:
            break
            
for a in ans[::-1]:
    print(a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main()
{
    int n;
    cin >> n;
    float a[n];
    REP(i,n){
        cin >> a[i];
    }
    sort(a, a + (sizeof(a) / sizeof(a[0])));
    float ans = (a[0] + a[1]) / 2;
    if(n>2){
        REP2(i,2,n){
            ans = (ans + a[i]) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n; cin>>n;
	int t;
	std::map<int, int> map;
	for(int i=0; i<n; i++)
	{
		cin>>t;
		map[t]++;
	}
	cout<<map.size();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <stdio.h>
#define ll long long
#define S second
#define F first
using namespace std;
const ll N = 1e5 + 100, P = 1e9 + 7;

int n;
int t[N];

int main(){
    ios_base::sync_with_stdio(false);
   // freopen("crypt.in", "r", stdin);
   // freopen("crypt.out", "w", stdout);
    ll ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> t[i];
    }
    for(int i = 1; i <= n; i++){
        if(t[t[i]] == i) ans++;
    }
    cout << ans / 2;
}


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

 
 
int main() {
int n;
    cin>>n;
    int A[n],count=0;
    for(int i=0;i<n ;i++){
        cin>>A[i];
    }
    for(int i=0;i<n ;i++){
       int L = A[i];
        int M =sqrt(L);
        for(int x=2;x<=M;x++){
            if(L%x==0){
                count--;
                break;
            }
           
    }count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int c=b,l=0;
	while(c) l++,c/=10;
	for(int i=0;i<l;i++) a*=10;
	a+=b;
	if((int)sqrt(a)==(double)sqrt(a)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
data=[]

while True:
    x = list(map(int, input().split()))
    if x[0] ==0 and x[1] == 0:
        break

    if x[0] > x[1]:
        temp = x[0]
        x[0] = x[1]
        x[1] = temp

    data.append(x)

for i in data:
    print(*i)


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int a, b; cin >> a >> b;
  if(a+b == 15) cout << "+" << endl;
  else if(a*b == 15) cout << "*" << endl;
  else cout << "x" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

int N, L;
int t[200];

int main() {
    cin >> N >> L;
    rep(i, N) {
        t[i] = L + i;
    }

    // rep(i, N) {
    //     cout << t[i] << endl;
    // }
    int sum = accumulate(t, t + N, 0);
    int ans = 1000000;
    int target_idx;
    rep(i, N) {
        // t[i] を食べる 
        int target = sum - t[i];
        if (ans > abs(sum - target)) {
            ans = abs(sum - target);
            target_idx = i;
        }
    }

    cout << sum - t[target_idx] << endl;
}

Measured memory_bytes: 256
#include <stdio.h> 
#include <algorithm>
int max(int a, int b) {
	return (a > b) ? a : b;
}

int main() {
	int ans = 0, N = 0, H[20] = {}, Hmax = -1;
	scanf("%d",&N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &H[i]);
		Hmax = max(Hmax, H[i]);
		if (Hmax == H[i])ans += 1;
	}
	printf("%d", ans);
	return 0;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    bool dp[k + 1];
    memset(dp, false, sizeof(dp));

    for (int i = 1; i <= k; i++) {
        for (auto &e: a) {
            if (i - e < 0) break;
            dp[i] |= !dp[i - e];
        }
    }

    cout << ((dp[k]) ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 384