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

#define MAX 300

class Stack{
    private:
        int top = 0;
        int stack[MAX];
    
    public:
        void push(int x){
            if(isfull()){
                runtime_error("size exceeded");
            }else{
                top += 1;
                stack[top] = x;
            }
        }
        
        int pop(){
            if (isempty()){
                runtime_error("no data in stack");
            }else{
                top -= 1;
                return stack[top+1];
            }
        }
        
        bool isempty(){
            return top == 0;
        }
        
        bool isfull(){
            return top == MAX;
        }
};

int main(void){
    string c;
    Stack s;
    
    while (cin >> c){
        if (c == "+"){
            int a = s.pop();
            int b = s.pop();
            s.push(b + a);
        }else if(c == "-"){
            int a = s.pop();
            int b = s.pop();
            s.push(b - a);
        }else if(c == "*"){
            int a = s.pop();
            int b = s.pop();
            s.push(b * a);
        }else{
            s.push(stoi(c));
        }
    }
    
    cout << s.pop() << endl;
    
    return 0;
}


Measured memory_bytes: 3172
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MAXN 100005
using namespace std ;

int n,x,y,t;

struct DATA{
	int x,y,t;
	bool operator <(const DATA v)const{return t<v.t;}
} A[MAXN];

inline int red(){
	int Res; char ch; bool flg; Res=flg=0;
	while (ch=getchar(),ch<48||57<ch) flg^=!(ch^'-'); Res=(ch&15);
	while (ch=getchar(),47<ch&&ch<58) Res=(Res<<1)+(Res<<3)+(ch&15);
	if (flg) return -Res; return Res;
}

int abs_(int x){
	if (x<0) return -x; return x;
}

int get(int x,int y,int x_,int y_){
	return abs_(x-x_)+abs_(y-y_);
}

int main(){
	n=red();
	for (int i=1;i<=n;i++) A[i].t=red(),A[i].x=red(),A[i].y=red();
	sort(A+1,A+1+n);
	for (int i=1;i<=n;i++){
		int len=get(x,y,A[i].x,A[i].y);
		if (!(len<=A[i].t-t&&(len&1)==((A[i].t-t)&1))){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0 ;
}

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

class SegTree{
private:
  int n;
  // 1-index (tree[0] is dummy), leaves are tree[n]-tree[2n-1]
  vector<int> tree;
  const int defVal = 0;
public:
  SegTree(int _n){
    int t;
    t = 1;
    while (t<_n) t*=2;
    n = t;
    tree = vector<int>(2*n, defVal);
    //cerr << "finish init" << endl;
    //cerr << "tree size is " << 2*n << endl;
  }
  // stab function
  void add(int l, int r, int x){ return _add(l,r,x,1,0,n);}
  void _add(int l, int r, int x, int k, int kl, int kr){
    //cerr << "add: "<<l<<" "<<r<<" "<<x<<" "<<k<<" "<<kl<<" "<<kr<<endl;
    if (kr<=l || r<=kl) return;
    else if (l<=kl && kr<=r){
      tree[k] += x;
      return;
    } else {
      if (tree[k]!=defVal){
        tree[k*2]+=tree[k]; tree[k*2+1]+=tree[k];
        tree[k]=defVal;
      }
      _add(l,r, x, k*2, kl,(kl+kr)/2);
      _add(l,r, x, k*2+1, (kl+kr)/2,kr);
    }
  }
  int get(int i){
    return _get(i,1,0,n);
  }
  int _get(int i, int k, int kl, int kr){
    //cerr << "get: "<<i<<" "<<k<<" "<<kl<<" "<<kr<<endl;
    if (k>=n) return tree[k];
    if (i<(kl+kr)/2) return tree[k]+_get(i, k*2, kl,(kl+kr)/2);
    else return tree[k]+_get(i, k*2+1, (kl+kr)/2,kr);
  }
  // debug
  void print(){
    cerr << "debug: ";
    for (int i=1; i<2*n; i++){
      if (i==n) cout << "| ";
      if (tree[i]==defVal) cout << "DV ";
      else cout << tree[i] << " ";
    }
    cout << endl;
  }
};

int main(void){
  int n,q;
  SegTree *st;
  
  cin >> n >> q;
  st = new SegTree(n);
  for (int i=0; i<q; i++){
    int c,s,t,x,id;
    cin >> c;
    if (c==0){
      cin >> s >> t >> x;
      st->add(s-1,t,x);
    }
    else if (c==1){
      cin >> id;
      cout << st->get(id-1) << endl;
    }
    else cout << "illegal command" << endl;
    //st->print();
  }
  return 0;
}


Measured memory_bytes: 4992
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    S = input().rstrip()

    words = ['dream','dreamer','erase','eraser']

    res = 'YES'

    pre = S
    now = S

    while True:
        for i in range(4):
            word = words[i]
            N = len(word)
            M = len(now)
            if N <= M:
                r = now[M-N:]
                if r == word:
                    now = now[:M-N]
        if now == '':
            break
        elif now == pre:
            res = 'NO'
            break
        else:
            pre = now

    print(res)



main()


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

struct face {
    int top, w, s, e, n, bottom;
};

int main () {
    face d;
    cin >> d.top >> d.s >> d.e >> d.w >> d.n >> d. bottom;

    char op;
    while (cin >> op) {
        int temp;
        if (op == 'N') {
            temp = d.top;
            d.top = d.s;
            d.s = d.bottom;
            d.bottom = d.n;
            d.n = temp;
        } else if (op == 'S') {
            temp = d.top;
            d.top = d.n;
            d.n = d.bottom;
            d.bottom = d.s;
            d.s = temp;
        } else if (op == 'E') {
            temp = d.top;
            d.top = d.w;
            d.w = d.bottom;
            d.bottom = d.e;
            d.e = temp;
        } else if (op == 'W') {
            temp = d.top;
            d.top = d.e;
            d.e = d.bottom;
            d.bottom = d.w;
            d.w = temp;
        }
    }
    cout << d.top << '\n';
}


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

const int TLE = 1001;

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

  int m = TLE;
  for (int i = 0; i < N; ++i) {
    int c, t;
    cin >> c >> t;
    if (t <= T) {
      m = min(m, c);
    }
  }
  if (m == TLE) {
    cout << "TLE" << endl;
  } else {
    cout << m << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

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

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

x = 1
for a in A:
    if a == x:
        x += 1

if x == 1:
    print(-1)
else:
    print(n - x + 1)



Measured memory_bytes: 18088
import numpy as np
x1, y1, x2, y2 = map(int, input().split())
p1=np.array([x1, y1])
p2 = np.array([x2, y2])
v21=p1-p2
p3=np.dot(np.array([[0,1],[-1,0]]), v21)+p2
p4=p3+v21
print(p3[0], p3[1], p4[0], p4[1])

Measured memory_bytes: 12520
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<random>

//#include"gap.h"

using namespace std;

const int int_max = 2147483647;


/*
const long long mod = 10e9 + 7;


long long dps(int K, const vector<vector<int>>&graph, int now, int from){

	int can_color_num;
	if(K == -1){
		can_color_num = K-1;
	}
	else{
		can_color_num = K - 2;
	}

	if(graph[now].size() > K){
		return 0;
	}
	else{
		long long case_num = 1;

		for(auto e : graph[now]){
			if(e == from) continue;

			case_num *= can_color_num;
			can_color_num--;
			case_num %= mod;
		}

		for(auto e : graph[now]){
			if(e == from) continue;

			case_num *= dps(K, graph, e, now);
			case_num %= mod;
		}

		return case_num;
	}
}

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

	vector<vector<int>> graph(N);

	for(int i=0; i<N; i++){
		int a, b;
		cin >> a >> b;

		a--; b--;

		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	long long ans = K * dps(K, graph, 0, -1);
	ans %= mod;
	cout << ans << endl;


	return 0;
}
*/



//数あてゲーム

int main(){
	int N;
	int p[200][3];
	int ans[200];

	cin >> N;
	for(int i=0; i<N; i++){
		for(int j=0; j<3; j++){
			cin >> p[i][j];
		}
		ans[i] = 0;
	}

	for(int i=0; i<3; i++){
		for(int j=0; j<N; j++){

			bool db = false;
			for(int k=0; k<N; k++){
				if(j == k) continue;

				if(p[j][i] == p[k][i]) db = true;
			}

			if(db == false){
				ans[j] += p[j][i];
			}
		}
	}

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


	return 0;
}



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


int main(){
    int N,K;
    cin >> N >> K;
    int cnt = 0;
    while(N>=K){
        N = (int)N/K;
        cnt++;
    }
    cout << cnt+1 << endl;
}


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

const int N = (int)1e5+5;
int n, a[N][3], dp[N][3];

int solve(int r, int c) {
	if (r == n-1) return 0;
	if (dp[r][c] != -1) return dp[r][c];
	int ret = 0;
	for (int i = 0; i < 3; i++) {
		if (i == c) continue;
		ret = max(ret, solve(r+1, i)+a[r+1][i]);
	}
	return dp[r][c] = ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++) scanf("%d", &a[i][j]);

	memset(dp, -1, sizeof dp);
	int ans = 0;
	for (int i = 0; i < 3; i++)
		ans = max(ans, solve(0, i)+a[0][i]);

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

	return 0;
}

Measured memory_bytes: 8832
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
////////////////いろいろあるよ//////////////////////////////////
int main(){
	long long N,K;
  	cin >> N >> K;
  	long long maxl=0;
  	long long data[K];
  	REP(i,K){
      cin >> data[i];
      if(i!=0){
		maxl = max(maxl,data[i]-data[i-1]);
      }
    }
  
  	long long dis = max(maxl,data[0]+N-data[K-1]);
  
  	cout << N-dis << endl;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"strings"
)

var LowerAlphabets = [...]string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
	"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}

func main() {
	var n int
	fmt.Scan(&n)
	var names []string
	for n > 0 {
		names = append([]string{LowerAlphabets[((n - 1) % 26)]}, names...)
		n = (n-1) / 26
	}
	fmt.Println(strings.Join(names, ""))
}


Measured memory_bytes: 1856
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

const int MOD = 1e9 + 7;

void MAIN() {
  int n; cin >> n;
  vector<int> a(n + 1), d(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    d[i] = a[i] + d[i - 1];
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    ans += (a[i] * ((d[n] - d[i]) % MOD)) % MOD;
    ans %= MOD;
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main(){
    int n, x;
    cin >> n >> x;
    int l[n];
    for(int i = 0; i < n; i++)  cin >> l[i];
    int ans = 1;
    int pos = 0;
    for(int i = 0; i < n; i++){
        pos += l[i];
        if(pos <= x)    ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll count(ll n, ll p) {
	ll ini = n;
	ll ret = 0;
	while(n) {
		ll add = n/p;
		if(p==5)
			add = add / 2;
		ret += add;
		n /= p;
	}
	//printf("ret=%lld at n=%lld, p=%lld\n", ret, ini, p);
	return ret;
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	ll n;
	cin >> n;
	if(n&1)
		return !(cout << 0);
	cout << min(count(n, 5), count(n, 2));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli x=0ll;
    cin>>x;
    lli res=0ll;
    lli d=x/500;
    x=x-(1ll*500*d);
    lli r=x/5;
    cout<<(1ll*d*1000+1ll*r*5)<<endl;
}


Measured memory_bytes: 256
n,m = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))
a = 0
b = 0
Mod = 10**9 + 7

for k in range(1,n+1):
    a += (k-1)*x[k-1] - (n-k)*x[k-1]
for j in range(1,m+1):
    b += (j-1)*y[j-1] - (m-j)*y[j-1]

res = a*b
print(a*b%Mod)

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

using namespace std;


void solve() {
    string s; cin >> s;
    int cnt = 0;
    for (char c: s) if (c=='p') cnt++;
    int res = (int)s.size()/2 - cnt;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct node{
    node *to[26];
    int len,cnt;
    bool ex;
    node(){
        len=0;
        rep(i,26)to[i]=NULL;
        cnt=0;
        ex=false;
    }
};

void add(node *t,string &s,int k){
    if(s.size()==k){
        t->ex=true;
    }
    else{
        int c=s[k]-'a';
        if(t->to[c]==NULL){
            t->to[c]=new node();
            t->to[c]->len=t->len+1;
        }
        add(t->to[c],s,k+1);
    }
    t->cnt=t->ex;
    rep(i,26)if(t->to[i]!=NULL)t->cnt+=t->to[i]->cnt;
}

node *ei(node *t){
    if(t==NULL)return NULL;
    rep(i,26)t->to[i]=ei(t->to[i]);

    int num=0;
    rep(i,26)if(t->to[i]!=NULL)num++;
    if(num!=1)return t;
    rep(i,26)if(t->to[i]!=NULL){
        t->to[i]->cnt+=t->ex;
        return t->to[i];
    }
}



int N;
string S[111111];

int pre[111111];

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

    cin>>N;
    rep(i,N)cin>>S[i];

    node *root=new node();
    rep(i,N)add(root,S[i],0);


    rep(i,N){
        node *t=root;
        rep(j,S[i].size()){
            pre[i]+=t->ex;
            t=t->to[S[i][j]-'a'];
        }
    }

    root=ei(root);


    int Q;cin>>Q;
    while(Q--){
        int k;
        string s;
        cin>>k>>s;k--;
        node *t=root;
        int ans=pre[k];
        while(t->len<S[k].size()){
            int c=S[k][t->len]-'a';
            for(int i=0;s[i]-'a'!=c;i++){
                if(t->to[s[i]-'a']==NULL)continue;
                ans+=t->to[s[i]-'a']->cnt;
            }
            t=t->to[c];
        }
        cout<<ans+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 114204
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

int main(void)
{
        int n;
        int k;
        cin >> n >> k;
        int a;
        int b[200010]={0};
        REP(i,n){
                cin >> a;
                b[a-1]++;
        }
        sort(b,b+n,greater<int>());
        int num;
        for(num=0; num < n; num++){
                if(b[num] == 0) break;
        }

        sort(b,b+n);
        int ans=0;
        int po = num-k;
        for(int i = n-num; i < n-num+po; i++){
                ans+=b[i];
        }

        cout << ans << endl;

        return 0;
}

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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

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

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N, K;
    cin >> N >> K;

    if (K==1) cout << 0 << endl;
    else
    {
        cout << N-K << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    set<int> s;
    for(int i = 0;i < 3;i++)
    {
        int a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << "\n";

    return 0;
}

Measured memory_bytes: 256
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
constexpr ll mod = 1000000007;

int main() {
    string ss, c;
    int t, f, q;
    deque<char> s;
    bool r = false;
    cin >> ss >> q;
    for (auto &e:ss) s.push_back(e);
    for (int i = 0; i < q; i++) {
        cin >> t;
        if (t == 1) {
            r = !r;
        } else if (t == 2) {
            cin >> f >> c;
            if ((!r && f == 1) || (r && f == 2)) s.push_front(c[0]);
            else s.push_back(c[0]);
        } else throw;
    }
    if (r) for (auto i = s.rbegin(); i != s.rend(); i++) cout << *i;
    else for (auto &e:s) cout << e;
    cout << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
               
    // }
    ll n;
    cin>>n;
    map<ll,ll>mp;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        if(mp[i-x]!=0)
        ans+=mp[i-x];
        mp[x+i]++;
    }
    cout<<ans;
    
}

Measured memory_bytes: 26264
#include <bits/stdc++.h>
#define INF 1e18
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    REP(i, N) {
        REP(j, D) cin >> X.at(i).at(j);
    }
    int ans = 0;
    REP(i, N) {
        REP(j, N) {
            if (i >= j) continue;
            int tmp = 0;
            REP(d, D) { 
                tmp += pow(X.at(i).at(d) - X.at(j).at(d), 2);
            }
            float distance = sqrt(tmp);
            int int_distance = (int)distance;
            if (distance == int_distance) ans += 1;
        }
    }
    print(ans);

}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    if left < l:
        left = l
    if right > r:
        right = r

ans = right - left

print(ans + 1 if ans >= 0 else 0)


Measured memory_bytes: 27220
import numpy as np
w,h,n=map(lambda x: int(x), input().split())
lec=np.array([[True for _ in range(w)] for _ in range(h)])
for i in range(n):
    x,y,a=map(lambda x: int(x), input().split())
    if a==1:
        lec[:,:x]=False
    elif a==2:
        lec[:,x:]=False
    elif a==3:
        lec[:y,:]=False
    elif a==4:
        lec[y:,:]=False
print(np.count_nonzero(lec))

Measured memory_bytes: 12444
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	string s;
	cin >> s;
	N = s.size();
	ll sum = 0;
	rep(i, pow(2, N-1)){
		string inte = "";
		inte += s[0];
		int value = i;
		rep(j, N){
			if(value%2 == 1){
				sum += atoll(inte.c_str());
				inte = "";
			}
			inte = inte + s[j+1];
			value /= 2;
		}
		sum += atoll(inte.c_str());
	}
	cout << sum;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)

n,m = map(int,input().split())
path = []
for i in range(m):
    a,b = map(int,input().split())
    path.append((a-1,b-1))

d = [0]*m
uf = UnionFind(n)
for i in range(m-1,-1,-1):
    a,b = path[i]
    if not uf.same(a,b):
        d[i] = uf.size[uf.find(a)]*uf.size[uf.find(b)]
    uf.unite(a,b)
s = [0]*(m+1)
for i in range(m):
    s[i+1] = s[i] + d[i]
print('\n'.join(str(i) for i in s[1:]))


Measured memory_bytes: 35796
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

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


int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N, 0), f(N, 0);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        cin >> f[i];
    }

    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());

    ll l = -1, r = 1e12 + 7;
    while(r - l > 1){
        ll m = (l + r) / 2;
        ll k = K;
        for(int i = 0; i < N; i++){
            ll x = max(a[i] - m / f[i], 0LL);
            k -= x;
        }
        // 足りた
        if(k >= 0){
            r = m;
        }
        else{
            l = m;
        }
    }

    cout << r << endl;


    return 0;
}


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

int main() {
		int n;
		char s[1000];
		cin >> n >> s;
		
		int num[1000] = {};
		for (int i = 0; i < n; i++) {
				if (s[i] == 'I') {
						num[i + 1] = num[i] + 1;
				} else {
					num[i + 1] = num[i] - 1;
				}
		}

		int ans = 0;
	for (int i = 0; i <=  n; i++) {
		ans = max(num[i], ans);
	}	

		cout << ans << endl;

		return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int k=kbd.nextInt();
   int n=kbd.nextInt();
   int[] s = new int[n];
   for(int i=0;i<n;i++){
     s[i]=kbd.nextInt();
}
   int a=0;
   a=k-s[n-1]+s[0];
   for(int i=n-1;i>1;i--){
   int b=s[i]-s[i-1];
          if(s[i]-s[i-1]>a){
       a=s[i]-s[i-1];
     }
   }

   System.out.println(k-a);
}
}


Measured memory_bytes: 66520
#include <stdio.h>
#define MAX 1000000
int f(int a);

int main() {
    int i, j, s, a[MAX];
    if (scanf("%d", &s) == -1) return -1;
    a[0] = s;
    for (i = 1; i < MAX; i++) {
        a[i] =f(a[i-1]);
        for (j = 0; j < i; j++) {
            if (a[i] == a[j]) {
                printf("%d\n", i+1);
                return 0;
            }
        }
    }
    return 0;
}

int f(int a) {
    if (a % 2 == 0) return a / 2;
    return 3 * a + 1;
}

Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll K = 0;
	ll Y = 0;
	ll X = 0;
	//ll m[100000] = {};
	//ll p[100] = {};
	//ll x[100] = {};
	ll *x, *c, *d;
	string S,T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 1;
	ll max = 0;
	int flag = 0;
	//char p;
	cin >> A >> B >> C;
	
	//x = (ll *)malloc(N * sizeof(ll));

	for (int i = 1; i < 101; i++) {

		sum = A * i;
		if (sum % B == C) {
			count = 1;
			break;
		}

	}

	if(count == 1)
	cout << "YES" << endl;
	else
		cout << "NO" << endl;


	return 0;

}



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

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "number", long, "times");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto s = sread();
    long[dchar] alf;
    long ans = 1;
    foreach (e; s)
    {
        alf[e]++;
    }
    sort(cast(ubyte[]) s);
    foreach (e; s.uniq)
    {
        ans *= alf[e] + 1;
        ans %= bignum;
    }
    (ans - 1).writeln();
}

Measured memory_bytes: 2428
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int i, n, least;
	string s;
	cin >> n;
	cin >> s;
	vector<int> lsum(n, 0);
	vector<int> rsum(n, 0);
	if (s[0] == 'W') lsum[0]++;
	for (i = 1; i < n; i++){
		lsum[i] = lsum[i - 1];
		if (s[i] == 'W') lsum[i]++;
	}
	if (s[n - 1] == 'E') rsum[n - 1]++;
	for (i = n - 2; i >= 0; i--){
		rsum[i] = rsum[i + 1];
		if (s[i] == 'E') rsum[i]++;
	}
	least = rsum[0];
	for (i = 1; i < n - 1; i++){
		least = min(least, lsum[i - 1] + rsum[i + 1]);
	}
	least = min(least, lsum[n - 1]);
	cout << least << endl;
	return 0;
}

Measured memory_bytes: 3076
s = list(input())

odd = [0] * len(s)
even = [1] * len(s)

for i, c in enumerate(s):
    if c == 'R':
        even[i + 1] += odd[i]
        odd[i + 1] += even[i]
        odd[i] = even[i] = 0

for i in range(len(s) - 1, -1, -1):
    if s[i] == 'L':
        even[i - 1] += odd[i]
        odd[i - 1] += even[i]
        odd[i] = even[i] = 0

for i in range(len(s)):
    if s[i] == 'R':
        even[i + 1] += odd[i]

    if s[i] == 'L':
        even[i - 1] += odd[i]

print(' '.join([str(x) for x in even]))


Measured memory_bytes: 11944
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#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 rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  reverse(S.begin(), S.end());
  cout<<S<<endl;
}



Measured memory_bytes: 3044
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define set set <ll>
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;
int main()
{
  fast();
  
  
  float n;
  cin >> n;
  float ans = 0;
  f(i,1,n+1)
  {
  	if(i % 2 != 0)
  	{
  		ans++;
  	}
  }
  cout << fixed << setprecision(6) << float(ans/n);
  return 0;
}


Measured memory_bytes: 384
using System;

namespace A
{
    class A
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input), i, j;
            int[,] graph = new int[n, n];
            for (i = 0; i < n; i++)
            {
                string[] input2 = Console.ReadLine().Split(' ');
                if (int.Parse(input2[1])!=0)
                {
                    for (j = 0; j < int.Parse(input2[1]); j++)
                    {
                        graph[int.Parse(input2[0]) - 1, int.Parse(input2[2 + j])-1] = 1;
                    }
                }
            }
            for (i = 0; i < n; i++)
            {
                for (j = 0; j < n; j++)
                {
                    if (j!=0)
                    {
                        Console.Write(" ");
                    }
                    Console.Write(graph[i,j]);
                }
                Console.WriteLine();
            }
        }
    }
}



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

const int N=310;
int n, m, i, j, ans, ma, mai, rest;
int a[N][N], now[N], g[N];
bool ca[N];

int main()
{
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; ++i)
	{
		for (j = 1; j <= m; ++j) scanf("%d", &a[i][j]);
		++g[a[i][1]];
		now[i] = 1;
	}
	
	ans = n;
	rest = m;
	do
	{
		ma = 0; mai = 0;
		for (i = 1; i <= m; ++i)
			if (g[i] > ma)
			{
				ma = g[i];
				mai = i;
			}
		ans = min(ans, ma);
		ca[mai] = 1;
		for (i = 1; i <= n; ++i)
		{
			--g[a[i][now[i]]];
			while (ca[a[i][now[i]]]) ++now[i];
			++g[a[i][now[i]]];
		}
		rest--;
	}
	while (rest > 0);
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r;
    cin >> r;
    double pi = asin(1) * 2;
    cout << r * pi * 2;
    return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>

using namespace std;

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (r <= x && w - r >= x && r <= y && h - r >= y) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}
	


Measured memory_bytes: 3092
#include<stdio.h>
//A is array and N is count
int bubble_sort(int array[],int size){
  int count=0,tmp,i,j;
  for(i=0;i<size;i++){
    for(j=size-1;j>i;j--){
      if(array[j]<array[j-1]){
        tmp=array[j];
        array[j]=array[j-1];
        array[j-1]=tmp;
        count++;
      }
    }
  }
  return count;
}

//int bubble_sort(int array[],int size){
//  int flag=1,count,j,tmp;
//  while(1){
//    flag=0;
//    for(j=size-1;j>=1;j--){
//      if(array[j]<array[j-1]){
//        tmp=array[j];
//        array[j]=array[j-1];
//        array[j-1]=tmp;
//        count++;
//        flag=1;
//      }
//    }
//    if(flag==0) break;
//  }
//  return count;
//}
int main(void){
  int i,size,array[100000],count;
  scanf("%d",&size);
  for(i=0;i<size;i++){
    scanf("%d",&array[i]);
  }
  count = bubble_sort(array,size);
  for(i=0;i<size;i++){
    if(i>0) printf(" ");
    printf("%d",array[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1836
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class abcD {
private:
    vector<vector<long long>> C;
    
    long long binomialCoeff(int n, int k)
    {
        int i, j;
        
        // Caculate value of Binomial Coefficient in bottom up manner
        for (i = 0; i <= n; i++)
        {
            for (j = 0; j <= min(i, k); j++)
            {
                // Base Cases
                if (j == 0 || j == i)
                    C[i][j] = 1;
                    
                    // Calculate value using previosly stored values
                else
                    C[i][j] = C[i-1][j-1] + C[i-1][j];
            }
        }
        
        return C[n][k];
    }
public:
    void solve(istream& in, ostream& out) {
        int N, A, B;
        in >> N >> A >> B;
        vector<long long> v(N);
        for (int i = 0; i < N; ++i) {
            in >> v[i];
        }
        sort(v.begin(), v.end(), greater<long long>());
        double sum = 0;
        for (int i = 0; i < A; ++i) {
            sum += v[i];
        }
        double mean = sum / A;
        
        out.precision(20);
        out << fixed << mean << "\n";
    
        C.assign(N+1, vector<long long>(N+1, 0));
        binomialCoeff(N, N);
        
        int cnt1 = 0, cnt2 = 0;
        for (int i = A-1; i >= 0 && v[i] == v[A-1]; --i) {
            ++cnt1;
        }
        for (int i = 0; i < N; ++i) {
            cnt2 += v[i] == v[A-1];
        }
        
        //cout << cnt1 << " " << cnt2 << endl;
        if (cnt1 == A) {
            long long ways = 0;
            for (int i = A; i <= B; ++i) {
                ways += C[cnt2][i];
            }
            out << ways << "\n";
        } else {
            long long ways = C[cnt2][cnt1];
            out << ways << "\n";
        }
    }
};


int main() {
	std::ios::sync_with_stdio(false);

	abcD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;


int get( string s) {
	if (s == "MON") return 1;
	if (s == "TUE") return 2;
	if (s == "WED") return 3;
	if (s == "THU") return 4;
	if (s == "FRI") return 5;
	if (s == "SAT") return 6;
	return 7;
}

int main () {
   SpeedForce;
	cin >> s;
	int id = get(s);
	id++;
	int res = 1;
	while (id != 14 && id != 7) {
		res++;
		id ++;
	}

	cout << res;

   return Accepted;
}

// B...a

Measured memory_bytes: 18688
def solve(n, A):
    # 方針: 下記のいずれかの条件を満たせばOK
    #  1. 4の倍数の数 == 奇数の数 - 1 and 2の倍数がない
    #  2. 4の倍数の数 >= 奇数の数
    count_odd, count_2n, count_4n = 0, 0, 0
    for a in A:
        if a % 2 == 1:
            count_odd += 1
        elif a % 4 == 0:
            count_4n += 1
        else:
            count_2n += 1
    return 'Yes' if (count_4n == count_odd - 1 and count_2n == 0) or count_4n >= count_odd else 'No'

_n = int(input())
_A = map(int, input().split())
print(solve(_n, _A))

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

int main() {
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i < s.size();i++) {
        if (s.at(i) == '+')
            sum++;
            else
                sum--;
    }
    cout << sum;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX 100000
#define INF 1000000000

typedef struct{
  int value;
  char suit;
}Card;

Card L[MAX], R[MAX];

void merge(Card A[], int left, int mid, int right)
{
  int n1, n2, i, j, k;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++) L[i] = A[left + i];
  for(i = 0; i < n2; i++) R[i] = A[mid + i];

  L[n1].value = INF;
  R[n2].value = INF;

  i = 0;
  j = 0;

  for(k = left; k < right; k++){
    if(L[i].value <= R[j].value){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(Card A[], int left, int right)
{
  int mid;

  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(Card A[], int p, int r)
{
  int n, i, j;
  Card x, tmp;

  x = A[r];
  i = p - 1;

  for(j = p; j < r; j++){
    if(A[j].value <= x.value){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = tmp;

  return i + 1;
}

void quickSort(Card A[], int p, int r){
  int q;

  if(p < r){
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

int main(void){
  int i, n, v, stable = 1;
  char S[10];
  Card X[MAX], Y[MAX];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s %d", S, &v);
    X[i].value = v;
    Y[i].value = v;
    X[i].suit = Y[i].suit = S[0];
  }

  mergeSort(X, 0, n);
  quickSort(Y, 0, n - 1);

  for(i = 0; i < n; i++){
    if(X[i].suit != Y[i].suit){
      stable = 0;
    }
  }

  if(stable == 1) printf("Stable\n");
  else  printf("Not stable\n");

  for(i = 0; i < n; i++){
    printf("%c %d\n", Y[i].suit, Y[i].value);
  }

  return 0;
}



Measured memory_bytes: 4044
#include<iostream>

int main() {

	using namespace std;

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

	if (a == b) {
		cout << "a == b" << endl;
	}else if (a > b) {
		cout << "a > b" << endl;
	}else {
		cout << "a < b" << endl;
	}

	return 0;

}


Measured memory_bytes: 3108
N, x = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()

tmp_total_a = 0
count_happy = 0
for a in a_list:
    tmp_total_a += a
    if tmp_total_a <= x:
        count_happy += 1
    else:
        break

if tmp_total_a < x:
    count_happy -= 1
    
print(count_happy)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int S;
    int W;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.S = sc.nextInt();
        this.W = sc.nextInt();
    }
    
    //解答処理
    private String solve() {
        String answer =  "safe";
        if (S <= W) {
        	answer = "unsafe";
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MM 1e9

string S;

void input() {
    cin >> S;
}

void solve(){
    char tmp='\0';
    bool b=false;
    for(auto c : S) {
        if (tmp=='\0') {
            tmp = c;
            continue;
        }
        if (tmp == c) {
            b=true;
            break;
        } else {
            tmp = c;
        }
    }
    if (b) puts("Bad");
    else puts("Good");
}

int main() {
    input();
    solve();
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
vector<P> factor;
int main() {
	int s;
	cin >> s;
	set<int> st;
	st.insert(s);
	int ans = 1;
	while (ans == st.size()) {
		if (s % 2) s = s * 3 + 1;
		else s /= 2;
		st.insert(s);
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    ll n,m=0,a=0,r=0,c=0,h=0;
    string s;
    cin >> n;
    rep(i,n){
        cin >> s;
        if(s[0]=='M') m++;
        else if(s[0]=='A') a++;
        else if(s[0]=='R') r++;
        else if(s[0]=='C') c++;
        else if(s[0]=='H') h++;
    }
    ll ans=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int l = s.length();
    int i, count=0;
    for(i=0;i<l;i++){
        if(s[i]!=t[i])count++;
    }
    cout << count << endl;
    return 0;
}

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

int main(){
    vector<int> haiku(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> haiku.at(i);
    }

    vector<int> comp1 = {5, 5, 7};
    vector<int> comp2 = {5, 7, 5};
    vector<int> comp3 = {7, 5, 5};

    if (haiku == comp1 || haiku == comp2 || haiku == comp3){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;    
}

Measured memory_bytes: 256
object Main {
    def step(s: (Int, Int, Int), i: Char) = i match {
        case 'N' => (s._2, 5-s._1, s._3)
        case 'E'  => (5-s._3, s._2, s._1)
        case 'W'  => (s._3, s._2, 5-s._1)
        case 'S' => (5-s._2, s._1, s._3)
    }
 
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines
        val nums = in.next.split(" ").map(_.toInt)
        println(nums(in.next.foldLeft((0, 1, 2))(step)._1))
    }
}

Measured memory_bytes: 43992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int dp[9000005];
struct node
{
    int w,q;
} N[3005];
bool cmp(node a,node b)
{
    return a.w<b.w;
}
int main()
{
    int n,t;
    scanf("%d%d",&n,&t);
    for(int i=0; i<n; i++)
        scanf("%d%d",&N[i].w,&N[i].q);
    sort(N,N+n,cmp);
    ll ans=0;
    for(int i=0; i<n; i++)
    {
        for(int j=t; j>=1; j--)
        {
            dp[j+N[i].w]=max(dp[j+N[i].w],dp[j]+N[i].q);
            ans=max<ll>(ans,dp[j+N[i].w]);
        }
    }
    printf("%lld",ans);
    return 0;
}


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

using namespace std;

class Solution {
public:
	void solve() {
		string s;
		cin >> s;
		if(s.length()%2 == 0){
			for(int i=0; i < s.length(); i++){
				if(i % 2 == 0){
					if(s[i] != 'h'){
						cout << "No\n";
						return;
					}
				}else{
					if(s[i] != 'i'){
						cout << "No\n";
						return;
					}
				}

			}
		}else{
			cout << "No\n";
			return;
		}
		cout << "Yes\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256