akhauriyash/Code-Regression huggingface dataset:
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  if(N == 2){
     myout(0);
    return;
  }
  var list = getDivisorList(N).sort(function(a,b){
  	return b - a;
  });
  var output = 0;
  for(var i = 0; i < Math.floor(list.length / 2); i++){
    if(list[i] <= Math.ceil(Math.sqrt(N))){
       break;
    }
    output += list[i] - 1;
  }
  myout(output);
  
}
function getDivisorList(val){
        var list = [];
        for(var i = 1; i * i <= val; i++){
                if(val % i == 0){
                        list.push(i);
                        if(i * i != val){
                                list.push(val / i);
                        }
                }
        }
        list.sort(function(a,b){ return a - b; });
        return list;
}

Measured memory_bytes: 11060
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
int main(){
    double pi=3.141592653589,r;
    cin >> r;
    cout << fixed << setprecision(6);
    cout << r*r*pi << ' ' << 2*r*pi << endl;
}



Measured memory_bytes: 3288
N,T=map(int,input().split())
ct=[list(map(int,input().split())) for a in range(N)]

ct=sorted(ct, key=lambda x:(x[0],x[1]))

for i in range(N):
    if ct[i][1]<=T:
        print(ct[i][0])
        break
else:
    print('TLE')

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

void solve(){
    ll N, M;
    cin >> N >> M;

    string S, T;
    cin >> S >> T;

    if (S[0] != T[0]) {
        cout << -1 << endl;
        return;
    }

    if (N == M) {
        if (S == T){
            cout << N << endl;
            return;
        }else{
            cout << -1 << endl;
            return;
        }
    }


    ll L;
    if (gcd(N,M) == 1) {
        L = N*M;
    }else{
        L = (N*M) / gcd(N,M);
    }

    map<ll, char> mp;
    for (ll i = 0; i < N; i++) {
        mp[i*(L/N)] = S[i];
    }

    for (ll i = 0; i < M; i++) {
        if (mp.count(i*(L/M)) == 1) {
            if (mp[i*(L/M)] != T[i]) {
                cout << -1 << endl;
                return;
            }
        }
    }

    cout << L << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
    ll N; cin >> N;
    if(N == 1){
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << 1 << " " << 1 << endl;
        cout << 1 << " " << 1 << endl;
        return 0;
    }
    ll N2 = 2*N;
    for(int i = 1; i < N; i++){
        if(i*(i+1) > 2*N) break;
        if(i*(i+1) == 2*N){
            cout << "Yes" << endl;
            cout << i+1 << endl;
            vector<set<ll>> V(i+1);
            ll cnt = 1;
            for(int j = 0; j < i; j++){
                for(int k = 0; k < i-j; k++){
                    V[j].insert(cnt);
                    V[j+k+1].insert(cnt);
                    cnt++;
                }
            }
            for(int j = 0; j < i+1; j++){
                cout << V[j].size() << " ";
                for(auto s : V[j]) cout << s << " ";
                cout << endl;
            }
            return 0;

        }
    }
    cout << "No" << endl;

}


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

int main() {
	long long N; cin >> N;
	vector<long long>A(N), B(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i) >> B.at(i);
	}
	long long ans = 0;
	for (long long i = N - 1; i >= 0; i--) {
		if ((A.at(i) + ans) % B.at(i) != 0) {
			long long num = B.at(i) - ((A.at(i) + ans) % B.at(i));
			ans += num;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4840
#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>;
using vv = vector<vector<ll>>;
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;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

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

int main() {
    int n;cin >> n;
    unsigned long long ans=1;
    bool ok = false;
    vector<ll> v(n);
    int keta=0;
    for(int i=0;i<n;i++){
	ll a;cin >> a;
	v[i] = a;
	if(a == 0) ok = true;
    }
    
    if(ok){
	cout << 0 << endl;
	return 0;
    }
    

    for(int i=0;i<n;i++){
	int tmp=0;
	ans *= v[i];
	while(v[i]){
	    v[i] /= 10;
	    tmp++;
	}
	keta += tmp-1;
	if(keta >= 18 && ans !=1000000000000000000){
	    cout << -1 << endl;
	    return 0;
	}
	if(ans>1000000000000000000){
	    cout << -1 << endl;
	    return 0;
	}
    }
    cout << ans << endl;
    return 0;
}


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


int main(){
  int A , B ; 
  cin >> A >> B ; 
  
  int cnt = 0 ; 
  
  for(int i = A ; i <= B ; i++){
    int T = 0 ; 
    string S = to_string(i) ;
    for(int j = 0 ; j < 5 ; j++){
      if(S.at(j) != S.at(4 - j )){
        T++ ; 
      }
    }
    
    if(T ==  0 ){
      cnt++ ; 
    }
         
    
  }
  
  cout << cnt << endl ; 
  
}

Measured memory_bytes: 3696
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int ans = 1;
    int count = 0;
    int x = 0;
    int n = sc.nextInt();
    for(int i=1; i<=n; i++){
      if(i%2 == 0){
        x = countHalf(i);
        if(count < x){
          count = x;
          ans = i;
        }
      }
    }
    System.out.println(ans);

    sc.close();
  }

  public static int countHalf(int i){
    int count = 0;
    boolean a = true;
    while(a){
      if(i%2 == 0){
        i /= 2;
        count++;
      } else {
        a = false;
      }
    }
    return count;
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  string s, t;
  cin >> s >> t;
  int x = s.size();
  int y = t.size();
  vector<int> S(x), T(y);
  for (int i = 0; i < x; i++) {
    S.at(i) = s.at(i) - 'a';
  }
  for (int i = 0; i < y; i++) {
    T.at(i) = t.at(i) - 'a';
  }
  sort(S.begin(), S.end());
  sort(T.begin(), T.end());
  int z = min(x,y);
  bool ans = true;
  for (int i = 0; i < z; i++) {
    if (S.at(i) < T.at(y-1-i)) {
      ans = true;
      break;
    }
    else if (S.at(i) > T.at(y-1-i)) {
      ans = false;
      break;
    }
    else if (x < y) ans = true;
    else ans = false;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int a[105];

int cost(int l, int r, int curWatered){ ///[l, r]
    if(r < l){
        return 0;
    }
    if(l == r){
        return (a[l] >= curWatered ? a[l] - curWatered : 0);
    }

    int mn = *min_element(a + l, a + r + 1);
    int mc = mn - curWatered;
//
    curWatered = mn;

    int strt;
    for(int i = l; i <= r; ++i){
        if(a[i] == mn){
            if(i == l){
                strt = l;
                break;
            }
            mc += cost(l, i - 1, curWatered);
            strt = i;
            break;
        }
    }

    for(int i = strt + 1; i <= r; ++i){
        if(a[i] == mn){
            if(i == strt || strt + 1 == i){
                continue;
            }
            mc += cost(strt + 1, i - 1, curWatered);
            strt = i;
            continue;
        }
        if(i == r){
            mc += cost(strt + 1, i, curWatered);
        }
    }

    return mc;
}

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


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	long x, r, count = 0;

	scanf("%ld", &x);

	r = x % 11;
	if(r > 6)
		count = 2*(x / 11) + 2;
	else if(r > 0)
		count = 2*(x / 11) + 1;
	else
		count = 2*(x / 11);
	printf("%ld", count);

	return 0;
}


Measured memory_bytes: 128
def main():
  n, k = map(int, input().split())
  if n == 2:
    if k == 0:
      print(1)
      print('1 2')
    else:
      print(-1)
  elif k > ((n-1) * (n-2) // 2):
    print(-1)
  else:
    nedge = ((n-1) * (n-2)) // 2
    print(nedge - k + n-1)
    print('2 1')
    print('1 3')
    for j in range(4, n+1):
      print('1 %d' % j)
    is_match = False
    for j in range(2, n+1):
      for _k in range(j+1, n+1):
        if nedge == k:
          is_match = True
          break
        print(j, _k)
        nedge -= 1
      if is_match:
        break

if __name__ == '__main__':
  main()


Measured memory_bytes: 3624
n = int(input())

if n == 0 or n == 1:
  print(1)
elif n == 2:
  print(2)
else:
  f = [1,1]
  for i in range(2, n+1):
    g = int(f[i-1]) + int(f[i-2])
    f.append(g)
  print(f.pop())


Measured memory_bytes: 5600
N = int(input())
p = list(map(int, input().split()))
p = [i - 1 for i in p]
ans = 0

for i in range(1, N):
    if p[i - 1] == i - 1:
        p[i - 1], p[i] = p[i], p[i - 1]
        ans += 1

for i in reversed(range(1, N)):
    if p[i] == i:
        p[i - 1], p[i] = p[i], p[i - 1]
        ans += 1

print(ans)

Measured memory_bytes: 14004
h,w=gets.chomp.split(" ").map { |e| e.to_i }
a=h.times.map {gets.chomp.split(" ").map { |e| (e.to_i)%2}}

ans = [];

indx = 0

for i in 0..h-1 do
  for j in 0..w-2 do
    if a[i][j] != 0
      a[i][j] = 0
      a[i][j+1] = (a[i][j+1] + 1) % 2
      ans[indx] = {'y1'=>i+1,'x1'=>j+1,'y2'=>i+1,'x2'=>j+2}
      indx += 1
    end
  end
end

for i in 0..h-2 do
  if a[i][w-1] != 0
    a[i][w-1] = 0
    a[i+1][w-1] =  (a[i+1][w-1] + 1) % 2
    ans[indx] = {'y1'=>i+1,'x1'=>w,'y2'=>i+2,'x2'=>w}
    indx += 1
  end
end

count = ans.length

puts count

for a in ans do
  printf("%d %d %d %d\n",a["y1"],a["x1"],a["y2"],a["x2"])

end


Measured memory_bytes: 45948
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int n;
		int ans;
		
		while(true){
			n = scan.nextInt();
			if(n== 0)break;
			
			ans = 0;
			
			while(n != 1){
				if(n % 2 == 0)n /= 2;
				else n = n * 3 + 1;
				ans++;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 26280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int i,ar[m],sum=0;
    for(i=0;i<m;i++)
    {
        cin>>ar[i];
        sum=sum+ar[i];
    }
    int d=n-sum;
    if(n<sum)
        cout<<"-1"<<endl;
    else if(n>m)
        cout<<d<<endl;
        else
            cout<<"0"<<endl;
}


Measured memory_bytes: 3636
' Imports System.Collections.Generic
' Imports System.Linq
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim N As Integer = Console.ReadLine()
        Console.WriteLine(Math.Floor((N + 1) / 2) / N)
        Return
    End Sub
End Class

Measured memory_bytes: 28448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
template <typename T>
#define all(v) v.begin(),v.end()
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
    tc = 1;  
    while (tc--)
    {
      int n;
      cin >> n;
      int a[n];
      set<int> se;
      int ans = 0;
      map<int, int> mp;
      for (int i = 0; i < n;i++){
          cin >> a[i];
          mp[a[i]]++;
          if(mp[a[i]]>=2){
              se.insert(a[i]);
          }
      }
      for(auto i:se){
          ans+=(mp[i]*(mp[i]-1))/2;
      }
      for (int i = 0; i < n;i++){
          if(mp[a[i]]<2){
              cout << ans << endl;
          }
          else{
              int v = ans;
            //  cout << ans <<" ";
              v -= (mp[a[i]] * (mp[a[i]] - 1)) / 2;
              v += ((mp[a[i]] - 1) * (mp[a[i]] - 2)) / 2;
              cout << v << endl;
          }
          
      }

    
    }

    return 0;
}


Measured memory_bytes: 13568
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int C = Integer.parseInt(tokens[2]);
		int resultA = 10 * A + B + C;
		int resultB = A + 10 * B + C;
		int resultC = C * 10 + A + B;
		System.out.println(Math.max(Math.max(resultA, resultB), resultC));
		in.close();
	}
}

Measured memory_bytes: 24148
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;



int main(){
    int n;
    cin >> n;
    cout << 180 * (n - 2) << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul

mod = 10 ** 9 + 7
sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

n = I()
A = LI()
max_ret = 0
min_ret = 0
max_arr = [0] * (n + 1)
min_arr = [0] * (n + 1)
for i in range(n, -1, -1):
    max_ret = max_ret + A[i]
    min_ret = (min_ret + 1) // 2 + A[i]
    max_arr[i] = max_ret
    min_arr[i] = min_ret

if max_ret >= 1 >= min_ret:
    ans = 1
    ret = 1
    for j in range(1, n + 1):
        ret = min((ret - A[j-1]) * 2, max_arr[j])
        ans += ret
    print(ans)
else:
    print(-1)








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

int main() {
  int A,B,C,K,S;
  cin >> A >> B >> C >> K;
  if(A>=K){
    S = K;
  }
  else if(A+B>=K){
    S = A;
  }
  else{
    S = A - (K-A-B);
  }
  cout << S << endl;
}

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

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"strconv"
	"strings"
)

//scanで一行づつ読み込む
var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

//sort
// array := []int{5, 1, 4, 2, 3}
// sort.Sort(sort.IntSlice(array))

func main() {
	// a := make([]int, n)
	// A := strings.Split(nextLine(), " ")

	N := strings.Split(nextLine(), " ")
	// n, _ := strconv.Atoi(input[0])

	n, _ := strconv.Atoi(N[0])
	m, _ := strconv.Atoi(N[1])

	var arr = make(map[int][]dishh)
	ans := make([]int, n+1, n+2)
	memo := make([]bool, n+1, n+2)
	in := make([]int, n+1, n+2)

	for i := 0; i < n+m-1; i++ {
		tmp := strings.Split(nextLine(), " ")
		a, _ := strconv.Atoi(tmp[0])
		b, _ := strconv.Atoi(tmp[1])
		in[b]++

		// dishCur := []dishh{{curA, curB}}
		if _, ok := arr[a]; ok {

			arr[a] = append(arr[a], dishh{a, b})
			memo[b] = true
		} else {
			arr[a] = []dishh{{a, b}}
			memo[b] = true
		}

	}

	queue := list.New()

	for i := 1; i < n+1; i++ {
		if !memo[i] {
			queue.PushBack(i)
		}
	}

	memo = make([]bool, n+1, n+2) //memo[:len(memo)+1]
	// memo[root] = true

	// costs := make([]int, n+1, n+2)
	for {

		curT := queue.Remove(queue.Front())

		if cur, ok := curT.(int); ok {
			memo[cur] = true
			// cost := costs[cur]

			for _, val := range arr[cur] {

				ans[val.second] = val.first

				// if memo[val.second] && costs[val.second] < cost+1 {
				// 	ans[val.second] = val.first
				// 	costs[val.second] = cost + 1
				// 	queue.PushBack(val.second)
				// } else if memo[val.second] {
				// 	continue
				// } else {
				// 	ans[val.second] = val.first
				// 	costs[val.second] = cost + 1
				// 	memo[val.second] = true

				// }

				in[val.second]--
				if in[val.second] == 0 {
					queue.PushBack(val.second)
				}
			}
		}

		if queue.Len() == 0 {
			break
		}
	}
	// fmt.Println(costs)

	for i := 1; i < n+1; i++ {
		fmt.Fprintln(wtr, ans[i])
	}

	// fmt.Fprintln(wtr, ans-against)
	_ = wtr.Flush()
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func com(a, b int) int {

	if a > b {
		return 0
	}
	return abs(a - b)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

type dishh struct {
	first  int
	second int
}

// 構造体のスライス
type dish []dishh

// 以下インタフェースを満たす

func (p dish) Len() int {
	return len(p)
}

func (p dish) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p dish) Less(i, j int) bool {

	return p[i].first+p[i].second > p[j].first+p[j].second
}


Measured memory_bytes: 16512
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

// return a^b mod MOD O(logB)
ll powmod(ll a, ll b) {
  ll ans = 1;
  ll temp = a;
  while (b > 0) {
    if (b % 2) {
      ans = (ans * temp) % MOD;
    }
    temp = (temp * temp) % MOD;
    b /= 2;
  }
  return ans;
}

// <= val の要素数
template <typename T, typename U>
inline int CountLowerE(const vector<T> &vec, U val) {
  return distance(vec.begin(), upper_bound(vec.begin(), vec.end(), val));
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  vll a(1, 1);
  {
    for(ll i = 2; i <= 1000; i++){
      for(ll j = 2; ; j++){
        if(powmod(i, j)>1000) break;
        a.emplace_back(powmod(i, j));
      }
    }
  }
  sort(ALL(a));
  dump(a);
  ll x;
  cin >> x;
  print(a[CountLowerE(a, x)-1]);
}


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

#define sz(a) (int)a.size()
#define rep(i,x,n,j) for(int i=x; i<n; i+=j)

int main()
{
	int X, Y; cin >> X >> Y;
	int num = Y-(2*X);
	if(num<0){
		cout << "No" << endl;
		return 0;
	}
	else if(num%2!=0 || num/2>X){
		cout << "No" << endl;
		return 0;
	}
	else{
		cout << "Yes" << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rint register int
#define rep(i,a,b) for (rint i=(a),_E=(b); i<=_E; ++i)
#define per(i,a,b) for (rint i=(a),_E=(b); i>=_E; --i)
#define REP(i,n) for (rint i=(0),_E=(n); i<_E; ++i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

inline int read() {
	char ch = getchar(); int op = 0, x = 0;
	while (!isdigit(ch)) op |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
	return op ? -x : x;
}
#define _(x) (x = read())

const int N = 1000005;
int q[N], f[N], fa[N], Real[N], n, u, v, rt, ans;
vi e[N];

inline int getReal(int x) {
	return Real[x] == x ? x : Real[x] = getReal(Real[x]);
}

void bfs() {
	int l = 0, r = 0, u, sz, v, c;
	q[r++] = rt, fa[rt] = 0;
	while (l < r) {
		u = q[l++], sz = e[u].size();
		REP (i, sz) if ((v = e[u][i]) != fa[u])
			q[r++] = v, fa[v] = u;
		if (e[u].size() == 2) 
			Real[u] = (e[u][0] == fa[u] ? e[u][1] : e[u][0]);
		else
			Real[u] = u;
	}
	per (i, n - 1, 0) {
		u = q[i], sz = e[u].size();
		if (e[u].size() == 1 || Real[u] != u) continue;
		c = 0;
		REP (j, sz) if ((v = e[u][j]) != fa[u]) {
			v = getReal(v);
			if (e[v].size() == 1) ++ c;
			f[u] += f[v];
		}
		if (c) f[u] += c - 1;
	}
}

int main() {
	scanf("%d", &n);
	if (n == 1) return puts("0"), 0;
	rep (i, 1, n - 1) {
		scanf("%d%d", &u, &v); ++ u; ++ v;
		e[u].pb(v), e[v].pb(u);
	}
	rep (i, 1, n)
		if (e[i].size() >= 3) {
			rt = i; break;
		}
	if (!rt) return puts("1"), 0;
	bfs();	
	printf("%d\n", f[rt]);
	return 0;
}

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

int main ()
{
    long long int a,b,s,m,su,xx;

    cin >> a>>b ;

    if (a<=8 && b<=8 && a+b<=16)
    {
        cout << "Yay!"<<endl;
    }

    else
    {
        cout << ":("<<endl;
    }







}




Measured memory_bytes: 256
from itertools import permutations
from math import sqrt, factorial


def calc(prev: list, _next: list):
    return sqrt((prev[0] - _next[0]) ** 2 + (prev[1] - _next[1]) ** 2)


def main(n: int, x_y: list):
    length = []

    for p in permutations(range(n), n):
        # some tuple
        # (1,2,3)

        i = 0
        while i < len(p) - 1:
            length.append(calc(x_y[p[i]], x_y[p[i + 1]]))
            i += 1

    print("{:.10f}".format(sum(length) / factorial(n)))

if __name__ == "__main__":
    n = int(input())
    x_y = [list(map(int, input().split())) for _ in range(n)]

    main(n, x_y)


Measured memory_bytes: 12080
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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(){
  ll N;
  cin>>N;
  if(N>=30) COYe;
  else CONo;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<map>

using namespace std;

map<unsigned long long int, unsigned long long int> mp;

int main(void)

{
    unsigned long long int N, K, a, b, i, range = 0;
    cin>>N>>K;
    for(i = 0; i < N; i++){
        cin>>a>>b;
        mp[a] += b;
    }
    map<unsigned long long int, unsigned long long int> :: iterator it;
    for(it = mp.begin(); it != mp.end(); it++){
        if(K <= it->second){
            cout<<it->first<<"\n";
            break;
        }
        K -= it->second;
    }
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<numeric>
#include<map>


#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;


int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }

    map<int,int> odd,even;

    REP(i,n){
        if(i % 2 == 0){
            even[a[i]]++;
        }else{
            odd[a[i]]++;
        }
    }

    int odd_maxi = -INF,odd_maxi_num,odd_second_maxi = 0,odd_second_maxi_num = 0;
    int even_maxi = -INF,even_maxi_num,even_second_maxi = 0,even_second_maxi_num = 0;

    for(auto itr:odd){
        if(odd_maxi < itr.second){
            odd_maxi = itr.second;
            odd_maxi_num = itr.first;
        }
    }

    for(auto itr:even){
        if(even_maxi < itr.second){
            even_maxi = itr.second;
            even_maxi_num = itr.first;
        }
    }
    for(auto itr:odd){
        if(odd_second_maxi < itr.second && itr.first != odd_maxi_num){
            odd_second_maxi = itr.second;
            odd_second_maxi_num = itr.first;
        }
    }
    for(auto itr:even){
        if(even_second_maxi < itr.second && itr.first != even_maxi_num){
            even_second_maxi = itr.second;
            even_second_maxi_num = itr.first;
        }
    }

    int ans = 0;
    

    if(odd_maxi_num != even_maxi_num){
        ans = n/2-odd_maxi + n/2-even_maxi;
    }else{
        int tmp = n/2-odd_maxi + n/2-even_second_maxi;
        int tmp2 = n/2-odd_second_maxi + n/2-even_maxi;
        ans = min(tmp,tmp2);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 5376
while True:
    ans=[]
    n,m = map(int,input().split())
    
    if n==0 and m==0:
        break
    
    a = list(map(int,input().split()))
    
    a = sorted(a)

    b = 0
    
    for i in range(n):
        for j in range(i+1,n):
            b = a[i]+a[j]
        
            if b <= m:
                ans.append(b)
            
            else:
                break
    if len(ans)==0:
        print("NONE")
    else:
        print(max(ans))


Measured memory_bytes: 27352
#include <iostream>
#include <algorithm>
#include <string> 
#include <math.h>
#include <set>
#include <vector>
#define rep(i,n) for(int i=0; i< (int)(n); i++)
using namespace std;


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

	int t[110000], x[110000], y[110000];
	t[0] = x[0] = y[0] = 0;
	rep(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];

	bool can = true;
	rep(i,n) {
		int dt = t[i+1] - t[i];
		int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
		if(dist > dt) can = false;
		if(dist % 2 != dt % 2) can = false;
	}
	if(can) cout << "Yes" << "\n";
	else cout << "No" << "\n";


 } 


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>
#include <climits>
using namespace std;
using Int = long long;

int main()
{
    int A, B;
    string S;
    cin >> A >> B >> S;
    if (S.size() != A + B + 1) goto NG;
    for (int i = 0; i < S.size(); i++) {
        if (i == A) {
            if (S[i] != '-') goto NG;
        } else if (!('0' <= S[i] && S[i] <= '9')) goto NG;
    }
    cout << "Yes" << endl;
    return 0;
NG:
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  REP(i, M) {cin >> B.at(i);}
  
  vector<vector<int>> A(N, vector<int>(M));
  REP(i, N) {
    REP(j, M) {
      cin >> A.at(i).at(j);
    }
  }
  
  int count = 0;
  REP(i, N) {
    int sum = 0;
    REP(j, M) {
      sum += A.at(i).at(j) * B.at(j);
    }
    if (sum + C > 0) {
      count++;
    }
  }
  
  cout << count << endl;
}


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

int main()
{
    int s,r,s1,s2,s3;
    cin>>s>>r;
    s1=s+r;
    s2=s-r;
    s3=s*r;

    int t=max(s1,max(s2,s3));
    cout<<t<<endl;


}


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

int X,Y;
int MOD = 1e+9 +7;
const int MAX = 1100000;
 
llong fac[MAX], finv[MAX], inv[MAX];
 
void comInit() {
	fac[0] = fac[1] = inv[1] = finv[0] = finv[1] = 1;
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
 
llong nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

void solve(llong x,llong y){
    comInit();
    cout<<nCr(x+y,x)<<endl;
}

int main(){
    cin>>X>>Y;
    llong z1 = (2*X-Y);
    llong z2 = (-X+2*Y);
    if(z1%3 != 0 || z2%3 != 0){
        cout<<0<<endl;
    }else{
        solve(z1/3,z2/3);
    }
    return 0;
}

Measured memory_bytes: 25984
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int n,a[100],ans=1;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=1;i<n;i++){
		int f=0;
		for (int j=0;j<i;j++) if (a[j]>a[i]) f=1;
		if (f==0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int a,b;
    cin>>a>>b;

    cout<<(3*a + b)/2<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1000000000


int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main() {
    double r,ans;
    cin>>r;
    ans=2*3.141592*r;
    printf("%.10f\n",ans);
}


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

int main(){

  long long N,i,Sum=0;
  cin>>N;
  map<long long, long long> A;
  
  for(i=0;i<N;i++){
    long long a;
    cin>>a;
    A[a]++;
  }
  
  for(auto p:A){
    
    if(p.first>p.second)Sum+=p.second;
    if(p.first<p.second)Sum+=p.second-p.first;
  }
  cout<<Sum<<endl;
  return 0;
}

Measured memory_bytes: 9488
N, K, S = map(int, input().split())
ans = []
for i in range(N):
    if i < K:
        ans.append(S)
    elif S == 1:
        ans.append(2)
    elif S == 2:
        ans.append(3)
    else:
        ans.append(S // 2 +1)
print(' '.join(map(str, ans)))     

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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		long num = k;
		for(int i = 1; i < n; i ++)
			num *= k-1;
		
		out.println(num);
		
		out.close();
	}
	static boolean func(StringBuilder sb1, StringBuilder sb2) {
		boolean res = true;
		for(int i = 0; i < sb1.length(); i++) {
			if ( sb1.charAt(i) != sb2.charAt(i)) {
				res = false;
				break;
			}
		}
		return res;
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> s;
	for (int i = 0; i < m; i++)
	{
		int k;
		vector<int> t;
		cin >> k;
		for (int j = 0; j < k; j++)
		{
			int temp;
			cin >> temp;
			t.push_back(temp);
		}
		s.push_back(t);
	}
	vector<int> p(m);
	for (int i = 0; i < m; i++)
		cin >> p.at(i);

	int ans = 0;
	for (int i = 0; i < pow(2, n); i++) //all pattern
	{
		bool l = true;
		for (int j = 0; j < m; j++) //s
		{
			int t = 0;
			for (int k = 0; k < s.at(j).size(); k++)
			{
				if ((bool)(i & (1 << s.at(j).at(k) - 1)))
					t++;
			}
			l = l && (t % 2 == p.at(j));
		}
		if (l)
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    char a;
    cin >> a;
    set<char> vow = {'a', 'i', 'u', 'e', 'o'};
    if (vow.count(a) == 1)
        cout << "vowel" << "\n";
    else
        cout << "consonant" << "\n";
    return 0;
}

Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール
ll msb(ll x) {
    ll r = 0;
    while (x) {
        x >>= 1;
        r++;
    }
    return r-1;
}

// 処理内容
int main() {
    
    ull n; cin >> n;
    vector<ull> a(n);
    REP(i, n) cin >> a[i];

    ull axor = 0;
    REP(i, n) {
        axor ^= a[i];
    }

    vector<ull> a2 = a;
    REP(i, n) a2[i] &= ~axor;

    REP(i, n) {
        sort(a2.begin() + i, a2.end(), greater<ll>());
        if (!a2[i]) break;
        ull mask = 1ULL << msb(a2[i]);
        REP(j, n) if (i != j) {
            if (mask & a2[j]) {
                a2[j] ^= a2[i];
            }
        }
    }
    ull rem = accumulate(ALL_OF(a2), 0ULL, [](ull x, ull y) {
        return x ^ y;
    });

    // cerr << "[DEBUG] MATRIX:" << endl;
    // REP(i, n) {
    //     cerr << bitset<60>(a2[i]) << endl;
    // }

    cout << (axor ^ rem) + rem << endl;

    
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<ctype.h>
using namespace std;
#include<cstring>
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
string s;
int cnt[27],mi[27];
int main(){
	memset(mi,0x3f,sizeof mi);
	int n=read();
	for(int i=1;i<=n;++i){
		memset(cnt,0,sizeof cnt);
		cin>>s;
		for(int j=0;j<s.length();++j)cnt[s[j]-'a']++;
		for(int j=0;j<26;j++)mi[j]=min(mi[j],cnt[j]);
	}
	for(int i=0;i<26;++i)for(int j=1;j<=mi[i];++j)putchar(i+'a');
	return 0;
}

Measured memory_bytes: 256