akhauriyash/Code-Regression huggingface dataset:
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n;
int vis[302][302][302];
double cache[302][302][302];
double dp(int one,int two,int three)
{
    int tot=one+two+three;
    if(!tot)
        return 0;
    if(one<0 || two<0 || three<0)
        return -1;
    if(vis[one][two][three])
        return cache[one][two][three];

    double ans=0;
    double x=n*1.0/(n-(n-tot)*1.0);
    ans=x*((n-tot)*1.0/n + (one*1.0/n)*(1+dp(one-1,two,three))
                +(two*1.0/n)*(1+dp(one+1,two-1,three))
                    +(three*1.0/n)*(1+dp(one,two+1,three-1)));
    vis[one][two][three]=1;
    return cache[one][two][three]=ans;
}
int32_t main() 
{
    IOS;
    cin>>n;
    int freq[4]={};
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        freq[a]++;
    }
    cout<<fixed<<setprecision(12);
    cout<<dp(freq[1],freq[2],freq[3]);
}


Measured memory_bytes: 321140
if __name__ == "__main__":
  NX = input().split(" ")
  LN = input().split(" ")
  
  sum = 0
  count = 1
  for i in range(int(NX[0])):
    sum = sum + int(LN[i])
    if sum <= int(NX[1]):
      count += 1
  print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i )
typedef std::pair<int,int> pint;

using namespace std;
typedef long long ll;

int main(){
    int A,B,C; cin >> A >> B >> C;
    int K; cin >> K;
    int a = A;
    int b = B;
    int c = C;
    int b_cnt = 0;
    int c_cnt = 0;
    while(a >= b){
        b = 2 * b;
        b_cnt++;
    }
    while(b >= c){
        c = 2 * c;
        c_cnt++;
    }
    if ((b_cnt + c_cnt) <= K){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    vector<vector<int>> v(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> v[i][j];
    rep(i, 101) {
        rep(j, 101) {
            rep(k, 101) {
                int b1 = v[0][0] - i, b2 = v[0][1] - i, b3 = v[0][2] - i;
                if(b1 < 0 || b2 < 0 || b3 < 0) continue;
                if(j + b1 != v[1][0] || j + b2 != v[1][1] || j + b3 != v[1][2]) continue;
                if(k + b1 != v[2][0] || k + b2 != v[2][1] || k + b3 != v[2][2]) continue;
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

struct xyz {
	ll a;
	ll b;
	ll c;
};

int main()
{
	int n;
	cin >> n;
	
	vector<xyz> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i].a >> v[i].b;
		v[i].c = v[i].a + v[i].b;
	}
	
	sort(ALL(v), [](const xyz &x, const xyz &y){return x.c > y.c;});
	
	int cnt = 0;
	ll takahashi = 0;
	ll aoki = 0;
	for(int i = 0; i < n; i++) {
		if(i % 2 == 0) {
			takahashi += v[i].a;
		}
		else {
			aoki += v[i].b;
		}
	}
	
	cout << takahashi - aoki << endl;
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Count Balls
            var line = ReadLine();
            var N = line[0];
            var A = line[1];
            var B = line[2];

            long ans = N / (A + B) * A;

            if (N % (A + B) >= A)
            {
                ans += A;
            }
            else
            {
                ans += N % (A + B);
            }

            Console.WriteLine(ans);
        }

        static List<long> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => long.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    int r, g;
    cin >> r >> g;
    if(g%r==0){
        cout << g+r << endl;
    }else{
        cout << g-r << endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#define rep(i,n) for(int i = 0; i < (long int)n; i++)
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
  }
  int ans = 0;
  for(int i = 1; i < n-1; i++){
    if(p[i-1] < p[i] and p[i] < p[i+1]
      or p[i-1] > p[i] and p[i] > p[i+1]){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	int n,m=0,sum=0;
	int p[10];

	cin >> n;
	rep(i, 0, n) {
		cin >> p[i];
		sum += p[i];
		m = max(m, p[i]);
	}

	cout << sum - m / 2 << endl;





	return 0;
}

Measured memory_bytes: 256
<?php
$input = STDIN;

list($x1, $y1, $x2, $y2) = array_map("floatval", explode(' ', trim(fgets($input))));

$d = (($x1 - $x2) ** 2 + ($y1 - $y2) ** 2) ** 0.5;

print $d . "\n";


Measured memory_bytes: 9252
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
int ans[100010];
 
signed main(){
  int m;
  int k;
  cin>>m>>k;
  if(k==0){
  for(int i=0;i<pow(2,m);i++){
    if(i!=0) cout<<" ";
    cout<<i<<" "<<i;
  }
  cout<<endl;
  return 0;
    }
  int x=0;
  for(int i=0;i<pow(2,m);i++){
    if(i==k) continue;
    else x=x^i;
  }
  if(x==k){
  for(int i=0;i<pow(2,m);i++){
    if(i==k) continue;
    else cout<<i<<" ";
  }
  cout<<k<<" ";
  for(int i=pow(2,m)-1;i>=0;i--){
    if(i==k) continue;
    else cout<<i<<" ";
  }
  cout<<k<<endl;
  }
  else cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>

using namespace std;


int main() {
	long long int D, N;
	cin >> D >> N;
	if (N != 100) {
		cout << pow(100, D)*N << endl;
	}
	else {
		long long int R = pow(100, D) * 101;
		cout << R<< endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 100000;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int main(){
  int N, M, S;
  while(cin >> N >> M >> S && N){
    N *= N;
    static int dp[2][3001][2001] = {};
    dp[0][0][0] = 1;
    for(int i = 0; i < N; i++){
      for(int sum = 1; sum <= S; sum++){
        for(int last = 1; last <= min(M, sum); last++){
          dp[(i + 1) & 1][sum][last] = (dp[(i + 1) & 1][sum - 1][last - 1] + dp[i & 1][sum - last][last - 1]) % MOD;
        }
      }
      memset(dp[i & 1], 0, sizeof(dp[i & 1]));
    }
    int ans = 0;
    for(int last = 1; last <= M; last++) ans = (ans + dp[N & 1][S][last]) % MOD;
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  long long a, b, c, k, ans = 0;
  cin >> a >> b >> c >> k;

  if (a > k) {
    ans = k;
  } else if (a + b >= k) {
    ans = a;
  } else {
    ans = a - (k - (a + b));
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define nn 100005
#define m 1000000007
int dp[102][nn];
int arr[102];
int cnt[102] = {0};
int n;
main() {
    int k;
    memset(dp, 0, sizeof(dp));
    cin >> n >> k;
    int i;
    for (i = 0; i < n; i++) {
        cin >> arr[i];
    }
    for (i = 0; i < nn; i++) {
        if (i > arr[0])
            break;
        dp[0][i] = 1;
    }
    for (i = 0; i < n; i++) {
        dp[i][0] = 1;
    }
    int j;
    for (i = 1; i < n; i++) {
        for (j = 1; j <= k; j++) {
            int x = 0;
            if (j - arr[i] -1 >= 0)
                x = dp[i-1][j - arr[i] - 1];
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - x + m ) % m;
        }
    }
    // for (i = 0; i < n; i++) {
    //     for (j = 0; j <= k; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[n - 1][k];
}

Measured memory_bytes: 80000
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

int main(){
    string S,T;
    int s;
    size_t l;
    s=0;
    cin >> S >> T;
    //cout << S << T << endl;
    l=S.length();
    //cout << l << endl;
    for(int i=0; i<l; i++){
        //cout << S[i] << T[i] << endl;
        
        if(S[i]!=T[i]){
            s+=1;
        }
        
    }
    cout << s << endl;
    return 0;
}

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
	string s; cin >> s;

	int n = s.length(), ind1 = 0, ind2 = n;
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'A') 
		{
			ind1 = i;
			break;
		}
	}
	for (int i = n - 1; i >= 0; --i)
	{
		if (s[i] == 'Z')
		{
			ind2 = i;
			break;
		}
	}
	cout << abs(ind2 - ind1) + 1 << endl;
}

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

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f

#define reps(i, s, n) for(int i=(s); i<=(n); ++i)
#define inside(i, H) ( (i) <= (H) )
using namespace std;

int H, A[2000010];
void maxHeapify(int i);

void increaseKey(int i, int key)
{
   if( key < A[i])return;
   A[i] = key;

   while(i > 1 && A[i/2] < A[i]){
      swap( A[i/2], A[i] );
      i /= 2;
   }
   return;
}

void insert(int key)
{
   ++H;
   A[H] = -INF;
   increaseKey(H, key);
}

int extract()
{
   int maxv;
   if(H < 1)return -INF;
   maxv = A[1];
   A[1] = A[H--];
   maxHeapify(1);
   return (maxv);
}

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

   int key;
   string com;

   for(;;){
      cin >> com;
      if( com == "end" )break;

      if( com[0] =='i') {
         cin >> key;
         insert(key);
      }
      else {
         cout << extract() << '\n';
      }
   }

   return(0);
}

void maxHeapify(int i)
{
   int l, r, lgst;
   l = i * 2;
   r = l + 1;
   lgst =  (inside(l,H) && A[l] > A[i]) ? l : i;
   if( inside(r,H) && A[r] > A[lgst] )lgst = r;
   if(lgst != i){
      swap( A[i], A[lgst] );
      maxHeapify(lgst);
   }
}




Measured memory_bytes: 7072
#include <stdio.h>
int main() {
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if(a >= 0 && a <= 100 && b>= 0 && b <= 100 && c >= 0 && c <= 100){
        if(a < b && b < c){
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
return 0;
}

Measured memory_bytes: 580
#include <stdio.h> 
int main(void) 
{ 
  int a, b, c, ans; 

   scanf("%d %d", &a,&b); 


  if(a<b){ 

    ans = a; 
    a = b; 
    b = ans; 


  } 
  c = a % b; 


  while(c!=0){ 

    a = b; 
    b = c; 
    c = a % b; 


  } 

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

  return 0; 
} 

Measured memory_bytes: 1844
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int n;
  while(cin >> str){
    if(str=="-") break;
    cin >> n;
    for(int i=0,h;i<n;i++){
      cin >> h;
      string cat = str.substr(0,h);
      str.erase(0,h);
      str+=cat;
    }
    cout << str << endl;
  }
}


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

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int>p(a);
	for (int i = 0; i < a; i++)cin >> p.at(i);
	vector<int>q(b);
	for (int i = 0; i < b; i++)cin >> q.at(i);
	vector<int>r(c);
	for (int i = 0; i < c; i++)cin >> r.at(i);
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	sort(r.begin(), r.end());
	reverse(p.begin(), p.end());
	reverse(q.begin(), q.end());
	reverse(r.begin(), r.end());
	priority_queue<int, vector<int>, greater<int>> pq;//大きいものを残す
	for (int i = 0; i < x; i++)pq.push(p.at(i));
	for (int i = 0; i < y; i++)pq.push(q.at(i));
	for (int i = 0; i < c; i++) {
		if (pq.top() < r.at(i)) {
			pq.pop();
			pq.push(r.at(i));
		}
		else break;
	}
	ll ans = 0;
	while (pq.size() > 0) {
		ans += pq.top();
		pq.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 2552
N=int(input())
L=list(map(int,input().split()))
R={}
sums=0
for i in range(N):
  sums+=L[i]
  if sums in R:
    R[sums]+=1
  else:
    R[sums]=1
k=0
if 0 in R:
  k=R[0]
print(sum([i*(i-1)//2 for i in R.values()])+k)

Measured memory_bytes: 41700
a, b, c = map(int, input().split())
s = sum([a, b, c])

ans = 0

while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    a, b, c = (b + c) / 2, (a + c) / 2, (a + b) / 2
    ans += 1
    if ans > 100000:
        ans = -1
        break

print(ans)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){

	ll N, K;
	cin>>N>>K;
	vll A;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	sort(A.begin(), A.end());
	//A.pb(INF);

	//cout<<K<<endl;
	// vll debug;
	// for(int i=0;i<N;i++)
	// 	for(int j=i+1;j<N;j++)
	// 		debug.pb(A[i]*A[j]);
	// sort(debug.begin(), debug.end());


	ll leq=-INFLL, high=INFLL;
	while(high-leq>1){
		ll mid=(high+leq)/2;
		//mid以下の数がいくつあるか？

		ll cnt=0;
		for(int i=0;i<N;i++){
			ll a=A[i];
			//mid以下の数を数える
			//cout<<"!"<<a<<" "<<endl;
			if(a>=0){
				ll alpha=i+1, beta=N;
				if(i==N-1 || A[alpha]*a>mid)
					goto skip;
				while(beta-alpha>1){
					int gamma=(alpha+beta)/2;
					if(A[gamma]*a<=mid)
						alpha=gamma;
					else
						beta=gamma;
				}
				cnt+=alpha-ll(i);
			}
			else{
				int alpha=i, beta=N-1;
				if(i==N-1 || A[beta]*a>mid)
					goto skip;
				while(beta-alpha>1){
					int gamma=(alpha+beta+1)/2;
					if(A[gamma]*a<=mid)
						beta=gamma;
					else
						alpha=gamma;
				}
				cnt+=ll(N)-beta;
			}
		}
		skip:
		//cout<<mid<<" "<<cnt<<endl;
		if(cnt<K)
			leq=mid;
		else
			high=mid;
	}
	//cout<<debug[K-1]<<endl;
	cout<<high<<endl;

	//cout<<debug[K-1]-high<<endl;

	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  double ans;
  // if(n%3==0)ans = n/3*n/3*n/3;
  // else if(n%3==1)ans = n/3*n/3*(n/3+1);
  // else ans = n/3*(n/3+1)*(n/3+1);
  ans = n/3.0*n/3.0*n/3.0;
  //ansはdouble
  printf("%.10f\n",ans);
}


Measured memory_bytes: 256
N, M = gets.chomp.split(" ").map(&:to_i)
V = Array.new(N+1).map{Array.new}
M.times{
  a, b = gets.chomp.split(" ").map(&:to_i)
  V[a] << b
  V[b] << a
}

ans = Array.new(N+1)
bef = [[1, 0]]
until bef.empty? do
  nxt = []
  bef.each{|v, f|
    next if not ans[v].nil?
    ans[v] = f
    V[v].each{|n| nxt << [n, v]}
  }
  bef = nxt
end

ans.shift
ans.shift
if ans.any?{|a| a.nil?} then
  puts 'No'
else
  puts 'Yes'
  puts ans*?\n
end


Measured memory_bytes: 49996
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;
int INF = (int)(1e9+7);
ll m = (ll)(1e9+7);


 
int main()
{ 	
	FIN;
	#ifdef input
		freopen("T3.txt", "r", stdin);
	#endif
	
	int n;
	string pal;
	cin >> n >> pal;
	vector < vector <ll> > dp(3005,vector <ll>(3005,0));
	forr(i,1,n+1) dp[0][i]=1;
	
	int pos_min = 1, pos_max = n;
	
	forr(i,1,n)
	{
		if(pal[i-1]=='>')
		{
			ll acum = 0;
			for(int j=pos_max; j>=1; j--)
			{
				dp[i][j]=acum;
				acum+=dp[i-1][j];
				acum%=m;
				dp[i][j]%=m;
			}
			pos_max--;
		}
		else
		{
			ll acum = 0;
			for(int j=pos_min; j<=n; j++)
			{
				dp[i][j]=acum;
				acum+=dp[i-1][j];
				acum%=m;
				dp[i][j]%=m;
			}
			pos_min++;
		}
	}
	/*
	forn(i,n+1)
	{
		forn(j,n+1) cout << dp[i][j] << " ";
		cout << endl;
	}*/
	
	ll ans = 0;
	forr(i,pos_min,pos_max+1) ans+=dp[n-1][i], ans%=m;
	cout << ans << "\n";
	
    return 0;
}



Measured memory_bytes: 73932
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 2e5 + 6 ;
#define int long long int

map<int, int> mp ;
set<int> s ;

void primeFactors(int n)  { 
    while(n%2 == 0) {  
        s.insert(2) ;
        n /= 2 ;  
    }
    
    for (int i = 3; i <= sqrt(n); i = i + 2) {  
        while (n % i == 0)  {  
            s.insert(i) ; 
            n = n/i;  
        }  
    }  
    
    if(n > 2)  
    s.insert(n) ;  
}  

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int findGCD(int arr[], int n) 
{ 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) { 
        result = gcd(arr[i], result);
        if(result == 1) 
        return 1 ;
    } 
    
    return result; 
} 

int32_t main() {
    IOS ;
    int n ; cin >> n ; int arr[n] ;
    cin >> arr[0] ;  
    s.empty() ;
    primeFactors(arr[0]) ; 
    for(auto x : s) mp[x]++ ;
    bool flag = true ;
    for(int i=1; i<n; i++) {
        s.clear() ; 
        // cout << s.size() << " " ; 
        cin >> arr[i] ; 
        primeFactors(arr[i]) ; 
        for(auto x : s) {
            if(mp[x] > 0) flag = false ; 
            else mp[x]++ ;
        }
    } 
    
    if(flag) cout << "pairwise coprime" ; 
    else {
        int x = findGCD(arr, n) ;
        if(x == 1) cout << "setwise coprime" ; 
        else cout << "not coprime" ;
    }
    
    return 0 ;
}


Measured memory_bytes: 16196
S = input()
N = len(S)
m = 0
for i in range(N+1):
    for j in range(i+1):
        s = S[j:i]
        l = list(s)
        l = [k for k in l if k not in ["A", "G", "C", "T"]]
        if len(l) == 0:
            m = max(m, i-j)
print(m)

Measured memory_bytes: 38256
#include <stdio.h>
#include <math.h>

int main(void)
{
  int a,b,p,r,X;
  scanf("%d",&X);
	
 	for(X=X;X>0;X--)
    {
    	for(b=32;b>0;b--)
   	 	{
    	  r=X%b;
    	  if(r==0)
    	  {
    		for(p=10;p>1;p--)
            { 
              a=pow(b,p);
              if(a==X)      
              { printf("%d\n",a);
               	break;
              }
       	   }
          }    
          if(a==X)
      	 		 break;          
 	 	  }
      if(a==X)
      	 		 break;
    }
}

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

typedef long long ll;
const int INF = 1e9 + 5;
int main() {
	ios_base::sync_with_stdio(false);

	int n, w;
	cin >> n >> w;
	vector<ll> weights(n + 1), values(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> weights[i] >> values[i];
	}
	
	vector<vector<ll>> dp(n + 1, vector<ll>(w + 1));
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= w; j++) {
			if (j >= weights[i]) {
				dp[i][j] = max({ dp[i][j], dp[i - 1][j - weights[i]] + values[i], dp[i - 1][j] });
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	cout << dp[n][w] << endl;
}

Measured memory_bytes: 80256
import os, sys, re, math

(N, Q) = [int(n) for n in input().split()]
S = input()

oc = [0]
n = 0
for i in range(len(S) - 1):
    if S[i:i+2] == 'AC':
        n += 1
    oc.append(n)
oc.append(n)

for i in range(Q):
    (l, r) = [int(n) for n in input().split()]
    print(oc[r - 1] - oc[l - 1])


Measured memory_bytes: 6332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k=1,d=0;
  cin >> n;
  int a[n+1];
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }
  while(d<n+1){
    d++;
    k=a[k];
    if(k==2){
      cout << d;
      return 0;
    }
  }
  cout << -1;
}


Measured memory_bytes: 640
import java.util.*;

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

    int a = sc.nextInt();
    int b = sc.nextInt();

    if(a > b){
      for(int i = 0; i < a; i++){
        System.out.print(b);
      }
    } else {
      for(int i = 0; i < b; i++){
        System.out.print(a);
      }
    }
  }
}


Measured memory_bytes: 22612
function search(h) {
    var is_start = false;
    for (var i = 0; i < h.length; i++) {
        if (is_start) {
            if (h[i] == 0) {
                break
            }
            h[i] -= 1

        } else {
            if (h[i] == 0) {
                continue;
            }

            is_start = true;
            h[i] -= 1
        }
    }
    return h
}

function main(arg) {
	var h = arg.split("\n")[1].split(" ").map(e => Number(e))
	var arr = []

	// 0対策
	if (h[0] == 0) {
		var b = h.filter((x, i, self) => self.indexOf(x) === i);
		if (b.length == 1) {
			console.log(0)
			return
		}
	}

    var i = 0;

    for (i = 1;;i++) {
        h = search(h)
        if (h[0] == 0) {
            var b = h.filter((x, i, self) => self.indexOf(x) === i);
            if (b.length == 1) {
                break
            }
        }
    }
	 console.log(i)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 8476
import java.util.*;
 
public class Main {
        public static void main(String[] 麺類総選挙){
            Scanner うどん = new Scanner(System.in);
            String そば = うどん.nextLine();
            int ラーメン = そば.length();
            String 山菜そば[] = そば.split("");
            String[] シチュー = new String[ラーメン];
            String[] 信州そば = new String[ラーメン];
            for(int 稲庭うどん=0;稲庭うどん<ラーメン;稲庭うどん++) {
                シチュー[稲庭うどん] = String.valueOf((稲庭うどん + 1)%2); //白スタート
                信州そば[稲庭うどん] = String.valueOf((稲庭うどん)%2);
            }
            //差分比較
            int 赤いきつね=0;
            int 緑のたぬき=0;
            for(int スパゲッティ=0;スパゲッティ<ラーメン;スパゲッティ++){
                if(!山菜そば[スパゲッティ].equals(シチュー[スパゲッティ])){
                    赤いきつね++;
                }else if(!山菜そば[スパゲッティ].equals(信州そば[スパゲッティ])){
                    緑のたぬき++;
                }
            }
            int 第三回人気投票;
            if (赤いきつね < 緑のたぬき) {
                第三回人気投票 = 赤いきつね;
            }else{
                第三回人気投票 = 緑のたぬき;
            }
            System.out.println(第三回人気投票);
        }
 
}

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

int main() {
    cout.tie(nullptr)->sync_with_stdio(false);
    long long int a, b, c, d; cin >> a >> b >> c >> d;
    long long int res = max({a*c, a*d, b*c, b*d});
    cout << res << '\n';
}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
  static int N, A, B, C;
  static int[] l;
  static final int INF = 1100000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    A = sc.nextInt();
    B = sc.nextInt();
    C = sc.nextInt();
    l = new int[N];
    for (int i = 0; i < N; i++) {
      l[i] = sc.nextInt();
    }
    System.out.println(dfs(0, 0, 0, 0, 0));
  }
  static int dfs(int i, int sa, int sb, int sc, int cnt) {
    if (i == N) {
      if (sa == 0 || sb == 0 || sc == 0) return INF;
      int ret = 10*cnt - 30;
      ret += Math.abs(A - sa);
      ret += Math.abs(B - sb);
      ret += Math.abs(C - sc);
      return ret;
    }

    int ret = dfs(i + 1, sa, sb, sc, cnt);
    ret = Math.min(ret, dfs(i + 1, sa + l[i], sb, sc, cnt + 1));
    ret = Math.min(ret, dfs(i + 1, sa, sb + l[i], sc, cnt + 1));
    ret = Math.min(ret, dfs(i + 1, sa, sb, sc + l[i], cnt + 1));
    return ret;
  }
}


Measured memory_bytes: 22584
#include<bits/stdc++.h>
using namespace std;
int main () {
  string s;
  cin>>s;
  for(int i=0;i<s.length();i++){
    if(s[i]=='9'){
        cout<<1;
    }else{
        cout<<9;
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x>=r&&y>=r&&W>=x+r&&H>=y+r){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (q, h, s, d) = get!(usize, usize, usize, usize);
    let n = get!(usize);

    let one = vec![4 * q, 2 * h, s].into_iter().min().unwrap();
    let two = min(one * 2, d);

    println!("{}", n / 2 * two + (n % 2) * one);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            List<int[]> AB = new List<int[]>();

            for (int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                int[] temp = new int[2];
                temp[0] = int.Parse(s[0]);
                temp[1] = int.Parse(s[1]);

                AB.Add(temp);
            }

            AB.Sort(Compare);

            int time = 0;

            for(int i = 0; i < AB.Count; i++)
            {
                time += AB[i][0];

                if(time > AB[i][1])
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
        }
        static int Compare(int[] x, int[] y)
        {
            return x[1].CompareTo(y[1]);            
        }
    }
}

Measured memory_bytes: 28196
import java.io.*;
import static java.lang.Integer.parseInt;

public class Main {
    
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str;
        while((str = br.readLine())!=null){
            String[] num = str.split(" ",0);
            int x = parseInt(num[0]);
            int y = parseInt(num[1]);
            if(0<=x&&x<=1000000&&0<=y&&y<=1000000){
            int z = x+y;
            System.out.println(Integer.toString(z).length());
            }
        }
    }
}

Measured memory_bytes: 24068
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int alphabet[26] = {0};
    int H,W;
    cin >> H >> W;
    for ( int i = 0; i < H; i++ ) {
        string S;
        cin >> S;
        
        for ( auto& s : S ) {
            alphabet[ s - 'a' ]++;
        }        
    }
    
    // int a = W%2;
    // int b = W/2;
    
    // int c = H%2;
    // int d = H/2;
    
    int four = (H/2)*(W/2);
    // int two = a*d+c*b;
    int two = (H%2)*W+(W%2)*H;
    int one = (H%2)*(W%2);
    
    // cout << "four: " << four << endl;
    // cout << "two: " << two << endl;
    // cout << "one: " << one << endl;
    
    // if ( H == 1 || W == 1 ) {
        // int x = (H*W)%2;
        // for ( int i = 0; i < 26; i++ ) {            
            // if ( !alphabet[i] ) { continue; }
            // if ( alphabet[i]%2 && x ) { x = 0; continue; }
            // if ( alphabet[i]%2 && !x ) {
                // cout << "No" << endl;  return 0;
            // }
        // }
        // cout << "Yes" << endl; return 0;
    // }
    
    for ( int i = 0; i < 26; i++ ) {        
        if ( !alphabet[i] ) { continue; }
        if ( alphabet[i]%2 && one ) {
            alphabet[i]--;
            one = 0;
            continue;
        }
        if ( alphabet[i]%2 && !one ) {
            cout << "No" << endl;  return 0;
        }
    }
    
    int f = 0;
    for ( int i = 0; i < 26; i++ ) {
        if ( alphabet[i] >= 4 ) {
            f += alphabet[i]/4;
        }
    }

    if ( four > f ) { cout << "No" << endl; return 0; }
    
    
    
    // for ( int i = 0; i < 26; i++ ) {
        // if ( !alphabet[i] ) { continue; }
        // if ( alphabet[i] >= 4 && four ) {
            // int x = max( 0, four-(alphabet[i]/4) );
            // alphabet[i] = x*4;
            // four = x;
        // }
    // }
    // if ( four ) { cout << "No" << endl;  return 0; }
    
    
    // for ( int i = 0; i < 26; i++ ) {
        // if ( !alphabet[i] ) { continue; }
        // if ( alphabet[i] >= 2 && two ) {
            // int x = max( 0, two-alphabet[i]/2 );
            // alphabet[i] = x*2;
            // two = x;
        // }
    // }
    // if ( two ) { cout << "No" << endl;  return 0; }
    
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#import <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a=0,b=0,c=0;
    int ans=0;
    for(int i=0;i<n;i++){
        a=b;
        b=c;
        scanf("%d",&c);
        if(i<=1) continue;
        if((a<b&&b<c)||(a>b&&b>c)) ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 2164
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

ll gcd(ll a, ll b){
  return b == 0 ? a : gcd(b, a % b);
}

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

  int n;
  cin >> n;

  ll a = 1;
  ll b = 1;
  REP(i, n) {
    ll x,y;
    cin >> x >> y;

    ll n = max((a-1)/x+1, (b-1)/y+1);
    a = n * x;
    b = n * y;
  }

  cout << a + b << endl;
  return 0;
}


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

int main(){
	int i,ch,j,t,n,b_n;
	char sen[128];
	while(scanf("%s",sen)!=-1){
		b_n=0;
		t=0;
		for(i=0;i<strlen(sen);i++){
			switch(sen[i]){
				case 'I':n=1;
					break;
				case 'V':n=5;
					break;
				case 'X':n=10;
					break;
				case 'L':n=50;
					break;
				case 'C':n=100;
					break;
				case 'D':n=500;
					break;
				case 'M':n=1000;
					break;
				default:n=0;
			}
			if(b_n){
				if(b_n>=n)t+=n;
				else t+=n-2*b_n;
			}else{
				t=n;
			}
			b_n=n;
		}
		printf("%d\n",t);
	}	
	return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,i,c=0;
  cin>>n;
  string s;
  unordered_map<string,long long int> mp;
  for(i=0;i<n;i++)
  {
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  for(auto x : mp)
  {
    c=c+(x.second*(x.second-1))/2;
  }
  cout<<c;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

signed main() {
    ll k, q;
    cin >> k >> q;
    vector<ll> d(k);
    for (int i = 0; i < k; i++) cin >> d[i];
    for (int i = 0; i < q; i++) {
        ll n, x, m;
        cin >> n >> x >> m;
        ll sum = 0, zero = 0, dSum = 0, zeroSum = 0;
        vector<ll> base(k);
        n--;
        for (int j = 0; j < k; j++) {
            base[j] = d[j] % m;
            if (base[j] == 0) zeroSum++;
            dSum += base[j];
        }
        sum = dSum * (n / k);
        zero = zeroSum * (n / k);
        for (int j = 0; j < n % k; j++) {
            sum += base[j];
            if (base[j] == 0) zero++;
        }
        sum += (x % m);
        cout << n - (sum / m) - zero << endl;
    }
}


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


int main() {
    int N;cin>>N;
    vector<int> v(N);
    for(int i=0;i<N;i++) cin>>v[i];

    sort(v.begin(), v.end());
    int l, r;
    
    l = (N/2)-1; r = N/2;
    int ans = v[r] - v[l];
    cout<<ans<<endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int64_t ans=0;
	for(int i=1;i<=n;++i){
		if(i%3==0||i%5==0)continue;
		ans+=i;
	}
	cout<<ans<<"\n"s;
}

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

int main(){
	int n,a,cnt = 0,f;
	cin >> n;
	for(int i = 0;i < n;++i){
		f = 1;
		cin >> a;
		for(int j = 2;j <= sqrt(a);++j){
			if(!(a % j)) {
				f = 0;
				break;
			}
		}
		if(f || a == 2) ++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1160
# pythonで青くなるブログ
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
lamps = [list(map(lambda x:int(x)-1, input().split()))[1:]
         #1個目は繋がっているスイッチの個数
         #2個目以降が繋がっているスイッチの番号
         for _ in range(M)]
p = list(map(int, input().split()))
# on になっているスイッチの個数を2で割った余りがpiに等しい時に点灯
ans = 0

# bit全探索(スイッチの入れ方を全探索する)
for i in range(1 << N):
    for r in range(M):  # 全てのランプがついてるかチェック
        on_sum = 0  # ランプrにおいて、onのスイッチの数
        for j in range(N):  # スイッチのj番目について
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1  
                # スイッチjがランプrに繋がってて、onならon_sum+=1
        if on_sum % 2 != p[r]:  # on_off check
            break  # 一つでもoffなら次のbitに
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
s = input()
t = input()
t_len =	len(t)

s_len =	len(s)
max=10000
for i in range(s_len-t_len+1):
  c=0
  for j in range(t_len):
    if s[i+j]!=t[j]:
      c+=1
  if c < max:
    max=c

print(max)

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



int main() {
	string s,t;
	char ss, tt;
	cin >> s >> t;
	int cnt = 0;
	for (int i = 0; i < s.length(); i++) {
		ss = s[i];
		tt = t[i];
		if (ss == tt)cnt++;
	}
	cout << s.length() - cnt << endl;
	
	return 0;
}

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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    int l=0;
    while(l<=(((int)s.size())-2) && s[l]=='h' && s[l+1]=='i')
    {
        l+=2;
    }
    if(l==s.size())
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using P   = pair<int, int>;
using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    set<int> s;
    for(int i=0;i<n;i++){
        int a;cin >> a;
        if(s.find(a) != s.end()){
            s.erase(a);
        }else{
            s.insert(a);
        }
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 4992
n=int(input())
a=[int(x) for x in input().split()]
q=int(input())
m=[int(x) for x in input().split()]


s = {0}
for i in a:
    s |= { x + i for x in s }

for q in m:
    if q in s:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5688
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll
//
//vector<int> G[20];
//
//// 巡回セールスマン問題
//
//signed main(){
//  int v,e;
//  cin>>v>>e;
//
//  for(int i=0; i<e; i++){
//    int a,b;
//    cin>>a>>b;
//    G[a].push_back(b);
//  }
//}























////  最長共通部分列

int dp[1005][1005];

signed main(){
  int n;
  cin>>n;
  for(int i=0; i<n; i++){
    string s1,s2;
    cin>>s1>>s2;
    s1=" "+s1;
    s2=" "+s2;
    int maxl=0;
    for(int i=0; i<=s1.size()-1; i++) for(int j=0; j<=s2.size(); j++) dp[i][j]=0;
    for(int i=1; i<=s1.size()-1; i++){
      for(int j=1; j<=s2.size(); j++){
        if(s1[i]==s2[j]) dp[i][j]=dp[i-1][j-1]+1;
        else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        maxl=max(maxl,dp[i][j]);
      }
    }
    cout<<maxl<<en;
  }
}




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

int main(){
  string s;
  cin>>s;
  int len = (int)s.length();
  int res = 0;
  for(int i = 0; i < len/2; i++){
    if(s[i]!=s[len-i-1]) res++;
  }
  cout<<res;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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 const INF = 1001001001;


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

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

if(a > 0) {
    cout << "Positive" << endl;
}
else if(a == 0) cout << "Zero" << endl;
else {
    if(b >= 0) cout << "Zero" << endl;
    else {
        if((b-a+1) % 2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
}

return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::io::*;

fn main() {
    let i = stdin();
    run(&mut i.lock(), &mut stdout());
}

fn run(i: &mut BufRead, o: &mut Write) {
    let n: usize = read(i);
    let mut cs = [0 as usize; 5];
    for _ in 0..n {
        let s = read_line(i);
        let h = h(&s);
        if let Some(i) = b"MARCH".iter().position(|&x| x == h) {
            cs[i] += 1;
        }
    }
    fn h(s: &String) -> u8 {
        s.as_bytes()[0]
    }

    let mut c0 = 0;
    for i0 in 0..cs.len() - 2 {
        let mut c1 = 0;
        for i1 in i0 + 1..cs.len() - 1 {
            let c2: usize = (&cs[i1 + 1..]).into_iter().sum();
            c1 += c2 * cs[i1];
        }
        c0 += c1 * cs[i0];
    }
    writeln!(o, "{}", c0).unwrap();
}

fn read_line(i: &mut BufRead) -> String {
    let mut line = String::new();
    i.read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn read<T: FromStr>(i: &mut BufRead) -> T {
    read_line(i).parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dp[3001][3001];

string getLCS(string &s, string &t, int l ){
    string ans="";
    int i=0,j=0;
    while(l>0){
        if(s[i]==t[j]){ans.push_back(s[i]);
            i++; j++; l--; 
        }
        else{
            if(dp[i+1][j]>dp[i][j+1]) i++;
            else j++;
        }
    }
    return ans;
}

int lenLCS(string &s, string &t, int n, int m, int i, int j){
    if(i>=n || j>=m) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    if(s[i]==t[j]) return dp[i][j]=lenLCS(s,t,n,m,i+1,j+1)+1; 
    else
    return dp[i][j]=max(lenLCS(s,t,n,m,i+1,j), lenLCS(s,t,n,m,i,j+1));
}

int main(){
    string s,t,p="";
    cin>>s>>t;
    memset(dp,-1,sizeof(dp));
    int n=s.length();
    int m=t.length();
    int l=lenLCS(s,t,n,m,0,0);
    cout<<getLCS(s,t,l);
    
}


Measured memory_bytes: 39316
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L;
    cin >> N >> L;
    int a[100010];
    rep(i, N) cin >> a[i];
    int idx = -1;
    rep(i, N - 1) {
        if(a[i] + a[i + 1] >= L) idx = i;
    }
    if(idx == -1) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    REP(i, 0, idx - 1) {
        cout << i + 1 << endl;
    }
    RREP(i, N - 2, idx + 1) {
        cout << i + 1 << endl;
    }
    cout << idx + 1 << endl;


    return 0;
}


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

int main(){
    int N,K;
    cin>>N>>K;
    int ans=0;
    for(int i=0;i<N;i++){
        int num;
        cin>>num;

        if(num>=K) ans++;
    }

    cout<<ans<<endl;


 return 0; 
}

Measured memory_bytes: 256