akhauriyash/Code-Regression huggingface dataset:
from fractions import gcd

a,b=map(int,input().split())

gcd=gcd(a,b)
ab_gcd=gcd

f=[]
for i in range(2,int(ab_gcd**0.5)+1):
    while gcd%i==0:
        gcd=gcd//i
        f.append(i)
if gcd!=1:
    f.append(gcd)

print(len(set(f))+1)


Measured memory_bytes: 5048
n, m = gets.chomp.split.map(&:to_i)

$graph = Array.new(n).map{Array.new(n,false)}
# 隣接行列を使う
m.times do
  a, b = gets.chomp.split.map(&:to_i)
  $graph[a-1][b-1] = true
  $graph[b-1][a-1] = true
end


# 深さ優先探索1回ごとにリセットされる
visited = Array.new(n, false)
visited[0] = true


def dfs(v, n, visited)
  all_visited = true

  # p visited

  # ループして全部に訪問したかを確認する
  n.times do |i|
    all_visited = false if visited[i] == false
  end

  return 1 if all_visited == true

  ret = 0
  n.times do |i|
    next if $graph[v][i] == false
    next if visited[i] == true
    # p i

    visited[i] = true
    ret += dfs(i, n, visited)
    visited[i] = false

  end

  return ret
end

# p $graph
# p visited

ans = dfs(0, n, visited)

p ans


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

// 100以下の素数一覧
const int prime[25] = {
    2, 3, 5, 7, 11,
    13, 17, 19, 23, 29,
    31, 37, 41, 43, 47,
    53, 59, 61, 67, 71,
    73, 79, 83, 89, 97};

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

    int cnt[25];
    fill(cnt, cnt + 25, 0);
    // cnt[i] = N!を素因数分解したときのprime[i]の指数

    for (int n = 1; n <= N; ++n) {
        int m = n;

        // mを素因数分解する
        for (int i = 0; i < 25; ++i) {
            while (m % prime[i] == 0) {
                ++cnt[i];
                m /= prime[i];
            }
        }
    }

    int ans = 0;

    // p^74の形
    for (int p = 0; p < 25; ++p) {
        if (cnt[p] >= 74) ++ans;
    }

    // p^2 q^24とp^4 q^14の形
    for (int p = 0; p < 25; ++p) {
        for (int q = 0; q < 25; ++q) {
            if (p == q) continue;
            if (cnt[p] >= 4 && cnt[q] >= 14) ++ans;
            if (cnt[p] >= 2 && cnt[q] >= 24) ++ans;
        }
    }

    // p^2 q^4 r^4の形
    for (int p = 0; p < 25; ++p) {
        for (int q = 0; q < 25; ++q) {
            // 重複カウントを防ぐためにq < rにしている
            for (int r = q + 1; r < 25; ++r) {
                if (p == q || r == p) continue;
                if (cnt[p] >= 2 && cnt[q] >= 4 && cnt[r] >= 4) ++ans;
            }
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
 int dp[n][3];
  dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
  for(int i=1;i<n;i++){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    
}

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

// template<typename T>
void self_max(ll &a, ll b)
{
	a = max(a, b);
}

int main() {
	int n, w;
	cin >> n >> w;
	vector<long long> dp(w + 1, 0);
	for(int i = 0; i < n; i++)
	{
		int weight, value;
		cin >> weight >> value;
		for(int j = w - weight; j >= 0; j--)
		{
			self_max(dp[j + weight], value + dp[j]);
		}		
	}
	long long sol = 0;
	for(int i = 0; i <= w; i++)
	{
		self_max(sol, dp[i]);
	}
	cout << sol << "\n";
	
	return 0;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {


    int A, B, C;
    cin >> A >> B >> C;
    cout << A * B / 2 << endl;




}
/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 3600
n = int(input())
a_list = list(map(int, input().split()))

a_list_even = [i for i in a_list if i % 2 == 0]
for a in a_list_even:
    if a % 3 == 0 or a % 5 == 0:
        continue
    else:
        print("DENIED")
        exit()

print("APPROVED")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  cin >> s;
  if (s.size() == 2) cout << s << endl;
  else cout << s[2] << s[1] << s[0] << endl;
}

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

using namespace std;

const int mod = 1000000007;

const int N = 200005;

int facs[N];
int invs[N];

int probs[N];

int p[N];
int q[N];

int mul(int a, int b) {
    return (1LL * a * b) % mod;
}

int add(int a, int b) {
    a += b;
    if (a >= mod) a -= mod;
    return a;
}

int powmod(int a, int p) {
    int res = 1;
    while (p) {
        if (p & 1) {
            res = mul(res, a);
        }

        a = mul(a, a);
        p >>= 1;
    }
    return res;
}

int choose(int n, int r) {
    return mul(facs[n], mul(invs[n - r], invs[r]));
}

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

    facs[0] = 1;
    for (int i = 1; i <= b + w; i++) {
        facs[i] = mul(facs[i - 1], i);
    }

    invs[b + w] = powmod(facs[b + w], mod - 2);

    for (int i = b + w - 1; i >= 0; i--) {
        invs[i] = mul(invs[i + 1], i + 1);
    }

    int two_inv = powmod(2, mod - 2);
    probs[0] = 1;
    for (int i = 1; i <= b + w; i++) {
        probs[i] = mul(probs[i - 1], two_inv);
    }

    for (int i = 0; i <= b + w; i++) {
        p[i] = 0;
        q[i] = 0;
    }

    for (int i = b; i <= b + w; i++) {
        p[i] = add(p[i - 1], mul(choose(i - 1, b - 1), probs[i]));
    }

    for (int i = w; i <= b + w; i++) {
        q[i] = add(q[i - 1], mul(choose(i - 1, w - 1), probs[i]));
    }

    for (int i = 1; i <= b + w; i++) {
        cout << mul(add(1, add(mod - p[i - 1], q[i - 1])), probs[1]) << endl;
    }



}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int A[N]; rep(i, N) cin >> A[i];
    vector<int> vec;
    rep(i, N){
        if(i == 0) vec.push_back(A[i]);
        else{
            int ng = -1, ok = vec.size();
            int m = (ok+ng)/2;
            while(abs(ok-ng) > 1){
                if(A[i] > vec[m]) ok = m;
                else ng = m;
                m = (ok+ng)/2;
            }
            if(ok == vec.size()) vec.push_back(A[i]);
            else vec[ok] = A[i];
        }
    }
    //rep(i, vec.size()) cout << vec[i] << " "; cout << endl;
    cout << vec.size() << endl;
    return 0;
}

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

int main() {
    int x;
    cin >> x;
    if(x>=30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3628
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#include <vector>
#include <iterator>
typedef  long long int ll;
typedef  long double ld;
#define PT(x) cout << (#x) << " is " << (x) << endl;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int M = 1000000007;
#define int long long
void PV( vi v) { for(ll i=0 ; i<v.size() ; i++) cout<< v[i] << " "; cout<< endl;}
void PA( int v[] , int n ){ for(ll i=0 ; i<n ; i++)cout<< v[i] << " " ; cout<< endl;}

signed  main(){
     SPD_emergency
   //ll t; cin>> t; while(t--)
    {
        string s;
        cin>>s;
        if(s[0]==s[1] && s[1]==s[2])cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    long a,z;
    for(long i=0;i<s.length();i++){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }
    for(long i=s.length()-1;i>0;i--){
        if(s[i]=='Z'){
            z=i;
            break;
        }
    }
    cout<<z-a+1<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 1000000007
using namespace std;


long long gcd(long long n, long long m) {
    if (m == 0)return n;
    else return gcd(m,n%m);
}


int main() {
    long long n;
    long long ans = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        long long t;
        cin >> t;
        ans = ans / gcd(ans, t)*t;
    }
    cout << ans << endl;
    return 0;
}


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


int x,y;
int main(){
  while( cin >> x >> y && (x||y) ){
    unordered_map<int,int> mp;
    int cnt = 0;
    while( x ){      
      if( mp.count(x) ) {
        cout << mp[x] << " " << cnt - mp[x] << endl;
        break;
      }
      mp[x] = cnt++;
      x *= 10;
      x %= y;      
    }
    if( x == 0 ) cout << cnt << " 0" << endl;
  }
}

Measured memory_bytes: 42380
import java.util.Arrays;
import java.util.Scanner;

class Main{
	static int N;
	static int[] a;
	static long[] sum;
	static long[][] dp;
	static long f(int i, int j) {
		if(i == j) return 0;
		if(dp[i][j] != -1) return dp[i][j];
		long ans = Long.MAX_VALUE;
		for(int k = i; k < j; k++) {
			ans = Math.min(ans, f(i, k) + f(k + 1, j) + sum[j + 1] - sum[i]);
		}
		return dp[i][j] = ans;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		a = new int[N];
		sum = new long[N + 1];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			sum[i + 1] = a[i];
			if(i != 0) sum[i + 1] += sum[i];
		}
		dp = new long[N][N];
		for(int i = 0; i < N; i++) Arrays.fill(dp[i], -1);
		System.out.println(f(0, N - 1));
	}
}

Measured memory_bytes: 25428
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	int n; cin >> n;
	vint L(2 * n);
	rep(i, 2 * n) cin >> L[i];
	sort(all(L));
	ll ans = 0;
	for (int i = 0; i < 2 * n; i += 2){
		ans += L[i];
	}
	printf("%lld\n", ans);
	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 ll long long int

int main(){
  string S;
  cin>>S;
  int ze=0,it=0;
  rep(i,S.size()){
    if(S[i]=='0')
      ze++;
    else
      it++;
  }
  cout<<2*min(ze,it)<<endl;


  return 0;
}
  


Measured memory_bytes: 512
def prime_factors(n):
    i = 2
    factors = {}
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            if i not in factors:
                factors[i] = 0
            factors[i] += 1
    if n > 1:
        if n not in factors:
            factors[n] = 0
        factors[n] += 1
    return factors


def count(factor_count):
    result = 0
    for i in range(1, 10000000000):
        if factor_count < i :
            break
        result += 1
        factor_count -= i
    return result


def solve(n):
    ans = 0
    pfactors = prime_factors(n)
    for factor in pfactors:
        ans += count(pfactors[factor])
    return ans


n = int(input())
print(solve(n))



Measured memory_bytes: 9208
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,q;
long long x[110],y[110],z[110],ans;
long long a[110][2],b[110][2],c[110][2];
int main(){
	cin>>n>>q;
	rep(i,2*n){
		cin>>x[i]>>y[i]>>z[i];
		a[i/2][i%2]=x[i];
		b[i/2][i%2]=y[i];
		c[i/2][i%2]=z[i];
	}
	sort(x,x+n*2);sort(y,y+n*2);sort(z,z+n*2);
	ans=0;
	rep(i,n*2-1)rep(j,n*2-1)rep(k,n*2-1){
		int cnt=0;
		rep(t,n){
			bool ok=true;
			rep(r,2){
				if(a[t][0]>x[i+r]||x[i+r]>a[t][1])ok=false;
				if(b[t][0]>y[j+r]||y[j+r]>b[t][1])ok=false;
				if(c[t][0]>z[k+r]||z[k+r]>c[t][1])ok=false;
			}
			if(ok)cnt++;
		}
		if(cnt>=q)ans+=(x[i+1]-x[i])*(y[j+1]-y[j])*(z[k+1]-z[k]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3132
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	print(max(a*b, c*d));
	return 0;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    if(x<1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
# input
s = input()

# solve
n = len(s)

## a[i] minimum moves to arrange "s[0:i]" into "...0101"
## b[i] minimum moves to arrange "s[0:i]" into "...1010"
a = [0 for i in range(n)]
b = [0 for i in range(n)]

if s[0] == '0':
	a[0] = 1
	b[0] = 0
else:
  a[0] = 0
  b[0] = 1

for i in range(1, n):
	if s[i] == '0':
		a[i] = b[i-1] + 1
		b[i] = a[i-1]
	else:
		a[i] = b[i-1]
		b[i] = a[i-1] + 1

print(min(a[n-1], b[n-1]))
		
		

Measured memory_bytes: 7924
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n;
int arr[17][17];
int val[1ll<<17];
int cache[1ll<<17];
bool vis[1ll<<17];
int dp(int mask)
{
    if(!mask)
        return 0;
    if(vis[mask])
        return cache[mask];

    int maxans=val[mask];
    for(int submask = mask; submask; submask=(submask-1)&mask)
        if(submask!=mask)
            maxans=max(maxans,dp(submask)+dp(mask-submask));

    cache[mask]=maxans;
    vis[mask]=1;
    return maxans;
}
int32_t main() 
{
    IOS;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>arr[i][j];

    for(int i=0;i<(1ll<<n);i++)
    {
        int ans=0;
        for(int j=0;j<n;j++)
            for(int k=j+1;k<n;k++)
                if(i&(1ll<<j))
                    if(i&(1ll<<k))
                        ans+=arr[j][k];
        val[i]=ans;
    }
    print(dp((1ll<<n)-1));
}


Measured memory_bytes: 4748
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Math.sin;
import static java.lang.Math.cos;
import static java.lang.Math.toRadians;

public class Main {

  private static StringBuilder buf = new StringBuilder();

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt( br.readLine() );
      Point2D p1 = new Point2D(0,0);
      Point2D p2 = new Point2D(100, 0);

      buf.append(p1);
      kochCurve( n, p1, p2 );
      buf.append(p2);

      System.out.print(buf);
      
    }
  }

  private static void kochCurve(int d, Point2D p1, Point2D p2) {
    if( d != 0) {
      Point2D s = new Point2D();
      Point2D t = new Point2D();

      s.x = (2*p1.x + p2.x) / 3;
      s.y = (2*p1.y + p2.y) / 3;
      t.x = (p1.x + 2*p2.x) / 3;
      t.y = (p1.y + 2*p2.y) / 3;

      Point2D u = new Point2D();
      double rad = toRadians(60);

      u.x = (t.x - s.x)*cos(rad) - (t.y - s.y)*sin(rad) + s.x;
      u.y = (t.x - s.x)*sin(rad) + (t.y - s.y)*cos(rad) + s.y;

      kochCurve(d-1, p1, s);
      buf.append(s);
      kochCurve(d-1, s, u);
      buf.append(u);
      kochCurve(d-1, u, t);
      buf.append(t);
      kochCurve(d-1, t, p2);
    }
  }
}

class Point2D {
  double x;
  double y;

  public Point2D() { }
  public Point2D(double x,double y) {
    this.x = x;
    this.y = y;
  }

  @Override
  public String toString() {
    return String.format("%.8f %.8f\n", x, y);
  }
  public double distance(Point2D p) {
    return Math.sqrt(Math.pow((p.x - this.x),2) + Math.pow((p.y - this.y), 2));
  }
}


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

int main()
{
	long long k,a,b;
	cin >> k >> a >> b;
	if(a+2 >= b){
		cout << 1 + k << "\n";
		return 0;
	}

	k -= a - 1;
	long long ans = a;

	if(k % 2 == 1){
		k--;
		ans++;
	}

	ans += (b-a) * k / 2;

	cout << ans << "\n";

	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 = 1;
		int min, max, num, sum;
		while(true) {
			n = sc.nextInt();
			if(n == 0) return;
			sum = 0;
			min = 1001;
			max = -1;
			for(int i = 0; i < n; i++) {
				num = sc.nextInt();
				if(min > num)min = num;
				if(max < num)max = num;
				sum += num;
			}
			sum -= min+ max;
			System.out.println(sum / (n - 2));
		}
	}
}



Measured memory_bytes: 28928
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

bool cant[100009];
ll dp[100009];

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

	int N, M; cin >> N >> M; 
	for (int i = 0; i < M; i++) {
		int tmp; cin >> tmp;
		cant[tmp] = true;
	}

	dp[0] = 1;
	for (int i = 1; i <= N; i++) {
		if (i == 1) dp[i] = dp[i - 1];
		else {
			dp[i] = 0;
			if (!cant[i - 1]) dp[i] += dp[i - 1];
			if (!cant[i - 2]) dp[i] += dp[i - 2];
			dp[i] %= MOD;
		}
	}
	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int> > S(M);
  int P[M];
  for(int i=0;i<M;i++){
    int k=0;
    cin >> k;
    S[i].resize(k);
    for(int j=0;j<k;j++){
      int s;
      cin >> s;
      S[i][j]=s-1;
    }
  }
  for(int p=0;p<M;p++){
    cin>>P[p];
  }
  int goal = 0;
  for (int bit = 0; bit < (1<<N); ++bit){
    bool sw = true;
    for (int j=0;j<M;j++){
      int ans =0;
      for (int i = 0; i < (int)S[j].size(); ++i) {
	if (bit & (1<<S[j][i])) {
	  ans += 1;
	}
      }
      if (ans%2 != P[j]){
	sw = false;
	break;
      }
    }
    if(sw) goal++;
  }
  cout << goal <<endl;
  
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <map>
int main(void){
  int n;
  int a[100000];
  int sum=0;
  std::map<int,int> m;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(m.find(a[i]) == m.end()){
      m.insert(std::make_pair(a[i],1));
    }else{
      m[a[i]]++;
    }
  }
  for(auto i=m.begin();i!=m.end();i++){
    if(i->first > i->second){
      sum += i->second;
    }else if(i->first < i->second){
      sum += i->second-i->first;
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 5120
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  int N, M; cin >> N >> M;
  if(!(1 < M && M < 2 * N - 1)){
    cout << "No" << endl;
    return 0;
  }
  vector<int> v;
  rep2(i, M-1, M+2){
    v.push_back(i);
  }
  int tmp = v[2];
  v[2] = v[0];
  v[2] = tmp;

  int k = 0;
  rep2(i, 1, 2 * N) {
    if(M-1 <= i && i <= M+1) continue;
    if(k < (2 * N - 1 - 3) / 2){
      k++;
      v.insert(v.begin(), i);
    }
    else{
      k++;
      v.push_back(i);
    }
  }

  cout << "Yes" << endl;

  rep(i, v.size()){
    if(i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

Measured memory_bytes: 2420
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXN=200005,INF=2000000005,MOD=1e9+7;
long long n,X,Y;
long long a[MAXN],w[MAXN],c[MAXN],d[MAXN];
long long jc[MAXN],Inv[MAXN];
long long ksm(long long x,long long y)
{
	long long k=1;
	while(y)
	{
		if(y&1)
			k=(k*x)%MOD;
		x=(x*x)%MOD;
		y>>=1;
	}
	return k;
}
void Init()
{
	jc[0]=1;
	for(long long i=1;i<MAXN;i++)
		jc[i]=(jc[i-1]*i)%MOD;
	Inv[MAXN-1]=ksm(jc[MAXN-1],MOD-2);
	for(long long i=MAXN-2;i>=0;i--)
		Inv[i]=(Inv[i+1]*(i+1))%MOD;
}
int main()
{
	//freopen("colorball.in","r",stdin);
	//freopen("colorball.out","w",stdout);
	Init();
	scanf("%lld %lld %lld",&n,&X,&Y);
	for(long long i=0;i<=n;i++)
		c[i]=INF;
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld %lld",&a[i],&w[i]);
		c[a[i]]=min(c[a[i]],w[i]);
	}
	long long MI=c[1]<c[2]?1:2,MC=c[1]<c[2]?2:1;
	for(long long i=3;i<=n;i++)
	{
		if(c[i]<c[MI])
		{
			MC=MI;
			MI=i;
		}
		else if(c[i]<c[MC])
			MC=i;
	}
	for(long long i=1;i<=n;i++)
		if(w[i]+c[a[i]]<=X)
			w[i]=c[a[i]];
	long long o=0;
	for(long long i=1;i<=n;i++)
		if((w[i]+c[MI]<=Y&&MI!=a[i])||(w[i]+c[MC]<=Y&&MC!=a[i]))
		{
			o++;
			d[a[i]]++;
		}
	long long ans=jc[o];
	for(long long i=1;i<=n;i++)
	{
		if(d[i])
			ans=(ans*Inv[d[i]])%MOD;
	}
	printf("%lld\n",ans);
	fclose(stdin);
	fclose(stdout);
}

Measured memory_bytes: 9472
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		double T = stdIn.nextInt();
		T = T + 0.5;
		
		int c = 0;
		for(; T >= A; T -= A) {
			c += B;
		}
		
		System.out.println(c);

	}

}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef vector<LL> vl;
typedef pair<LL, LL> pl;
typedef vector<pair<LL, LL>> VP;
typedef tuple<LL, LL, LL> tl;
const LL N=pow(10, 9)+7;
#define endl "\n"
#define REP(i, a, b) for(LL i=a; i<b; i++)
#define RREP(i, a, b) for(LL i=a; i>b; i--)
#define WE(i) while(i--)
#define PB push_back
#define PF pop_front
#define MP make_pair
#define MT make_tuple
#define F first
#define S second

LL sod(LL a)
{
    LL sum=0;
    while(a!=0)
    {
        sum=sum+a%10;
        a=a/10;
    }
    return sum;
}

LL num1(LL a)
{
    LL s=0;
    while(a!=0){
        if(a%2==1){
            s++;
        }
        a=a/2;
    }
    return s;
}

LL bmod(string s, LL a)
{
    LL res=0;
    REP(i, 0, s.length()){
        res=(10*res+(LL)s[i]-'0')%a;
    }
    return res;
}

void pd(LL n) 
{ 
    LL ans=0, x=sqrt(n);
    if(x%1==0){
        REP(i, 1, x+1){
            if(n%i==0){
                ans+=2;
            }
            if(n==i*i){
                ans--;
            }
        }
    }
    else{
        REP(i, 0, x){
            if(n%i==0){
                ans+=2;
            }
        }
    }
    cout << ans << endl;
}

LL solve()
{
    LL n, x;
    cin >> n;
    float a=1, y=0, z;
    REP(i, 0, n){
        cin >> x;
        y+=(a/x);
    }
    z=1/y;
    cout << fixed << setprecision(5) <<  z << endl;
    return 0;
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    LL T=1;
    //cin >> T;

    WE(T){
        solve();
    }
    return 0;
}

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

int main() {
int N;
  double ans;
  cin >> N;
  vector<double> a(N);
    rep(i,N){
      cin >> a.at(i);
    }
  sort(a.begin(), a.end());
    ans = a.at(0);
  rep2(i, 1, N)
    ans = (ans + a.at(i))/2;
  printf("%.20lf\n", ans);
}

Measured memory_bytes: 256
/*  
	Come feed the rain
	Cos I'm thirsty for your love
	Dancing underneath the skies of lust
	Yeah feed the rain...
	Cos without your love my life
	Ain't nothing but this carnival of rust
    _________________________
    _________________________
    864 Hours of Solitude
    Quarantine_Day : 36
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005
#define MOD 1000000007

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

	int r, c; cin>>r>>c;
	REP(i, c + 2) cout<<'#';
	cout<<"\n";
	REP(i, r){
		string s; cin>>s;
		cout<<"#"<<s<<"#\n";
	}
	REP(i, c + 2) cout<<'#';
	cout<<"\n";

	return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

int A[1 << 20];

Int f(int N)
{
	int i;
	int prev = 0;
	Int res = 0;
	RFOR(i, N, 0)
	{
		if (A[i] < prev - 1 || i < A[i]) return -1;
		if (A[i] != prev - 1) res += A[i];
		prev = A[i];
	}

	return res;
}

int main()
{
	int N;
	scanf("%d", &N);

	int i;
	FOR(i, 0, N)
		scanf("%d", &A[i]);

	printf("%lld\n", f(N));
	return 0;
};


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
using pdd = pair<ld, ld>;

constexpr ld INF = 1e9;

bool intersect(pdd a, pdd b, pdd c, pdd d) {
    ld ax = a.first, ay = a.second;
    ld bx = b.first, by = b.second;
    ld cx = c.first, cy = c.second;
    ld dx = d.first, dy = d.second;
    ld ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
    ld tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
    ld tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
    ld td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
    return tc * td < 0 && ta * tb < 0;
}

ld length(pdd a, pdd b) {
    ld x1 = a.first, y1 = a.second;
    ld x2 = b.first, y2 = b.second;
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main() {
    int Na, Nb;
    cin >> Na >> Nb;
    vector<pdd> pa(Na), pb(Nb);
    for (int i = 0; i < Na; ++i) {
        ld x, y;
        cin >> x >> y;
        pa[i] = make_pair(x, y);
    }
    for (int i = 0; i < Nb; ++i) {
        ld x, y;
        cin >> x >> y;
        pb[i] = make_pair(x, y);
    }

    auto dijkstra = [&](const vector<pdd> &p, int st, int gl, pair<pdd, pdd> seg) {
        vector<ld> dist(p.size(), INF);
        dist[st] = 0;
        priority_queue<pair<ld, int>, vector<pair<ld, int>>, greater<pair<ld, int>>> pq;
        pq.push({0, st});
        while (!pq.empty()) {
            int v = pq.top().second; pq.pop();
            for (int w = 0; w < p.size(); ++w) {
                if (intersect(seg.first, seg.second, p[v], p[w])) continue;
                ld cost = length(p[v], p[w]);
                if (dist[w] > dist[v] + cost) {
                    dist[w] = dist[v] + cost;
                    pq.push(make_pair(dist[w], w));
                }
            }
        }
        return dist[gl];
    };

    ld ans = INF;
    {
        // pa[0] <--> pa[1] 直線
        ld tmp = length(pa[0], pa[1]) + dijkstra(pb, 0, 1, make_pair(pa[0], pa[1]));
        ans = min(ans, tmp);
    }
    {
        // pa[0] <--> pb[1] 直線
        ld tmp = length(pb[0], pb[1]) + dijkstra(pa, 0, 1, make_pair(pb[0], pb[1]));
        ans = min(ans, tmp);
    }
    cout << setprecision(20) << fixed << (ans >= INF ? -1 : ans) << endl;
}



Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#define lli long long int
#define pb push_back
using namespace std;

int main()
{

	vector<pair<lli,lli> > jobs;
	int n;
	cin>>n;
	int i;
	int a,b;
	bool poss = true;
	for(i=0;i<n;i++)
	{
		cin>>a>>b;
		jobs.pb(make_pair(b,a));
	}
	sort(jobs.begin(),jobs.end());
	lli cursum = 0;
	for(i=0;i<n;i++)
	{
		cursum = cursum + jobs[i].second;
		if(cursum>jobs[i].first)
		{
			poss = false;
			break;
		}
	}
	if(poss)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s;
  cin >> s;
  int n = s.size();
  int ans=n/2;
  rep(i,n){
    if(s[i]=='p')ans--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=5005*2;
int n,k;
char s[N],mi='z';
int cl[N];
int cmp(char *a,char *b,int len){
	For(i,0,len-1)
		if (a[i]!=b[i])
			return a[i]<b[i];
	return 0;
}
int main(){
	n=read(),k=read()-1;
	cin>>(s+1);
	For(i,1,n)
		s[i+n]=s[i];
	reverse(s+n+1,s+n*2+1);
	For(i,1,n)
		mi=min(mi,s[i]);
	For(i,1,n*2)
		cl[i]=s[i]!=s[i-1]?1:cl[i-1]+1;
	int mx=1;
	For(i,1,n*2)
		if (s[i]==mi)
			mx=max(mx,cl[i]);
	k=min(k,15);
	if ((mx<<k)>=n){
		For(i,1,n)
			putchar(mi);
		puts("");
		return 0;
	}
	int rlen=n-(mx<<k);
	int res=0;
	For(i,1,n*2-(n-mx))
		if (s[i]==mi&&cl[i]==mx){
			if (!res||!cmp(s+res,s+i+1,rlen))
				res=i+1;
		}
	For(i,1,(mx<<k))
		putchar(mi);
	For(i,0,rlen-1)
		putchar(s[res+i]);
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
 
  int N=0;
  int i=0;
  int max=0;
  int ans=1;
 
  scanf("%d", &N);
 
  int H[100];
 
  for(i = 0; i < N; i++){
    scanf("%d", &H[i]);
  }
 
  max = H[0];
 
  for(i = 1; i < N; i++){
    if(max <= H[i]){
      ans++;
      max = H[i];
    }
  }
 
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())
mod = 10**9 + 7
if abs(N-M) > 1:
    print(0)
else:
    ans = 1
    for i in range(2,N+1):
        ans *= i
        ans %= mod
    for i in range(2,M+1):
        ans *= i
        ans %= mod
    if abs(N-M) == 1:
        print(ans)
    elif N==M:
        print((ans*2)%mod)

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  string o,e;
  cin >> o >> e;
  REP(i, e.size())
    cout << o[i] << e[i];
  if(o.size() != e.size())
    cout << o[o.size()-1];
  cout << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 101

//void bubbleSort(struct Card *,int);
//void selectionSort(struct Card *, int);

struct Card{
	char number;
	char suit;
};

int main(void){
	struct Card c1[MAX],c2[MAX];
	int i,n,flag=1;
	char a;
	
	
	scanf("%d%c",&n,&a);
	for(i=0;i<n;i++){
		scanf("%c%c%c",&c1[i].suit,&c1[i].number,&a);
		c2[i].suit = c1[i].suit;
		c2[i].number = c1[i].number;
		
	}
	
	bubbleSort(c1,n);
	printf("Stable\n");
	
	selectionSort(c2,n);
	
	for(i=0;i<n;i++){
		if(c1[i].suit!=c2[i].suit){
			printf("Not stable\n");
			flag=0;
			break;
		}
	}
	if(flag==1)printf("Stable\n");
	return 0;
}

void bubbleSort(struct Card *C,int n){
    int i,j,a;
    struct Card tmp;
     
    for(i=0;i<n;i++){
        for(j=n-1;j>=i+1;j--){
            if(C[j].number<C[j-1].number){
                tmp=C[j];
                C[j]=C[j-1];
                C[j-1]=tmp;
            }
        }
    }
    for(a=0;a<n;a++){
    printf("%c%c",C[a].suit,C[a].number);
    if(a!=n-1)printf(" ");
    if(a==n-1)printf("\n");
    }
}

void selectionSort(struct Card *C,int n){
  int i,j,a,minj;
  struct Card tmp;
 
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(C[j].number<C[minj].number){
        minj=j;
      }
    }
    tmp = C[i];
    C[i]=C[minj];
    C[minj]=tmp;
  }
  for(a=0;a<n;a++){
  	printf("%c%c",C[a].suit,C[a].number);
    if(a!=n-1)printf(" ");
    if(a==n-1)printf("\n");
	}
}

Measured memory_bytes: 612
import java.util.*;
 

public class Main {
    public static void main(String[] args) {   
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S[] = new String[N];
        String count = "Three";
       
        for(int i=0; i<N; i++){
            S[i] = sc.next();   
            if(S[i].equals("Y"))
            count = "Four";
        }

        System.out.println(count);            
    
    }    
}




Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
using vs = vector<string> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N;cin>>N;
  ll tmp_t,tmp_a;cin>>tmp_t>>tmp_a;
  ll ans=0;
  rep(i,N-1){
    ll t,a;cin>>t>>a;
    if(tmp_t*a==tmp_a*t) continue;
    else {
      ll base_t=t,base_a=a;
      //ここ高速化
      ll prod = max(tmp_t/t,tmp_a/a);
      if(t*prod<tmp_t || a*prod<tmp_a) prod++;
      tmp_t = t*prod;
      tmp_a = a*prod;
      //cout << "tmpt" << tmp_t << "tmpa" << tmp_a << endl;
    }
  }
  cout << tmp_t + tmp_a << endl;
}

Measured memory_bytes: 256
N =int(input())
T,A =[int(i)for i in input().split()]
H =[T- 0.006*int(i) for i in input().split()]
ans = 0
for i,h in enumerate(H):
    if (H[ans] -A)**2 >= (h -A)**2:
        ans = i
print(ans+1)


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

using namespace std;

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


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

using namespace std;

const int INF = 1 << 29;
const int MAX_N = 15;

double dp[1 << MAX_N][MAX_N];
int route[1 << MAX_N][MAX_N];

int num[MAX_N];
double dis[MAX_N];
double kin[MAX_N];

double calc_dist ( int a, int b )
{
	return fabs(dis[a] - dis[b]);
}

double calc_cost ( int a, int b, double w )
{
	return calc_dist(a, b) / (2000.0 / (70.0 + w));
}
double calc_cost ( int i )
{
	return dis[i] / (2000.0 / 70.0);
}

double calc_wait ( int n, int state )
{
	double res = 0;
	for (int i = 0; i < n; ++i) {
		if (state & (1 << i)) { res += kin[i]; }
	}
	return res;
}

int main ( void )
{
	int n;
	while (cin >> n) {
		for (int i = 0, I = 1 << n; i < I; ++i) {
			fill(dp[i], dp[i]+n, INF);
			fill(route[i], route[i]+n, -1);
		}

		for (int i = 0; i < n; ++i) {
			cin >> num[i] >> dis[i] >> kin[i];
			kin[i] *= 20.0;
			dp[1 << i][i] = calc_cost(i);
			route[1 << i][i] = i;
		}
		for (int s = 0, S = 1 << n; s < S; ++s) {
			for (int i = 0; i < n; ++i) {
				if (dp[s][i] == INF) { continue; }
				for (int j = 0; j < n; ++j) {
					int next = s | (1 << j);
					double tocost = dp[s][i] + calc_cost(i, j, calc_wait(n, s));
					if (dp[next][j] > tocost) {
						dp[next][j] = tocost;
						route[next][j] = i;
					}
				}
			}
		}
		int v = -1, state = (1 << n) - 1;
		for (int i = 0; i < n; ++i) {
			if (v == -1 || dp[state][v] > dp[state][i]) { v = i; }
		}
		vector<int> vs;
		while (state) {
			vs.push_back(num[v]);
			int next = state & ~(1 << v);
			v = route[state][v];
			state = next;
		}
		reverse(vs.begin(), vs.end());
		for (int i = 0, I = vs.size(); i < I; ++i) {
			cout << vs[i] << (i+1 == I ? '\n' : ' ' );
		}
	}
	return 0;
}

Measured memory_bytes: 7012
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int costs[1010][1010];
int times[1010][1010];
int d[1010];
#define INF 10000
struct E
{
    int a,b,c;
    E(){};
    E(int a,int b,int c):a(a),b(b),c(c){};
};
#define MONEY 0
#define EKI 1

int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        if(n==0&&m==0)break;
        memset(costs,INF,sizeof(costs));
        memset(times,INF,sizeof(times));
        vector<E> cs;
        vector<E> ts;
        int a,b,c,t;
        rep(i,n)
        {
            cin>>a>>b>>c>>t;
            costs[a][b] = c; costs[b][a] = c;
            times[a][b] = t; times[b][a] = t;
            cs.push_back(E(a,b,c));
            cs.push_back(E(b,a,c));
            ts.push_back(E(a,b,t));
            ts.push_back(E(b,a,t));
        }
        rep(i,m)
        {
            costs[i][i] = 0;
            times[i][i] = 0;
        }
        int k,p,q,r;
        cin>>k;
        rep(i,k)
        {
            memset(d,INF,sizeof(d));
            cin >> p >> q >> r;
            d[p] = 0;
            if(r==MONEY)
            {
                //rep(j,n*2){if(cs[j].a == p) d[cs[j].b] = cs[j].c;}
                while(true)
                {
                    bool update = false;
                    rep(j,n*2)
                    {
                        //cout <<"edge"<< j<<cs[j].a<<"to"<<cs[j].b << endl;

                        if( (d[ cs[j].a] != INF) && d[cs[j].b] > d[cs[j].a] + cs[j].c)
                        {
                            d[cs[j].b] = d[ cs[j].a] + cs[j].c;
                            update = true;
                            //cout << "updated" <<d[cs[j].b] <<endl;
                        }
                    }
                    if(!update)break;
                }
                cout << d[q]<<endl;
            }
            else
            {
                //rep(j,n*2){if(ts[j].a == p) d[ts[j].b] = ts[j].c;}
                while(true)
                {
                    bool update = false;
                    rep(j,n*2)
                    {
                        if(d[ ts[j].a] != INF && d[ts[j].b] > d[ts[j].a] + ts[j].c)
                        {
                            d[ts[j].b] = d[ ts[j].a] + ts[j].c;
                            update = true;
                        }
                    }
                    if(!update)break;
                }
                cout << d[q]<<endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 9104
n, m = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]
xs.sort()
step = 0

if n < m:
    l = sorted([b - a for a, b in zip(xs, xs[1:])])
    step = sum(l[:1-n]) if n > 1 else sum(l)

print(step)

Measured memory_bytes: 13840
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int a = (int)sqrt(n);
  cout << a*a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int N;
	ll D;
	cin >> N >> D;
	int ans = 0;
	D = D * D;
	for (int i = 0; i < N; i++) {
		ll X, Y;
		cin >> X >> Y;
		if (X*X + Y * Y <= D) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int c=0,d=0;
  vector <int> a(3);
  
  for(int i; i<3; i++)
    cin >> a.at(i);
  
  for(int i;i<3;i++){
    if(a.at(i) == 5)
      c++;
    if(a.at(i) == 7)
      d++;
  }
  if(c == 2 && d ==1)
    cout <<"YES"<<endl;
  else
    cout <<"NO"<<endl;
}

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

int main() {
	// your code goes here
	int n,i,b,sum;
	double k;
	cin>>n;
	int a[n];
	sum=0;
	for(i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	k=(double)sum/n;
	b=round(k);
	sum=0;
	for(i=0;i<n;i++)
	{
	    sum+=(b-a[i])*(b-a[i]);
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;
		int z = 0;
		for(int x=0;x<=k;x++) {
			for(int y=0;y<=k;y++) {
				z=s-(x+y);
					if(z<=k&&z>=0) {
						count++;
					}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define fto(i, a, b) for (int i = a; i <= b; i++)
#define fdto(i, a, b) for (int i = a; i >= b; i--)
#define fi first
#define se second
#define NTLiinhh "bai1"
const int base = 1e9 + 7;
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
int m, d;
void Input()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    //freopen(NTLiinhh".inp", "r", stdin);
    //freopen(NTLiinhh".out", "w", stdout);
    cin >> m >> d;
}

void Solve()
{
    int res=0;
    fto (i, 1, d)
        if (i%10>=2 && i/10>=2 && (i%10)*(i/10)<=m) ++res;
    cout << res;
}

int main()
{
    Input();
    Solve();
}


Measured memory_bytes: 256