akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static void Main(string[] args)
        {
          //入力を受け取る
          var S = Console.ReadLine();
          var ans = 0;
          for(int i =0;i< S.Length ;i++){
            if(S[i] == '+'){
              ans++;
            }else{
              ans--;
            }
          }

          Console.WriteLine(ans);
        }
  
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;

  int ans = k;
  for (int i = 0; i < n - 1; i++) {
    ans *= (k - 1);
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
  ll N;
  scanf("%lld",&N);
  ll W;
  scanf("%lld",&W);
  vector<ll> w(N);
  vector<ll> v(N);
  for(int i=0; i<N; i++){
    scanf("%lld",&w[i]);
    scanf("%lld",&v[i]);
  }

  vector<vector<ll>> dp(N+1, vector<ll>(W+1, 0));
  for (int i=0; i<N; i++) {
    for (int j=0; j<=W; j++) {
      if (j>=w[i]) {
        dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
      } else {
        dp[i+1][j] = dp[i][j];
      }
    }
  }
  cout << dp[N][W] << endl;

  return 0;
}


Measured memory_bytes: 80256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        long N = Long ();

        int max = (int) Math.Sqrt ((double) N) + 1;
        long min = 10000000000000;
        for (int i = 1; i < max; i++) {
            if (N % i != 0) {
                continue;
            }
            min = Math.Min (min, i - 1 + N / i - 1);
        }

        Console.WriteLine (min);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 13140
N = input()
A = map(int,raw_input().split())

flag = 1
x = 0
while flag:
    flag = 0
    for i in range(1,N):
        j = N - i
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            x += 1
            flag = 1

for i in range(N-1):
    print A[i],
print A[-1]

print x

Measured memory_bytes: 6420
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
// static const int max_n = 110;
// static const llong max_cost = 2000000000000000;
// // vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// // vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
// vector<vector<pair<llong, int>>> adj_list(max_n);
// vector<llong> distance_table(max_n, max_cost);
// set<pair<llong, int>> points_sort_x;
// set<pair<llong, int>> points_sort_y;

// int N;



int main(){
    // int u, v;
    // bool updated = false;
    ll H, W, low_h, high_h, low_w, high_w;
    cin >> H >> W;

    if(H%2==0){
        low_h = H /2;
        high_h = H /2;
    }else{
        low_h = (H - 1) / 2;
        high_h = (H + 1)/2;
    }

    if(W % 2 == 0){
        low_w = W / 2;
        high_w = W / 2;
    }else{
        low_w = (W - 1) / 2;
        high_w = (W + 1)/ 2;
    }

    ll ans = low_w * low_h + high_w * high_h;
    if(H==1){
        ans = 1;
    }
    if(W==1){
        ans = 1;
    }
    printf("%lld\n", ans);


    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vint;
typedef vector<vint> vvint;

static int n;
static vint arr;

long long solve(void){
    long long res = 0;

    for(int i = 1; i < n; i++){
        if(arr[i] < arr[i-1]){
            res += arr[i-1] - arr[i];
            arr[i] = arr[i-1];
        }
    }

    return res;
}

int main()
{
	while(cin >> n){
		arr.resize(n);
        for(int i = 0; i < n; i++)
            cin >> arr[i];

        cout << solve() << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second
#define all(a) a.begin(),a.end()
#define rev(a) reverse(all(a))
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mod 1000000007
#define inf 100000000
#define limit 200005
#define minval -100000000000000000
#define maxval 1000000000000000
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 
void input()
{
  int n, m, nt;
  cin >> n >> m >> nt;
  int xt[nt];
  int yt[nt];
  rep(i,nt)
  {
    cin >> xt[i] >> yt[i];
    xt[i]--, yt[i]--;
  }
  vi fx(n,0), fy(m, 0);
  rep(i,nt)
      fx[xt[i]]++, fy[yt[i]]++;
  
  int mfx = -1, mfy = -1;
  rep(i,n)
    mfx = max(mfx, fx[i]);
  rep(i,m)
    mfy = max(mfy, fy[i]);
  
  vi flagx(n,0), flagy(m,0);
  int cx = 0, cy = 0;
  rep(i,n)
    if(fx[i] == mfx)
        flagx[i]++, cx++;
  rep(i,m)
    if(fy[i] == mfy)
        flagy[i]++, cy++;

  lli ans = mfx + mfy - 1, cnt = 0;
  rep(i,nt)
  {
      if(flagx[xt[i]] && flagy[yt[i]])
        cnt++;
  }
  if(1LL*cx*cy > cnt)
    ans++;
  cout << ans << '\n';

}
int main()
{
   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   */
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}


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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define LOCAL
#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 <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector<string> v;
    set<string> s;
    int n;
    cin>>n;
    f(n){
        string tmp;cin>>tmp;
        v.pb(tmp);
        s.insert(tmp);
    }
    if(sz(s)!=n){
        cout<<"No";
        return 0;
    }
    f(n-1){
        if(v[i][sz(v[i])-1]!=v[i+1][0]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();
		sc.close();

		int cnt = 0;
		for (int i = 0; i < S.length; i++) {
			if (S[i] != T[i]) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 41832
#include<stdio.h>
#include<stdlib.h>

int compare_int_big(const void *a,const void *b){
    return *(int *)b - *(int *)a;
}

int compare_int_small(const void *a,const void *b){
    return *(int *)a - *(int *)b;
}

int main(void)
{
    int ans = 0;

    int N;
    char S[51];
    int flag=0;

    scanf("%d",&N);
    scanf("%s",S);

    for(int i =0; i< N ; i++){
        if(S[i]=='A'){
            if(S[i+1]=='B'){
                if(S[i+2]=='C'){
                    ans++;
                }
            }
        }
    }

    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll K;
    cin >> K;

    queue<ll> que;
    repi(i, 10) que.push(i);

    ll cnt = 0;
    while (true) {
        ll v = que.front();
        que.pop();
        cnt++;
        if (cnt == K) {
            put(v);
            return;
        }

        ll m = v % 10;
        if (m != 0) que.push(10 * v + m - 1);
        que.push(10 * v + m);
        if (m != 9) que.push(10 * v + m + 1);
    }

}
signed main(){ Main();return 0;}

Measured memory_bytes: 5112
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template <typename T> using order_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T1, typename T2> using order_map = tree <T1, T2, less <T1>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T> bool MIN(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool MAX(T &a, T b) { return a < b ? (a = b, true) : false; }

#define ll              long long int
#define endl            '\n'
#define pii             pair <int, int>
#define pll             pair <ll, ll>
#define mk              make_pair
#define ff              first
#define ss              second
#define all(a)          (a).begin(), (a).end()
#define rall(a)         (a).rbegin(), (a).rend()
#define eb              emplace_back
#define pb              push_back
#define LINE            __LINE__

static const int maxn = 2e5 + 5;
static const int logn = 19;

vector < vector <int> > graph;
int par[maxn];
bool vis[maxn];

void bfs(int src = 1) {
      queue <int> pq;
      pq.push(src);
      vis[src] = 1;
      while (pq.size()) {
            int u = pq.front(); pq.pop();
            for (int v : graph[u]) {
                  if (vis[v]) {
                        continue;
                  }
                  vis[v] = 1;
                  par[v] = u;
                  pq.push(v);
            }
      }
}

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

      int n, m;
      cin >> n >> m;
      graph.resize(n + 1);
      for (int e = 1; e <= m; e++) {
            int u, v;
            cin >> u >> v;
            graph[u].eb(v);
            graph[v].eb(u);
      }
      bfs();
      for (int i = 1; i <= n; i++) {
            if (vis[i] == 0) {
                  cout << "No" << endl;
                  return 0;
            }
      }
      cout << "Yes" << endl;
      for (int i = 2; i <= n; i++) {
            cout << par[i] << endl;
      }

      #ifndef ONLINE_JUDGE
            cerr << endl << "Time : " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
      #endif // ONLINE_JUDGE
}


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

int main()
{
    long long n;
    cin>>n;
    long long ax=sqrt(n);
    long long s;
    for(int i=ax;i>=1;i--)
    {
        if(n%i==0)
        {
            s=i;
            break;
        }
    }
    s=n/s;
    int ans=0;
    while(s!=0)
    {
        s/=10;
        ans++;
    }cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string S;
    cin >> S;
    map<char,int> m;
    REP(i,S.size()) ++m[S[i]];
    bool check = true;
    if((m['E']==0&&m['W']!=0)||(m['E']!=0&&m['W']==0)) check = false;
    if((m['N']==0&&m['S']!=0)||(m['N']!=0&&m['S']==0)) check = false;
    cout << (check ? "Yes" : "No") << '\n';
    return 0;
}

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

int n, a[100];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	cout << a[n - 1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  auto GG(G);
  vector<Int> a(m),b(m);
  for(Int i=0;i<m;i++) cin>>a[i]>>b[i];
  
  vector<vector<Int> > H(n);
  for(Int i=0;i<m;i++){
    a[i]--;b[i]--;
    H[a[i]].emplace_back(i);
    H[b[i]].emplace_back(i);
  }
  
  Int ans=0;
  vector<vector<Int> > C(n*m+114514);
  auto sw=
    [&](Int x){
      queue<Int> q({x});
      while(!q.empty()){
	x=q.front();q.pop();
	swap(a[x],b[x]);
	for(Int y:C[x]) q.emplace(y);
      }
    };

  vector<Int> used(n*m+114514,0);
  while(1){
    Int idx=-1;
    for(Int i=0;i<n;i++)
      if(G[i].size()==1u) idx=i;
    if(idx<0) break;
      
    H[idx].erase(remove_if(H[idx].begin(),H[idx].end(),
			   [&](Int v){return used[v];}),
		 H[idx].end());      
      
    Int x=-1,y=-1;
    if(H[idx].size()>1u){
      x=H[idx].back();
      H[idx].pop_back();
      y=H[idx].back();
      H[idx].pop_back();

      Int u=a[x]!=idx?a[x]:b[x];
      Int v=a[y]!=idx?a[y]:b[y];
	
      if(u!=a[x]) sw(x);
      if(v!=b[y]) sw(y);

      used[x]=used[y]=1;
      if(u!=v){
	H[u].emplace_back(a.size());
	H[v].emplace_back(b.size());
	  
	C[a.size()].emplace_back(x);
	C[b.size()].emplace_back(y);
	  
	a.emplace_back(u);
	b.emplace_back(v);
      }
      ans+=2;
    }else ans+=H[idx].size();

	  
    Int k=G[idx][0];
    G[idx].clear();
    G[k].erase(remove_if(G[k].begin(),G[k].end(),
			 [&](Int v){return v==idx;}),
	       G[k].end());
      
    vector<Int> tmp(H[idx]);
    H[idx].clear();
    for(Int z:tmp){
      if(used[z]) continue;
      used[z]=1;
      Int u=(a[z]==idx?k:a[z]);
      Int v=(b[z]==idx?k:b[z]);
      if(u==v) continue;
      
      H[u].emplace_back(a.size());
      H[v].emplace_back(b.size());
      
      C[a.size()].emplace_back(z);
      
      a.emplace_back(u);
      b.emplace_back(v);
    }
  };
  {
    vector<Int> ps(n);
    function<void(Int, Int)> dfs=
      [&](Int v,Int p){
	ps[v]=p;
	for(Int u:GG[v])
	  if(u!=p) dfs(u,v);
      };
    using P = pair<Int, Int>;
    set<P> sp;
    for(Int i=0;i<m;i++){
      dfs(b[i],-1);
      Int v=a[i];
      while(v!=b[i]){
	sp.emplace(v,ps[v]);
	v=ps[v];
      }
    }
    Int res=sp.size();
    //cout<<res<<" "<<ans<<endl;
    ans=res;
    //assert(res==ans);
  }
  cout<<ans<<endl;
  for(Int i=0;i<m;i++) cout<<++a[i]<<" "<<++b[i]<<endl;
  return 0;
}


Measured memory_bytes: 130816
#include<bits/stdc++.h>
using namespace std;
int main()
{
long a[10000],i,k,l,c,v;
string s;
while(cin>>s)
{
c=0;
for(i=0;i<s.size();i++)
{if(s[i]=='1')
c++;
}
cout<<c<<endl;
}
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

def check
end

if $0 == __FILE__
  S = gets.chomp

  targets = %w(dreamer dream eraser erase)
  # i文字目で区切れる場合dp[i] = true
  # e.g. S = dreamer -> dp[0], dp[5], dp[7] = true
  # erasedream
  dp = Array.new(S.length+1)
  dp[0] = true

  i = 0
  while i <= S.length
    if dp[i]
      targets.each do |t|
        if S[i...(i+t.length)] == t
          dp[i+t.length] = true
        end
      end
    end

    i += 1
  end

  puts(dp[S.length] ? 'YES' : 'NO')
end



Measured memory_bytes: 2812
#include <iostream>
#include <queue>

using namespace std;

namespace {

const char kOps[4] = {'S', 'N', 'E', 'W'};

struct State {
  const int* v;
  int top;
  int bottom;
  int front;
  int back;
  int left;
  int right;

  void Init(const int* a) {
    v = a;
    top = 1;
    bottom = 6;
    front = 2;
    back = 5;
    left = 4;
    right = 3;
  }

  bool Equal(const State& o) const {
    return v[top - 1] == o.v[o.top - 1] && v[bottom - 1] == o.v[o.bottom - 1] &&
           v[front - 1] == o.v[o.front - 1] && v[back - 1] == o.v[o.back - 1] &&
           v[left - 1] == o.v[o.left - 1] && v[right - 1] == o.v[o.right - 1];
  }

  // void Print() const {
  //   printf("%d %d %d %d %d %d\n", v[top - 1], v[bottom - 1], v[front - 1],
  //          v[back - 1], v[left - 1], v[right - 1]);
  // }
};

State Next(const State& s, char c) {
  State o;
  o.v = s.v;
  int temp = 0;
  switch (c) {
    case 'S':
      temp = s.front;
      o.front = s.top;
      o.top = s.back;
      o.back = s.bottom;
      o.bottom = temp;
      o.left = s.left;
      o.right = s.right;
      break;
    case 'N':
      temp = s.back;
      o.back = s.top;
      o.top = s.front;
      o.front = s.bottom;
      o.bottom = temp;
      o.left = s.left;
      o.right = s.right;
      break;
    case 'E':
      temp = s.right;
      o.right = s.top;
      o.top = s.left;
      o.left = s.bottom;
      o.bottom = temp;
      o.front = s.front;
      o.back = s.back;
      break;
    case 'W':
      temp = s.left;
      o.left = s.top;
      o.top = s.right;
      o.right = s.bottom;
      o.bottom = temp;
      o.front = s.front;
      o.back = s.back;
      break;
  }
  return o;
}

bool BFS(const int* values1, const int* values2) {
  State goal;
  goal.Init(values1);

  State start;
  start.Init(values2);
  queue<State> q;
  q.push(start);

  int n = 0;
  while (!q.empty()) {
    if (n >= 24) break;
    const State p = q.front();
    q.pop();

    for (size_t i = 0; i < 4; ++i) {
      State o = Next(p, kOps[i]);
      if (goal.Equal(o)) {
        return true;
      }
      q.push(o);
    }
    ++n;
  }

  return false;
}

}  // namespace

int main() {
  int values1[6];
  int values2[6];

  for (int i = 0; i < 6; ++i) {
    cin >> values1[i];
  }
  for (int i = 0; i < 6; ++i) {
    cin >> values2[i];
  }
  if (BFS(values1, values2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
#include <vector>
#define N1 1001
using namespace std;
int Search(int);
int N,M,P[N1];
vector<int> V;
int main(){
  int i,j,maxv,r;
  while(1){
    cin >> N >> M;
    if(N==0&&M==0) break;
    for(i=0;i<N;i++){
      cin >> P[i];
      V.push_back(P[i]);
    }
    V.push_back(0);
    for(i=0;i<N;i++){
      for(j=i;j<N;j++){
	V.push_back(P[i]+P[j]);
      }
    }
    sort(V.begin(),V.end());
    //    for(i=0;i<V.size();i++) cout << V[i] << endl;
    maxv=0;
    for(i=0;i<V.size();i++){
      if(V[i]<M){
	r=Search(V[i]);
	maxv=max(maxv,V[i]+r);
      }
    }
    cout << maxv << endl;
    V.clear();
  }
  return 0;
}
int Search(int a){
  int left=0,right=V.size(),mid;
  while(left<right){
    //x    cout << left << ' ' << right << endl;
    mid=(right+left)/2;
    if(a+V[mid]<=M) left=mid+1;
    else if(a+V[mid]>M) right=mid;
  }
  return V[left-1];
}

Measured memory_bytes: 3172
package main

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

var (
	BufferSize = 10 * 10 * 10 * 10 * 10 * 10
)

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func getRev(before byte) byte {
	if before == '0' {
		return '1'
	}
	return '0'
}

func cSum() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	k := scanInt(sc)
	s := scanStr(sc)

	// fmt.Printf("n = %+v\n", n)
	// fmt.Printf("k = %+v\n", k)
	// fmt.Printf("s = %+v\n", s)

	csum := make([]int, 0, len(s)+10)

	before := s[0]
	csum = append(csum, 1)
	for i := 1; i < n; i++ {
		if s[i] != before {
			csum = append(csum, csum[len(csum)-1]+1)
		} else {
			csum[len(csum)-1]++
		}
		before = s[i]
	}

	// fmt.Printf("csum = %+v\n", csum)

	max := 0
	for i := 0; i < len(csum); i += 2 {
		var rightIndex int
		if s[0] == '0' {
			rightIndex = i + 2*k - 1
		} else {
			rightIndex = i + 2*k
		}
		var right int
		if rightIndex > len(csum)-1 {
			rightIndex = len(csum) - 1
		}
		right = csum[rightIndex]

		var leftIndex int
		if s[0] == '0' {
			leftIndex = i - 2
		} else {
			leftIndex = i - 1
		}
		var left int
		if leftIndex < 0 {
			leftIndex = -1
			left = 0
		} else {
			left = csum[leftIndex]
		}
		length := right - left
		// fmt.Printf("[%d](%d) - [%d](%d): %d\n", leftIndex, left, rightIndex, right, length)
		if length > max {
			max = length
		}
	}

	fmt.Printf("%d\n", max)
}

func main() {
	cSum()
}


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

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

int ans[10][10];
int latte[10][10];

void change(int y,int x){
    for(int d=0;d<5;d++){
        int ty=y+dy[d],tx=x+dx[d];
        if(ty<0||ty>=10||tx<0||tx>=10)continue;
        latte[ty][tx]=1-latte[ty][tx];
    }
}

void solve(){
    int fld[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin>>fld[i][j];
        }
    }

    for(int s=0;s<(1<<11);s++){
        fill_n(*ans,100,0);

        for(int i=0;i<10;i++)
            for(int j=0;j<10;j++)
                latte[i][j]=fld[i][j];

        for(int i=0;i<10;i++){
            if((s>>i)&1){
                ans[0][i]=1;
                change(0,i);
            }
        }

        for(int i=1;i<10;i++){
            for(int j=0;j<10;j++){
                if(latte[i-1][j]){
                    ans[i][j]=1;
                    change(i,j);
                }
            }
        }

        bool f=true;
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(latte[i][j])f=false;
            }
        }

        if(f){
            for(int i=0;i<10;i++){
                for(int j=0;j<10;j++){
                    if(j)cout<<" ";
                    cout<<ans[i][j];
                }
                cout<<endl;
            }
            return;
        }
    }
}

int main(){
    int N;
    cin>>N;
    while(N--)solve();
    return 0;
}

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

using namespace std;

int T[1010],prime[1010],cnt;
bool ok[1010];
typedef long long LL;
LL MOD = 1000000007;

int main()
{	
	memset(ok,true,sizeof(ok));
	for (int i=2;i<=1000;i++)
	{
		if (ok[i]) prime[++cnt]=i;
		for (int j=2*i;j<=1000;j+=i)ok[j]=false;
	}
	//for (int i=1;i<=cnt;i++)printf("%d\n",prime[i]);
	int N;
	scanf("%d",&N);
	for (int i=1;i<=N;i++)
	{
		int tmp=i;
		for (int j=1;j<=cnt;j++)
		{
			while(tmp%prime[j]==0)
			{
				tmp/=prime[j];
				T[j]++;
			}
		}
	}
	LL ans=1;
	for (int i=1;i<=cnt;i++)ans=ans*LL(T[i]+1)%MOD;
	cout<<ans<<endl;
}

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

using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<pair<int, int>> p(N);
    int a, b;
    for (int i = 0; i < N; ++i) {
        cin >> a >> b;
        p[i] = pair<int, int>(a, b);
    }

    sort(p.begin(), p.end());
    long long cost = 0;
    for (int i = 0, cnt = 0; cnt != M; ++i) {
        long long bc = min(p[i].second, M-cnt);
        cnt   += bc;
        cost  += bc * p[i].first;
    }

    cout << cost << endl;

}

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

bool eight(int n){
  int y = 0;
  for(int i = 1; i <= n; i++){
    if(n % i == 0){
      y++;
    }
  }
  return y == 8;
}

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(i % 2 == 1){
    if(eight(i)) ans++;
  }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define faster_io ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
using namespace std;
const ll N = 1e6 + 7, M = 1e5 + 7, mod = 998244353, inf = 1e9 + 7;
ll n, m, q, a, b, c, d, i, j, k, ans;
//ll ar[N];
string s;
vector < ll > vec;

int main()
{
    faster_io;
    cin >> n >> m;
    if(n * 500 >= m)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifdef BIZON
	#define rr(x) cerr << "\e[1;38;5;172m" << #x << "\e[0m = " << (x) << endl;
#else
	#define rr(x)
	#define endl '\n'
#endif
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

int __; 
#define in (cin>>__, (int)__)


int main(){
	if(auto f="in.txt"; fopen(f,"r") && freopen(f,"r",stdin));
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(9);cout<<fixed;
	
	
	int n = in, D = in;
	
	vector<int> x(n);
	for(auto &_ : x) cin>>_;
	
	constexpr int L = 18;
	vector<array<pair<int,ll>,L>> pl(n), pr(n);
	
	for(int i=n-1, j = n; i>=0; --i){
		while(j-1>i && abs(x[j-1]-x[i])>=D) --j;
		pr[i][0] = {j, 0};
		for(int l=1;l<L;++l){
			int k = pr[i][l-1].first;
			if(k==n) pr[i][l] = pr[i][l-1];
			else pr[i][l] = {pr[k][l-1].first, pr[k][l-1].second + pr[i][l-1].second + k};
		}
	}
	
	for(int i=0, j = -1; i<n; ++i){
		while(j+1<i && abs(x[j+1]-x[i])>=D) ++j;
		pl[i][0] = {j, 0};
		for(int l=1;l<L;++l){
			int k = pl[i][l-1].first;
			if(k==-1) pl[i][l] = pl[i][l-1];
			else pl[i][l] = {pl[k][l-1].first, pl[k][l-1].second + pl[i][l-1].second + k};
		}
	}
	
	
	int m = in;
	while(m--){
		int l = in-1, r = in-1;
		
		int fr = l, cr = 1;
		ll sr = 0;
		for(int k=L-1; k>=0; --k) if(pr[fr][k].first<=r) 
			sr+=fr+pr[fr][k].second, fr = pr[fr][k].first, cr+=1<<k;
		sr+=fr;
		
		
		int fl = r, cl = 1;
		ll sl = 0;
		for(int k=L-1; k>=0; --k) if(pl[fl][k].first>=l) 
			sl+=fl+pl[fl][k].second, fl = pl[fl][k].first, cl+=1<<k;
		sl+=fl;
		
		//cout<<cl<<' '<<cr<<endl;
		assert(cl==cr);
		
		ll res = cl + sl - sr;
		cout<<res<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 116424
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class UnionFindTree
{
private:
    const int n;
    int groupNum;       // ??°??????????????°
    vector<int> parent; // ????????????
    vector<int> rank;   // ??¨??????????????????
    vector<int> num;    // ??°????????????????´???°
    int find(int i){
        if(parent[i] == i)
            return i;
        else
            return parent[i] = find(parent[i]);
    }
public:
    UnionFindTree(int n) : n(n){ // ?????????????????????
        groupNum = n;
        parent.resize(n);
        for(int i=0; i<n; ++i)
            parent[i] = i;
        rank.assign(n, 0);
        num.assign(n, 1);
    }
    void unite(int a, int b){ // a??¨b?????°??????????????????
        if((a = find(a)) != (b = find(b))){
            if(rank[a] < rank[b]){
                parent[a] = b;
                num[b] += num[a];
            }
            else{
                parent[b] = a;
                if(rank[a] == rank[b])
                    ++ rank[a];
                num[a] += num[b];
            }
            -- groupNum;
        }
    }
    bool same(int a, int b){ // a??¨b?????°?????????????????????????????????
        return find(a) == find(b);
    }
    int getNum(){ // ??°??????????????°?????????
        return groupNum;
    }
    int getNum(int a){ // a?????°????????????????´???°?????????
        return num[find(a)];
    }
};

bool solve(const vector<vector<int> >& edges)
{
    int n = edges.size();

    UnionFindTree uft(n);
    for(int a=0; a<n; ++a){
        if(edges[a].size() > 2)
            return false;
        for(int b : edges[a]){
            if(a < b){
                if(uft.same(a, b))
                    return false;
                uft.unite(a, b);
            }
        }
    }
    return true;
}

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<vector<int> > edges(n);
        for(int i=0; i<m; ++i){
            int u, v;
            cin >> u >> v;
            -- u;
            -- v;
            edges[u].push_back(v);
            edges[v].push_back(u);
        }

        if(solve(edges))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}

Measured memory_bytes: 7340
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/

/+---test
2020 2040
---+/
/+---test
4 5
---+/

void main(string[] args) {
  long L, R;
  readf(" %d %d ", &L, &R);

  auto ans = long.max;
  foreach (i; L..R+1) foreach (j; i+1..R+1) {
    ans.amin(i*j%2019);
    if (ans == 0) goto FINALIZE;
  }

FINALIZE:
  ans.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define clr(A, x) memset(A, x, sizeof(A))
#define cpy(A, B) memcpy(A, B, sizeof(B))
#define g(s) getline(cin, s) ///ai grija la fin/cin ///
#define FASTIO ios_base::sync_with_stdio(0)
const long long INFLL = 2 * 1e18 + 100;
const int INFINT = 2 * 1e9 + 100;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//ifstream fin("input.txt");
//ofstream fout("output.txt");
void die()
{
    cout << "-1";
    exit(0);
}
const int NMAX = 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;

int fixat[20];
int liber, sol;

int main()
{
    FASTIO;
    int n;
    cin >> n;
    for1(i, n)
    {
        int a;
        cin >> a;
        int ori = 1;
        while(400 * ori <= 3200)
        {
            if(a < 400 * ori)
            {
                fixat[ori] = 1;
                break;
            }
            ori++;
        }
        if(400 * ori > 3200) liber++;
    }
    for1(i, 15)
        sol += fixat[i];
    if(liber) cout << max(sol, 1) << ' ';
    else cout << sol << ' ';
    cout << sol + liber;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  while(true){
    int n,p=0,sum=0,score[15]={};
    char c;
    cin>>n;
    if(n==0) break;
    else{
      for(int i=0;i<100;i++){
	cin>>c;
	if(p>=n) p=0;
	if(c=='M'){
	  score[p]++;
	  p++;
	}
	else if(c=='S'){
	  score[p]++;
	  sum+=score[p];
	  score[p]=0;
	  p++;
	}
	else if(c=='L'){
	  score[p]++;
	  score[p]+=sum;
	  sum=0;
	  p++;
	}
      }
      sort(score,score +n);
      for(int i=0;i<n;i++){
	cout<<score[i]<<" ";
      }
      cout<<sum<<'\n';
      sum=0;
      p=0;
    }
  }
  return(0);
}



Measured memory_bytes: 3224
import heapq

h,w=map(int,input().split())

a=[input() for _ in range(h)]

alphabet={}

for i in range(h):
    for j in range(w):
        if a[i][j] in alphabet:
            alphabet[a[i][j]]+=1
        else:
            alphabet[a[i][j]]=1

same=[-x for x in alphabet.values()]
heapq.heapify(same)

cnt={}

for i in range(h):
    for j in range(w):
        hh=min(i,h-i-1)
        ww=min(j,w-j-1)

        if (hh,ww) in cnt:
            cnt[(hh,ww)]+=1
        else:
            cnt[(hh,ww)]=1

cntv=sorted(cnt.values())

while cntv:
    c=heapq.heappop(same)
    c=-c
    ccnt=cntv.pop()

    if ccnt>c:
        print('No')
        exit(0)
    elif ccnt<c:
        heapq.heappush(same,ccnt-c)

print('Yes')

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

void fst()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int nxt()
{
    int x;
    cin >> x;
    return x;
}
int nex_l()
{
    long long x;
    cin >> x;
    return x;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define binary(n) cout << bitset<31>(n) << "\n";
#define FOR(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define input_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cin >> a[i];
#define print_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cout << a[i] << " ";
#define deb(n) cerr << #n << "=" << n << "\n";

int main()
{
    ll n;
    cin >> n;
    map<ll, ll> m;
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        m[x]++;
        sum += x;
    }
    int q;
    cin >> q;
    while (q--)
    {
        int b, c;
        cin >> b >> c;
        sum -= b * m[b];
        sum += c * m[b];
        m[c] += m[b];
        m[b] = 0;
        cout << sum << "\n";
    }
}


Measured memory_bytes: 9432
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
using namespace std;

typedef long long ll;
string s;
int N;
ll m, a, r, c, h;
ll D[5];
int P[10] = { 0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2 };
int Q[10] = { 1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3 };
int R[10] = { 2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4 };
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> s;
		if (s[0] == 'M') m++;
		if (s[0] == 'A') a++;
		if (s[0] == 'R') r++;
		if (s[0] == 'C') c++;
		if (s[0] == 'H') h++;
	}
	D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;
	ll res = 0;
	for (int d = 0; d < 10; d++) {
		res += D[P[d]] * D[Q[d]] * D[R[d]];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int fibonacci (int);
int f[50];

int main (void)
{
  int n,sum;

  scanf ("%d",&n);

  if (n >= 0 && n <= 44)
    sum = fibonacci (n);

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

  return 0;
}

int fibonacci (int n)
{
  if (n == 0 || n == 1)
    return f[n] = 1;
  if (f[n])
    return f[n];

  return f[n] = fibonacci(n-2) + fibonacci(n-1);
}

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

    class Program
    {
        static void Main(string[] args)
        {
        int N_length=int.Parse(System.Console.ReadLine());
        string A = (System.Console.ReadLine());
        string B = (System.Console.ReadLine());
        string C = (System.Console.ReadLine());
        int difference = 0;
        for(int i = 0; i < N_length; i++)
        {
            if (A[i].Equals(B[i])&& A[i].Equals(C[i])) { }
            else if(A[i].Equals(B[i])|| A[i].Equals(C[i])|| C[i].Equals(B[i])) { difference++; }
            else { difference += 2; }
        }
        System.Console.WriteLine(difference);
    }
    }


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

int main(){
  double w;
  while(cin>>w){
    if(w<=48)cout<<"light fly"<<endl;
    else if(48<w&&w<=51)cout<<"fly"<<endl;
    else if(51<w&&w<=54)cout<<"bantam"<<endl;
    else if(54<w&&w<=57)cout<<"feather"<<endl;
    else if(57<w&&w<=60)cout<<"light"<<endl;
    else if(60<w&&w<=64)cout<<"light welter"<<endl;
    else if(64<w&&w<=69)cout<<"welter"<<endl;
    else if(69<w&&w<=75)cout<<"light middle"<<endl;
    else if(75<w&&w<=81)cout<<"middle"<<endl;
    else if(81<w&&w<=91)cout<<"light heavy"<<endl;
    else if(91<w)cout<<"heavy"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3208
W,H,x,y,r = map(int, raw_input().split())
if x - r >= 0 and x + r <= W and y - r >= 0 and y + r <= H:
        print "Yes"
elif x - r < 0 or x + r > W or y - r < 0 or y + r > H:
        print "No"
else:
        print "No"

Measured memory_bytes: 6396
while True:
    input_value = input()

    height, width = map(int, input_value.split())

    if height == 0 and width == 0:
        break

    columns = ['#'] * width
    line = ''.join(columns)

    rows = [line] * height
    rectangle = '\n'.join(rows)

    print(rectangle)
    print()


Measured memory_bytes: 5640
n, m = map(int, input().split())

ans = 0
s = []
for i in range(m):
    S = list(map(int, input().split()))
    s.append(S[1:])

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

for i in range(2**n):
    flag = 0
    for j in range(m):
        count = 0
        for sj in s[j]:
            if (1 << (sj-1)) & i:
                count += 1
        if count % 2 != p[j]:
            flag = 1
            break
    if flag:
        continue
    ans += 1

print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner inputs = new Scanner(System.in);
		String s = inputs.next();
		if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	cin >> a >> b >> c >> d;
	//string s;
	//std::cin >> s;
	if (a + b > c + d) {
		cout << "Left" << "\n";
	}
	else if (a + b == c + d) {
		cout << "Balanced" << "\n";
	}
	else if (a + b < c + d) {
		cout << "Right" << "\n";
	}
	std::cin >> e;
}

Measured memory_bytes: 256
z64 = 9876543210 - 9876543210
e64 = z64 + 1

k = gets.to_s.to_i

q = Array.new(9){|i| e64+i }

(k-1).times do
  s = q.shift
  -1.upto(1) do |i|
    a = s % 10 + i
    q.push s * 10 + a if 0 <= a && a <= 9
  end
end

p q[0]

Measured memory_bytes: 5372
#define    ll           long long
#define    dn           double
#define    mp           make_pair
#define    pb           push_back
#define    se           second
#define    fi           first
#define    mod          1000000007
#define    sob(v)       v.begin(),v.end()
#define    sobr(v)      v.rbegin(),v.rend()
#define    fr(i,a,b)    for(int i=a;i<=b;++i)
#define    frr(i,a,b)   for(int i=a;i>=b;--i)
#define    pi           acos(-1.00)
#define    check        cout<<"*"<<endl
#define    ffix(x)      cout<<fixed<<setprecision(x)
#define    fast         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<int,vi> pp;

int dr[8]= {0,0,-1,1,-1,-1,+1,+1};
int dc[8]= {-1,1,0,0,-1,+1,-1,+1};

const int N=2000005;

/*inline void normal(ll &a){if(a>mod) a%=mod; (a<0) && (a+=mod);}
inline ll mod_mul(ll a,ll b){normal(a),normal(b); return (a*b)%mod;}
inline ll mod_add(ll a,ll b){normal(a),normal(b); return (a+b)%mod;}
inline ll mod_sub(ll a,ll b){normal(a),normal(b); a-=b; normal(a); return a;}
inline ll mod_pow(ll a,ll b){ll r=1; while(b>0){if(b&1)r=mod_mul(r,a); a=mod_mul(a,a); b>>=1;} return r;}
inline ll mod_inverse(ll a){return mod_pow(a,mod-2);}
inline ll mod_div(ll a,ll b){return mod_mul(a,mod_inverse(b));}*/

int lp[N+1];
vector<int> pr;

void sieve()
{
    for (int i=2; i<=N; ++i)
    {
        if (lp[i] == 0)
        {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}
int main()
{
    int n;
    cin>>n;
    sieve();
    int a[n+1],g=0;
    map<int,int>mm;

    fr(i,1,n)
    {
        cin>>a[i];
        g=__gcd(g,a[i]);
        int x=a[i];
        while(x>0)
        {
            int y=lp[x];
            if(!y)break;
            mm[y]++;
            while(x%y==0)x/=y;
        }
    }
    int nn=pr.size(),f=0;
    fr(i,0,nn-1)
    {
        if(mm[pr[i]]>1)
        {
            f=1;
            break;
        }
    }
    if(f==0)cout<<"pairwise coprime"<<endl;
    else if(g==1)cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}


Measured memory_bytes: 22540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >>N;
  vector<long long>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int count=0;
  for(int i=0;i<N;i++){
    while(A.at(i)%2==0){
      count++;
      A.at(i)/=2;
    }
  }
  cout <<count<<endl;
}

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

int gcd(int a, int b)
{
    if (b > a)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    int k = a % b;

    while (k != 0)
    {
        a = b;
        b = k;
        k = a % b;
    }

    return b;
}

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int K;

    ist >> K;

    /* ------- 計算 ------- */

    long long ans = 0;

    for (int a = 1; a <= K; a++)
    {
        for (int b = 1; b <= K; b++)
        {
            for (int c = 1; c <= K; c++)
            {
                ans += gcd(gcd(a,b),c);
            }
        }
    }

    ost << ans << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3216
#include<stdio.h>

int main(void){

	char s[10];
	int n;

	while(fgets(s,sizeof(s),stdin) != NULL){

		sscanf(s,"%d",&n);

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

	}
	return(0);
}

int func(int n){
	int a,b,c,d,m = 0;

	for(a=0;a<=9;a++){
		for(b=0;b<=9;b++){
			for(c=0;c<=9;c++){
				for(d=0;d<=9;d++){
					if(a+b+c+d == n){
						m+=1;
					}
				}
			}
		}
	}
	return m;
}

Measured memory_bytes: 0
import java.util.Scanner;

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

		int[] v = new int[n];
		int[] c = new int[n];

		int i;
		for(i = 0; i < n; i++) {
			v[i] = scan.nextInt();
		}

		for(i = 0; i < n; i++) {
			c[i] = scan.nextInt();
		}

		int ans = 0;

		for(i = 0; i < n; i++) {
			if(v[i] > c[i])
				ans += v[i] - c[i];
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 21844