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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(string S) {
  stack<char> SS;
  int ans = 0;
  for(int i = 0 ; i < S.size() ; i++){
    if( SS.size() == 0 || SS.top() == S[i] ){
      SS.push(S[i]);
    }else{
      ans += 2;
      SS.pop();
    }
  }
  cout << ans << endl;
}

int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}


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

int main(){
    int a,b,c,d,n;
    cin>>n;
    int build[4][3][10] = {{{}}};
    int count=0;
    while(count<n){
        count++;
        cin>>a>>b>>c>>d;
        build[a-1][b-1][c-1]+=d;
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                cout<<" ";
                cout<<build[i][j][k];
            }
            cout<<endl;
        }
        if(i<3) cout<<"####################"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3116
n=int(input())
a=[]

for j in range(0,n):
  a.append(int(input()))
  
x=max(a)
y=a.index(x)
del a[y]
z=max(a)

for i in range(0,n):
  if i!=y:
    print(x)
  else:
    print(z)
  


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 200005

int main(){
sp;
int n,k;
cin>>n>>k;
ll h[n+1];
for(int i=1; i<=n; ++i)cin>>h[i];
ll dp[n+1];
memset(dp,0,sizeof dp);
ll ans=0;
dp[2]=abs(h[1]-h[2]);
for(int i=3; i<=n; ++i){
        dp[i]=1LL<<55;
for(int j=1; j<=k&&i>j; ++j)
    dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
}
cout<<dp[n];
return 0;}


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

bool zcomp(string::iterator first1, string::iterator last1, string::iterator first2) {
    bool flag = true;
    for (auto it1 = first1, it2 = first2; it1 != last1; it1++, it2++) {
        if (*it1 != *it2 && *it2 != '?') {
            flag = false;
            break;
        }
    }
    return flag;
}

int main(void) {
    string s, t;
    set<string> ans;
    cin >> s >> t;
    for (int i = s.size() - t.size(); i >= 0; i--) {
        if (zcomp(t.begin(), t.end(), s.begin() + i)) {
            string temp = s;
            temp.replace(i, t.size(), t);
            replace(temp.begin(), temp.end(), '?', 'a');
            ans.insert(temp);
        }
    }
    cout << (!ans.empty() ? *ans.begin() : "UNRESTORABLE") << endl;
}

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

diff = N - M
for i in range(diff+1):
    for j in range(diff+1):
        flag = True
        for k in range(M):
            if not (B[k] in A[j+k][i:i+M]):
                flag = False
        if flag:
            print('Yes')
            exit(0)

print('No')


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(){
  char s[100010] = {};
  int flag[30] = {};//'a'+iがs[]に含まれればs[i]==1，そうでなければs[i]==0

  scanf("%s", s);

  for(int i = 0; i < strlen(s); i++){
    flag[s[i] - 'a'] = 1;
  }

  for(int i = 0; i < 26; i++){
    if(flag[i] == 0){
      printf("%c\n", 'a' + i);
      return 0;
    }
  }

  printf("None\n");

  return 0;
}


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

void Show(int *A,int N) {
	for (int i = 0;i < N-1;i++)
		cout << A[i] << " ";
	cout << A[N-1]<<endl;
}

int main()
{
	int N, v, j, A[100];
	cin >> N;

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

	Show(A, N);

	for (int i = 1;i < N;i++) {
		v = A[i];
		j = i - 1;
		while (A[j] > v && j >= 0) {
			A[j + 1] = A[j];
			j--;
		}
		A[j+1] = v;
		Show(A, N);
	}
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e6+5;
string s;
int n,m;
map<string, int> ma;
map<string, int>::iterator ite;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  rep(i,n) {
    cin >> s;
    ma[s]++;
  }
  cin >> m;
  rep(i,m) {
    cin >> s;
    ma[s]--;
  }
  int result = 0;
  for(ite = ma.begin(); ite != ma.end(); ++ite) result = max(result, ite->second);
  cout << result << endl;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	if (n % 2 == 0) {
		if (n / 2 >= k) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	else {
		if (n / 2 + 1 >= k) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  string s; cin >> s;
  int K; scanf("%d", &K);
  set<string> cong;
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    for (int len = 1; len <= K; ++len) {
      cong.insert(s.substr(i, len));
    }
  }
  vector<string> v(cong.begin(), cong.end());
  sort(v.begin(), v.end());
  printf("%s\n", v[K - 1].c_str());
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string s,t;
int main(){
	cin>>s>>t;
	bool ok=true;int pnt=0;
	for(int i=0;i<s.size();i+=2){
		while(true){
			if(pnt==t.size()){ok=false;break;}
			if(t[pnt]==s[i]){pnt++;break;}
			pnt++;
		}
	}
	if(ok){cout<<"Yes"<<endl;return 0;}
	ok=true;pnt=0;
	for(int i=1;i<s.size();i+=2){
		while(true){
			if(pnt==t.size()){ok=false;break;}
			if(t[pnt]==s[i]){pnt++;break;}
			pnt++;
		}
	}
	if(ok){cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3180
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a;
	cin>>b;
	cin>>c;
	if(a==1&&b==0&&c==0){
		cout<<"Close"<<endl;
	}
	else if(a==0&&b==1&&c==0){
		cout<<"Close"<<endl;
}
	else if(a==1&&b==1&&c==0){
		cout<<"Open"<<endl;
	}
	else if(a==0&&b==0&&c==1){
		cout<<"Open"<<endl;
	}
	else{
		cout<<"Close"<<endl;
}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int n,maxn=0;
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		for(int j=1;j<n;j++){
			if(i*j<n){
				maxn++;
			}else{
				break;
			}
		}
	}
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
int n,k,a[100005],m;
int gcd(int x,int y){
	if (x%y==0) return y;
	return gcd(y,x%y); 
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		m=std::max(m,a[i]);
		if (k==a[i]){
			puts("POSSIBLE");
			return 0;
		}
	}
	if (k>m){
		puts("IMPOSSIBLE");
		return 0;
	}
	int j=a[1];
	for (int i=2;i<=n;i++) j=gcd(j,a[i]);
	if (k%j==0) {
		puts("POSSIBLE");
		return 0;
	}
	for (int i=1;i<=n;i++){
		if (a[i]%j){
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
	return 0;
} 

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

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}

int main(void) {

  char s[5001];
	scanf("%s", s);
  int k;
  scanf("%d", &k);
  int length = strlen(s);
  int list_size = length*k-(k-1)*k/2;
  char list[list_size][k+1];
  int cur = 0;
  for (int head = 0; head < length; head++) {
    for (int tail = head; tail < length; tail++) {
      if (tail >= head+k) {
        break;
      }
      for (int i = head; i <= tail; i++) {
        list[cur][i-head] = s[i];
      }
      list[cur][tail-head+1] = '\0';
      cur++;
    }
  }
  qsort(list, list_size, sizeof(list[0]), cmp_s);
  cur = 1;
  for (int i = 0; i < list_size; i++) {
    if (i != 0 && strcmp(list[i-1],list[i]) != 0) {
      cur++;
    }
    if (cur == k) {
      printf("%s\n", list[i]);
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 508
#include <stdio.h>
int main()
{
  int n,c,d,p;
  float e,f,g,h;
  scanf("%d",&n);
  if(n==1)
  {
    printf("1.0000000000");
  }
  else if(n%2==0)
  {
  	c =n/2;
  	e = c;
  	f = e/n;
  	printf("%f",f);
  }
  else if(n%2!=0)
  {
  	d = n-1;
  	d = d/2;
  	d = d+1;
  	g = d;
  	h = g/n;
  	printf("%f",h);
  }
}

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

using namespace std;

int main() {
	vector<bool> used(26);
	string s; cin >> s;
	for (int i = 0; i < s.size(); ++i)
		used[s[i] - 'a'] = true;
	string ans = "None";
	for (int i = 0; i < 26; ++i) {
		if (!used[i]) {
			ans = 'a' + i;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ALL(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define mod 1000000007

vector<ll> ab;
vector<ll> abc;

int main(){
  ll x,y,z,k;
  cin >> x >> y >> z >>k;
  ll a[1010]={0},b[1010]={0},c[1010]={0};
  rep(i,x)cin >>a[i];
  rep(i,y)cin >> b[i];
  rep(i,z)cin >> c[i];
  rep(i,x){
    rep(j,y){
      ab.push_back(a[i]+b[j]);
    }
  }
  sort(ALL(ab),greater<ll>());
  ll res=min(x*y,k);
  rep(i,res){
    rep(j,z){
      abc.push_back(ab[i]+c[j]);
    }
  }
  sort(ALL(abc),greater<ll>());
  rep(i,k){
    cout << abc[i] <<endl;
  }
}


Measured memory_bytes: 43236
package main

import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)

const MaxBuf = 200100
var buf []byte
var sc = bufio.NewScanner(os.Stdin)

func init() {
   sc.Split(bufio.ScanWords)
   sc.Buffer(buf,MaxBuf)
}

func readString() string {
   sc.Scan()
   return sc.Text()
}

func readInt64() int64 {
   sc.Scan()
   r,_ := strconv.ParseInt(sc.Text(),10,64)
   return r
}

func readInt() int {
   sc.Scan()
   r,_ := strconv.Atoi(sc.Text())
   return r
}

func main() {
	n := readInt()
	k := readInt()
	q := readInt()
	l := make([]int,n)
	for i := 0; i < q ; i++ {
		l[readInt()-1]++
	}

	for _,v := range l {
		if k - q + v > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

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

typedef long long ll;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define all(x) (x).begin() ,(x).end()

const int p = 1e9 + 7;

ll binpow(ll a, ll b , ll mod) {
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res % mod;
}

const int dx[] = {1 , -1 , 0 , 0};
const int dy[] = {0 , 0 , -1 , 1};
const ll inf = 1e18 - 5LL;
const int N = 1e5 + 9;



void solve() {

	ll a , b , c , d;
	cin >> a >> b >> c >> d;

	ll ans = b * d;
	ans = max(ans , a * d);
	ans = max(ans , a * c);
	ans = max(ans , b * c);

	cout << ans << "\n";
}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
		solve();

	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

typedef int Weight;
struct Edge{
    int from, to;
    Weight weight;
    int rev;     // ネットワークフロー時の逆辺
    Edge(int from, int to, Weight weight) :
            from(from), to(to), weight(weight) { }
    Edge(int from, int to, Weight weight, int rev) :
            from(from), to(to), weight(weight), rev(rev){ }
};
bool operator < (const Edge &a, const Edge &b){
    if(a.weight != b.weight) return a.weight > b.weight;
    if(a.from != b.from) return a.from > b.from;
    return  a.to > b.to;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void addFlowEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, 0, g[a].size() - 1));
}
void addUndirectedEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, c, g[a].size() - 1));
}

void dfs(const Graph &g, int v, vector<int> &w, int u) {
    for (auto e: g[v]) {
        if (e.to == u) continue;
        w[e.to] += w[v];
        dfs(g, e.to, w, v);
    }
}

void solve(long long N, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> p, std::vector<long long> x){
    ++N;
    Graph g(N);
    for(int i = 0; i < a.size(); ++i) {
        addUndirectedEdge(g, a[i], b[i], 0);
    }

    vector<int> w(N);
    for(int i = 0; i < p.size(); ++i) {
        w[p[i]] += x[i];
    }

    dfs(g, 1, w, 1);

    for(int i = 1; i < N; ++i) {
        cout << w[i] << (i == N - 1 ? "\n" : " ");
    }
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    std::vector<long long> p(Q);
    std::vector<long long> x(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&p[i]);
        scanf("%lld",&x[i]);
    }
    solve(N, Q, std::move(a), std::move(b), std::move(p), std::move(x));
    return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
  int x,y;
  cin >> x >> y;

  int ans=2e9;
  if(x<y){
    ans=min(ans,abs(x-y));
    ans=min(ans,abs(x+y)+1);
  }
  else{
    ans=min(ans,abs(x+y)+1);
    ans=min(ans,abs(x-y)+2);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// abc174_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int K;
  cin>>K;
  set<int> s;
  ll cnt = 1;
  ll ele = 7 % K;
  while(s.count(ele) == 0) {
    if (ele == 0) {
      cout<<cnt<<endl;
      return 0;
    }

    s.insert(ele);
    cnt++;
    ele = (ele * 10 + 7) % K;
  }

  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 50516
#include <stdio.h>

int main() {
  int n, a, min = 1000000, max = -1000000;
  long long sum = 0;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &a);
    if (a > max) max = a;
    if (a < min) min = a;
    sum += a;
  }
  printf("%d %d %lld\n", min, max, sum);
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

ll dp[101][1000000];

int main() {
    ll N, W;
    cin >> N >> W;

    ll w, v;
    for (int i = 1; i <= N; i++) {
        cin >> w >> v;

        rep(j, W + 1) {
            chmax(dp[i][j], dp[i - 1][j]);
            if (j - w >= 0) chmax(dp[i][j], dp[i - 1][j - w] + v);
        }
    }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 289024
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

typedef long long int ll;

ll num[50];
ll num2[50];
ll num3[50];
//ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
priority_queue<double> pq;


int main(void)
{
    double ans=0.0,d,d1,d2,sumd=0.0;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>n>>s;
    while(s.find("ABC") != s.npos)
    {
        a=s.find("ABC");
        s.assign(s,a+3,s.size()-a-3);
        sum++;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int n, m;
int cnt[N];

int main() {
  cin >> n >> m;
  for(int i = 1; i <= m; ++i){
    int x, y;
    cin >> x >> y;
    cnt[x]++, cnt[y]++;
  }
  for(int i = 1; i <= n; ++i){
    if(cnt[i] % 2){
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Deque<Integer> deq = new ArrayDeque<>();
        for(int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (n % 2 == 0) {
                if (i % 2 == 0) {
                    deq.addLast(num);
                } else {
                    deq.addFirst(num);
                }
            } else {
                if (i % 2 == 0) {
                    deq.addFirst(num);
                } else {
                    deq.addLast(num);
                }
            }
        }
        deq.stream().forEach(i -> System.out.print(i + " "));
    }
}

Measured memory_bytes: 100376
<?php
// 1以上N以下の整数のうち、10進法での各桁の和がA以上B以下であるものの総和を出力せよ。
$nab = explode(' ', trim(fgets(STDIN)));
$n   = $nab[0];
$a   = $nab[1];
$b   = $nab[2];

$sum = 0;
for ($i = 1; $i <= $n; $i++) {
    $sum_digit = sumEachDigit($i);
    if ($sum_digit >= $a && $sum_digit <= $b) {
        $sum += $i;
    }
}

print "$sum\n";

function sumEachDigit(int $number)
{
    $sum = 0;
    while ($number !== 0) {
        $sum    += $number % 10;
        $number = intdiv($number, 10);
    }
    return $sum;
}


Measured memory_bytes: 4728
h,w=map(int,input().split())
s=[]
s.append("."*(w+2))
for _ in range(h):
    s.append("."+input()+".")
s.append("."*(w+2))


flag=True



for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=="#":
            if s[i-1][j]=="." and s[i][j-1]=="." and s[i][j+1]=="."  and s[i+1][j]=="." :
                flag=False

        
            
if flag:
    print("Yes")
else:
    print("No")
            

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;

int main(){
    int n;
    cin>>n;
    priority_queue<int>q;
    REP(i,n){
        int a;
        cin>>a;
        q.push(a);
    }
    while(SZ(q)>1){
        int x,y;
        x=q.top();
        q.pop();
        y=q.top();
        if(x%y!=0)q.push(x%y);
    }
    OUT(q.top());
    return 0;
}

Measured memory_bytes: 892
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let m: u64 = input();
    println!("{}", 48 - m);
}


Measured memory_bytes: 2084
from math import ceil
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
    ai, bi = map(int,input().split())
    a.append(ai)
    b.append(bi)
ans = 0
maxa = max(a)
b2 = sorted([i for i in b if i > maxa],reverse=True)
for k in b2:
    if h > 0:
        ans += 1
        h -= k
if h > 0: ans += ceil(h/maxa)
print(ans)

Measured memory_bytes: 12856
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,M,O,H; // Nは入力する値、Mは桁数を調べるために仮にNを代入する値、HはNがSUMで割り切れるかどうかを計算するために仮にNを代入する値
 int Keta = 1;
 int SUM = 0;
 cin >> N;
 M = N;
 H = N;
 string Q;
 for(int i=0; i<10; i++){
  M = M / 10;
  if(M < 1) {
   break;
  }else{
   Keta += 1;
  }
 }
 for (int i=Keta; i>=1; i--){
  O = N % 10;
  SUM += O;
  N = N / 10;
 }
 if(H % SUM == 0){
  Q  = "Yes";
 }else{
  Q = "No";
 }
 cout << Q << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include<stdio.h>
#include<cstdio>
#include<cstring>
#include<string>
#include<math.h>

using namespace std;






int i, tatenosa,yokonosa,zikannsa,n, flg, sennennsatu,gosenen,tate[200000],yoko[200000],toki[200000];
string mozi,kopi;
int main() {
	cin >> n;
	i = n*n*n;
		printf("%d\n",i);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    long long a,b;
    cin>>a>>b;
    int amod2=a%2;
    int bmod2=b%2;
    if((amod2+bmod2)%2==1)cout<<"IMPOSSIBLE"<<endl;
    else cout<<(a+b)/2<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

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

int main(void) {
    li A, B, C, D;
    cin >> A >> B >> C >> D;

    li first = A * B;
    li second = C * D;
 
    cout << ((first > second) ? first : second);

    return 0;
}


Measured memory_bytes: 256
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [b]
    else
      match str.[ct] with
        ' ' -> b::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let _n = read_line ()
  and s = read_line () in
  let l = split s in
  let result = match l with
      [h] -> h
    | h::t -> List.fold_left (fun x y -> y^" "^x ) h t
    | _ -> ""
  in
  Printf.printf "%s\n" result;;

Measured memory_bytes: 2648
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;

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

    long double third = l / 3.0;

    printf("%.12Lf\n", third * third * third);

    return 0;
}


Measured memory_bytes: 256
n=input()
a=[int(i) for i in input().split()]
def chk(a,t):
    ans=0
    x=0
    for i in a:
        x+=i
        if t==True and x<1:
            ans+=1-x
            x=1
        elif t==False and x>-1:
            ans+=x+1
            x=-1
        t=not t
    return ans
print(min(chk(a,True),chk(a,False)))

Measured memory_bytes: 63344
import collections
import sys
def countString (str):
    alphalist = [chr(ord('a') + i) for i in range(26)] # ['a', 'b', 'c', ... , 'z']
    strlist = list(str.lower())
    c = collections.Counter(strlist)
    for s in alphalist:
        print('{0} : {1}'.format(s, c[s]))

if __name__ == '__main__':
    mojiretsu = ""
    for line in sys.stdin:
        mojiretsu += line
    countString(mojiretsu)


Measured memory_bytes: 5968
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
string str;
int si;

int hoge(char x, int j) {
	static int ro[30];
	if (j == 0) for (int i = 0; i < 30; i++) ro[i] = 0;
	ro[0] = 1;
	if (x == 'z' + 1) return 0;
	if (ro[x - 'a']) {
		if (x != str[j]) return 0;
	}
	else {
		if ((x - 1) != str[j]) return 0;
		ro[x - 'a'] = 1;
	}

	return 1;
}

int main() {
	int ni, j, t;
	string temp;
	

	while (1) {
		vector <string> vst = {};
		int ans = 0;
		cin >> str;

		if (str == "#") break;

		si = str.size();
		ni = pow(2, si);

		for (int i = 0; i < ni;i++) {
			temp = str;
			for (j = 0; j < si; j++) {
				t = si - j - 1;
				if ((i >> t) & 1) temp[j]++;//temp[j] += (temp[j] == 'z') ? 0 : 1;
				if (!hoge(temp[j], j)) { 
					break;
				}
			}
			//i += 1 << t;
			if (j == si) {
				ans++;
				vst.push_back(temp);
			}
		}

		sort(vst.begin(), vst.end());

		cout << ans << endl;

		if (ans > 10) {
			for (int i = 0; i < 5 && i < vst.size(); i++) cout << vst.at(i) <<  endl;
			for (int i = vst.size() - 5; i < vst.size(); i++) cout << vst.at(i) << endl;
		}
		else for (int i = 0; i < ans; i++) cout << vst.at(i) << endl;


	}

	return 0;
}


Measured memory_bytes: 4296
# cook your dish here
# from math import * 
#for _ in range(int(input().strip())):

s = input()
k = int(input())
var = 0
sub = set()
size = 0
for var in range(97,123):
    if len(sub)>k:
        break
    for i in range(len(s)):
        size=0
        if s[i]==chr(var):
            for j in range(i,len(s)):
                if size>=k:
                    break
                sub.add(s[i:(j+1)])
                size+=1 
l = list(sub)
l.sort()
print(l[k-1])

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

int main(){
  string S;
  cin>>S;
 long long N,ans,g,p;
N=S.size();
  g=0;
  p=0;
  for(int i=0;i<N;i++){
    if(S[i]=='g'){
      g++;
    }
    else{
      p++;
    }
  }
  ans=N/2-p;
    cout<<ans<<endl;
 }

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <climits>
#include <vector>
#include <map>
#include <algorithm>
#include <cstring>
#include <queue>
#define ll long long
#define REP(a,b) for(ll a=0; a<b; a++)
using namespace std;

ll mx[100005];
ll mn[100005];
priority_queue <ll, vector<ll>, greater<ll>> front;
vector <ll> middle;
priority_queue <ll> back;
ll sumf = 0;
ll sumb = 0;

int main() {
  ll N;
  scanf("%lld", &N);
  REP(i, N){
    ll temp;
    scanf("%lld", &temp);
    front.push(temp);
    sumf += temp;
  }
  REP(i, N){
    ll temp;
    scanf("%lld", &temp);
    middle.push_back(temp);
  }
  REP(i, N){
    ll temp;
    scanf("%lld", &temp);
    back.push(temp);
    sumb += temp;
  }
  ll mxm = LLONG_MIN;
  int l = 0;
  while(l < N){
    mx[l] = sumf;
    if(middle[l] - front.top() > 0){
      sumf -= front.top();
      sumf += middle[l];
      front.pop();
      front.push(middle[l]);
    }
    l++;
  }
  mx[l] = sumf;
  int r = N;
  mn[r] = sumb;
  r--;
  while(r >= 0){
    if(back.top() - middle[r] > 0){
      sumb -= back.top();
      sumb += middle[r];
      back.pop();
      back.push(middle[r]);
    }
    mn[r] = sumb;
    r--;
  }
  REP(i, N+1){
    mxm = max(mxm, mx[i]-mn[i]);
  }
  cout << mxm << endl;
}

Measured memory_bytes: 4340
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String A = sc.next();
        String B = sc.next();
        sc.close();

        if(A.length() > B.length()){
            System.out.println("GREATER");
            return;
        } else if(A.length() < B.length()){
            System.out.println("LESS");
            return;
        } else {
            for(int i = 0; i < A.length(); i++){
                if((int)A.charAt(i) > B.charAt(i)){
                    System.out.println("GREATER");
                    return;
                } else if((int)A.charAt(i) < B.charAt(i)){
                    System.out.println("LESS");
                    return;
                }
            }
            System.out.println("EQUAL");
        }
    }
}

Measured memory_bytes: 23764
n = int(input())
A = list(map(int,input().split()))

a = A[::-1]
s = [0]*(n+1)

for i in range(n):
    s[i+1] = s[i] + a[i]

s = s[:n]
s = s[::-1]

tot = 0
for i in range(n-1):
    tot += A[i]*s[i]
    
print(tot%(10**9+7))


Measured memory_bytes: 94792
# coding: utf-8
# Your code here!

import math

while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int, input().split()))
    
    ave = sum(s)/n
    a2 = 0
    for i in range(n):
        a2 += (s[i]-ave)**2
    
    print(math.sqrt(a2/n))


Measured memory_bytes: 5704
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
  int N;
  string S1,S2;
  cin >> N >> S1 >> S2;
  long long dp[N];
  dp[0] = (S1[0] == S2[0] ? 3 : 6);
  for (int i = 1; i < N; i++) {
    if (S1[i] == S1[i-1]) {
      dp[i] = dp[i-1];
    } else if (S1[i] == S2[i] && S1[i-1] == S2[i-1]) {
      dp[i] = 2*dp[i-1];
      dp[i] %= MOD;
    } else if (S1[i] == S2[i]) {
      dp[i] = dp[i-1];
    } else if (S1[i] != S2[i] && S1[i-1] == S2[i-1]) {
      dp[i] = 2*dp[i-1];
      dp[i] %= MOD;
    } else {
      dp[i] = 3*dp[i-1];
      dp[i] %= MOD;
    }
  }
  cout << dp[N-1];
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#define MAX_NUM 100
using namespace std;

int x[MAX_NUM];
int y[MAX_NUM];

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    for (int i = 0; i < N; i++) cin >> x[i];
    for (int i = 0; i < M; i++) cin >> y[i];
    sort(x, x + N);
    sort(y, y + M);
    if (x[N - 1] < y[0] && X < y[0] - 1 && Y > x[N - 1] + 1 && X < Y) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    s = input()

    length = None
    for i in range(1, len(s)-1):
        tmp = s[:len(s)-i]
        if len(tmp)%2 != 0:
            continue
        elif tmp[:len(tmp)//2] == tmp[len(tmp)//2:]:
            length = len(tmp)
            break
    print(length)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#!/usr/bin/env python3
import math
Q = int(input())
for _ in range(Q):
    A, B, C, D = map(int, input().split())
    K = math.ceil(max(A, B) / (min(A, B) + 1))
    lo, hi = 0, A + 1
    while hi - lo > 1:
        mid = (lo + hi) // 2
        rA, rB = A - mid, B - max(0, (mid - 1) // K)
        if (rA + 1) * K < rB:
            hi = mid
        else:
            lo = mid
 
    f = ''
    for i in range(C - 1, D):
        na = lo
        nb = max(0, (na - 1) // K)
        if i < nb * (K + 1):
            f += ('A', 'B')[i % (K + 1) == K]
        elif i < na + nb:f += 'A'
        else:
            j = A + B - i - 1
            nb = B - nb
            na = max(0, (nb - 1) // K)
            if j < na * (K + 1):f += ('B', 'A')[j % (K + 1) == K]
            else:f += 'B'
    print(f)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), L(N + 1), R(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  L[0] = 0;
  for (int i = 1; i <= N; i++) {
    L[i] = __gcd(L[i - 1], A[i - 1]);
  }
  R[0] = 0;
  for (int i = 1; i <= N; i++) {
    R[i] = __gcd(R[i - 1], A[N - i]);
  }
  int ans = 1;
  for (int i = 1; i <= N; i++) {
    ans = max(ans, __gcd(L[i - 1], R[N - i]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
class PermutationTree {
private:
    int n;
    vector<vector<int>> edge;
    vector<int> parent, dep;
    vector<bool> isOnDiameter;
    int bfs(int s) {
        parent.assign(n, -1);
        dep.assign(n, 0);
        queue<int> que;
        que.push(s);
        while (!que.empty()) {
            int u = que.front();
            que.pop();
            for (int v : edge[u]) {
                if (v == parent[u])
                    continue;
                parent[v] = u;
                dep[v] = dep[u] + 1;
                que.push(v);
            }
        }
        return max_element(dep.begin(), dep.end()) - dep.begin();
    }
    vector<int> findPermutation(const vector<int> &k) {
        vector<int> perm;
        int cnt = 0;
        for (int x : k) {
            int u = cnt++;
            for (int i = 0; i < x; ++i)
                perm.push_back(cnt++);
            perm.push_back(u);
        }
        return perm;
    }
public:
    void solve() {
        cin >> n;
        edge.resize(n);
        isOnDiameter.resize(n);
        for (int i = 0; i < n - 1; ++i) {
            int u, v;
            cin >> u >> v;
            --u;
            --v;
            edge[u].push_back(v);
            edge[v].push_back(u);
        }
        int s = bfs(0);
        int t = bfs(s);
        vector<int> k;
        for (int u = t; u != -1; u = parent[u]) {
            isOnDiameter[u] = true;
            k.push_back(u == s || u == t ? 0 : (int)edge[u].size() - 2);
        }
        for (int i = 0; i < n; ++i) {
            if (!isOnDiameter[i] && (int)edge[i].size() != 1) {
                cout << -1 << endl;
                return;
            }
        }
        auto ans = findPermutation(k);
        reverse(k.begin(), k.end());
        ans = min(ans, findPermutation(k));
        for (int i : ans)
            cout << i + 1 << " \n"[i == ans.back()];
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    PermutationTree().solve();
    return 0;
}

Measured memory_bytes: 8064
s = input()

c = 0
check = True
for i in range(len(s)):
    c += 1
    if c % 2 == 1:
        if s[i] == 'L':
            check = False
            break
    else:
        if s[i] == 'R':
            check = False
            break
if check:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 39896
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7')cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;

class Minimum_Prime_Factors {
	vector<int> minimum_prime_factors;

public:
	Minimum_Prime_Factors(int& n) : minimum_prime_factors(n + 1) {
		for (int i = 0; i <= n; i++) {
			minimum_prime_factors[i] = i;
		}
		for (int i = 2; i * i <= n; i++) {
			if (minimum_prime_factors[i] == i) {
				for (int j = i * i; j <= n; j += i) {
					if (minimum_prime_factors[j] == j) {
						minimum_prime_factors[j] = i;
					}
				}
			}
		}
	}

	int get_minimum_prime_factor(int& a) {
		return minimum_prime_factors[a];
	}
};

unordered_set<int> prime_factorization_unique(int a, Minimum_Prime_Factors& minimum_prime_factors) {
	unordered_set<int> prime_factors_unique;
	while (1 < a) {
		prime_factors_unique.insert(minimum_prime_factors.get_minimum_prime_factor(a));
		a /= minimum_prime_factors.get_minimum_prime_factor(a);
	}
	return prime_factors_unique;
}

vector<unordered_set<int>> A_prime_factorization_unique(vector<int>& A) {
	vector<unordered_set<int>> A_prime_factors_unique;
	Minimum_Prime_Factors minimum_prime_factors(*max_element(A.begin(), A.end()));
	for (int& i : A) {
		A_prime_factors_unique.push_back(prime_factorization_unique(i, minimum_prime_factors));
	}
	return A_prime_factors_unique;
}

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int& i : A) {
		cin >> i;
	}
	vector<unordered_set<int>> A_prime_factors_unique;
	A_prime_factors_unique = A_prime_factorization_unique(A);
	bool pairwise_coprime = true;
	unordered_set<int> prime_factors_unordered_set;
	for (unordered_set<int>& i : A_prime_factors_unique) {
		for (const int& j : i) {
			if (prime_factors_unordered_set.find(j) != prime_factors_unordered_set.end()) {
				pairwise_coprime = false;
				break;
			}
			prime_factors_unordered_set.insert(j);
		}
		if (!pairwise_coprime) {
			break;
		}
	}
	if (pairwise_coprime) {
		cout << "pairwise coprime" << endl;
		return 0;
	}
	int A_gcd = A.front();
	for (int i = 1; i < N; i++) {
		A_gcd = gcd(A[i], A_gcd);
	}
	if (A_gcd == 1) {
		cout << "setwise coprime" << endl;
		return 0;
	}
	cout << "not coprime" << endl;
}

Measured memory_bytes: 278092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=2005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    set<string> SE;
    while(N--){
        string S;cin>>S;
        SE.insert(S);
    }
    cout<<SE.size()<<endl;
}





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


int main()
{
    string s;
    getline(cin,s);
    for(int i=0;;i++){
        if(islower(s[i]))   s[i] = toupper(s[i]);
        else if(isupper(s[i]))  s[i] = tolower(s[i]);
        if(s[i] == '\0')    break;
    }

    cout<<s<<'\n';
}


Measured memory_bytes: 3200
#include<stdio.h>
int main(){
  int a,b,c,i,j,n[100],k=0;
  scanf("%d%d%d",&a,&b,&c);
  if(a<b){
    j=b;
  }else{
    j=a;
  }
  for(i=1;i<=j;i++){
    if(a%i==0&&b%i==0){
      n[k]=i;
      k++;
    }
  }
  c=k-c;
  printf("%d\n", n[c]);
  return 0;
}

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

using namespace std;

int main(){
  string s;
  int i = 0;
  int count = 0;
  
  cin >> s;
  
  for(i=0;i<s.length();i++){
    if (s[i] == '1') {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
def makelist2(n,m):
    return[[0 for k in range(m)]for i in range(n)]

n,a = map(int,input().split())
x = list(map(int,input().split()))
X = max(x)
X = max(X,a)
b=[]
for i in range(n):
    b.append(x[i]-a)


dp =makelist2(n+1,2*n*X+1)
dp[0][n*X] = 1
for j in range(n+1):
    for t in range(2*n*X+1):
        if j>=1 and (t-b[j-1] < 0 or t-b[j-1]>2*n*X):
            dp[j][t] = dp[j-1][t]
        elif j>= 1:
            dp[j][t] = dp[j-1][t] + dp[j-1][t-b[j-1]]
print(dp[n][n*X]-1)

Measured memory_bytes: 42588
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	n--;

	int offset = 0;
	std::vector<i64> now;
	for(int i = 1; i < 10; i++) now.push_back(i);
	while(offset + now.size() <= n) {
		std::vector<i64> nxt;
		for(auto v: now) {
			i64 tail = v % 10;
			nxt.push_back(v * 10 + (tail));
			if(tail - 1 >= 0) nxt.push_back(v * 10 + (tail - 1));
			if(tail + 1 <= 9) nxt.push_back(v * 10 + (tail + 1));
		}
		
		offset += now.size();
		sort(begin(nxt), end(nxt));
		nxt.erase(unique(begin(nxt), end(nxt)), end(nxt));
		now.swap(nxt);
	}

	printf("%lld\n", now[n - offset]);
	return 0;
}


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

vector<int> link;
vector<int> size;
stack<pair<int, int>> edges;
vector<ll> ans;

int find(int x)
{
	while (x != link[x]) x = link[x];
	return x;
}

ll unite(int a, int b)
{
	a = find(a);
	b = find(b);
	if (a != b)
	{
		ll pairs = size[a] * size[b];
		if (size[a] < size[b]) swap(a, b);
		size[a] += size[b];
		link[b] = a;
		return pairs;
	}
	return 0;
}

ll calc_pairs()
{
	vector<int> groups;
	for (int i = 0; i < link.size(); ++i)
		if (i == link[i]) groups.push_back(size[i]);
		
	ll total = 0;
	for (int i = 0; i < groups.size() - 1; ++i)
	{
		ll sum = accumulate(groups.begin()+i+1, groups.end(), 0);
		total += groups[i] * sum;
	}
	return total;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll N, M;
	cin >> N >> M;
	
	link.resize(N);
	for (int i = 0; i < N; ++i)
		link[i] = i;
	size.assign(N, 1);
	
	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b; a--; b--;
		edges.push({a, b});
	}
	
	ll total = N*(N-1)/2;
	ans.push_back(total);
	while (edges.size() != 1)
	{
		int a, b;
		tie(a, b) = edges.top();
		edges.pop();
		total -= unite(a, b);
		ans.insert(ans.begin(), total);
	}
	
	for (ll i : ans)
		cout << i << '\n';
}


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

int main() {
	int a,s ;
	char str[1000];

	cin >> a >> str;
	
	if (a>=3200) {
		cout << str << '\n';
	}
	if(a<3200)
	{
		cout << "red"<< '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

int main(void){
	ll N,A,even=0,odd=0,P;
	ll ans=1;
	cin>>N>>P;
	rep(i,N){
		cin>>A;
		if(A%2==0)even++;//偶数
		else odd++;//奇数
	}
	rep(i,even){
		ans*=2;
	}
	rep(i,odd-1){
		ans*=2;
	}
	if(P==1 && odd==0)ans=0;
	if(P==0 && even==0 && odd==1)ans=0;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import collections

N,K=map(int,input().split())
a_n = list(map(int,input().split()))

dict = collections.Counter(a_n)

v_list = list(dict.values())
v_list_s = sorted(v_list)

cnt = 0
if len(v_list_s) <= K:
    print(0)
else:
    x = len(v_list_s) - K
    for i in range(x):
        cnt += v_list_s[i]
    print(cnt)

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
int n;
string ans;
int main() {
    cin>>n;
    if(n<1200) ans="ABC";
    else if(n<2800) ans="ARC";
    else ans="AGC";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,K;cin>>N>>K;
    vector<int> h(N);
    REP(i,N) cin>>h[i];
    sort(All(h));
    int ans=1e9;
    K--;
    REP(i,N-K) ans=min(ans,h[i+K]-h[i]);
    cout<<ans<<endl; 
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	string s; int N, K;
	cin >> N >> K >> s;
	if (s[K - 1] == 'A')s[K - 1] = 'a';
	if (s[K - 1] == 'B')s[K - 1] = 'b';
	if (s[K - 1] == 'C')s[K - 1] = 'c';
	cout << s << endl;
}



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

typedef long long ll;
 
ll X, Y;
 
int main(){
  	cin >> X >> Y;
  	if(abs(X - Y) <= 1){
    	cout << "Brown" << endl;
    }else cout << "Alice" << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

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

    int K;
    cin >> K;

    while (K > 0 && a >= b) {
        --K;
        b <<= 1;
    }

    while (K > 0 && b >= c) {
        --K;
        c <<= 1;
    }

    cout << ((a < b && b < c) ? "Yes" : "No") << newl;

    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  int a, b;
  cin >> a >> b;
  if(a+b==15) cout << "+\n";
  else if(a*b == 15) cout << "*\n";
  else cout << "x\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 256