akhauriyash/Code-Regression huggingface dataset:
/*
                                                  
  _|_|                              _|  _|    _|  
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|    
_|    _|  _|_|          _|          _|  _|_|      
_|    _|  _|          _|      _|    _|  _|  _|    
  _|_|    _|        _|_|_|_|    _|_|    _|    _|  
                                                                                                    
*/ 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=186;
int sum[maxn][maxn],n,m,dp[2][maxn][maxn][maxn];
char s[maxn];
int que(int xl,int xr,int yl,int yr){
	int siz=(xr-xl+1)*(yr-yl+1),tot=sum[xr][yr]-sum[xl-1][yr]-sum[xr][yl-1]+sum[xl-1][yl-1];
	if(!tot||tot==siz)return 1;
	return 0;
}
void init(){
/*	rep(i,1,n)rep(j,i,n)for(int r=1,l=1;l<=m;l=r+1){
		r=l;bool flag=0;
		while(r<m&&que(i,j,l,r+1))flag=1,
		r++;
		//if(!flag)r=l-1;
		rep(k,l,r)dp[0][i][j][k]=(flag)?r:(r-1);
	}*/
	 for(int i=1;i<=n;++i)
        for(int j=i;j<=n;++j)
            for(int l=1,r;l<=m;l=r)
            {
                r=l;
                while(que(i,j,l,r)&&r<=m)r++;
                for(int p=l;p<r;++p)dp[0][i][j][p]=r-1;
                if(l==r)dp[0][i][j][l]=l-1,r++;
            }
}
/*int find(int c,int i,int j,int st){
	int l=i,r=j;
	int ans=0;
	while(l<r){
		int mid=(l+r)>>1;
	//	cout<<mid<<endl;
		ans=max(ans,min(dp[c][i][mid][st],dp[c][mid+1][r][st]));
		if(dp[c][i][mid][st]<dp[c][mid+1][r][st])r=mid;
		else l=mid+1;
	}
	return ans;
}*/
int find(int c,int u,int d,int L){
    int l=u,r=d-1,mid;
    int res=0;
    int v1,v2;
    while(l<=r)
    {
        mid=(l+r)/2;
        v1=dp[c][u][mid][L];
        v2=dp[c][mid+1][d][L];
        res=max(res,min(v1,v2));
        if(v1<v2)r=mid-1;
        else l=mid+1;
    }
    return res;
}
void go(int c){
	rep(i,1,n)rep(j,i,n)rep(l,1,m){
		//cout<<c<<' '<<i<<' '<<j<<' '<<l<<endl;
		int r=dp[c^1][i][j][l],tar;
		if(r!=m){
			tar=dp[c^1][i][j][r+1];tar=max(tar,find(c^1,i,j,l));
		}
		else tar=m;
		dp[c][i][j][l]=tar;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n){
		scanf("%s",s+1);
		rep(j,1,m){
			sum[i][j]=(s[j]=='#');
		}
	}
	rep(i,1,n)rep(j,1,m)sum[i][j]+=sum[i][j-1];
	rep(i,1,n)rep(j,1,m)sum[i][j]+=sum[i-1][j];
	init();
	int ans=0;
	for(int i=1;dp[(i&1)^1][1][n][1]<m;i++)go(i&1),ans=i;
	printf("%d",ans);
	return 0; 
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int w, e;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    rep(i, N) {
        if (S[i] == 'W') w++;
        if (S[i] == 'E') e++;
    }
    int ans=1e8;
    int sumw=0, sume=0;
    rep(i, N) {
        ans = min(ans, sumw+(e-sume-(S[i]=='E')));
        if (S[i] == 'W') sumw++;
        if (S[i] == 'E') sume++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 900
#include <stdio.h>

int main()
{
  int i, j, k;
  int h, w;
  int lastobst;
  char str[2001];
  int yoko[2000][2000];
  int tate[2000][2000];
  char obst[2000][2000];
  scanf("%d%d", &h, &w);
  for (i = 0; i < h; i++) {
    scanf("%s", str);
    for (j = 0; j < w; j++) {
      if (str[j] == '#') obst[i][j] = 1; else obst[i][j] = 0;
    }
  }
  for (i = 0; i < h; i++) {
    lastobst = -1;
    for (j = 0; j < w; j++) {
      if (obst[i][j]) {
        if (lastobst < 0) {
          for (k = 0; k < j; k++) yoko[i][k] = j;
        }
        else {
          for (k = lastobst+1; k < j; k++) yoko[i][k] = j-lastobst-1;
        }
        lastobst = j;
        yoko[i][j] = 0;
      }
    }
    if (obst[i][w - 1]==0) for (k = lastobst + 1; k < w; k++) yoko[i][k] = w - lastobst-1;
  }
  for (j = 0; j < w; j++) {
    lastobst = -1;
    for (i = 0; i < h; i++) {
      if (obst[i][j]) {
        if (lastobst < 0) {
          for (k = 0; k < i; k++) tate[k][j] = i;
        }
        else {
          for (k = lastobst + 1; k < i; k++) tate[k][j] = i - lastobst - 1;
        }
        lastobst = i;
        tate[i][j] = 0;
      }
    }
    if (obst[h-1][j] == 0) for (k = lastobst + 1; k < h; k++) tate[k][j] = h - lastobst-1;
  }
  int maxlight = 0;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (tate[i][j] + yoko[i][j]-1 > maxlight) maxlight = tate[i][j] + yoko[i][j]-1;
    }
  }
  printf("%d\n", maxlight);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
double pi = 3.141592653589793;

int main(){
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  
  double HH;
  
  HH = ((double)H * 60.0 + (double)M)/2;
  M *= 6;
  
  double x = HH-M;
  
  long double ans;
  long double c = cos(x * pi /180.0000000000 );
  
  ans = pow(A,2.0) + pow(B,2.0) - 2 * A * B * c;
  
  cout << fixed << setprecision(100);
  
  cout << sqrt(ans) << endl;
  //cout << c;
}

Measured memory_bytes: 4232
#include <iostream>

using namespace std;

int main () {

    double t,v,y;
    while(cin >> v){
        t = v/9.8;
        y = 4.9 * t * t;
        int N = 0;
        while(5*N-5<y) N++;
        cout << N << endl;
    }

    return 0;
}

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

int main() {
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << fixed << setprecision(12);
  cout << w*h/2 << " ";
  if(x*2==w&&y*2==h) cout << 1 << endl;
  else cout << 0 << endl;
}

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

using int64 = long long int;
using Vint = vector<int>;
using Vint64 = vector<int64>;
using Wint = vector<Vint>;
using pii = pair<int, int>;

const int MOD = 1e9 + 7;

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto (i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec) for(auto (i) = (vec).end()-1;(i) != (vec).begin()-1;(i)--)

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

template <class T>
class my_array{
  private:
    int n, mx = -(1e9+19), mn = 1e9 + 19;
    vector<T> A;
  public:
    my_array(int k){n = k; A.resize(n);}
    ~my_array(void){};
    // input a_0, a_1, ..., a_(n-1)
    void get(void){
      for(int i = 0; i < n; i++){
        cin >> A.at(i);
        mx = std::max(A.at(i), mx);
        mn = std::min(A.at(i), mn);
      }
    }
    // sort A
    void sorted(bool flag = true){
      if(flag) sort(A.begin(), A.end());
      else sort(A.begin(), A.end(), greater<T>());
    }
    // print : a_0, a_1, ... a_(n-1)
    void show(void){
      for(int i = 0; i < n - 1; i++) cout << A.at(i) << " ";
      cout << A.at(n - 1) << "\n";
    }
    int Var(int k){
      int tmp, res = 0;
      vREP(ele, A){
        tmp = k - (*ele);
        res += tmp * tmp;
      }
      return res;
    }
    int solve(void){
      int res = 1e9 + 19;
      FOR(i, mn, mx + 1) res = std::min(res, Var(i));
      return res;
    }
};

int main(void){
  int n; cin >> n;
  my_array<int> A(n); A.get();
  cout << A.solve() << "\n";
  return 0;
}

Measured memory_bytes: 256
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

// #define N 50005


int32_t main() {

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

    int s;
    cin >> s;

    int pr = s;
    set<int> S;
    S.insert(s);

    repA(i,2,1000000) {
    	if(pr%2) {
    		pr = 3*pr + 1;

    	}
    	else {
    		pr = pr / 2;
    	}
		if(S.find(pr) != S.end()) {
			cout << i << '\n';
			return 0;
		}

		S.insert(pr);
    } 
}

Measured memory_bytes: 256
#define N 3 //文字列の長さ                                                                                     

#include<iostream>
#include<math.h>
//#include<map>                                                                                                        
using namespace std;

int main()
{
  // 文字列の入力                                                                                                      
  char forecast[N+1];
  char weather[N+1];
  cin >> forecast >> weather;

  int ans = 0; //一致した数                                                                                  

  //文字列の比較                                                                                                       
  for(int i=0; i<N; i++){
    if(forecast[i]==weather[i])
      ans++;
  }

  // 出力                                                                                                              
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, K;
	cin >> N >> K;

	int A[10000];
	rep(i, N) cin >> A[i];

	sort(A, A + N);

	int kotae = 0;
	rep(i, K) {
		kotae += A[i];
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 3696
//
// Created by kash on 16/05/20.
//

#include <bits/stdc++.h>

using namespace std;
#define mod 1e9+7
#define ll long long
#define rev_rep(it, last, first) for(int it=last-1;it>=first;--it)
#define out(x) cout << x;
#define pln(x) cout << x << "\n";
#define debug(x) cout << "Debug: " << x << "\n";
#define in(x) cin >> x;
#define rep(it, start, end) for(int it=start;it<end;++it)
#define x first
#define y second


void set_io(int inp) {
#ifndef ONLINE_JUDGE
    string folder = string(getenv("HOME")) + "/CLionProjects/CompetitiveProgramming/inputs/";
    string input_file = folder + "input-" + to_string(inp) + ".txt";
    string output_file = folder + "output-" + to_string(inp) + ".txt";
    freopen(input_file.c_str(), "r", stdin);
    freopen(output_file.c_str(), "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

}

long long int inp_dec() {
    string str;
    in(str);
    ll f = 0;
    int i = 0;

    while (i < str.size()) {
        if (str[i] == '.')
            break;
        f = f * 10 + str[i] - '0';
        i++;
    }
    i++;
    int tmp = 12;
    while (i < str.size()) {
        tmp--;
        f = f * 10 + str[i] - '0';
        i++;
    }
    while (tmp--)
        f *= 10;
    return f;
}

int main() {
    set_io(1);

    int n;
    in(n);
    pair<string, char> str[n];

    rep(i, 0, n) {
        in(str[i].x)
        str[i].y = str[i].x[0];
        reverse(str[i].x.begin(), str[i].x.end());
        str[i].x.pop_back();
    }
    sort(str, str + n);
    string ns[n];
    rep(i, 0, n) {
        ns[i] = str[i].x;
        ns[i].push_back(str[i].y);
    }
    vector<int> values[n][26];
    rep(i, 0, n) {
        rep(j, 0, 26) {
            vector<int> tmp(ns[i].length(), 0);
            tmp[ns[i].length() - 1] = (ns[i][ns[i].length() - 1] - 'a' == j);
            values[i][j] = tmp;
            rev_rep(k, ns[i].length() - 1, 0) {
                values[i][j][k] = values[i][j][k + 1] || (ns[i][k] - 'a' == j);
            }
            rep(k, 0, min(ns[i].length(), i ? ns[i - 1].length() : 0)) {
                values[i][j][k] += values[i - 1][j][k];
            }
//            if (j == 0) {
//                for (auto it:values[i][0])
//                    cout << it << " ";
//                cout << "\n";
//            }
        }
    }
    long long sol = 0;
    rep(i, 0, n) {
        int low = i, high = n - 1;
        while (low < high) {
            int mid = (low + high + 1) / 2;
            if (ns[mid].length() < ns[i].length())
                high = mid - 1;
            else {
                int j = 0;
                for (; j < ns[i].length() - 1; j++)
                    if (ns[i][j] != ns[mid][j])
                        break;
                if (j == ns[i].length() - 1)
                    low = mid;
                else
                    high = mid - 1;
            }
        }
        sol += values[low][ns[i][ns[i].length() - 1] - 'a'][ns[i].length() - 1] -
               values[i][ns[i][ns[i].length() - 1] - 'a'][ns[i].length() - 1];

    }
    out(sol);


    return 0;
}


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

using namespace std;

int main(){
  string s;
  int k;
  cin >> s >> k;
  int n=s.length();
  set<string> t;
  vector<string> v;
  int i=0;
  while(k>=i){
    for(int j=0;j<n-i;j++){
      string u;
      for(int m=0+j;m<=i+j;m++){
        u+=s[m];
      }
      t.insert(u);
    }
    i++;
  }
  for(string x:t){
    v.push_back(x);
  }
  cout << v[k-1] << endl;
}


Measured memory_bytes: 2560
import bisect

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    a = bisect.bisect_left(A,b)
    c = bisect.bisect_right(C,b)
    ans += a*(N-c)

print(ans)

Measured memory_bytes: 29556
// https://atcoder.jp/contests/abc046/tasks/arc062_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

  ll t = 1, a = 1, ti, ai, mm;
  REP(i, n)
  {
    cin >> ti >> ai;

    mm = max(t / ti, a / ai);
    while (ti * mm < t || ai * mm < a)
      mm++;
    t = ti * mm;
    a = ai * mm;
  }

  cout << (t + a) << '\n';

  return 0;
}


Measured memory_bytes: 256
n, m, x, y = map(int, raw_input().split())
arrx = map(int, raw_input().split())
arry = map(int, raw_input().split())
arrx.append(x)
arry.append(y)
if max(arrx)+1 > min(arry):
    print "War"
else:
    print "No War"


Measured memory_bytes: 2568
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def make_successive_count(S: str):
    X = []
    N = len(S)
    num = 1
    for i in range(N - 1):
        if S[i] == S[i + 1]:
            num += 1
        else:
            X.append(num)
            num = 1
    if num != 1:
        X.append(num)
    else:
        X.append(1)
    return X
    

def main():
    S = input()
    N = len(S)
    X = make_successive_count(S)
    assert(len(X) % 2 == 0) #絶対に偶数
    ans = [0] * N

    num = -1
    for i in range(0, len(X), 2):
        left_bound = num + X[i]
        right_bound = num + X[i] + 1
        if ((X[i] + X[i + 1]) % 2) == 0:
            ans[left_bound] = (X[i] + X[i + 1]) // 2
            ans[right_bound] = (X[i] + X[i + 1]) // 2
        else:
            if max(X[i], X[i + 1]) % 2 != 0: #でかいほうが奇数
                #でかいほうが大きくなる
                if X[i] > X[i + 1]:
                    ans[left_bound] = (X[i] + X[i + 1] + 1) // 2
                    ans[right_bound] =  (X[i] + X[i + 1] - 1) // 2
                else:
                    ans[right_bound] = (X[i] + X[i + 1] + 1) // 2
                    ans[left_bound] =  (X[i] + X[i + 1] - 1) // 2
            else:
                #小さいほう大きくなる
                if X[i] > X[i + 1]:
                    ans[right_bound] = (X[i] + X[i + 1] + 1) // 2
                    ans[left_bound] =  (X[i] + X[i + 1] - 1) // 2
                else:
                    ans[left_bound] = (X[i] + X[i + 1] + 1) // 2
                    ans[right_bound] =  (X[i] + X[i + 1] - 1) // 2
                # ans[right_bound] = (X[i] + X[i + 1] + 1) // 2
                # ans[left_bound] =  (X[i] + X[i + 1] - 1) // 2
        num += X[i] + X[i + 1]
    
    n = len(ans)
    for i in range(n):
        print(ans[i], end="")
        if i != n - 1:
            print(end=" ")
    print()
        




if __name__ == '__main__':
    main()

Measured memory_bytes: 15460
#include <stdio.h>

//Istiyak Hossain

int main()
{
    int n, i, j, x;

    scanf("%d", &n);

    i = 1;
    do{
        x = i;

        if(x % 3 == 0){
            printf(" %d", i);
            continue;
        }
        while(x)
        {
            if(x % 10 == 3){
                printf(" %d", i);
                break;
            }
            x /= 10;
        }

    }while(++i <= n);
    printf("\n");

    return 0;
}



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

int main(){

    string s;
    cin >> s;

    int b_start = 0;
    int w_start = 0;

    for(int i = 0; i < s.length(); i++){
        if(i % 2){
            if (s[i] == '0') {
                b_start ++;
            }
            else{
                w_start ++;
            }
        }
        else{
            if (s[i] == '1') {
                b_start ++;
            }
            else{
                w_start ++;
            }
        }
    }

    cout << min(b_start, w_start) << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  double a;
  double b;
  double x;
  double theta;
  cin >> a;
  cin >> b;
  cin >> x;
  x = x / a;
  if (x <= a * b / 2.0) {
    theta = (double)atan(x * 2.0 / b / b);
  } else {
    x = a * b - x;
    theta = (double)atan(a * a / 2.0 / x);
  }
  theta = 90.000000 - theta * (180.0 / 3.141592653589793238463);
  cout << std::setprecision(10) << theta << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 100
#define M 99

int main(void)
{
  int cnt = 0;
  char ch[N];
  int num[M];


  while(scanf("%s",ch) != EOF){
    if(ch[0]=='+'){
      num[cnt-2]+=num[cnt-1];
      cnt--;
    }
    else if(ch[0]=='-'){
      num[cnt-2]-=num[cnt-1];
      cnt--;
    }
    else if(ch[0]=='*'){
      num[cnt-2]*=num[cnt-1];
      cnt--;
    }
    else{
      num[cnt]=atoi(ch);
      cnt++;
    }
  }
  printf("%d\n",num[cnt-1]);
  return 0;
}



Measured memory_bytes: 2144
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let S = scan.word::<String>();
    let T = scan.word::<String>();

    let mut n = 0;
    for (s, t) in S.chars().zip(T.chars()) {
        if s != t {
            n += 1;
        }
    }

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


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int x, y, z; cin >> x >> y >> z;
    cout << (x-z)/(y+z);
}


Measured memory_bytes: 256
K = STDIN.gets.chomp.to_i
s = '1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51'
a = s.split(',')
puts a[K-1]



Measured memory_bytes: 1788
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;

const long long M = 1000000007;
template<int Size>
struct UF{
	UF(){
		for(int i=0;i<Size;i++){
			rep[i]=i;
			cnt[i]=1;
		}
	}
	int find(int a){
		while(a!=rep[a]){
			a=rep[a]=rep[rep[a]];
		}
		return a;
	}

	int rep[Size];
	int cnt[Size];
	bool uni(int a,int b){
		a=find(a);
		b=find(b);
		if(a==b){
			return false;
		}
		rep[a]=b;
		cnt[b]+=cnt[a];
		return true;
	}
};
// powmod p^n%mod
LL powmod(LL p,LL n,LL mod){
	LL q=p%mod;
	LL pow=1;
	while(n){
		if(n&1){
			pow*=q;
			pow%=mod;
		}
		q=q*q;
		q%=mod;
		n/=2;
	}
	return pow;
}
// a>=0, b>=0, x*a+y*b=gcd>=0, a>0,b>0=>abs(y)<=a,abs(x)<=b
LL gcdex(LL a,LL b,LL& x, LL& y){
	LL ax=1,ay=0;
	LL bx=0,by=1;
	while(b){
		LL r=a/b;
		LL t=a-r*b; a=b; b=t;
		LL tx=ax-r*bx; ax=bx; bx=tx;
		LL ty=ay-r*by; ay=by; by=ty;
	}
	x=ax;
	y=ay;
	return a;
}
LL modinv(LL a, LL m){
	LL x,y;
	gcdex(a,m,x,y);
	if(x<0){
		x+=m;
	} else if(x>=m){
		x-=m;
	}
	return x;
}
void solve(long long N, std::vector<long long> P){
	UF<5001> uf;
	for(int i=0;i<P.size();i++){
		if(P[i]!=-1){
			uf.uni(i+1,P[i]);
		}
	}
	LL c=0;
	vector<int> vs;
	for(int i=1;i<=N;i++){
		int r=uf.find(i);
		if(r==i){
			c++;
		}
		if(P[i-1]==-1){
			vs.push_back(uf.cnt[r]);
		}
	}
	vector<LL> w(vs.size(),1);
	LL p[5001];
	for(int i=0;i<=vs.size();i++){
		LL s=0;
		for(int j=0;j<w.size();j++){
			s+=w[j];
			s%=M;
			w[j]*=vs[j];
			w[j]%=M;
		}
		p[i]=s;
	}
	LL e[5001];
	e[0]=1;
	for(int k=1;k<=vs.size();k++){
		LL s=0;
		for(int i=1;i<=k;i++){
			if(i%2==0){
				s+=M-e[k-i]*p[i]%M;
			}
			else{
				s+=e[k-i]*p[i];
			}
			s%=M;
		}
		s*=modinv(k,M);
		s%=M;
		e[k]=s;
	}
	LL pN1[5001];
	pN1[0]=1;
	LL K=vs.size();
	for(int i=1;i<=K;i++){
		pN1[i]=pN1[i-1]*(N-1);
		pN1[i]%=M;
	}
	LL ret=pN1[K]*(N-c)%M;//powmod(N-1,k,M)*(N-c)%M;
	//cerr << ret << endl;
	for(auto v:vs){
		ret+=(N-v)*pN1[K-1];
		ret%=M;
	}
	//cerr << ret << endl;

	LL f=1;
	for(int i=2;i<=K;i++){
		//cerr << f << ", " << e[i] << ", " << pN1[K-i] << endl;
		ret+=M-f*e[i]%M*pN1[K-i]%M;
		ret%=M;
		//cerr << ret << endl;
		f*=i;
		f%=M;
	}

	cout << ret << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x;
cin>>x>>n;
int a[n+1];
map<int,int> m;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	m[a[i]]++;
}
int ans=110,diff=103;
for(int i=0;i<=104;i++)
 {   // int f=1;
	// for(int j=0;j<n;j++)
		// {
		// if(i==a[j])
		// {
		// 	f=0;break;
		// }
		// }
		 if(!m.count(i))
		{
			if(diff>abs(i-x)){ans=i;diff=abs(i-x);}
		}

}
cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> W(N, 0);

    for(auto&& x : W){
        cin >> x;
    }

    int minvar = 1<<30;

    for (int i = 0; i < N; ++i){
        int S1{0}, S2{0};
        for (int j = 0; j <= i; ++j ){
            S1 += W[j];
        }
        for (int k = i + 1; k < N;++k){
            S2 += W[k];
        }
        minvar = min(minvar, abs(S1 - S2));
    }

    cout << minvar << endl;

    return 0;
}

Measured memory_bytes: 256
S = list(input())

num = 0
num_list = [0]
for i in S:
    if i == "A" or i == "T" or i == "G" or i == "C":
        num += 1
        num_list.append(num)
    else:
        num_list.append(num)
        num = 0
print(max(num_list))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
using namespace std;
#define MAX_TEXT 1000
char str[MAX_TEXT];
int i, n;

int main(){
  scanf("%s", str);
  n = strlen(str);
  for(i = 0; i < n; i++){
    if(str[i] >= 'D'){
      str[i] -= 3;
      continue;
    }
    str[i] += 'X' - 'A';
  }
  printf("%s\n", str);
  return 0;
}

Measured memory_bytes: 948
N = int(input())
A = []

for i in range(N):
  A.append(int(input()))

A.sort()

ans = sum(A)

minX = 20000
for a in A:
  if a % 10 != 0:
    minX = a
    break
    
i = 0
while ans % 10 == 0 and i < N:
  ans -= A[i]
  i += 1
  
print(max(ans, sum(A)-minX))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
int n,a,b,c;
cin >> n;
a = n / 100;
b = (n - 100*a)/10;
c = (n - (100*a + 10*b));
if(a == 7 || b == 7 || c == 7){
    cout << "Yes" << endl;
}else{
    cout << "No" << endl;
}

return 0;

}


Measured memory_bytes: 3600
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.nextInt()
    println(problem116b(s))
}

fun problem116b(s: Int): Int {
    fun f(n: Int): Int {
        return if (n % 2 == 0) n / 2 else 3 * n + 1
    }
    val a = mutableListOf<Int>()
    a.add(s)
    for (i in 1..Math.pow(10.0, 6.0).toInt()) {
        val f = f(a[i - 1])
        if (a.contains(f)) return i + 1
        a.add(f)
    }
    return 0
}

Measured memory_bytes: 31260
// Karm Karta ja, Phal Ki Chinta na Kar:)
#include <bits/stdc++.h>
using namespace std;
#include<stdio.h>
typedef long long int ll;
int main()
{
   ll N;
   cin>>N;
   ll i,j;
   ll ans=1e15;
   for(i=1;i*i<=N;i++)
   {
       if(N%i==0)
       {
           j=N/i;
           ll p=max(i,j),q=min(i,j);
           ll res=2*(q-1)+(p-q);
           ans=min(ans,res);
       }
   }
   cout<<ans;
}



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

mod = 998244353

S = [0, 1]

for i in range(2, N+1):
    a = 0
    for l, r in LR:
        a = (a + S[max(i-l, 0)]-S[max(i-r-1,0)]) % mod
    S.append((S[-1] + a) % mod)

print(a)


Measured memory_bytes: 17004
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, p[100];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> p[i];
  sort(p, p + n, greater<int>());
  int a = 0, b = 0;
  for(int i = 0; i < n; i++){
    if(i % 2 == 0) a += p[i];
    else b += p[i];
  }
  cout << a - b << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int n,k;
cin>>n>>k;
V<ll> a(n),d,sum(n+1,0);
for(int i=0;i<n;i++){
    cin>>a[i];
    sum[i+1]=a[i]+sum[i];
}
for(int i=0;i<n;i++){
    for(int j=i+1;j<=n;j++)d.push_back(sum[j]-sum[i]);
}
ll ans=0;
for(int i=60;i>=0;i--){
    int cnt=0;
      for(int j=0;j<d.size();j++){
            if(d[j]&(1ll<<i))cnt++;
      }
    if(cnt>=k){
          V<ll> tmp;
    for(int j=0;j<d.size();j++){
         if(d[j]&(1ll<<i))tmp.push_back(d[j]);
      }
      d.clear();
      ans+=(1ll<<i);
      d=tmp;
      }
}
cout<<ans<<endl;
}

Measured memory_bytes: 6256
import java.io.*;
import java.math.*;
import java.util.*;

class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        sc.nextLine();
        int maxX = Arrays.stream(sc.nextLine().split(" +")).mapToInt(Integer::parseInt).max().getAsInt();
        int minY = Arrays.stream(sc.nextLine().split(" +")).mapToInt(Integer::parseInt).min().getAsInt();
        maxX = Math.max(maxX, x);
        minY = Math.min(minY, y);

        System.out.println(maxX < minY ? "No War" : "War");

        sc.close();
    }
}

Measured memory_bytes: 28624
fn main() {
    proconio::input! {
        n: usize,
        q: usize,
        tuv: [(usize,usize,usize);q],
    }
    let mut uf=petgraph::unionfind::UnionFind::new(n);
    for (t,u,v) in tuv {
        if t==0 {
            uf.union(u, v);
        }
        else {
            println!("{}",if uf.equiv(u, v) {1} else {0});
        }
    }
}

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

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    if (n==1 && m==0) {
        puts("0");
        return 0;
    }
    int a[m], b[m];
    for (int i=0; i<m; i++)
        cin >> a[i] >> b[i];

    if (n==1 && m==1 && a[0]==1 && b[0]==0) {
        puts("0");
        return 0;
    }

    for (double i=ceil(pow(10, n-1)); i<=pow(10, n)-1; i++) {
        bool good = true;
        for (int j=0; j<m; j++) {
            int cifra = i/pow(10, n-a[j]);
            cifra %= 10;
            if (cifra!=b[j]) {
                good = false;
                break;
            }
        }
        if (good) {
            cout << i << "\n";
            return 0;
        }
    }
    puts("-1");

    return 0;
}


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

int globalIndex, V, E, Q, i, tempA, tempB;
int parent[10001], rank1[10001];
int index1[10001], lowlink[10001];
bool onStack[10001];
vector<vector <int> > graph (10001);
stack <int> s;

void initUF(int n){
  for(i = 0; i < n; ++i){
    parent[i] = i;
    rank1[i] = 0;
    index1[i] = -1;
    onStack[i] = false;
  }
}

void link1(int x, int y){
  if(rank1[x] > rank1[y])
    parent[y] = x;
  else{
    parent[x] = y;
    if(rank1[x] == rank1[y])
      rank1[y]++;
  }
}

int findSet1(int x){
  if(parent[x] != x)
    parent[x] = findSet1(parent[x]);
  return parent[x];
}

void union1(int x, int y){
  link1(findSet1(x), findSet1(y));
}

void strongconnect(int v){
  index1[v] = globalIndex;
  lowlink[v] = globalIndex;
  globalIndex++;
  s.push(v);
  onStack[v] = true;
  for(vector<int>::iterator it = graph[v].begin();
      it != graph[v].end();
      ++it){
    if(index1[*it] == -1){
      strongconnect(*it);
      lowlink[v] = lowlink[v] < lowlink[*it] ? lowlink[v] : lowlink[*it];
    }
    else{
      if(onStack[*it])
	lowlink[v] = lowlink[v] < index1[*it] ? lowlink[v] : index1[*it];
    }
  }
  if(lowlink[v] == index1[v]){
    int w;
    do{
      w = s.top();
      s.pop();
      onStack[w] = false;
      union1(v, w);
    } while(w != v);
  }
}

void tarjan(int n){
  globalIndex = 0;
  for(i = 0; i < n; ++i){
    if(index1[i] == -1){
      strongconnect(i);
    }
  }
}

int main(){

  scanf("%d %d\n", &V, &E);
  initUF(V);
  
  for(i = 0; i < E; ++i){
    scanf("%d %d\n", &tempA, &tempB);
    graph[tempA].push_back(tempB);
  }

  tarjan(V);
  
  scanf("%d\n", &Q);
  for(i = 0; i < Q; ++i){
    scanf("%d %d\n", &tempA, &tempB);
    cout << ((parent[tempA] == parent[tempB]) ? 1 : 0) << endl;
  }
  
  return 0;
}



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

int main() {

  string str;
  cin >> str;

  if(str=="AAA"){
  cout << "No" << endl; 
  }
  
  else if(str=="BBB"){
     cout << "No" << endl; 
  }

  else{
  cout << "Yes" << endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    char c;
    cin >> c;
    if(c == 'A') cout << "T" << endl;
    if(c == 'T') cout << "A" << endl;
    if(c == 'C') cout << "G" << endl;
    if(c == 'G') cout << "C" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N,M,K,A;
    scanf("%d%d",&N,&M);
    int cnt[M];
    for(int p=0;p<M;p++){
        cnt[p]=0;
    }
    int ans=0;
    for(int i=0;i<N;i++){
        scanf("%d",&K);
        for(int m=0;m<K;m++){
            scanf("%d",&A);
            cnt[A-1]++;
        }
    }
    for(int l=0;l<M;l++){
        if(cnt[l]==N){
            ans++;
        }
    }
    printf("%d",ans);
}

Measured memory_bytes: 128
s = input()
if s == 'SUN':
    print('7')
if s == 'MON':
    print('6')
if s == 'TUE':
    print('5')
if s == 'WED':
    print('4')
if s == 'THU':
    print('3')
if s == 'FRI':
    print('2')
if s == 'SAT':
    print('1')


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
are = [0]*(m-1)
for i in range(m-1):
        are[i]= a[i+1] -a[i]
are.sort()
for i in range(n-1):
        if are:
                are.pop()
print(sum(are))

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	lint l[]={1,0,0,1,2,3,4,5,6,7,8,9,9,10};
	lint r[]={9,9,19,29,39,49,59,69,79,89,99,99,109,119};
	vector<lint> ans;
	rep(i,14) for(int j=l[i];j<r[i];j++) {
		ans.emplace_back(stoll(to_string(j)+string(i,'9')));
	}

	int k; cin>>k;
	rep(i,k) cout<<ans[i]<<endl;

	return 0;
}

// experiment
/*
int f(lint n){
	int res=0;
	while(n>0){
		res+=n%10;
		n/=10;
	}
	return res;
}

int main(){
	lint n=1e7;
	vector<long double> r(n);
	for(int i=1;i<n;i++){
		lint a=i*10000000000LL+9999999999LL;
		r[i]=(long double)f(a)/a;
	}

	double mx=0;
	for(int i=n-1;i>0;i--) if(r[i]>=mx) {
		mx=r[i];
		printf("%10d,9999999999\t%.14Lf\n",i,r[i]);
	}

	return 0;
}
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long;
#define ld long double
#define pb push_back
const int mod=1e9+7;
const int mxN=2e6+3;

int main(){
    int x;
    cin>>x;
    if(x)cout<<"0"<<endl;
    else cout<<"1"<<endl;
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    int n,m;
    cin>>n>>m;
    
    pair<long long,int>p;
    
    vector<pair<long long,int>> v;
    
    for(int i=0;i<n;i++)
    {
        long long x;
        int y;
        cin>>x>>y;
        p.first=x;
        p.second=y;
        v.push_back(p);
    }
    
    sort(v.begin(),v.end());
    
    long long tot=0;
    int baki=m;
    
    int i=0;
    
    while(baki && i<n)
    {
        if(baki>=v[i].second)
        {
            tot=tot+v[i].first*v[i].second;
            baki-=v[i].second;
        }
        else
        {
            tot=tot+baki*v[i].first;
            baki=0;
        }
        
        i++;
    }
    
    cout<<tot;
    
    
    return 0;
        
    

}

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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//const int MOD = 1e9 + 7;
const int MAX = 1e5 + 1;
int arr[MAX];

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		for(int i = 1; i <= 100; ++i)
		{
			for(int j = 1; j <= 100; ++j)
			{
				for(int k = 1; k <= 100; ++k)
				{
					int ind = i * i + j * j + k * k + i * j + i * k + k * j;
					arr[ind] += 1;
				}
			}
		}
		for(int i = 1; i <= n; ++i)
			cout << arr[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3876
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define si(x) scanf("%d",&x)
#define pi(x) printf("%d\n",x)
#define s(x) scanf("%I64d",&x)
#define p(x) printf("%I64d\n",x)
#define sc(x) scanf("%s",x)
#define pc(x) printf("%s",x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define M 1000000007
#define N 1000002
#define inf 1e15
#define PQG priority_queue< int,std::vector<int>,std::greater<int> >
#define PQL priority_queue< int,std::vector<int>,std::less<int> >
#define PQPL priority_queue<pii ,vector< pii >, less< pii > >
#define PQPG priority_queue<pii ,vector< pii >, greater< pii > >
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;


int main() {
    fast_io;
    int a,b,c;
    cin>>a>>b>>c;
int x=a;
    while(a<=1e6) {
        if(a%b==c) {
            cout<<"YES\n";
            return 0;
        }
        a+=x;
    }
    cout<<"NO\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
#define X real()
#define Y imag()
const double EPS = (1e-10);

P line_symmetry(L l, P p){
  P f = l.first, s = l.second - f, q = p - f;
  if(abs(q) < EPS) return p;
  return f + norm(q/s)*s*s/q;
}

int main(){
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  L l = L(P(x1,y1),P(x2,y2));
  int q;
  cin >> q;
  for(int i = 0; i < q; ++i){
    cin >> x1 >> y1;
    P p = line_symmetry(l, P(x1,y1));
    printf("%.9lf %.8lf\n",p.X,p.Y);
  }
  return 0;
}



Measured memory_bytes: 3352
n,m = map(int,input().split())
k=[]
for i in range(m):
    k.append(list(map(int,input().split())))
p=list(map(int,input().split()))

res=0
for s in range(2 ** n):
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1,len(k[i])):
            w=k[i][j]
            if s>>(w-1)&1 == 1:#Sをw-1分ビットシフトしたものが1ならば（kで定義された番号のスイッチがONならば）
                cnt +=1
        if cnt %2 !=p[i]:
            judge = False

    if judge:
        res += 1
print(res) 

Measured memory_bytes: 3064
import java.util.Scanner

import scala.collection.mutable.ListBuffer

object PrimeInt {
  val ps: Stream[Int] = 2 #:: Stream.from(3).filter(i => ps.takeWhile(j => j * j <= i).forall(k => i % k > 0))

  def isPrime(n: Int): Boolean = ps.takeWhile(_ <= n).contains(n)
}

object Primes extends Iterable[Long] {
  var checked = 2L
  val xs = ListBuffer(2L)

  def contains(i: Long): Boolean = xs.takeWhile(_ <= i).contains(i)

  def apply(i: Int): Long = {
    while (xs.length <= i) {
      var n = checked + 1
      while (xs.takeWhile(j => j * j <= n).exists(n % _ == 0)) {
        n += 1
      }
      xs.append(n)
      checked = n
    }
    xs(i)
  }

  override def iterator: Iterator[Long] = new Iterator[Long] {
    var i = 0

    override def hasNext: Boolean = true

    override def next(): Long = {
      val x = apply(i); i += 1; x
    }
  }
}

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def prime(n: Int, primes: Seq[Int]) = primes.forall(p => n % p != 0)

  def solve(sc: Scanner): String = {
    val X = sc.nextInt

    var i = X
    while (!PrimeInt.isPrime(i)) i += 1

    i.toString
  }
}


Measured memory_bytes: 46684
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

void dfs(vvi &G,vi &dist,int v,int pv,int depth){
  dist.at(v) = depth;
  for(int nv : G.at(v)){
    if(nv == pv) continue;
    //cout << nv << " ";
    dfs(G,dist,nv,v,depth+1);
  }
  //cout << endl;
  return;
}

int main(){
  int n;
  cin >> n;
  vvi Graph(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    Graph.at(a).push_back(b);
    Graph.at(b).push_back(a);
  }
  vi distF(n,1e9);
  vi distS(n,1e9);
  distF.at(0) = 0;
  distS.at(n-1) = 0;
  dfs(Graph,distF,0,-1,0);
  dfs(Graph,distS,n-1,-1,0);
  int F = 0;
  int S = 0;
  rep(i,n){
    if(distF.at(i) <= distS.at(i)) F++;
    else S++;
  }
  if(F > S) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
}


Measured memory_bytes: 14336
import java.util.*;

class Main{
  public static void main(String[] args){
    ArrayList<String> array = new ArrayList<String>();
    Scanner in = new Scanner(System.in);
    while (in.hasNext()){
      int n = in.nextInt();
      if (n == 0){
        break;
      }
      int s1 = 0;
      int s2 = 0;
      for (int i = 0; i < n; i++){
        int p1 = Integer.parseInt(in.next());
        int p2 = Integer.parseInt(in.next());
        if (p1 > p2){
          s1 += p1 + p2;
        }else if (p1 < p2){
          s2 += p1 + p2;
        }else if (p1 == p2){
          s1 += p1;
          s2 += p2;
        }
      }
      array.add(s1 + " " + s2);
    } 
    for (String s: array){
      System.out.println(s);
    } 
  }
}

Measured memory_bytes: 44932
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    int x,n;
    cin>>x>>n;
    map<int,bool> m;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        m[t]=true;
    }

    int ans=1e9;
    bool flag=false;
    for(int i=0;;i++){
        if(!m[x-i]){
            ans=min(x-i,ans);
            flag=true;
        } 
        if(!m[x+i]){
            ans=min(x+i,ans);
            flag=true;
        }
        if(flag){
            cout<<ans<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
  int n,Y[100],M[100],D[100],i,j,k,l,ans,L,sum;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d %d %d", &Y[i], &M[i], &D[i]);
    sum=0;
    for(j=Y[i];;j++){
      if(Y[i]==1000) break;
      for(k=M[i];k<11;k++){
	if(j%3==0) L=20;
	else if(j%3!=0&&k%2==1) L=20;
	else if(j%3!=0&&k%2==0) L=19;
	for(l=D[i];l<L+1;l++){ 
	  if(D[i]==L) D[i]=1;
	  else if(D[i]<L) D[i]++;
	  sum++;
	}
        if(M[i]==10) M[i]=1;
	else if(M[i]<10) M[i]++;
      }
      Y[i]++;
    }
    printf("%d\n", sum);
  }

  return 0;
}


Measured memory_bytes: 596
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int count = 1;
    int ans = 0;

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

    for (int i = 0; i < n; i++) {
      if (a[i] == count) {
        count++;
      } else if (a[i] != count) {
        ans++;
      }
    }

    if (ans < n) {
      System.out.println(ans);
    } else {
      System.out.println(-1);
    }

  }
}


Measured memory_bytes: 87196
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()

    var ans = 0L
    var i = 1L

    while (i * i < n) {
        if (n % i == 0L && ((n - i) / i) > i ) {
            ans += (n - i) / i
        }
        i++
    }
    print(ans)
}

Measured memory_bytes: 31788
def solve():
  ans = 0
  N, x = map(int, input().split())
  A = list(map(int, input().split()))
  if A[0]>x:
    ans += A[0]-x
    A[0] = x
  for i in range(1,N):
    if A[i]+A[i-1]>x:
      ans += A[i]+A[i-1]-x
      A[i] = x-A[i-1]
  return ans
print(solve())

Measured memory_bytes: 19968
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n,m;
  int i,j,k;
  double dp[105][105];
  double grow[105][105];
  int maxi[105];//テヲツ按静ゥツ閉キテ」ツ?古ヲツ慊?・ツ、ツァテ」ツ?ォテ」ツ?ェテ」ツつ凝」ツ?ィテ」ツ?催」ツ?ョテァツ崢エテ・ツ可催」ツ?ョティツつ・テヲツ鳴?

  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;

    rep(i,n)rep(j,n)
      cin>>grow[i][j];

    double temp;
    int tempi;
    rep(j,n){
      temp=0;
      rep(i,n)
        if(temp<grow[i][j]){
	  temp=grow[i][j];
	  tempi=i;
	}
      maxi[j]=tempi;
    }

    rep(j,n)
      dp[0][j]=1.0;

    for(i=1;i<m;i++)
      for(j=0;j<n;j++){
	temp=0;
	rep(k,n)
	  temp=max(temp,dp[i-1][k]*grow[k][j]);
	dp[i][j]=temp;
      }
      
    double sum=0;

    rep(j,n)
      sum=max(sum,dp[m-1][j]);
 
    printf("%.2f\n",sum);
  }

}

Measured memory_bytes: 1416
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll mod = 1000000007;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> v(n), c(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	for (int i = 0; i < n; i++)
		cin >> c[i];
	vector<int> s(n);
	for (int i = 0; i < n; i++)
		s[i] = v[i] - c[i];
	sort(all(s), greater<int>());
	int ans = 0;
	for (int i = 0; s[i] > 0; i++)
		ans += s[i];
	cout << ans;
}

Measured memory_bytes: 256