akhauriyash/Code-Regression huggingface dataset:
<?php
$n = intval(trim(fgets(STDIN)));
for($i = 0; $i < $n; $i++){
    $array[] = $i+1;
}
$str1 = trim(fgets(STDIN));
$str2 = trim(fgets(STDIN));
$i = 0;
do{
    $i++;
    if($str1 == implode(" ", $array))$a = $i;
    if($str2 == implode(" ", $array))$b = $i;
}while(next_permutation($array));
echo abs($a-$b);

function next_permutation(&$a){
    $n = count($a);
    for($i = $n - 2; $i >= 0; $i--)if($a[$i] < $a[$i+1])break;
    if($i < 0){
        reverse($a, 0, $n);
        return false;
    }
    $k = $i;
    for($i = $n - 1; $i >= $k + 1; $i--)if($a[$k] < $a[$i])break;
    $l = $i;
    list($a[$l], $a[$k]) = [$a[$k], $a[$l]];
    reverse($a, $k + 1, $n - ($k + 1));
    return true;
}
function reverse(&$a, $start, $size){
    $end = $start + $size - 1;
    while($start < $end){
        list($a[$start++], $a[$end--]) = [$a[$end], $a[$start]];
    }
}

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

int main() {
	int n,k;
	cin >> n >> k;
	vector<bool> s(n,true);
	rep(i,k) {
		int d;
		cin >> d;
		rep(j,d) {
			int a;
			cin >> a;
			a--;
			s[a] = false;
		}
	} 
	int ans = 0;
	rep(i,n) if (s[i]) ans++;
	cout << ans << endl;
	return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static int solve(int n,int[] p)
        {
            int cnt = 0;
            for (int i = 1; i < n - 1; i++)
            {
                if (p[i] < p[i + 1] && p[i] > p[i - 1]) cnt++;
                if (p[i] < p[i - 1] && p[i] > p[i + 1]) cnt++;

            }


            return cnt;
        }
        static void Main(string[] args)
        {
            int n   = int.Parse(Console.ReadLine());
            int[] p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);


            int ans = solve(n,p);
            Console.WriteLine(ans);
            
        }


    }
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("1");
            WillReturn.Add("4");
            WillReturn.Add("3");
            //4
            //3
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2");
            WillReturn.Add("5");
            WillReturn.Add("5");
            //5
            //5
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        var AList = new List<int>();
        foreach (string EachStr in InputList.Skip(1)) {
            AList.Add(int.Parse(EachStr));
        }

        var DescArr = AList.ToArray();
        Array.Sort(DescArr, (A, B) => B.CompareTo(A));

        //最大値
        int FirstMax = DescArr[0];

        //最大値の個数
        int SecondMax = DescArr[1];

        for(int I=0;I<=AList.Count-1;I++){
            if (AList[I] == FirstMax) {
                Console.WriteLine(SecondMax);
            }
            else {
                Console.WriteLine(FirstMax);
            }
        }
    }
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(2,vector<int>(N));

    for(int i=0; i<2; i++){
        for(int j=0; j<N; j++){
            cin >> A.at(i).at(j);
        }
    }

    //何処で下に曲がるか全探索

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

        int sum =0;
        for(int j=0; j<=i; j++)
        sum += A.at(0).at(j);
        for(int j=i; j<N; j++)
        sum += A.at(1).at(j);

        ans = max(ans,sum);
    }

    cout << ans << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 112345;

struct Edge {
  int id;
  int a, b, c;
};

int K;
vector<Edge> g[MAX_N];

void dfs(int v, int prev, int prev_color) {
  K = max(K, prev_color);
  int color = 1;
  for (Edge &e : g[v]) if (e.b != prev) {
    if (color == prev_color) color++;
    e.c = color;
    dfs(e.b, v, e.c);
    color++;
  }
}

int main2() {
  K = 0;
  REP(i, MAX_N) g[i].clear();
  int N = nextInt();
  REP(i, N-1) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back({i, a, b, 0});
    g[b].push_back({i, b, a, 0});
  }
  dfs(0, -1, -1);

  vector<Edge> ans;
  REP(i, N) {
    for (Edge e : g[i]) if (e.c != 0)
      ans.push_back(e);
  }
  sort(ALL(ans), [](const Edge&a, const Edge& b){
    return a.id < b.id;
  });

  printf("%d\n", K);
  for (Edge e : ans)
    printf("%d\n", e.c);
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 11640
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    string a;
    cin >> a;
    for(int i = 0; i < a.length(); i++){
        if(i == 5 || i  == 13){
            cout << " ";
        }else{
            cout << a[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお
ll gcd(ll x, ll y){
    return y?gcd(y,x%y):x;
}

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

int main() {
    int n; cin >> n;
    ll ans = 1;
    rep(i,n) {
        ll t; cin >> t;
        ans = lcm(ans,t);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
c.sort()
d=sum(c)
e=0
if a<=b:
  print(0)
else:
  for i in range(1,b+1):
    e=e+c[-i]
  print(d-e)

Measured memory_bytes: 31756
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int* suu = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> suu[i];
	}
	vector<int> dp;
	dp.push_back(suu[0]);
	for (int i = 1;i < n;i++) {
		int index = lower_bound(dp.begin(), dp.end(), suu[i]) - dp.begin();
		if (index == dp.size()) {
			dp.push_back(suu[i]);
		}
		else {
			dp[index] = suu[i];
		}
	}
	cout << dp.size() << endl;
}


Measured memory_bytes: 3920
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i = 0 ; i <= 1000 ; i++) {
            if (a <= i * k && i * k <= b) {
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }
}


Measured memory_bytes: 35732
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 55
using namespace std;

typedef long long ll;
ll n, a, b, s, c1, c2, ans, v[N], c[N][N];
int main()
{
	ll i, j;
	cin >> n >> a >> b;
	for (i = 0; i <= n; i++) {
		c[i][0] = 1;
		for (j = 1; j <= i; j++) {
			c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
		}
	}
	for (i = 0; i < n; i++) scanf("%lld", &v[i]);
	sort(v, v + n, greater<ll>());
	for (i = 0; i < a; i++) s += v[i];
	for (; i < n; i++) {
		if (v[i] == v[a - 1]) c1++;
		else break;
	}
	for (i = a - 1; i >= 0; i--) {
		if (v[i] == v[a - 1]) c1++, c2++;
		else break;
	}
	if (v[0] != v[a - 1]) {
		printf("%.9f\n%lld", 1.0 * s / a, c[c1][c2]);
	} else {
		for (i = a; i <= b; i++) ans += c[c1][i];
		printf("%.9f\n%lld", 1.0 * s / a, ans);
	}
    return 0;
}

Measured memory_bytes: 256
a,b,c,k = map(int, input().split())

if a >= k:
  an = k
  bn = 0
  cn = 0
elif a+b >= k:
  an = a
  bn = k - (a)
  cn = 0
else:
  an = a
  bn = b
  cn = k - (a+b)
  
print(an-cn)


Measured memory_bytes: 61640
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();

    int[] L = new int[N];

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

    sc.close();

    Arrays.sort(L);

    int sum = 0;

    for (int i = N-2; 0 <= i; i--) {
      sum += L[i];
    }

    if (L[N-1] < sum) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

}

Measured memory_bytes: 22996
def gcd(a, b):
    """Calculate the Greatest Common Divisor of a and b.

    Unless b==0, the result will have the same sign as b (so that when
    b is divided by it, the result comes out positive).
    """
    while b:
        a, b = b, a%b
    return a


n = map(int, raw_input().split())
a = map(int, raw_input().split())

lcm = 1
cnt = 0
MOD = int(1e9 + 7)

for x in a:
    lcm = x*lcm/gcd(lcm, x)
    
for x in a:
    cnt += lcm/x 
    
print cnt % MOD 

Measured memory_bytes: 3460
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	int m = n;
	int M = 1e9 + 7;
	rep(i, n) {
		int b;
		cin >> b;
		a[b]++;
	}
	int count = 0;
	if (n % 2 == 0) {
		n /= 2;
		rep(i, n) {
			if (a[m - i * 2 - 1] == 2) {
				count += 2;
			}
		}
	}
	else {
		n /= 2;
		n++;
		if (a[0] == 1) {
			count++;
		}
		rep(i, n) {
			if (a[m - i * 2 - 1] == 2) {
				count += 2;
			}
		}
	}
	if (count == m) {
		ll ans = 1;
		rep(i, m/2) {
			ans *= 2;
			ans %= M;
		}
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
	
}


Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> friend_list[100001], ng_list[100001];
int component_size[100001];
int group_num[100001];

void dfs(int v, int c)
{
    group_num[v] = c;
    component_size[c]++;

    for (int i = 0; i < friend_list[v].size(); i++) {
        if (!group_num[friend_list[v][i]]) {
            dfs(friend_list[v][i], c);
        }
    }
}

int main()
{
    int N, M, K;

    scanf("%d %d %d", &N, &M, &K);

    for (int i = 0; i < M; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        x--; y--;
        friend_list[x].push_back(y);
        friend_list[y].push_back(x);
    }

    for (int i = 0; i < K; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        x--; y--;
        ng_list[x].push_back(y);
        ng_list[y].push_back(x);
    }

    int id = 1;

    for (int i = 0; i < N; i++) {
        if (!group_num[i]) dfs(i, id++);
    }

    for (int i = 0; i < N; i++) {
        int cnt = component_size[group_num[i]] - 1;
        cnt -= friend_list[i].size();
        for (int j = 0; j < ng_list[i].size(); j++) {
            if (group_num[ng_list[i][j]] == group_num[i]) cnt--;
        }

        printf("%d%c", cnt, " \n"[i + 1 == N]);
    }

    return 0;
}

Measured memory_bytes: 12288
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    ii = [2**i for i in range(17)]

    while True:
        n = I()
        if n == 0:
            break

        a = [LI() for _ in range(n)]
        for i in range(n):
            for j in range(n+1):
                a[i][j] = (a[i][j], ii[j])
            a[i].sort()

        d = collections.defaultdict(lambda: inf)
        d[1] = 0
        for _ in range(n):
            e = collections.defaultdict(lambda: inf)
            for k,v in d.items():
                for i in range(n):
                    t = ii[i+1]
                    if t & k:
                        continue
                    m = inf
                    cai = inf
                    for c,ai in a[i]:
                        if ai & k:
                            m = c
                            cai = ai
                            break
                    vv = v + m
                    if e[k|t] > vv:
                        e[k|t] = vv
            d = e
        rr.append(min(d.values()))


    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 12760
employees = int(input())
boss_array = input().split(' ') 

counter = {}
for idx in range(1, employees+1):
    counter[str(idx)] = 0;

for boss_id in boss_array:
    counter[boss_id] = counter[boss_id] + 1

for idx in range(1, employees+1):
    print(counter[str(idx)])

Measured memory_bytes: 50600
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

s = input()
n = len(s)
ans = 0
acgt = set(['A', 'C', 'G', 'T'])
for i in range(n):
    for j in range(i + 1, n + 1):
        t = s[i:j]
        flag = 1
        for k in t:
            if k not in acgt:
                flag = 0
                break
        if flag:
            ans = max(ans, len(t))
print(ans)
                

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

int main(){
    int tap = 1;
    int ans = 0;
    int A, B;
    cin >> A >> B;

    while(tap<B){
        tap--;
        tap += A;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func diff(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n, n+2)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}
	as = append([]int{0}, as...)
	as = append(as, 0)
	sum := 0
	for i := 0; i < len(as)-1; i++ {
		sum += diff(as[i], as[i+1])
	}
	for i := 1; i < len(as)-1; i++ {
		ans := sum
		ans -= diff(as[i-1], as[i]) + diff(as[i], as[i+1])
		ans += diff(as[i-1], as[i+1])
		fmt.Println(ans)
	}
}


Measured memory_bytes: 6528
N = $stdin.gets.to_i
c = 0
r = 'No'
0.upto(N - 1) do |i|
  d1, d2 = $stdin.gets.split.map {|j| j.to_i }
  if d1 == d2
    c += 1
    if c >= 3
      r = 'Yes'
    end
  else
    c = 0
  end
end
puts r


Measured memory_bytes: 14360
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int a[100004],MOD=1e9+7;
bool vis[100004];
int main(){
	int n,m;cin>>n>>m;
	for (int i=0;i<m;i++){
		int x;cin>>x;vis[x]=1;
	}
	a[0]=1;
	for (int i=1;i<=n;i++) if (!vis[i]) a[i]=(a[i-1]+(i>1?a[i-2]:0))%MOD;
	cout<<a[n];
}

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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

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

  int a,b,c;
  cin >> a >> b >> c;
  for (int i = min(a,b); i >= 1; i--) {
    if ((a%i == 0) && (b%i == 0)) {
      c--;
      if (c == 0) {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
	int n;
	cin >> n;
	int num = n;
	bool flag = 1;
	while (1){
		flag = 1;
		for (int i = 2; i <= sqrt(num); i++){
			if (num % i == 0) {
				flag = 0;
				break;
			}
		}
		if (flag){
			cout << num << endl;
			return 0;
		}
		num++;
	}




}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  vector<ll> va(a), vb(b), vc(c);
  rep(i, a) cin >> va[i];
  rep(i, b) cin >> vb[i];
  rep(i, c) cin >> vc[i];
  sort(All(va), greater<ll>()); 
  sort(All(vb), greater<ll>());
  sort(All(vc), greater<ll>());
  vector<ll> v(x+y+c);
  int j = 0;
  rep(i, x) v[j++] = va[i];
  rep(i, y) v[j++] = vb[i];
  rep(i, c) v[j++] = vc[i];
  sort(All(v), greater<ll>());
  ll ans = 0;
  rep(i, x+y) ans += v[i];
  cout << ans << endl;
  system("pause");
}

Measured memory_bytes: 4984
//InTheNameOfGod
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
const int maxn = 2e5+5;
string s;
int e[maxn],l,r;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>s;
    rep(i,0,s.size())
    {
        if(s[i]=='1')s[i]=1;
        else s[i]=0;
    }
    r=maxn-1,l=1;
    while(r-l>1)
    {
        int md=(l+r)>>1;
        int p=0;
        fill(e,e+s.size(),0);
        bool f=true;
        if(md>(int)s.size())
        {
            r=md;
            continue;
        }
        rep(i,0,(int)s.size()-md+1)
        {
            p^=e[i];
            if(s[i]^p)
            {
                p^=1;
                e[i+md]=1;
            }
        }
        int sz=0;
        rep(i,(int)s.size()-md+1,s.size())
        {
            p^=e[i];
            if(p^s[i])sz++;
            else if(sz)
            {
                if(i-sz-md<0)
                {
                    //cout<<i<<' '<<sz<<' '<<md<<endl;
                    f=false;
                    break;
                }
                sz=0;
            }
        }
        if(sz&&(int)s.size()-sz-md<0)
            f=false;
        if(f)l=md;
        else r=md;
    }
    cout<<l;
    return 0;
}


Measured memory_bytes: 848
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll h,w;
    ll n,x;
    ll a,b,d;
    cin>>str;
    set<char> s;
    rep(i,str.length()) s.insert(str[i]);
    char c='a';
    for(;c!='z'+1;c++){
        if(s.find(c)==s.end()){
            cout<<c<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    
    
    return 0;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    reader.next();
    out.println("A" + reader.next().substring(0, 1) + "C");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 22484
#include <iostream>
using namespace std;
#define MAX 2000000

int H,A[MAX + 1];

void maxHeapify(int i){
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int main(){

  cin >> H;
  for(int i=1; i <= H; ++i)  cin >> A[i];

  for(int i=H/2; i>=1; --i) maxHeapify(i);

  for(int i=1; i<=H; ++i){
    cout << " " << A[i];
  }
  cout << endl;


  return 0;
}



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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int n;
    cin >> n;
    int h[n];
    rep(i,n) cin >> h[i];
    int ans=1;
    int highest=h[0];
    for(int i=1;i<n;i++){
        if(highest<=h[i]){
            ans++;
            highest=h[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int takoyaki=0;
  int array[50];
  int repair=0;
  cin>>takoyaki;
  for(int i=0;i<takoyaki;i++)
  {
    cin>>array[i];
  }
  for(int j=0;j<takoyaki;j++)
  {
    for(int k=j+1;k<takoyaki;k++)
    {
      repair+=array[j]*array[k];
    }
  }
  cout<<repair<<endl;
  return 0;
}

Measured memory_bytes: 256
let words str =
  let len = String.length str in
  let buf = Buffer.create 10 in
  let rec loop cont = function
      i when i = len -> cont [Buffer.contents buf |> int_of_string]
    | i ->
      loop
        (match str.[i] with
         | ' ' ->
           let v = Buffer.contents buf |> int_of_string in
           Buffer.clear buf; (fun x -> cont (v::x))
         | c ->
           Buffer.add_char buf c; cont)
        (i+1)
  in loop (fun x -> x) 0

let counter = ref 0

let merge array left mid right =
  let init n p = Array.init (n+1) (fun i -> if i=n then max_int else array.(p+i)) in
  let xs = init (mid-left) left in
  let ys = init (right-mid) mid in
  let rec loop i j k =
    if k < right then
      (incr counter;
       if xs.(i) <= ys.(j) then (array.(k) <- xs.(i); loop (i+1) j (k+1))
       else (array.(k) <- ys.(j); loop i (j+1) (k+1)) )
  in loop 0 0 left

let rec msort array left right =
  if left+1 < right then
    let mid = (left+right)/2 in
    msort array left mid;
    msort array mid right;
    merge array left mid right

let () =
  let n = read_int () in
  let (l : int array) = read_line () |> words |> Array.of_list in
  msort l 0 n;
  Array.iteri (fun i v -> Printf.printf (if i = n-1 then "%d\n" else "%d ") v) l;
  Printf.printf "%d\n" !counter

Measured memory_bytes: 48052
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n;
  ll k;
  cin >> n >> k;
  vll a(n);
  rep(i,n) cin >> a[i];
  
  ll ans = 0;
  // d桁目より上は一致、d桁目はkは1、xは0、d桁目より下はなんでもいいので貪欲
  // k = 1 0 1 0 1 1
  // x = 1 0 0 0 1 0
  //         d
  //       e->

  for (int d = 60; d >= -1; --d) {// d = -1 は x = k の場合
  // x = k でないとき、kのd桁目は1でないとダメ
    if (d != -1 && !(k & (1LL<<d))) continue;
    ll tmp = 0;
    for (int e = 60; e >= 0; --e) {
      ll mask = 1LL<<e;
      // a[0], a[1], ..., a[n-1]のe桁目の1の数の合計
      int num = 0;
      rep(i,n) if (a[i] & mask) num++;
      
      // e > dの場合kとxのe桁目は一致
      if (e > d) {
        // 両方とも1の場合、xのe桁目が1なので、
        // a[0], a[1], ..., a[n-1]のe桁目のビットが反転
        if (k & mask) tmp += mask*(n-num);

        // 両方とも0の場合、xのe桁目が0なので、
        // a[0], a[1], ..., a[n-1]のe桁目のビットが反転しない
        else tmp += mask*num;
      }
      else if (e == d) {
        // kのe(=d)桁目は1で、xのe(=d)桁目は0なので、反転しない
        tmp += mask*num;
      }
      else {
        // e < dなのでxのe桁目は0でも1でもいい
        // 答えが大きくなる方を貪欲
        tmp += mask*max(num, n-num);
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

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

mod = 10 ** 9 + 7

dp = [0] * (N + 100)
dp[0] = 1
a_set = set(a_list)

for i in range(N+10):
    if i in a_set:
        continue
    else:
        dp[i + 1] += dp[i]
        dp[i + 1] %= mod
        dp[i + 2] += dp[i]
        dp[i + 2] %= mod

print(dp[N] % mod)


Measured memory_bytes: 13984
n = int(input())
A = list(map(int,input().split()))
M = [0 for i in range(n)]
for i in reversed(range(1,n+1)):
    k = 0
    j = 2*i
    while j<=n:
        if M[j-1] == 1:
            k += 1
        j += i
    if (k+1)%2 == A[i-1]:
        M[i-1] = 1
B = []
for i in range(n):
    if M[i] == 1:
        B += [i+1]
print(len(B))
if len(B) > 0:
    print(*B)

Measured memory_bytes: 14140
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

ll N,A,B;
vec v;

int solve(ll ans){
  ll i,now=0,plus;
  rep(i,N){
    if(v[i]<=ans*B)break;
    plus=(v[i]-ans*B+A-1)/A;
    now+=plus;
    if(now>ans)return 0;
  }
  return 1;
}

int main(){
  ll i,ok,ng=0;
  cin>>N>>A>>B;
  A=A-B;
  v.resize(N);
  rep(i,N)cin>>v[i];
  vrsort(v);
  ok=v[0]/B+1;
  while(ok-ng>1){
    ll mid=(ok+ng)/2;
    if(solve(mid)){
      ok=mid;
    }else{
      ng=mid;
    }
  }
  cout<<ok<<endl;
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))

B = [abs(A[i]) for i in range(N)]
A.sort()
B.sort()
count=0
for i in range(N):
    if A[i]<0:
        count+=1

if count%2==0:
    print(sum(B))
else:
    print(sum(B[1:])-B[0])

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

int main() {
	int a, b;
	cin >> a >> b;
	int max;
	if(a + b > a - b) max = a + b;
	else max = a - b;
	if(max < a * b) max = a * b;
	cout << max << endl;
	return 0;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}


Measured memory_bytes: 256
def nCr(n, r):
    r = min(r, n-r)

    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator


n = int(input())
s = sorted([sorted(input()) for _ in range(n)])


ans = 0
cnt = 0
for i in range(n-1):
    if i == n-2 and s[i] == s[i+1]:
        cnt += 1
        ans += nCr(cnt+1, 2)
        print(ans)
        exit()
    if s[i] == s[i+1]:
        cnt += 1
    else:
        if cnt > 0:
            ans += nCr(cnt+1, 2)
            cnt = 0
print(ans)


Measured memory_bytes: 100312
import java.util.Scanner;

public class Main {
    void run() {
        Scanner scan = new Scanner(System.in);
        System.out.println("" + scan.next().charAt(0) + scan.next().charAt(1) + scan.next().charAt(2));
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 22356
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return a * b // gcd(a,b)

N = int(input())
ans = int(input())
for i in range(N-1):
    ans = lcm(ans,int(input()))
print(ans)

Measured memory_bytes: 62568
#include <iostream>
#include <string>

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

struct card {
  char suit;
  int num;
};

void swapCard(card *x, card *y) {
  card temp = *x;
  x->suit = y->suit;
  x->num = y->num;

  y->suit = temp.suit;
  y->num = temp.num;
}

void bubbleSort(card *c, int n) {
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; j > i; j--) {
      if (c[j].num < c[j - 1].num) {
        swapCard(&c[j], &c[j - 1]);
      }
    }
  }
}

void selectionSort(card *c, int n) {
  rep(i, n) {
    int minIndex = i;
    for (int j = i; j < n; ++j) {
      if (c[j].num < c[minIndex].num) {
        minIndex = j;
      }
    }

    swapCard(&c[i], &c[minIndex]);
  }
}

bool isStable(card *origin, card *sorted, int n) {
  rep(i, n) {
    for (int j = i + 1; j < n; ++j) {
      if (origin[i].num == origin[j].num) {
        int a, b;
        for (int k = 0; k < n; ++k) {
          if (sorted[k].suit == origin[i].suit &&
              sorted[k].num == origin[i].num) {
            a = k;
          } else if (sorted[k].suit == origin[j].suit &&
                     sorted[k].num == origin[j].num) {
            b = k;
          }
        }

        // std::cout << "i, j: " << i << ", " << j << '\n';
        // std::cout << "a, b: " << a << ", " << b << '\n';
        if (a > b)
          return false;
      }
    }
  }

  return true;
}

int main() {
  int n;
  std::cin >> n;
  std::string a[n];
  rep(i, n) std::cin >> a[i];

  card c[n];
  rep(i, n) {
    c[i].suit = a[i][0];
    c[i].num = a[i][1] - '0';
  }

  card d[n];
  rep(i, n) {
    d[i].suit = c[i].suit;
    d[i].num = c[i].num;
  }

  bubbleSort(d, n);

  rep(i, n) {
    std::cout << d[i].suit << d[i].num;
    if (i == n - 1)
      std::cout << '\n';
    else
      std::cout << ' ';
  }

  if (isStable(c, d, n))
    std::cout << "Stable" << '\n';
  else
    std::cout << "Not stable" << '\n';

  //
  rep(i, n) {
    d[i].suit = c[i].suit;
    d[i].num = c[i].num;
  }

  //
  selectionSort(d, n);

  rep(i, n) {
    std::cout << d[i].suit << d[i].num;
    if (i == n - 1)
      std::cout << '\n';
    else
      std::cout << ' ';
  }

  if (isStable(c, d, n))
    std::cout << "Stable" << '\n';
  else
    std::cout << "Not stable" << '\n';

  return 0;
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll dp[100010][2]; //dp[i][j] = i桁目まで決めたときの通り数

int main() {
    string S;
    cin >> S;
    dp[0][1] = 2;
    dp[0][0] = 1;
    for(int i = 0;i < S.size() - 1;i++) {
        if(S.at(i + 1) == '0') {
            dp[i + 1][1] = dp[i][1];
            dp[i + 1][0] = dp[i][0] * 3 % MOD;
        }
        else {
            dp[i + 1][1] = dp[i][1] * 2 % MOD;
            dp[i + 1][0] = (dp[i][1] + dp[i][0] * 3) % MOD;
        }
    }
    cout << (dp[S.size() - 1][0] + dp[S.size() - 1][1]) % MOD << endl;
}

Measured memory_bytes: 2048
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String S = keyboard.next();
		int z = 0;
		int o = 0;
		
		for(int s=0; s<S.length(); s++){
		if(S.charAt(s) == '0'){
				z++;
		}else{
		o++;		
		}
}
		
		System.out.println(2*Math.min(z,o));
		keyboard.close();	
		
	}
}


Measured memory_bytes: 39524
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<LL,LL> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	LL x;
	while(cin >> x) {
		int n;
		cin >> n;
		vector<LL> r(n+1);
		REP(i,n) cin >> r[i+1];
		n++;
		int q;
		cin >> q;
		// vector<int > za(q);
		vector<P> quv(q);
		REP(i,q){
			cin >> quv[i].S >> quv[i].F;
		}
		vector<LL> a(n), b(n), c(n);
		a[0] = 0;
		b[0] = x;
		c[0] = 0;

		REP(i,n-1){
			LL di = r[i+1]-r[i];
			if(i&1) {
				c[i+1] = c[i]+di;
				if(c[i+1] >= x) {
					c[i+1] = x;
					a[i+1] = b[i+1] = 0;
				} else if(c[i+1]+b[i]-a[i] >= x) {
					b[i+1] = a[i]+(x-c[i+1]);
					a[i+1] = a[i];
				} else {
					a[i+1] = a[i];
					b[i+1] = b[i];
				}
			} else {
				c[i+1] = c[i]-di;
				if(c[i+1]+b[i]-a[i] <= 0) {
					c[i+1] = 0;
					a[i+1] = b[i+1] = 0;
				} else if(c[i+1] <= 0) {
					a[i+1] = a[i];
					b[i+1] = b[i];
					a[i+1] -= c[i+1];
					c[i+1] = 0;
				} else {
					a[i+1] = a[i];
					b[i+1] = b[i];
				}
			}
		}
		dpite(ALL(a));
		dpite(ALL(b));
		dpite(ALL(c));
		REP(i,q) {
			LL aa, t;
			tie(aa,t) = quv[i];
			DEBUG(t);
			DEBUG(aa);
			auto ite = upper_bound(ALL(r), t);
			ite--;
			int ind = ite-r.begin();
			LL di = t-r[ind];
			assert(di >= 0);
			DEBUG(di);
			{
				LL ans;
				if(aa < a[ind]) {
					ans = c[ind];
				} else if(aa < b[ind]) {
					ans = c[ind]+aa-a[ind];
				} else {
					ans = c[ind]+b[ind]-a[ind];
				}
				DEBUG(ans);
				if(ind&1) cout << min(ans+di,x) << endl;
				else cout << max(ans-di,0ll) << endl;
				DEBUG(endl);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 5888
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if(a <= 5) cout << 0 << endl;
	else if(a <= 12) cout << b/2 << endl;
	else cout << b << endl;
	return 0;
}


Measured memory_bytes: 3632
N, M = gets.strip.split.map(&:to_i)

k = [0]
s = [0]

1.upto(M) do |i|
  tmp = gets.strip.split.map(&:to_i)
  k << tmp[0]
  s << tmp[1..-1]
end

p = [nil] + gets.strip.split.map(&:to_i)

ans = 0

[0,1].repeated_permutation(N) do |switches|
  switches.unshift nil
  ok = true
  1.upto(M) do |i|
    sum = 0
    1.upto(switches.size) do |j|
        sum += switches[j] if s[i].include?(j)
    end
    unless sum % 2 == p[i]
      break ok = false
    end
  end
  ans +=1 if ok == true
end

puts ans

Measured memory_bytes: 14456
#include "iostream"

using namespace std;

int main() {

	int num;
	int a[100];
	int snum = 0;

	cin >> num;

	for (int i = 0; i < num; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < num; i++) {
		int minj = i;
		int s = 0;
		for (int j = i; j < num; j++) {
			if (a[j] < a[minj]) {
				minj = j;
				s = 1;
			}
		}
		if (s == 1) {
			int b = a[i];
			a[i] = a[minj];
			a[minj] = b;
			snum++;
		}
	}


	for (int i = 0; i < num; i++) {
		cout << a[i];
		if (i < num - 1) cout << " ";

	}
	cout << endl;
	cout << snum << endl;


	return 0;
}

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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/


int h, w;

string s[1200];
int cnt[100];
int c1, c2, c4;

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; ++i)
		cin >> s[i];
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			if (h - 1 - i > i)
				continue;
			if (w - 1 - j > j)
				continue;
			int c = 0;
			if (h - 1 - i == i)
				++c;
			if (w - 1 - j == j)
				++c;
			if (c == 0)
				++c4;
			else if (c == 1)
				++c2;
			else
				++c1;
		}
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			++cnt[s[i][j] - 'a'];
		}
	for (int i = 0; i < 26; ++i) {
		int go = cnt[i] / 4;
		go = min(go, c4);
		c4 -= go;
		cnt[i] -= go * 4;
		go = cnt[i] / 2;
		go = min(go, c2);
		c2 -= go;
		cnt[i] -= go * 2;
		go = cnt[i] / 1;
		go = min(go, c1);
		c1 -= go;
		cnt[i] -= go * 1;
		if (cnt[i] != 0) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}




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

int main(){
    int N;
    cin >> N;
    int sum = 0, minimum = 1e9;
    for(int i = 0; i < N; ++i){
        int s;
        cin >> s;
        sum += s;
        if(s % 10) minimum = min(s, minimum);
    }
    if(sum % 10) cout << sum << endl;
    else cout << max(0, sum - minimum) << endl;
    return 0;
}


Measured memory_bytes: 256
s = list(input())
a = s[0]
b = s[1]
c = s[2]
d = s[3]

if a == b and c ==d and a!=c:
  print("Yes")
elif a == c and b == d and a != b:
  print("Yes")
elif a == d and b == c and a != c:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9060
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int N,P,Q;
	scanf("%d%d%d",&N,&P,&Q);
	vector<long long>c(N),a(N+1);
	for(int i=0;i<N;i++){
		scanf("%lld",&c[i]);
		c[i]+=(long long)P*i;
	}
	for(int i=1;i<=N;i++){
		a[i]=((long long)Q+(i-1)*2)*P+a[i-1];
	}
	sort(c.begin(),c.end());
	long long s=0,ma=a[N];
	for(int i=N-1;i>=0;i--){
		s+=c[i];
		ma=max(ma,s+a[i]);
	}
	printf("%lld\n",ma-(long long)P*N*(N-1)/2);
}

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

int main(){
  int ans=0;
  string s; cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='-'){
      ans--;
    }
    else{
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;

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

    return 0;
}


Measured memory_bytes: 3080
import java.util.Scanner;
public class Main {

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		
		int J = K -1;
		String str = S.substring(J,J + 1);
		String str2 = str.toLowerCase();
		
		int num = S.length();
		
		System.out.print(S.substring(0,J));
		System.out.print(str2);
		System.out.println(S.substring(K,N));
		
		
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int H, W, n;
    cin >> H >> W >> n;
    vl x(n), y(n);
    rep(i, n) {
        cin >> y[i] >> x[i];
        if(x[i] <= W) --x[i];
        y[i] = H - y[i] + 1;
    }
    vi idx(n);
    rep(i, n) idx[i] = i;
    sort(all(idx), [&](int a, int b) {return abs(x[a]-W)+y[a] < abs(x[b]-W)+y[b];});

    int ans = 0;
    rep(i, n) {
        int t = abs(x[idx[i]]-W) + y[idx[i]];
        // cout << " " << t << endl;
        if(ans >= t) ++ans;
        else ans = t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12496
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string.h>

using namespace std;
int main (){

int x, a;
cin>> x;
cin>> a;
if((x>=0 && x<=9) && (a>=0 && a<=9)){
if(x<a) cout<< "0" << endl;
else if(x>a) cout<< "10" << endl;
else
    cout<< "10" << endl;

}


return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int UF_MAX = 1e5 + 3;

class UF{
	int x[UF_MAX];
	LL p[UF_MAX];
	priority_queue<pair<LL,int>,vector<pair<LL,int>>,greater<pair<LL,int>>> Q[UF_MAX];
	
public:

	void clear(){
		fill(x,x+UF_MAX,-1);
		fill(p,p+UF_MAX,0);
		repp(i,0,UF_MAX) while(!Q[i].empty()) Q[i].pop();
	}
	
	int boss(int a){
		int s = a;
		while(x[s] > -1) s = x[s];
		if(s != a) x[a] = s;
		return s;
	}
	
	void uni(int a , int b){
		int s = boss(a);
		int t = boss(b);
		if(s != t){
			if(Q[s].size() < Q[t].size()) swap(s,t);
			while(!Q[t].empty()){
				Q[s].push(Q[t].top());
				Q[t].pop();
			}
			if(x[s] < x[t]){
				x[s] += x[t];
				x[t] = s;
				p[s] += p[t];
			} else {
				x[t] += x[s];
				x[s] = t;
				p[t] += p[s];
				swap(Q[s],Q[t]);
			}
		}
	}

	LL get_p(int a){
		return p[boss(a)];
	}

	int get_q(int a){
		a = boss(a);
		return Q[a].empty()?-1:Q[a].top().second;
	}

	void set(int a , LL b){
		p[a] = b;
	}

	void push(int a , int b , LL c){
		Q[a].push({c,b});
	}

	void pop(int a){
		Q[boss(a)].pop();
	}
};

const int MC = 1e5 + 3;
int N,M;
LL A[MC],B[MC],S;
vector<int> V[MC];
UF uf;

bool eval(LL z){
	vector<int> used(N,0);
	queue<int> Q;
	uf.clear();
	repp(i,0,N){
		for(auto u : V[i]) uf.push(i,u,A[u]);
		if(z >= A[i]){
			Q.push(i);
			uf.set(i,B[i]);
			used[i] = 1;
		}
	}
	while(!Q.empty()){
		int k = Q.front(); Q.pop();
		for(int u = uf.get_q(k) ; u >= 0 && (z + uf.get_p(k) >= A[u] || (used[u] && z + uf.get_p(u) >= A[k])) ; u = uf.get_q(k)){
			if(!used[u]){
				Q.push(u);
				uf.set(u,B[u]);
				used[u] = 1;
			}
			uf.pop(k);
			uf.uni(k,u);
		}
	}
	int c = 0;
	repp(i,0,N) c += used[i];
	return c == N;
}

LL BS(LL x , LL y){
	if(x-y<2) return x;
	LL z = (x+y)/2;
	return eval(z)?BS(z,y):BS(x,z);
}

int main(){
	cin >> N >> M;
	repp(i,0,N){
		cin >> A[i] >> B[i];
		S += B[i];
		A[i] -= B[i];
	}
	repp(i,0,M){
		int x,y; cin >> x >> y;
		V[--x].push_back(--y);
		V[y].push_back(x);
	}
	cout << S + BS(1e9,-1) << endl;
	return 0;
}


Measured memory_bytes: 22140