akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <stack>

using namespace std;

int main(void){
    int month,day,ans;
    while(1){
        cin >> month >> day;
        if(month==0) break;
        if(month==1){
            ans=day;
        }
        if(month==2){
            ans=day+31;
        }
        if(month==3){
            ans=day+60;
        }
        if(month==4){
            ans=day+91;
        }
        if(month==5){
            ans=day+121;
        }
        if(month==6){
            ans=day+152;
        }
        if(month==7){
            ans=day+182;
        }
        if(month==8){
            ans=day+213;
        }
        if(month==9){
            ans=day+244;
        }
        if(month==10){
            ans=day+274;
        }
        if(month==11){
            ans=day+305;
        }
        if(month==12){
            ans=day+335;
        }
        ans=ans%7;
        if(ans==1) cout << "Thursday" << endl;
        if(ans==2) cout << "Friday" << endl;
        if(ans==3) cout << "Saturday" << endl;
        if(ans==4) cout << "Sunday" << endl;
        if(ans==5) cout << "Monday" << endl;
        if(ans==6) cout << "Tuesday" << endl;
        if(ans==0) cout << "Wednesday" << endl;
    }
    return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a;
  //string A, B, C, D;
  cin >> a;
  
  double ans = 0;
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  int cnt = 0;
  ans = a * a * a;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
Imports System

Module Module1

    Sub Main()
        Dim N As Int32 = Int32.Parse(Console.ReadLine())

        If (N Mod 2 = 1) Then
            Console.WriteLine(Math.Floor(N / 2) + 1)
        Else
            Console.WriteLine(Math.Floor(N / 2))
        End If
    End Sub

End Module


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

public class Main {

    static Parser parser = new Parser();

    public static void main(String[] args) throws IOException {

        int N = parser.parseInt();

        int wIdx[] = new int[N + 1];
        int bIdx[] = new int[N + 1];

        for(int i = 0; i < 2 * N; i++){
            char ch = parser.parseString().charAt(0);
            int idx = parser.parseInt();

            if(ch == 'W'){
                wIdx[idx] = i;
            }else{
                bIdx[idx] = i;
            }
        }

        int wCost[][] = new int[N + 1][N + 1];
        int bCost[][] = new int[N + 1][N + 1];

        for(int i = 1; i <= N; i++){
            for(int j = i + 1; j <= N; j++){
                if(wIdx[i] > wIdx[j]){
                    wCost[i][N] += 1;
                }
                if(bIdx[i] > bIdx[j]){
                    bCost[N][i] += 1;
                }
            }
        }

        for(int i = 1; i <= N; i++){
            for(int j = N - 1; j >= 0; j--){
                wCost[i][j] = wCost[i][j + 1] + (wIdx[i] > bIdx[j + 1] ? 1 : 0);
            }
        }

        for(int i = 1; i <= N; i++){
            for(int j = N - 1; j >= 0; j--){
                bCost[j][i] = bCost[j + 1][i] + (bIdx[i] > wIdx[j + 1] ? 1 : 0);
            }
        }

        int dp[][] = new int[N + 1][N + 1];
        for(int i = 0; i <= N; i++){
            Arrays.fill(dp[i], (int)1e9);
        }

        dp[0][0] = 0;
        for(int i = 0; i <= N; i++){
            for(int j = 0; j <= N; j++){

                if(i > 0){
                    dp[i][j] = Math.min(dp[i][j], dp[i - 1][j] + wCost[i][j]);
                }

                if(j > 0){
                    dp[i][j] = Math.min(dp[i][j], dp[i][j - 1] + bCost[i][j]);
                }
            }
        }

        System.out.println(dp[N][N]);
    }
}

class Parser {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final Iterator<String> stringIterator = br.lines().iterator();
    private static final Deque<String> inputs = new ArrayDeque<>();

    void fill() throws IOException {
        if(inputs.isEmpty()){
            if(!stringIterator.hasNext()) throw new IOException();
            inputs.addAll(Arrays.asList(stringIterator.next().split(" ")));
        }
    }

    Integer parseInt() throws IOException {
        fill();
        if(!inputs.isEmpty()) {
            return Integer.parseInt(inputs.pollFirst());
        }
        throw new IOException();
    }

    Long parseLong() throws IOException {
        fill();
        if(!inputs.isEmpty()) {
            return Long.parseLong(inputs.pollFirst());
        }
        throw new IOException();
    }

    Double parseDouble() throws IOException {
        fill();
        if(!inputs.isEmpty()) {
            return Double.parseDouble(inputs.pollFirst());
        }
        throw new IOException();
    }

    String parseString() throws IOException {
        fill();
        return inputs.pollFirst();
    }

}

Measured memory_bytes: 83944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());

		int a =(int) (N / 1.08);
		
		
		if((int)(a*1.08) == N) {
			System.out.println(a);
		}else if((int)((a+1)*1.08) == N) {
			System.out.println(a+1);
		}else {
			System.out.println(":(");
		}
		
	}



}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);

	ll n, k;
	cin >> n >> k;
	vi v(n);
	rep(i, n) cin >> v[i];
	cout << ((n - 1) + (k - 2)) / (k - 1) << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int N,A,B;
	int x1,x2,min;
	scanf("%d%d%d",&N,&A,&B);
	x1=N*A;
	x2=B;
	min=x1>x2?x2:x1;
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
N,M=gets.chomp.split(" ").map(&:to_i)
lst=[]
for i in 1..N do
  a,b = gets.chomp.split(" ").map(&:to_i)
  lst.push([a,b,a*b])
end
lst=lst.sort
m=0
i=0
cost=0
while(m<M)
  m+=lst[i][1]
  cost+=lst[i][2]
  i+=1
end
if(m>M)
  cost-=lst[i-1][0]*(m-M)
end
print(cost)


Measured memory_bytes: 11128
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<vector<int>> c(3,vector<int>(3));

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c.at(i).at(j);
        }
    }

    bool tf = true;

    vector<int> a(3),b(3);
    a.at(0)=0;
    b.at(1)=c.at(0).at(1)-a.at(0);
    b.at(2)=c.at(0).at(2)-a.at(0);
    b.at(0)=c.at(0).at(0)-a.at(0);
    a.at(1)=c.at(1).at(0)-b.at(0);
    a.at(2)=c.at(2).at(0)-b.at(0);

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(c.at(i).at(j)!=a.at(i)+b.at(j)){
                tf = false;
            }
        }
    }

    if(tf==true)cout << "Yes" <<endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int cnt=700;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='o')cnt+=100;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
dat_a = map(int, input().split())
dat_a = list(dat_a)
count = 0
f = True
while f:
    for i in range(n):
        if dat_a[i] % 2 == 1:
            f = False
        else:
            dat_a[i] /= 2
    if f:
        count += 1
    else:
        break
print(count)

Measured memory_bytes: 39664
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
vector<string> ans;
map<string,int> mp;
int n,mx=-1;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		mp[s]++;
	}
	for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++) mx=max(mx,it->se);
	for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
		if(it->se==mx)
			ans.pb(it->fi);
	sort(all(ans));
	for(int i=0;i<sz(ans);i++) cout<<ans[i]<<"\n";	
	re 0;
}

Measured memory_bytes: 27296
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var N = NK[0];
            //var K = NK[1];

            Sort(A);
            var used = new long[A[N-1]+1];
            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                if (used[A[i]] == 0)
                {
                    ans++;
                    var st = A[i];
                    used[st] = 2;
                    st += A[i];
                    while (st <= A[N - 1])
                    {
                        used[st] = 1;
                        st += A[i];
                    }
                }else if (used[A[i]] == 2)
                {
                    ans--;
                    used[A[i]] = 1;
                }
            }


            Console.WriteLine(ans);
        }


      
    }

}


Measured memory_bytes: 51744
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

long long dp[100001];

/**
 * Recursive solution.
 */
int solve_recursive(vector<long long> &weights, vector<int> &values, int index, int cur_max, int left_weight) {

    if (index == weights.size()) {
        return cur_max;
    }

    if (left_weight <= 0) {
        return cur_max;
    }

    if (weights[index] <= left_weight) {
        int value_taken =
            solve_recursive(weights, values, index + 1, cur_max + values[index], left_weight - weights[index]);
        int value_not_taken = solve_recursive(weights, values, index + 1, cur_max, left_weight);

        return max(value_taken, value_not_taken);
    } else {
        return solve_recursive(weights, values, index + 1, cur_max, left_weight);
    }
}

vector<int> weights;
vector<int> values;

int solve_dp(int W) {
    int s = weights.size();

    long long MAX_VALUE = 1e18 - 1e9;

    for (int i = 1; i <= s * 1000; ++i)
        dp[i] = MAX_VALUE;

    dp[0] = 0;
    for (int i = 1; i <= s; i++) {
        for (int j = s * 1000; j >= values[i - 1]; --j) {
            long long taken = dp[j - values[i - 1]] + weights[i - 1];
            long long not_taken = dp[j];
            if (taken < not_taken) {
                dp[j] = taken;
            } else {
                dp[j] = not_taken;
            }
        }
    }

    int max_value = 0;
    for (int i = 0; i <= s * 1000; ++i) {
        if (dp[i] <= W) {
            max_value = i;
        }
    }

    return max_value;
}
/**
 * @param N number of items.
 * @param W max weigth of the knapsack.
 */
int solve(int N, int W) {

    weights.resize(N);
    values.resize(N);

    for (int i = 0; i < N; ++i) {
        cin >> weights[i];
        cin >> values[i];
    }

    // for (int i = 0; i < N; ++i) {
    //     cout << weights[i] << " -> " << values[i] << endl;
    // }

    // int ans_rec = solve_recursive(weights, values, 0, 0, W);
    int ans = solve_dp(W);

    // cout << "Recursive: " << ans_rec << endl;
    // cout << "Dyn Prog : " << ans << endl;

    return ans;
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie();

    int N, W;
    cin >> N >> W;

    int ans = solve(N, W);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

const int dif = 'A' - 'a';

int main(){
	string str;
	getline(cin, str);

	for(int i = 0; i < static_cast<int>(str.size()); i++){
		if('A' <= str[i] && str[i] <= 'Z'){
			str[i] -= dif;
		}else if('a' <= str[i] && str[i] <= 'z'){
			str[i] += dif;
		}
	}

	cout << str << endl;
}

Measured memory_bytes: 3136
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int N=1e5+3;
int n,a,b;
ll h[N];
bool check(ll x){
	ll sum=0;
	for(int i=1;i<=n;i++){
		if(h[i]<=x*b) continue;
		sum+=(h[i]-x*b)/(a-b);
		if((h[i]-x*b)%(a-b)) sum++;
	}
	if(sum<=x) return true;
	return false;
}
int main(){
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++) cin>>h[i];
    int l=1,r=1e9;
	while(r-l>5){
		int m=(l+r)>>1;
		if(check(m)) r=m;
		else l=m;
	}
	while(l<=r){
		if(check(l)) break;
		l++;
	}
	cout<<l<<endl;
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split();
            int n = int.Parse(line[0]), m = int.Parse(line[1]);
            var array = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            Array.Sort(array);

            if (n >= m)
            {
                Console.WriteLine(0);
                return;
            }

            var diff = new int[m - 1];

            for (var i = 0; i < m - 1; i++)
            {
                diff[i] = array[i + 1] - array[i];
            }
            Array.Sort(diff);

            var total = 0L;
            for (var i = 0; i < m - n; i++)
            {
                total += diff[i];
            }

            Console.WriteLine(total);
        }
    }
}

Measured memory_bytes: 19936
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

global n,k
global ws

def iSok(Pmax):
    truck = 0
    now = 0
    for i in range(n):
        if ws[i]>Pmax:
            return False
        if now+ws[i]>Pmax:
            truck += 1
            now = ws[i]
        else:
            now += ws[i]
    if now > 0:
        truck += 1
    if truck > k:
        return False
    else:
        return True

n,k = map(int,input().split())

now = 0
ws = [int(input()) for i in range(n)]
amin = 0
amax = sum(ws)

while amax-amin >1:
    amid = (amin + amax)//2
    if iSok(amid):
        amax = amid
    else:
        amin = amid
print(amax)



Measured memory_bytes: 10804
#include <iostream>
using namespace std;
int main () {
	long long int N;
	cin >> N;
	long long int ans=N+1;
	for (long long int i=1; i*i<=N; i++) {
		if (N%i==0) {
			ans=min(ans, ((i-1)+(N/i)-1));
		}	
	}
	cout << ans << endl;
}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  if(a>b){cout<<b<<" ";} else {cout<<a<<" ";}
  if(a+b>n){cout<<a+b-n<<endl;} else {cout<<0<<endl;}
  return 0;
}


Measured memory_bytes: 256
'''
Created on 2020/08/21

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  A,B,C=map(int,pin().split())
  ans=0
  while True:
    if A%2==1 or B%2==1 or C%2==1:
      print(ans)
      break
    if A==B and A==C:
      print(-1)
      break
    a=A 
    b=B 
    c=C 
    A=b//2+c//2
    B=a//2+c//2
    C=a//2+b//2
    ans+=1
  return 
main()
    

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    string s;
    cin>>s;
    string x;
    rep(i,s.length()){
        if(i%2==0){
            x += s[i];
        }
    }
    cout<<x<<endl;
    return  0;
}


Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cmath>
#include <map>
#include <unordered_map>

using namespace std;
typedef long long ll;

#define cout (cout << setprecision(12))

ll combination(ll n, ll r) {
    ll bunbo = 1, bunshi = 1;
    for (int i = 0; i < r; i++) {
        bunshi *= n - i;
        bunbo *= r - i;
    }
    return bunshi / bunbo;
}

int main() {
    int N, tmp;
    vector<int> A;
    cin >> N;
    unordered_map<ll, ll> m, ans_m, calc_with_self_m, calc_without_self_m;
    ll sum_with_self = 0, sum_without_self = 0;
    for (int i = 0; i < N; i++) {
        scanf("%d", &tmp);
        m[tmp]++;
        A.push_back(tmp);
    }

    auto mm = m;

    for (const auto& e : m) {
        calc_with_self_m[e.first] = combination(e.second, 2);
        sum_with_self += calc_with_self_m[e.first];
        calc_without_self_m[e.first] = combination(e.second - 1, 2);
//        sum_without_self += calc_without_self_m[e.first];
    }

    for (const auto& e : m) {
        ll ans = sum_with_self - calc_with_self_m[e.first] + calc_without_self_m[e.first];
        ans_m[e.first] = ans;
    }

    for (const auto& a : A) {
        cout << ans_m[a] << endl;
    }
}

Measured memory_bytes: 33212
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    BigInteger x = BigInteger.valueOf(Long.parseLong(sc.next()));
    BigInteger k = BigInteger.valueOf(Long.parseLong(sc.next()));
    BigInteger d = BigInteger.valueOf(Long.parseLong(sc.next()));
    BigInteger maxMove = k.multiply(d);
    if (x.abs().compareTo(maxMove) >= 0) {
      pw.println(x.abs().add(maxMove.abs().negate()));
    } else {
      BigInteger[] goToNearest = x.divideAndRemainder(d);
      if (k.add(goToNearest[0].negate()).remainder(BigInteger.TWO).compareTo(BigInteger.ZERO)
        == 0) {
        pw.println(goToNearest[1].abs());
      } else {
        pw.println(goToNearest[1].add(d).abs().min(goToNearest[1].add(d.negate()).abs()));
      }
    }
  }
}


Measured memory_bytes: 35928
#include <vector>
#include <iostream>
using namespace std;
//Using recursion
int cost(int h1, int h2){
    int val = h1-h2;
    if(val<0)
    {
        return(-val);
    }
    return(val);
}
int min(int val1, int val2)
{
    if(val1<val2){
        return(val1);
    }
    return(val2);
}


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> heights;
    vector<int> costAt;
    for(int i =0; i<n; i++)
    {
        
        int num;
        cin >> num;
        heights.push_back(num);
        costAt.push_back(0);
    }
    for(int i = 0; i<k; i++)
    {
        if(!(i<n)){
                break;
            }
        costAt[i] = cost(heights.at(0),heights.at(i));
    }
    
    for(int i =k; i<n; i++)
    {
        if(!(i<n)){
                break;
            }
        int minCost = costAt.at(i-1)+cost(heights.at(i),heights.at(i-1));
        for(int j = 1; j<=k; j++){
            if(!(j+1<n)){
                break;
            }
            int costL = costAt.at(i-j)+cost(heights.at(i),heights.at(i-j));
            if(costL<minCost){
                minCost = costL;
            }

        }
        costAt[i] = minCost;

    }
    cout << costAt.at(n-1)<< endl;
    
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, n) for(ll i=0;i<n;i++)
#define r(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    puts(a+b+c>=22?"bust":"win");

}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

const int D = 60;
const int MAX_N = 200005;

int to[D][MAX_N];
const double PI = 3.141592653589793;

int main()
{

    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double tyou, tann;
    tyou = 0.5 * (h * 60 + m);
    tann = 6 * m;
    double kakudo = min(abs(tyou - tann), 360 - abs(tyou - tann));

    double ans;
    ans = a * a + b * b - 2 * a * b * cos(kakudo * PI / 180);
    ans = sqrt(ans);
    printf("%.9f\n", ans);

    return 0;
}


Measured memory_bytes: 4228
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	int n, d[100];
	int sum = 0;
	cin >> n;
	FOR(n) {
		cin >> d[i]; 
	}

	FORR(0, n-1) {
		for (int j = i + 1; j < n; ++j)
			sum += d[i] * d[j];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.AbstractMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;

// the simulation of the round robin scheduler
public class Main {
	// log in the order of termination
	public static void simulate(Queue<Map.Entry<String, Integer>> budgets, int q) {
		int global_timer = 0;

		
		Map.Entry<String, Integer> budget;
		int time_consumpt;
		
		while(!budgets.isEmpty()) {
				budget = budgets.poll();
				time_consumpt = Math.min(budget.getValue(), q);
				budget.setValue(budget.getValue() - time_consumpt);
				global_timer += time_consumpt;
				if(budget.getValue() == 0) {
					System.out.println(budget.getKey() +" "+global_timer);
				}else {
					budgets.add(budget);
				}
		}


		return;
		
	}
	
	
	
	
	public static void main(String [] args) {
		Scanner cin = new Scanner(System.in);
		int len = cin.nextInt();
		int q = cin.nextInt();


		Queue<Map.Entry<String, Integer>> budgets = new LinkedList<Map.Entry<String, Integer>>() ;
		
		for(int i = 0; i < len; i++) {
			budgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));
		}
		cin.close();
		
		simulate(budgets, q);
		

		
	}
}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

#define endl '\n'
#define MAX

typedef long long ll;
typedef pair<int,int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;


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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	const ll oo = 0x3f3f3f3f3f3f3f3f;
	
	int n, m;
	cin >> n >> m;
	vector<ll> a(n), dp(n, oo);

	for(int i = 0; i < n; i++)
		cin >> a[i];

	dp[n - 1] = 0;
	for(int i = n - 2; i >= 0; i--)
		for(int k = 1; k <= m; k++)
			if(i + k < n)
				dp[i] = min(dp[i], dp[i + k] + abs(a[i] - a[i + k]));
	
	cout << dp[0] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

int main()
{
    int X,A,B;
    cin >> X >> A >> B;
    cout << (X - A)%B << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){

  int a[200];
  int b[50];
  for(int i=0;i<200;i++)a[i]=i*(i+1)*(i+2)/6;
  for(int i=0;i<50;i++)b[i]=(4*i+1)*(4*i+2)*(4*i+3)/6;

  vector<int> dp1;
  dp1.assign(1500000,0);

  for(int i=0;i<1500000;i++)dp1[i]=i;
  for(int i=1;i<1500000;i++){
    for(int j=0;j<200;j++){
      if(i>=a[j])dp1[i]=min(dp1[i],dp1[i-a[j]]+1);
    }
  }

  vector<int> dp2;
  dp2.assign(1500000,0);
  for(int i=0;i<1500000;i++)dp2[i]=i;
  for(int i=0;i<1500000;i++){
    for(int j=0;j<50;j++){
      if(i>=b[j])dp2[i]=min(dp2[i],dp2[i-b[j]]+1);
    }
  }

  int n;
  cin >> n;
  while(n!=0){
    cout << dp1[n] <<" " << dp2[n] << endl;
    cin >> n;
  }


}


Measured memory_bytes: 14200
//2018.09.14 1hour

#include <iostream>
using namespace std;

int main() {
    int A,B,X;
    cin >> A >> B >> X;

    if(A>X)cout << "NO" << endl;

    else if((A+B)>=X){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

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

  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (b <= a) {
    cout << 1 << endl;
    return 0;
  }

  ll ans = 1;
  b = b - a;
  a = a - 1;
  while(1) {
    ans++;
    b = b - a;
    if (b <= 0) break;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(A>B){
    A^=B;
    B^=A;
    A^=B;
  }
  if(A<C && C<B) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
N, M = [ int(it) for it in input().split() ]
MOD = 1000000007

import math
sM = int(math.sqrt(M)+1)

p_li = []
m = M
for j in range(2,sM+1):
  for i in range(sM):
    if (m%j)==0:
      p_li.append(j)
      m//=j
    else:
      break
  if (m==1):
    break
if (m!=1):
  p_li.append(m)
    
    
import collections
co = collections.Counter(p_li)
vec = co.values()

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

s = 1
for v in vec:
  X=N-1+v
  Y=N-1
  if (X-Y<Y):
    Y=X-Y
  ss = 1
  sd = 1
  for i in range(X,X-Y,-1):
    ss = (ss*i)%MOD
  for i in range(Y,0,-1):
    sd = (sd*i)%MOD
  
  ss = (ss*mod_inv(sd,MOD))%MOD
  s = (s*ss)%MOD
print (s%MOD)
      




Measured memory_bytes: 38768
#! /usr/bin/ruby -w
# encoding: utf-8
#

class Result < Struct.new(:found, :finish)
  def complete?
    found and finish
  end

  def to_s
    "%d %d" % [found ? found : 0, finish ? finish : 0]
  end
end

class MyTime
  def initialize
    @value = 0
  end

  def inc
    @value = @value + 1
  end

  def to_s
    @value
  end

  attr_reader :value
end

def search(num, graph, time, result)
  unless result[num].complete?
    result[num].found = time.inc
    row = graph[num]
    row.each_with_index do |e, idx|
      next if idx == num
      next unless result[idx].found.nil? # 訪れたことがある場合
      if e == 1
        search(idx, graph, time, result)
      end
    end
    result[num].finish = time.inc
  end
end

if __FILE__ == $0
  n = gets.to_i
  g = []
  n.times {
    a = Array.new(n, 0)
    info = gets.split.map(&:to_i)
    info[1].times do |idx|
      outdegree = info[idx + 2]
      a[outdegree - 1] = 1
    end
    g << a
  }

  time = MyTime.new
  result = Array.new(n).map { Result.new }
  n.times do |num|
    search(num, g, time, result)
  end

  result.each_with_index do |r, idx|
    puts "%d %s" % [idx + 1, r]
  end
end



Measured memory_bytes: 7268
//
// Created by yamunaku on 2020/02/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b==c){
        CNO;
        return 0;
    }
    if(a==b||b==c||c==a){
        CYES;
        return 0;
    }
    CNO;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
C = [0] * (N - 1)
S = [0] * (N - 1)
F = [0] * (N - 1)
for i in range(N - 1):
    C[i], S[i], F[i] = map(int, input().split())
for n in range(N):
    time = 0
    for i in range(n, N - 1):
        dep = S[i]
        time = max(time, dep)
        while time > dep:
            dep += F[i]
        time = dep + C[i]
    print(time)


Measured memory_bytes: 42668
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int n = (int)Math.sqrt(N)+1;
		for(int i = n; i > 0; i--) {
			long a = N/i;
			if(i*a == N) {
				System.out.println(i+a-2);
				break;
			}
		}
		sc.close();
	}
}

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

int main() {
    int n;
    scanf("%d", &n);
    map<pair<int,int>, int> cnt;
    for(int i = 0; i < n; ++i) {
        double x;
        scanf("%lf", &x);
        long long xl = llround(x * 1e9);
        int two = 0, five = 0;
        while(xl % 2 == 0) {
            two++;
            xl /= 2;
        }
        while(xl % 5 == 0) {
            five++;
            xl /= 5;
        }
        ++cnt[{two,five}];
    }
    long long answer = 0;
    for(auto p1 : cnt) {
        for(auto p2 : cnt) {
            if(p1.first.first+p2.first.first >= 18 && p1.first.second+p2.first.second >= 18) {
                if(p1 < p2) {
                    answer += (long long) p1.second * p2.second;
                }
                else if(p1 == p2) {
                    answer += (long long) p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    printf("%lld\n", answer);
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < 3; i++)
        if(s[i] == t[i])
            ans += 1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;

public class program{
    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        var p=Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
        var min=new int[n];
        min[0]=p[0];
        var temp=p[0];
        var c=0;
        for(var i=1;i<n;i++){
            if(p[i]<temp) temp=p[i];
            min[i]=temp;
        }
        for(var i=0;i<n;i++){
            if(p[i]<=min[i]) c++;
        }
        Console.WriteLine(c);
    }
}


Measured memory_bytes: 32196
#include <iostream>
#include <vector>
#include <cmath>

const double EPS = 1e-10;
#define equals(a, b) (fabs((a) - (b)) < EPS )

using namespace std;

struct Point {
    double x, y;

    Point(double x_, double y_) : x(x_), y(y_){}

    Point operator+(Point &p) {
        return Point(this->x + p.x, this->y + p.y);
    }

    Point operator-(Point &p) {
        return Point(this->x - p.x, this->y - p.y);
    }

    Point operator*(double k) {
        return Point(this->x * k, this->y * k);
    }

    Point operator/(double a) {
        return Point(x / a, y / a);
    }

    double norm() { return sqrt(x * x + y * y); }

    bool operator<(const Point &p) {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator==(const Point &p) {
        return fabs(this->x - p.x) < EPS && fabs(this->y - p.y) < EPS;
    }

    double dot(Point &p) {
        return this->x * p.x + this->y * p.y;
    }

    double cross(Point &p) {
        return this->x * p.y - this->y * p.x;
    }

};

typedef Point Vector;

struct Segment {
    Point p1, p2;
    Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_) {}
};

typedef Segment Line;

class Circle {
    Point c;
    double r;

    Circle(Point c, double r = 0.0) : c(c), r(r) {}
};

typedef vector<Point> Polygon;

double norm(Vector a) {
    return sqrt(a.x * a.x + a.y * a.y);
}


int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        double x0, y0;
        double x1, y1;
        double x2, y2;
        double x3, y3;
        cin >> x0 >> y0;
        cin >> x1 >> y1;
        cin >> x2 >> y2;
        cin >> x3 >> y3;

        auto p0 = Point(x0, y0);
        auto p1 = Point(x1, y1);
        auto p2 = Point(x2, y2);
        auto p3 = Point(x3, y3);
        auto v1 = p1 - p0;
        auto v2 = p2 - p3;
        double dt = v1.dot(v2) / v1.norm() / v2.norm();
        if(abs(dt - 1.0) < EPS || abs(dt + 1.0) < EPS ) {
            cout << 2 << endl;
        } else if(abs(dt) < EPS) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }


    return 0;
}






Measured memory_bytes: 3228
s = input()
mode = "R"
ans = [0] * len(s)
lpos = -1
lc = 0
point = 0
for i, c in enumerate(s):
    if mode == "R":
        if c == "L":
            lpos = i
            lc = 1
            mode = "L"
    else:
        if c == "R":
            d = i - point
            rc = d - lc
            ans[lpos] = (rc // 2) + (lc - lc // 2)
            ans[lpos - 1] = (rc - rc // 2) + (lc // 2)
            point = i
            mode = "R"
        else:
            lc += 1

i = len(s)
d = i - point
rc = d - lc
ans[lpos] = (rc // 2) + (lc - lc // 2)
ans[lpos - 1] = (rc - rc // 2) + (lc // 2)

print(*ans, sep=" ")


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x <<": "<<x<<"\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> using vec = std::vector<T>;
template <class T = int> T in(){T x; cin>>x;return(x);}
template <class T > void print(T& x){cout<<x<<"\n";}
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,C;
  cin >>A>>B>>C;
  int ans = C-A+B;
  cout << (ans<0?0ll:ans)<<endl;

}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

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

    Int a, b, x;
    cin >> a >> b >> x;

    cout << Floor(b, x) - Ceil(a, x) + 1LL << endl;

    return 0;
}


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

#define ALL(c) std::begin(c), std::end(c)

using namespace std;
using ll = long long;

void solve() {
    vector<ll> bc(10e5 + 2);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ++bc[a];
        ++bc[a + 1];
        ++bc[a + 2];
    }
    cout << *max_element(ALL(bc)) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


Measured memory_bytes: 8064
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;

public class Main {

    static boolean succeeded;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        boolean[] k = new boolean[33];
        for (int i = 0;i <= 32;++i){
            if((n - 1) % -2 == 0){
                k[32 - i] = true;
                --n;
            }
            n /= -2;
        }
        boolean flag = false;
        StringBuilder sb = new StringBuilder();
        for (boolean b:k){
            if(b){
                sb.append('1');
                flag = true;
            }
            else if(flag)sb.append('0');
        }
        if(sb.length() == 0){
            sb.append('0');
        }
        System.out.println(sb.toString());
    }






























}


Measured memory_bytes: 23764
public class Main {

	public static void main(String[] args) {
		java.util.Scanner scanner = new java.util.Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		System.out.print(a * b);
		System.out.print(" ");
		System.out.println(2 * ( a + b));
					}
}

Measured memory_bytes: 26120
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a*b>c*d){
		cout << a*b << endl;
	}
	else{
		cout << c*d << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String array[] = new String[n];
        int cnt = 0;
        int cnt2=0;

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

        Arrays.sort(array);

        String a = array[0];
        cnt++;
        for(int i=0;i<n;i++){
        
            if(a.equals(array[i])){

            }else{
                cnt++;
            }
             a = array[i];
       }
       System.out.println(cnt);
    }
}

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

int main(){
    while(true){
    int n, getA = 0, getB = 0;
    cin >> n;
    if(n == 0) break;
    int A,B;
    for(int i = 0; i < n; i++){
        cin >> A >> B;
        if( A > B ) getA += A + B;
        else if( A < B ) getB += A + B;
        else{
            getA += A;
            getB += B;
        }
    }
    cout << getA << " " << getB << endl;
    }
    return 0;
}


Measured memory_bytes: 2992
import java.util.Scanner;


public class Main {


	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
//		String[] s = sc.next().split("");
		int n = Integer.parseInt(sc.next());
		if(n == 1) {
			System.out.println(0);
		}else {
			System.out.println(1);
		}
		
		
	}
}


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

int main() {
    int x, y;
    cin >> x >> y;
    string ans = "No";

    int i, j;
    for(i = 0; i < x + 1; i++) {
        j = x - i;
        if (i*2 + j*4 == y) {
            ans = "Yes";
        }
    }
    cout << ans << endl;
}


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

bitset<10> next(bitset<10> &s) {
	int d = 0;
	while(s[d]) s[d] = false, d++;
	s[d] = true;
	return s;
}


int main() {
	int N, M;
	cin >> N >> M;
	vector<bitset<10> > s(M);
	for(int i = 0; i < M; i++) {
		int k;
		cin >> k;
		for(int j = 0; j < k; j++) {
			int t;
			cin >> t;
			s[i][t-1] = true;
		}
	}

	vector<int> p(M);
	for(auto &x: p) cin >> x;

	int res = 0;
	for(bitset<10> sw; sw.to_ulong() < (1UL << N); sw = next(sw)) {
		for(int i = 0; i < M; i++) {
			bitset<10> t = sw & s[i];
			if(t.count() % 2 != p[i]) goto nextset;
		}
		res++;
		nextset:
		;
	}

	cout << res << endl;
}


Measured memory_bytes: 256
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()

def main():
    MAX = 10 ** 5
    Q = int(input())

    ans = np.array([0] * (MAX + 1))
    sum = 0
    prime = set()
    memo = np.array([False] * 2 + [True] * (MAX - 1))
    for i in range(2, MAX + 1):
        if memo[i]:
            prime.add(i)
            for j in range(i * 2, MAX + 1, i):
                memo[j] = False
            if (i + 1) // 2 in prime:
                sum += 1
        ans[i] = sum
    
    for _ in range(Q):
        l, r = map(int, input().split())
        print(ans[r] - ans[l-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 16632
import itertools

n, m = map(int, list(input().split(' ')))
paths = {}
for i in range(m):
    a, b = map(int, list(input().split(' ')))
    if a in paths:
        paths[a].add(b)
    else:
        paths[a] = set([b])

ans = 0
for t in itertools.permutations(range(2, n+1), n - 1):
    arr = list(t)
    arr.insert(0, 1)
    for i in range(len(arr) - 1):
        a = arr[i]
        b = arr[i + 1]
        if a > b:
            tmp = a
            a = b
            b = tmp
        if not a in paths:
            break
        if not b in paths[a]:
            break
    else:
        ans += 1

print(ans)


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

int main() {
    string s, rs;
    cin >> s;
    rs = s;
    int ans = 0;
    reverse(rs.begin(), rs.end());
    for (int i = 0; i < s.size() / 2 + s.size() % 2; i++) {
        if (s[i] != rs[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    ll p[200010];
    rep(i, n) cin >> p[i];
    ll pos[200010];
    rep(i, n) pos[p[i]] = i;
    set<ll> larger_pos;
    larger_pos.insert(pos[n]);
    ll sum = 0;

    const int invalid = -1053;

    for (ll t = n - 1; t >= 1; t--) {
        ll l1, l2, r1, r2;
        auto itr = larger_pos.lower_bound(pos[t]);

        if (itr == larger_pos.end()) {
            r1 = n;
            r2 = invalid;
        } else {
            r1 = *itr;
            itr++;
            r2 = (itr == larger_pos.end() ? n : *itr);
            itr--;
        }
        if (itr == larger_pos.begin()) {
            l1 = -1, l2 = invalid;
        } else {
            itr--;
            l1 = *itr;
            if (itr == larger_pos.begin()) l2 = -1;
            else {
                itr--;
                l2 = *itr;
                itr++;
            }
        }

        if (l2 != invalid) sum += (l1 - l2) * (r1 - pos[t]) * t;
        if (r2 != invalid) sum += (r2 - r1) * (pos[t] - l1) * t;

        larger_pos.insert(pos[t]);
    }
    
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 7808
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n, t = map(int, input().split())
    ab = []
    for _ in range(n):
        a, b = map(int, input().split())
        ab.append((a, b))
    ab.sort()
    dp = [0] * (t + 1)
    for a, b in ab:
        mx = 0
        for i in range(t - 1, -1, -1):
            dpi = dp[i]
            if dpi > mx: mx = dpi
            if i - a >= 0:
                dp[i] = max(dpi, dp[i - a] + b)
        dp[t] = max(dp[t], mx + b)
    print(dp[t])
    # print(dp)

main()


Measured memory_bytes: 45036
N = int(input())
S = input()

white = [0] * (N + 1)
for i in range(N):
    if S[i] == ".":
        white[i + 1] = white[i] + 1
    else:
        white[i + 1] = white[i]

ans = N
for i in range(N + 1):
    tmp = (i - white[i]) + (white[-1] - white[i])
    if tmp < ans:
        ans = tmp

print(ans)


Measured memory_bytes: 11144
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll x,y;cin>>x>>y;
    cout<<x+y/2<<endl;

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	double ans;
	double pow = 1.0;
	for(int i = 0; i < m; i++) pow *= 2.0;
	ans = (((double)m)*1800.0 + ((double) n)*100.0) *pow;
	cout<<(int)ans<<endl;
	return 0;
}

Measured memory_bytes: 256