akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
  int N, M, C;
  cin >> N >> M >> C;
  int A[101][101];
  int B[101];
  for(int i = 0; i < M; i++){
    cin >> B[i];
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    int sum = 0;
    for(int j = 0; j < M; j++){
      //cout << B[i] << endl;
      //cout << A[i][j] << endl;
      sum += A[i][j] * B[j];
    }
    if(sum + C > 0){
      count = count + 1;
    }
  }

  cout << count << endl;

  return 0;
}

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

double reverse(double number){
  return 1/number ;
}

int main(){
  int N; 
  double sum = 0;
  int n_values;
  cin >> N;
  for(int i = 0; i <N ; i++){
    cin >> n_values;
    sum += reverse(n_values);
  }
  
  cout <<  1/sum ;
  return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score = 0;
    rep(i,n-1) {
        if (s[i] == s[i+1]) score++;
    }
    int ans = min(score+2*k, n-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int N, M = 0, A = 0, R = 0, C = 0, H = 0, i, ans = 0;
	scanf("%lld", &N);
	char **S = (char **)malloc(sizeof(char *) * N);
	for(i = 0; i < N; i++){
		S[i] = (char *)malloc(sizeof(char) * 11);
		scanf("%s", S[i]);
		if(S[i][0] == 'M'){
			M++;
		}
		if(S[i][0] == 'A'){
			A++;
		}
		if(S[i][0] == 'R'){
			R++;
		}
		if(S[i][0] == 'C'){
			C++;
		}
		if(S[i][0] == 'H'){
			H++;
		}
	}
	ans += M * A * R;
	ans += M * A * C;
	ans += M * A * H;
	ans += M * R * C;
	ans += M * R * H;
	ans += M * C * H;
	ans += A * R * C;
	ans += A * R * H;
	ans += A * C * H;
	ans += R * C * H;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

struct Output {
private:
	vector<ll> contestList;
	
public:
	
	
};


class Input {
	vector<ll> decreaseRates;
	vector<vector<ll>> satisfacitons;
	ll numContests = 26;
	ll numDay = 365;
	vector<ll> contestList;
	vector<ll> lastContest;
	ll m_score;

public:
	void initialize() {
		contestList.resize(numDay + 1);
		lastContest.resize(numContests + 1);
	}
	void initializeLastContest() {
		lastContest.clear();
		lastContest.resize(numContests + 1);
	}
	void readInputs() {
		decreaseRates.resize(numContests + 1);
		for (ll i = 1; i <= numContests; i++) {
			cin >> decreaseRates[i];
		}
		satisfacitons.resize(numDay + 1);
		for (ll i = 1; i <= numDay; i++) {
			satisfacitons[i].resize(numContests + 1);
			for (ll j = 1; j <= numContests; j++) {
				cin >> satisfacitons[i][j];
			}
		}
	}

	ll getNumContests() { return numContests; }
	ll getNumDay() { return numDay; }
	vector<ll> getDecreaseRates() { return decreaseRates; }
	vector<vector<ll>> getSatisfactions() { return satisfacitons; }
	ll getContest(ll day) {
		return contestList[day];
	}
	vector<ll> getContestList() { return contestList; }
	void setNumContests(ll num) { numContests = num; }
	void setNumDay(ll day) { numDay = day; }
	void setContest(ll day, ll contest) {
		contestList[day] = contest;
	}

	

	ll calcScore() {
		ll score = 0;
		initializeLastContest();

		for (ll day = 1; day <= numDay; day++) {
			ll dayContest = contestList[day];
			lastContest[dayContest] = day;
			score += satisfacitons[day][dayContest];
			for (ll contest = 1; contest <= numContests; contest++) {
				score -= decreaseRates[contest] * (day - lastContest[contest]);
			}
		}
		m_score = score;
		return score;
	}

};




int main() {
	ll numDay;
	cin >> numDay;

	Input input;
	input.setNumDay(numDay);
	input.initialize();
	input.readInputs();
	for (ll i = 1; i <= numDay; i++) {
		ll contest;
		cin >> contest;
		input.setContest(i, contest);
	}
	ll Q;
	cin >> Q;
	ll score = input.calcScore();
	for (ll i = 0; i < Q; i++) {
		ll day, contest;
		cin >> day >> contest;
		input.setContest(day, contest);
		cout << input.calcScore() << endl;
	}
	
}


Measured memory_bytes: 3688
import Control.Arrow
main=print.solve.map read.words=<<getLine
solve[h,w]=minimum$f h w++f w h
f x y=map(g x=<<(y-))[1..(y+1)`div`2]
g x y i=min(h x y z)(h y x z)where z=i*x
h x y z=uncurry(-)$(maximum&&&minimum)[z,x*d,x*(y-d)]where d=y`div`2

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

int main()
{
    int A,B;
    cin >> A >>B;
    auto temp = A*B;
    if((temp*1 %2==1 || temp*2 %2==1 || temp*3 %2==1)){
        cout << "Yes";
    }else
    {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.size()) {
        if (s[i] != t[i]) ans++;
    }
    cout <<ans << endl;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  vector<int> v(32);
  v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n;
  cout << v[n-1] << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

use std::collections::BTreeMap;
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    let arr: Vec<usize> = sc.vec(n);

    let mut cnt = vec![0; 2000_000];
    let mut g = arr[0];
    for a in arr {
        g = gcd(g, a);
        cnt[a] += 1;
    }

    let mut i = 2;
    while i <= 1000_000 {
        let mut j = i;
        let mut x = 0;
        while j <= 1000_000 {
            x += cnt[j];
            j += i;
        }
        if x >= 2 {
            break;
        }
        i += 1
    }

    if i == 1000_001 {
        println!("pairwise coprime");
    } else if g == 1 {
        println!("setwise coprime");
    } else {
        println!("not coprime");
    }
}

fn prime_factor(n: usize) -> BTreeMap<usize, usize> {
    let mut ret = BTreeMap::new();
    let mut n = n;
    let mut i: usize = 2;
    while i * i <= n {
        while n % i == 0 {
            *ret.entry(i).or_insert(0) += 1;
            n /= i;
        }
        i += 1;
    }

    if n != 1 {
        *ret.entry(n).or_insert(0) += 1;
    }
    ret
}

fn gcd(m: usize, n: usize) -> usize {
    if m < n {
        gcd(n, m)
    } else {
        if n == 0 {
            m
        } else {
            gcd(n, m % n)
        }
    }
}


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

bool isPrime(int x) {
    if(x == 2) return true;
    for(int i = 3; i < x; i += 2) {
        if(x % i == 0) return false;
    }
    return true;
}

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

    for(int i = x; i < x * 2; i++) {
        if(isPrime(i)) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

int main()
{
    int n,m;
    std::cin >> n >> m;
    std::vector<int> x(m);
    for (int i = 0; i < m; i++) { std::cin >> x[i]; }
    std::sort(x.begin(), x.end());

    std::vector<int> d(m-1);
    for (int i = 0; i < m-1; i++) {
        d[i] = x[i+1] - x[i];
    }
    std::sort(d.begin(), d.end());
    // for (int i = 0; i < m-1; i++) { std::cout << d[i] << ","; } std::cout << std::endl;
    int mov = 0;
    for (int i = 0; i < (m-1) - (n-1); i++) {
        mov += d[i];
    }
    std::cout << mov << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>

int a, b;

int main(){
	while(~scanf("%d %d", &a, &b)){
		if(a<=0 && b>=0){
			puts("Zero");
		} else if(a > 0){
			puts("Positive");
		} else {
			a = -a;
			if(b < 0){
				b = -b;
			} else {
				b = 1;
			}
			a = a - b + 1;
			if(a & 1){
				puts("Negative");
			} else {
				puts("Positive");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 150
ll n,k,w[N],v[N],memo[N][(int)2e5];

ll dp(int curr , int val) {
    if (curr > n) return val == 0 ? 0 : INT_MAX;
    ll &sol = memo[curr][val];
    if (sol != -1) return sol;
    sol = dp(curr + 1 , val);
    if (val >= v[curr]) {
        sol = min(
            dp(curr + 1 , val - v[curr]) + w[curr] ,
            sol
        );
    }
    return sol;
}

int main() {
    scanf("%lld%lld" , &n , &k);
    ll sum = 0, highestw = LLONG_MIN;
    for (int i = 1 ; i <= n ; i++) {
        scanf("%lld%lld" , &w[i] , &v[i]);
        sum += v[i];
        highestw = max(highestw , w[i]);
    }
    memset (memo , -1 , sizeof memo);
    ll sol = LLONG_MIN;
    for (ll i = 1 ; i <= sum ; i++) {
        ll DP = dp(1 , i);
        if (DP == INT_MAX) continue;
        if (DP <= k)
            sol = max(sol , i);
    }
    printf("%lld\n" , sol);
}


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


int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int ans;
    if (d[n/2-1] == d[n/2]) {
        ans = 0;
    }else{
        ans = d[n/2] - d[n/2-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
function Main(input) {
	input = input.trim().split("");
  if(input.length == 3){
    var tmp = input[0]; 
    input[0] = input[2];
    input[2] = tmp;
     }
  console.log(input.join(""));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
def main():
    str = input()
    str2 = input()

    err_flg = 0

    for i in range(len(str)):
        if (str[i] != str2[i]):
            err_flg = 1
            break

    if err_flg == 1:
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9008
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;
const double PI=3.14159265358979323846;

int main(){
  int r;
  cin >> r;
  double ans = 2 * PI * r;
  printf("%.6f", ans);
  return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>
int main (){
    int R;
    scanf ("%d", &R);
    
    if (R < 1200){
        printf ("ABC");
    }
    else if (1200 <= R && R < 2800){
        printf ("ARC");
    }
    else if (2800 <= R){
        printf ("AGC");
    }
    return 0;
}

Measured memory_bytes: 128
n=int(input())
b=list(map(int,input().split()))

sum=b[0]
last=0
for i in range(1,n):
  if i==n-2:
    sum=sum+min(b[i],b[i-1])
    last=b[i]
  elif i==n-1:
    sum=sum+max(last,b[i-1])
  else:
    sum=sum+min(b[i],b[i-1])
    
print(sum)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>

using std::vector;

struct item_t {
  int w;
  int v;

  bool operator<(const item_t &r) const { return w < r.w; }
  void operator+=(const item_t &r) {
    w += r.w;
    v += r.v;
  }
};

vector<item_t> rekkyo(vector<item_t> item) {
  vector<item_t> a;
  a.push_back({0, 0});
  for (auto i : item) {
    vector<item_t> b = a, c;
    for (auto &e : b) {
      e += i;
    }
    std::merge(a.begin(), a.end(), b.begin(), b.end(), std::back_inserter(c));
    a = c;
  }
  return a;
}

void chmax(int &a, int b) { a = std::max(a, b); }

int solve(vector<item_t> item, int l) {
  int n = item.size();
  auto a = rekkyo({item.begin(), item.begin() + n / 2});
  auto b = rekkyo({item.begin() + n / 2, item.end()});
  std::reverse(a.begin(), a.end());

  int ans = 0;
  int maxv = -10000000;
  auto itr = b.begin();
  for (auto e : a) {
    while (itr != b.end() && e.w + itr->w <= l) {
      chmax(maxv, itr->v);
      ++itr;
    }
    chmax(ans, e.v + maxv);
  }

  return ans;
}

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

  int n;
  std::cin >> n;

  vector<item_t> item(n);
  for (auto &e : item) {
    std::cin >> e.v >> e.w;
  }
  item.insert(item.begin(), {0, 0});

  int q;
  std::cin >> q;
  for (int i = 0; i < q; ++i) {
    int v, l;
    std::cin >> v >> l;
    vector<item_t> qi;
    while (v != 0) {
      qi.push_back(item[v]);
      v /= 2;
    }
    std::cout << solve(qi, l) << "\n";
  }
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 n, m, v, p; scanf("%lld%lld%lld%lld", &n, &m, &v, &p);
	std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(begin(a), end(a));

	auto f = [&](int t) {
		if(a[t] + m < a[n - p]) return false;
		i64 V = std::max(0L, v - (p - 1 + t + 1));
		i64 rem = V * m;
		
		for(int i = t + 1; i <= n - p; i++) rem -= std::min(m, (a[t] + m) - a[i]);
		return rem <= 0;
	};

	int ok = n - p, ng = -1;
	while(std::abs(ok - ng) > 1) {
		int mid = (ok + ng) >> 1;

		if(f(mid)) ok = mid;
		else ng = mid;
	}

	printf("%d\n", n - ok);
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <iostream>
#include <functional>
#include <map>
using namespace std;



int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a + c == b || b + c == a)
		cout << "Yes"<< endl;
	else
		cout << "No" << endl;





	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, sum[5001] = {};
  while(cin >> n, n){
    for(int i = 0; i < n; i++){
      int a;
      cin >> a;
      sum[i + 1] = sum[i] + a;
    }
    int ret = sum[1];
    for(int i = 0; i <= n; i++){
      for(int j = i + 1; j <= n; j++){
        ret = max( ret, sum[j] - sum[i]);
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1184
import math
 
A, B, H, M = map(int, input().split())
 
deg_long = M * 6
deg_short = 30 * H + M / 2
    
rad = math.radians( min(deg_long - deg_short, 360-(deg_long-deg_short)))
print( math.sqrt(A **2 + B ** 2 - 2* A * B* math.cos(rad)) )

Measured memory_bytes: 9560
#include<stdio.h>
#include<string.h>
int main(void)
{
	int x,y;
	char s[100];
	scanf("%s",&s);
	x=strlen(s);
	x=x-2;
	y=x+1;
	printf("%c%d%c\n",s[0],x,s[y]);
	return 0;
}

Measured memory_bytes: 128
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    n = int(input())
    d = list(map(int, input().split()))
    sum = 0
    for i in range(n-1):
        for k in range(i+1,n):
            sum += d[i]*d[k]
    print(sum)
    
    
main()


Measured memory_bytes: 5076
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n;
	cin >> n;
	map<vector<int>,int> m;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		vector<int> v(26,0);
		for(auto &x : s){
			v[x-'a']++;
		}
		m[v]++;
	}
	int ans = 0;
	for(auto x : m){
		ans += x.S*(x.S-1)/2;
	}
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 29952
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int s[100001]={};
	s[0]=1;s[1]=1;
	for(int i=2;i*i<100000;i++){
		if(s[i]==0){
			for(int j=i*i;j<100000;j+=i){s[j]=1;}
		}
	}

	int m,a,b;
	while(scanf("%d%d%d",&m,&a,&b)&&!(m==0&&a==0&&b==0))
	{
		int ans(0);
		int w;
		int h;
		
		for(int i=m;i>=2;i--)
		{
			if(!s[i])
			{
				for(int j=min(m/i,i);j>=2;j--)
				{
					if(!s[j])
					{
						if(ans<i*j&&i*j<=m&&j*b>=i*a)
						{
							ans = i*j;
							w = j;
							h = i;
						}
					}
				}
			}
		}
		printf("%d %d\n",w,h);
	}
	return 0;
}

Measured memory_bytes: 1584
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

res = 0
for i in range(2**N):
    sw = [0]*N
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            sw[j] = 1
    
    for i, ksi in enu(ks):
        sumv = 0
        for s in ksi[1:]:
            sumv += sw[s-1]
        if sumv%2 != p[i]:
            break
    else:
        res += 1
print(res)


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] h = cin.arrayInt();

        int ret = 0;
        while (true)
        {
            bool start = false;
            for (int i = 0; i < N; i++)
            {
                if (!start)
                {
                    if (h[i] > 0)
                    {
                        start = true;
                    }
                    else if (i == N - 1)
                    {
                        Console.WriteLine(ret);
                        return;
                    }
                }
                if (start)
                {
                    if (h[i] == 0)
                    {
                        break;
                    }
                    h[i]--;
                }
            }
            ret++;
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

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

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const int MOD = 1e9 + 7;

int com[2001][2001];

int main(){

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

    memset(com, 0, sizeof(com));

    for(int i = 0; i < 2001; i++){
        for(int j = 0; j <= i; j++){
            if(j == 0){
                com[i][j] = 1;
            }
            else{
                com[i][j] = (com[i - 1][j] + com[i - 1][j - 1]) % MOD;
            }
        }
    }

    int blue = K;
    int red = N - K;

    for(int i = 1; i <= K; i++){
        int restB = blue - i;
        int restR = red - (i - 1);

        int a = (i - 1) + restB;
        long long temp = com[a][restB];
        int b = i + restR;
        temp = (temp * com[b][restR]) % MOD;
        
        cout << temp << endl;
    }

    return 0;
}

Measured memory_bytes: 15872
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//const int mod = 998244353;
const int N = 2000005;
const int K = 1000000;
vector < int > ans[N];
vector < int > pol;
int mod;
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
vector < int > mp(vector < int > p, int x, int y){
    vector < int > res;
    int c = 0;
    for (int i = 0; i < p.size(); i++){
        p[i] += c;
        res.pb((p[i] * x % mod + mod) % mod);
        c = (y * (p[i] - c) % mod + mod) % mod;
    }
    res.pb(c);
    return res;
}
vector < int > dv(vector < int > p, int x, int y){
    vector < int > res;
    int c = 0;
    for (int i = 0; i < p.size() - 1; i++){
        p[i] += c;
        res.pb((p[i] % mod + mod) % mod);
        c = (-y * p[i] % mod + mod) % mod;
    }
    return res;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> mod;
    pol.pb(1);
    pol.pb(0);
    for (int i = 1; i < mod; i++){
        pol = mp(pol, 1, -i);
    }
  //  for (auto j: pol){
    //    cout << j << " ";
  //  }
    //cout << endl;
    for (int i = 0; i < mod; i++){
        int f = 1;
        for (int j = 0; j < mod; j++){
            if (j == i) continue;
            int k = i - j;
            if (k < 0) k += mod;
            f = f * binpow(k, mod - 2) % mod;
        }
        ans[i] = dv(pol, 1, -i);
        for (int j = 0; j < ans[i].size(); j++) ans[i][j] = ans[i][j] * f % mod;
        reverse(ans[i].begin(), ans[i].end());
        while(ans[i].size() < mod) ans[i].pb(0);
     //   for (auto j: ans[i]){
       //     cout << j << " ";
       // }
       // cout << endl;
    }
    vector < int > res;
    res.resize(mod, 0);
    for (int i = 0; i < mod; i++){
        int x;
        cin >> x;
        if (x == 1)
        for (int j = 0; j < mod; j++){
         //   cout << ans[i][j] << " ";
            res[j] = (2 * mod + ans[i][j] + res[j]) % mod;
        }
       // cout << endl;
    }
    for (auto i: res) cout << i << " ";
}


Measured memory_bytes: 94336
n = gets.to_i

a = Array.new(5,0)

n.times do 
    b = gets
    if b[0] == 'M'
        a[0] += 1
    elsif b[0] == 'A'
        a[1] += 1
    elsif b[0] == 'R'
        a[2] += 1
    elsif b[0] == 'C'
        a[3] += 1
    elsif b[0] == 'H'
        a[4] += 1
    end
end
sum = 0
(0..2).each do |i|
    (i + 1..3).each do |j|
        (j + 1..4).each do |k|
            sum += a[i] * a[j] * a[k] if a[k] + a[j] + a[i] >= 3
        end
    end
end
puts sum

Measured memory_bytes: 3964
N = list(map(int, list(input())))
L = len(N)
K = int(input())

dp = [[[0] * (K+1) for j in range(2)] for i in range(L+1)]
dp[0][0][0] = 1

for i in range(L):
    ni = N[i]
    if ni == 0:
        for j in range(K):
            dp[i+1][1][j+1] += dp[i][1][j] * 9
        for j in range(K+1):
            dp[i+1][0][j] += dp[i][0][j]
    else:
        for j in range(K+1):
            dp[i+1][1][j] += dp[i][0][j]
        for j in range(K):
            dp[i+1][1][j+1] += (dp[i][0][j] * (ni-1) + dp[i][1][j] * 9)
            dp[i+1][0][j+1] += dp[i][0][j]

    for j in range(K+1):
        dp[i+1][1][j] += dp[i][1][j]

print(dp[L][0][K]+dp[L][1][K])


Measured memory_bytes: 9108
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int W = sc.nextInt();
        int[] weights = new int[n];
        long[] values = new long[n];
        for (int i = 0; i < n; i++) {
            weights[i] = sc.nextInt();
            values[i] = sc.nextLong();
        }
        
        long[][] dp = new long[n + 1][W + 1];
        for (int w = 0; w <= W; w++) {
            dp[0][w] = 0;
        }
        
        for (int i = 0; i < n; i++) {
            for (int w = 0; w <= W; w++) {
                if (weights[i] <= w) {
                    dp[i + 1][w] = Math.max(dp[i][w - weights[i]] + values[i], dp[i][w]);
                } else {
                    dp[i + 1][w] = dp[i][w];
                }
            }
        }
        
        System.out.println(dp[n][W]);
    }
}

Measured memory_bytes: 126420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

ll dp[4][4][4][4][105];
int main()
{
    int N; cin >> N;
    rep(i, 4) rep(j, 4) rep(k, 4) rep(l, 4) dp[i][j][k][l][4] = 1;
    rep(i, 4)
    {
        dp[i][1][3][2][4] = 0;
        dp[1][i][3][2][4] = 0;
        dp[1][3][i][2][4] = 0;
        dp[1][3][2][i][4] = 0;
        dp[i][3][1][2][4] = 0;
        dp[i][1][2][3][4] = 0;
        dp[3][1][2][i][4] = 0;
        dp[1][2][3][i][4] = 0;

    }

    for (int n = 4; n <= N; n++)
    {
        rep(i, 4) rep(j, 4) rep(k, 4) rep(l, 4) rep(m, 4)
        {
            dp[j][k][l][m][n + 1] += dp[i][j][k][l][n];
            dp[j][k][l][m][n + 1] %= mod;
        }
        rep(i, 4)
        {
            dp[i][1][3][2][n + 1] = 0;
            dp[1][i][3][2][n + 1] = 0;
            dp[1][3][i][2][n + 1] = 0;
            dp[1][3][2][i][n + 1] = 0;
            dp[i][3][1][2][n + 1] = 0;
            dp[i][1][2][3][n + 1] = 0;
            dp[3][1][2][i][n + 1] = 0;
            dp[1][2][3][i][n + 1] = 0;
        }
    }

    ll ans = 0;
    rep(i, 4) rep(j, 4) rep(k, 4) rep(l, 4)
    {
        ans += dp[i][j][k][l][N];
        ans %= mod;
    }
    if (N == 3) cout << 61 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 512
import math
n,h=map(int,input().split())
m=0
b=[]
for _ in range(n):
    A,B=map(int,input().split())
    if A>m: m=A
    b.append(B)
b.sort()
j=n-1
ans=0
while True:
    if j<0 or b[j]<=m:
        ans+=math.ceil(h/m)
        break
    h-=b[j]
    j-=1
    ans+=1
    if h<=0: break
print(ans)

Measured memory_bytes: 13096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s,t,ans="";
  int flag=0,y=-1;
  cin>>s>>t;
  rep(i,s.size()-t.size()+1){
    flag=0;
    if (s.at(i)==t.at(0) || s.at(i)=='?') {
        rep(j,t.size()){
          if (s.at(i+j)==t.at(j) || s.at(i+j)=='?') {
            flag+=1;
          }
        }
      }
    if (t.size()==flag) {
      y=max(y,i);
    }
  }
  if (y!=-1) {
    rep(i,s.size()){
      if (i<y || i>y+t.size()-1) {
        if (s.at(i)!='?') {
          ans+=s.at(i);
        }
        else{
          ans+='a';
        }
      }
      else if (i>=y && i<y+t.size()) {
        ans+=t.at(i-y);
      }
    }
    cout<<ans<<endl;
  }
  else{
    cout<<"UNRESTORABLE"<<endl;
  }
}

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


int game(char s)
{
	if(s=='0')
	{
		return 0;
	}
	else if(s=='1')
	{
		return 1;
	}
	else if(s=='2')
	{
		return 2;
	}
	else if(s=='3')
	{
		return 3;
	}
	else if(s=='4')
	{
		return 4;
	}
	else if(s=='5')
	{
		return 5;
	}
	else if(s=='6')
	{
		return 6;
	}
	else if(s=='7')
	{
		return 7;
	}
	else if(s=='8')
	{
		return 8;
	}
	else if(s=='9')
	{
		return 9;
	}
	return -1;
}





int main()
{
	string s;
	cin>>s;
	
	int x=(game(s[0]))*10+game(s[1]);
    int y=(game(s[2]))*10+game(s[3]);	
	
	int f1=0,f2=0;

	if(x>12 || x==0)
	{
		f1=1;
	}
	if(y>12 || y==0)
	{
		f2=1;
	}

    if(f1==0 && f2==0)
    {
    	cout<<"AMBIGUOUS"<<endl;
	}
	else if(f1==0)
	{
		cout<<"MMYY"<<endl;
	}
	else if(f2==0)
	{
		cout<<"YYMM"<<endl;
	}
	else
	{
		cout<<"NA"<<endl;
	}

return 0;	
	
}

Measured memory_bytes: 256
unittest
{
	assert( [ "20" ].parse.expand.solve == 23 );
	assert( [ "2" ].parse.expand.solve == 2 );
	assert( [ "99992" ].parse.expand.solve == 100003 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	return 100003L.primes.find!( ( a, b ) => b <= a )( n ).front;
}

// 素数列
auto primes( long x )
{
	Appender!( long[] ) ps;
	if( x < 2 ) return ps.data;
	
	auto cs = new bool[]( x + 1 );
	ps ~= 2L;
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps.data;
}


Measured memory_bytes: 2300
loop do
	n = gets.to_i
	break if n.zero?

	dataset = Hash.new
	dataset.default = 0
	
	n.times do
		id, selling_price, quantity = gets.chomp.split.map(&:to_i)
		dataset[id] += selling_price * quantity
	end
	
	satisfying_id = dataset.select{|id, sales| sales >= 1000000 }.keys.join(?\n)
	
	puts (satisfying_id.empty? ? "NA" : satisfying_id)
end

Measured memory_bytes: 6108
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int min = 1000, max = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    if (a < min) {
      min = a;
    }
    if (a > max) {
      max = a;
    }
  }
  cout << max-min << endl;
  return 0;
}


Measured memory_bytes: 256
h1, h2 = map(int,input().split())
k1, k2 = map(int,input().split())
a, b, c, d = map(int,input().split())

if h1 > 9:
    hn = int(h1/10)
else:
    hn = 0
if h2 > 19:
    hm = int(h1/20)
else:
    hm = 0
if k1 > 9:
    kn = int(k1/10)
else:
    kn = 0
if k2 > 19:
    km = int(k2/20)
else:
    km = 0
    
h = h1*a + hn*c + h2*b + hm*d 
k = k1*a + kn*c + k2*b + km*d 

if h<k:
    print("kenjiro")
elif k<h:
    print("hiroshi")
elif h == k:
    print("even")


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

int main(){
  string s;
  cin >> s;
  int zeronum = 0;
  for(auto x : s){
    if(x == '0') zeronum++;
  }
  int n = s.size();
  int ans = 2*min(zeronum, n-zeronum);
  cout << ans << endl;
}

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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int x,y,a[13]={0,0,2,0,1,0,1,0,0,1,0,1,0};
	cin>>x>>y;
	if (a[x]==a[y]){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(b<a){
		printf("%d\n", a-1);
	}else{
		printf("%d\n", a);
	}
	return 0;
}

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

int main() {
  int N,n,b;
  cin >> N;
  string s;
  s="Yes";

  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  int i=0;
  H.at(0)--;
  while(i<(N-1)){
    if(H.at(i+1)>H.at(i)){
      H.at(i+1)--;
      }else if(H.at(i+1)<H.at(i)){
      s="No";
      break;
    }
    
    i++;
  }
  cout << s << endl;
}



Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int K = Integer.parseInt(in.next());
            boolean ok = false;
            if (2 * (K - 1) + 1 <= N) {
                ok = true;
            } else {
                ok = false;
            }
            out.println(ok ? "YES" : "NO");

        }

    }
}



Measured memory_bytes: 22100
N = int(input())
s_l = []
t_l = []
for i in range(N):
    s,t = input().split()
    t= int(t)
    s_l.append(s)
    t_l.append(t)

X = input()

for i in range(N):
    if s_l[i]==X:
        break
ans = 0
for j in range(i+1,N):
    ans+=t_l[j]

print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    string s;
    cin >> s;
    string s1, s2;
    int n1 = 0, n2 = 0;
    rep(i, s.size() / 2) {
        s1 += "01";
        s2 += "10";
    }
    if (s.size() % 2 == 1) {
        s1 += "0";
        s2 += "1";
    }
    rep(i, s.size()) {
        if (s[i] != s1[i]) {
            n1++;
        }
        if (s[i] != s2[i]) {
            n2++;
        }
    }
    
    if (n1 < n2) {
        cout << n1 << endl;
    } else {
        cout << n2 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 768
(function(input) {
    var p = input.split('\n').map(Number);
    var n = p.shift();
    var a = p.slice(0, n);

    var max = -Infinity;
    var min = Infinity;
    for (var i = 0; i < a.length; i++) {
        max = Math.max(max, a[i] - min);
        min = Math.min(min, a[i]);
    }
    console.log(max);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 37372
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
int tb[32];

bool isup(int x,int i){
    return (x&(1<<i)) == (1<<i);
}

int popcnt(int x){
    int ans = 0;
    rep(i,18) ans += ( (x&(1<<i)) == (1<<i) ? 1 : 0);
    return ans;
}

int main(){
    int n; string s; cin >> n >> s;
    rep(i,32) tb[i] = 0;
    rep(i,2*n) tb[s[i] - 'a']++;
    rep(i,32){
        if(tb[i] % 2 != 0){cout << 0 << endl; return 0;}
        tb[i] /= 2;
    }
    map<pair<int, string>, int> m;
    rep(i, 1<<n){
        string rs,bs;
        rep(j,n){
            if(isup(i,j)) rs += s[j];
            else bs += s[j];
        }
        reverse(all(bs));
        pair<int,string> tem = make_pair(popcnt(i), rs + bs);
      //  cout << popcnt(i) << ":" << rs + bs << endl;
        if(m.find(tem) == m.end()) m[tem] = 1;
        else m[tem]++;
    }
    reverse(all(s));
  //  cout << "*****" << endl;
    ll ans = 0;
    rep(i, 1<<n){
        string rs,bs;
        rep(j,n){
            if(isup(i,j)) rs += s[j];
            else bs += s[j];
        }
        reverse(all(rs));
        pair<int,string> tem = make_pair(bs.length(), bs + rs);
      // cout << rs.length() << ":" << bs + rs << ":" << m[tem] << endl;
        if(m.find(tem) != m.end()) ans = ans + m[tem];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20736
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    long double t, x, a, rec;
    lli n, ans;
    cin >> n >> t >> a;
    rep(i,n){
        long double h;
        cin >> h;
        if(i==0){
            ans = 1;
            rec = abs(a - (t - 0.006 * h));
        }
        else{
            if (rec > abs(a - (t - 0.006 * h))){
                rec = abs(a - (t - 0.006 * h));
                ans = i + 1;
            }
        }
    }
    out(ans);
}

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

using namespace std;

int main() {
    int N, a[200];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int counter = 0;
    bool odd_exist = false;
    while (true) {
        for (int i = 0; i < N; i++) {
            if (a[i] % 2 == 1) {
                odd_exist = true;
                break;
            }
            a[i] /= 2;
        }
        if (odd_exist) {
            break;
        }
        counter++;
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
import collections

n = int(input())
a = list(map(int, input().split()))
co = collections.Counter(a)
d = dict(co)
s = sum(a)
q = int(input())

for i in range(q):
    b, c = map(int, input().split())
    if b in d:
        v = d[b]
        del d[b]
        if c in d:
            d[c] += v
        else:
            d[c] = v
        s = s - (b-c)*v
        print(s)
    else:
        print(s)

Measured memory_bytes: 102664
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long LL;
int main()
{
    LL n,k;

    cin >> n >> k;
    if(k==0)
    {
        cout << n*n << endl;
    }
    else
    {
        LL sum = 0;

        for(int i = k+1;i<=n;i++)
        {
            int b = i;

            sum+=n/b*(b-k);

            if(n%b>=k){
                sum+=n%b-k+1;
            }
        }

        cout << sum << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define min(a,b) ((a < b) ? a : b)

int main(){
  int N;        //文字列長
  char S[200001];
  scanf("%d",&N);
  scanf("%s",S);
  int ans;

  int w = 0;    //白の数
  int b = 0;    //黒の数

  for(int i = 0; i < N; i ++){
    if(S[i] == '.'){
      w ++;
    }else{
      b ++;
    }
  }

  ans = min(w,b);

  int ww = 0;   //二周目白の数計算用
  int bb = 0;   //二周目黒の数確認用
  for(int i = 0; i < N; i ++){
    if(S[i] == '.'){
      ww ++;
    }else{
      bb ++;
    }
    ans = min(ans,bb + (w - ww));
  }

  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 384
n,k = map(int,input().split())
p = list(map(int,input().split()))
a = [0 for i in range(n+1)]
for i in range(1,n+1):
    a[i] = a[i-1] + (p[i-1]+1)/2
ans = 0
for i in range(n-k+1):
    ans = max(ans,a[i+k]-a[i])
print(ans)

Measured memory_bytes: 80524
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

lint invmod(lint n, lint m) {
	//nの逆元を返す
	lint ret = 0;
	ret = power(n, m - 2, m);
	return ret;
}


int main() {
	lint N, K;
	cin >> N >> K;
	lint MOD = pow(10, 9) + 7;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint S1 = 0;
	lint S2 = 0;
	rep(i, N) {
		rep(j, N) {
			if (A[i] > A[j]) {
				S1++;
				S1 %= MOD;
			}
		}
	}
	rep(i, N) {
		rep(j, N) {
			if (i < j) {
				if (A[i] > A[j]) {
					S2++;
					S2 %= MOD;
				}
			}
		}
	}
	lint ans = (K%MOD * S2%MOD)%MOD + K%MOD * (K - 1)%MOD*invmod(2,MOD)%MOD * S1%MOD;
	ans %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
 
    string str;
    
    cin >> str;
    int Max = 0;
    for(int i = 1; str.length()/2 > i; i++){
        bool f = 1;
        for(int j = 0; i > j; j++) {
            if(str[j] != str[j + i]){
                f = 0;
            }
        }
        if(f)
            Max = max(Max, i);
    }
    
    printf("%d\n", Max*2);
    
    return 0;
}

Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())

d = []
for _ in range(n):
    tmp = int(input())
    tmpa = getSomeInputListInt(tmp)
    d.append(tmpa)



ans = 0
for i in range(int(pow(2, n))):
    flg = True
    cnt = 0
    for j in range(len(d)):
        tmp = (i >> j) & 1
        if tmp == 0:
            continue

        cnt += 1

        for k in range(len(d[j])):
            tmp = (i >> (d[j][k][0]-1)) & 1
            if tmp != d[j][k][1]:
               flg = False
               break
        if not flg:
            break

    if flg:
        ans = max(ans, cnt)

print(ans)




Measured memory_bytes: 5360