akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimize("O3")

# include <x86intrin.h>
# include <bits/stdc++.h>

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

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
int a[N];
ordered_set < int > q;

int main () {
   SpeedForce;
   cin >> n >> k;
   for (int i = 1; i <= n; i ++) {
   	cin >> a[i];
   }
   //exit(0);
                   
   int ans = 0;
   ll cur = 0;
   int kek = 0;

   for (int i = 1, j = 0; i + k - 1 <= n; i ++) {
   	bool was = 0;
   	if (i > 1) {
   		q.erase(a[i - 1]);
   	
   		int change = q.order_of_key(a[i - 1]);
   		was |= (change > 0);
   	   cur -= change;
   	}

   	while (j - i + 1 < k) {
   		j ++;
   		int change = q.size() - q.order_of_key(a[j]);
   		cur += change;
   		was |= (change > 0);
   		q.insert(a[j]);
   		
   	}
   	//if (!was) {
   	//	cout << cur << ' ' << i << '\n';
   	//}
      if (cur == 0) kek = 1;
   	//cout << i << ' ' << was << '\n';
   	ans += (was&&cur>0);
   }
   //cout << kek << ' ';
   ans += kek;
   cout << ans << '\n';

   return Accepted;
}

// B...a

Measured memory_bytes: 10368
#include <stdio.h>
#include <string.h>

#define INFTY 1000000001

typedef struct{
  char egara;
  int kazu;
}card;


int P(card *,int,int);

void QS(card *,int,int);

void MG(card *,int,int,int);

void MS(card *,int,int);

int main()
{
  int n,i,hata=1;
  
  scanf("%d",&n);
  
  card A[n],B[n];

  for(i=0;i<n;i++)
    {
      scanf("%*c%c%d",&A[i].egara,&A[i].kazu);
      B[i]=A[i];
    }

  QS(A,0,n-1);
  MS(B,0,n);

  for(i=0;i<n;i++)
    {
      if(A[i].egara!=B[i].egara)hata=0;
    }

  if(hata==1)printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++)printf("%c %d\n",A[i].egara,A[i].kazu);
  
  return 0;
}

int P(card *A,int p,int r)
{
  int x,i,j;
  card koukan;

  x=A[r].kazu;
  i=p-1;
  for(j=p;j<r;j++)
    {
      if(A[j].kazu<=x)
	{
	  i=i+1;
	  koukan=A[i];
	  A[i]=A[j];
	  A[j]=koukan;
	}
    }
  koukan=A[i+1];
  A[i+1]=A[r];
  A[r]=koukan;
  
  return i+1;
}

void QS(card *A,int p,int r)
{
  int q;

  if(p<r)
    {
      q = P(A,p,r);
      QS(A,p,q-1);
      QS(A,q+1,r);
    }
}

void MS(card *A,int L,int R)
{
  int M;
  
  if(L+1<R)
    {
      M=(L+R)/2;
      MS(A,L,M);
      MS(A,M,R);
      MG(A,L,M,R);
    }
}

void MG(card *A,int L,int M,int R)
{
  int n1,n2,i,j,k;

  n1=M-L;
  n2=R-M;

  card l[n1+1],r[n2+1];

  for(i=0;i<n1;i++) l[i]=A[L+i];
  for(i=0;i<n2;i++) r[i]=A[M+i];

  l[n1].kazu=INFTY;
  r[n2].kazu=INFTY;

  i=0;
  j=0;

  for(k=L;k<R;k++)
    {
      if(l[i].kazu<=r[j].kazu)
	{
	  A[k]=l[i];
	  i=i+1;
	}
      else
	{
	  A[k]=r[j];
	  j=j+1;
	}
    }
}

  



Measured memory_bytes: 4060
<?php
  $ans=0;
  fscanf(STDIN,"%d %d",$n,$d);

  for($h=0;$h<$n;$h++){
    fscanf(STDIN,"%d %d",$x,$y);
    if(sqrt(($x*$x)+($y*$y))<=$d) $ans++;
  }

  echo $ans."\n";


Measured memory_bytes: 16188
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,dp[5];
int main(){
	int i,x;
	cin>>n;
	for(i=0;i<n;++i){
		cin>>x;
		dp[0]+=x;
		dp[1]=min(dp[1]+(x?x&1:2),dp[0]);
		dp[2]=min(dp[2]+(x+1&1),dp[1]);
		dp[3]=min(dp[3]+(x?x&1:2),dp[2]);
		dp[4]=min(dp[4]+x,dp[3]);
	}
	cout<<dp[4]<<endl;
	return 0;
}

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

int main() {
    int n, a[105][105]{}, ans = -IINF;
    cin >> n;
    REP(i,n)REP(j,n){
        cin >> a[i+1][j+1];
        a[i+1][j+1] += a[i+1][j] + a[i][j+1] - a[i][j];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=i+1;k<=n;k++){
                for(int l=j+1;l<=n;l++){
                    ans = max(ans, a[k][l] - a[k][j] - a[i][l] + a[i][j]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

struct Vertex{
	int key;
	int parent;
	int left;
	int right;
};

vector<Vertex> V;
int root=-1;

void Preorder(int r){
	cout <<" "<< V[r].key;
	if(V[r].left!=-1) Preorder(V[r].left);
	if(V[r].right!=-1) Preorder(V[r].right);
	return;
}

void Inorder(int r){
	if(V[r].left!=-1) Inorder(V[r].left);
	cout <<" "<< V[r].key;
	if(V[r].right!=-1) Inorder(V[r].right);
	return;
}

void Postorder(int r){
	if(V[r].left!=-1) Postorder(V[r].left);
	if(V[r].right!=-1) Postorder(V[r].right);
	cout <<" "<< V[r].key;
	return;
}

void insert(int k){
	Vertex z;
	z.key=k;
	z.left=-1;
	z.right=-1;
	
	int y=-1;
	int x=root;
	while(x!=-1){
		y=x;
		if (z.key<V[x].key){
			x=V[x].left;
		}else{
			x=V[x].right;
		}
	}
	z.parent=y;
	V.push_back(z);
	
	if(y==-1){
		root = 0;
	}else if(z.key < V[y].key){
		V[y].left=V.size()-1;
	}else{
		V[y].right=V.size()-1;
	}
}

void printVertex(int i){
	cout << V[i].key <<" " <<V[i].parent <<" " << V[i].left << " " << V[i].right <<endl;
}

void print(){
	Inorder(root);
	cout <<endl;
	Preorder(root);
	cout <<endl;
}

int find(int k){
	int v=root;
	while(1){ 
		if(k == V[v].key){
			return v;
		}else if(k < V[v].key){
			if(V[v].left==-1){
				return -1;
			}else{
				v=V[v].left;
			}
		}else{
			if(V[v].right==-1){
				return -1;
			}else{
				v=V[v].right;
			}
		}
	}
}

int next(int k){
	int u=V[k].right;
	while(V[u].left!=-1){u=V[u].left;}
	return u;
}

void del(int k){
	int vk=find(k);
	int par=V[vk].parent;
	//printVertex(vk);
	//cout << endl;
	if(V[vk].left==-1 && V[vk].right==-1){
		if(par == -1){
			root = -1;
		}else if(V[par].left==vk) {
			V[par].left=-1;
		}else{
			V[par].right=-1;
		}
	}else if(V[vk].left==-1 && V[vk].right!=-1){
		if(par == -1){
			root=V[vk].right;
		}else if(V[par].left==vk){
			V[par].left=V[vk].right;
		}else{
			V[par].right=V[vk].right;
		}
		V[V[vk].right].parent=par;
	}else if(V[vk].left!=-1 && V[vk].right==-1){
		if(par==-1){
			root=V[vk].left;
		}else if(V[par].left==vk) {
			V[par].left=V[vk].left;
		}else{
			V[par].right=V[vk].left;
		}
		V[V[vk].left].parent=par;
	}else{
		int x=V[next(vk)].key;
		del(x);
		V[vk].key=x;
	}
}

int main(){
	int n,k;
	string s;
	cin >> n;
	for (int i=0;i<n;i++){
		cin >> s;
		if(s=="insert"){
			cin >> k;
			insert(k);
		}else if(s=="find"){
			cin >> k;
			if(find(k)!=-1){
				cout <<"yes"<<endl;
			}else{
				cout << "no" <<endl;
			}
		}else if(s=="delete"){
			cin >> k;
			del(k);
		}else{
			print();
		}
	}
	/*
	for(int i=0;i<n;i++){
		printVertex(i);
		cout <<endl;
	}
	*/
	return 0;
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		long N = fs.nextInt(), M = fs.nextInt(), K = fs.nextInt();
		
		long sumM = (M-1)*M%mod*(M+1)%mod *((N*N)%mod);
		sumM %= mod;
		sumM = sumM * modpow(6, mod-2) % mod;
		
		long sumN = (N-1)*N%mod*(N+1)%mod *((M*M)%mod);
		sumN %= mod;
		sumN = sumN * modpow(6, mod-2) % mod;
		
		long comb = fermatComb(N*M-2, K-2); 
		
		long ans = (sumM + sumN)%mod * comb %mod;
		System.out.println(ans);
	}
	
	//Fermat Combination
	static long fermatComb(long a, long b) {
		if (b > a - b)
			return fermatComb(a, a - b);
		long ansMul = 1, ansDiv = 1;
		for (int i = 0; i < b; i++) {
			ansMul *= (a - i);
			ansMul %= mod;
			ansDiv *= (i + 1);
			ansDiv %= mod;
		}
		long ans = ansMul * modpow(ansDiv, mod - 2) % mod;
		return ans;
	}

	//modの元での高速pow()
	static long modpow(long a, int p) {
		if (p == 0)
			return 1;
		if (p % 2 == 0) {
			int halfP = p / 2;
			long root = modpow(a, halfP);
			return root * root % mod;
		} else
			return a * modpow(a, p - 1) % mod;
	}
	
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 22868
#include<stdio.h>
int main()
{
	int L, A, B, C, D,a=0,b=0;
	scanf("%d%d%d%d%d",&L,&A,&B,&C,&D);
	if (A%C != 0)
		a++;
	if (B%D != 0)
		b++;
	a += A / C;
	b += B / D;
	if (a > b)
		printf("%d\n", L - a);
	else
		printf("%d\n", L - b);
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
h = list(map(int, input().split()))

#print(h)
tmp = 0
ans = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        tmp += 1
    else:
        if tmp > ans:
            ans = tmp
        tmp=0

if tmp > ans:
    ans = tmp

print(ans)

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

using namespace std;

int mToTen(string str){
	int num=0;
	int sum=0;
	char tmp[5]="mcxi";

	while(1){
		int ten=1;
		int keisuu=1;

		if(str.at(num)-'0'<=9 && str.at(num)-'0'>=2){
			keisuu = str.at(num)-'0';
		//	cout<<"keisuu="<<keisuu<<endl;
			num++;
		}

		for(int i=0;i<4;i++){
			if(str.at(num)==tmp[i]){

				if(i==0)ten=1000;
				else if(i==1)ten=100;
				else if(i==2)ten=10;
				else ten=1;
				num++;
				break;
			}
		}
	//	cout<<"keisuu="<<keisuu<<" ten="<<ten<<endl;

		sum += keisuu*ten;

		if(num==str.size())break;
	}

	return sum;
}
	
void tenToM(int num){
	int ans[4];

	for(int i=0;i<4;i++){
		ans[i] = num%10;
		num/=10;
	}
	
	for(int i=3;i>=0;i--){
		if(ans[i]>=2&&ans[i]<=9){
			cout<<ans[i];
		}
		else if(ans[i]==0)continue;

		if(i==3)cout<<'m';
		else if(i==2)cout<<'c';
		else if(i==1)cout<<'x';
		else cout<<'i';
	}
	cout<<endl;
}
	


int main(){

	int n;
	cin>>n;

	for(int i=0;i<n;i++){
		string str1,str2;
		cin>>str1>>str2;
		int ans = mToTen(str1)+mToTen(str2);
		tenToM(ans);

	}

	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back
const ll mod = 1000000007;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

// 約数列挙
vector< ll > divisor(ll n) {
	vector< ll > ret;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret), greater<ll>());
	return (ret);
}

int main() {
	ll a, b;
	cin >> a >> b;
	ll ans = max({ a + b, a - b, a * b });

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

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

map<int,int> m;

int main(){
  int n,c=0,p;
  cin>>n;	
  for(int i = 0; i < n; i++){
    cin>>p;
    if(m.find(p) == m.end())	c++, m[p] = 1;
  }
  cout<<c;
  return 0;
}

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

using namespace std;

#define int long long

const int inf = 1e18;

const int maxN = 100 + 100;
const int maxW = 1e5 + 1000;
const int maxV = 1e3 + 100;

int w[maxN], v[maxN];

int dp[maxN][maxV * maxN];

signed main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n, can;
    cin >> n >> can;
    
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < maxV * maxN; j++) {
            dp[i][j] = inf;
        }
    }
    
    dp[0][0] = 0;
    
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < maxV * maxN; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= v[i]) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
            }
        }
    }
    
    int ans = 0;
    
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < maxV * maxN; j++) {
            if (dp[i][j] <= can) {
                ans = max(ans, j);
            }
        }
    }
    
    cout << ans;
    
    return 0;
    
}


Measured memory_bytes: 174336
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A1s = [0, 0, 0]
A2s = [0, 0, 0]
A3s = [0, 0, 0]
N = int(input())
for i in range(N):
  b = int(input())
  if b in A1:
    A1s[A1.index(b)]=1
  if b in A2:
    A2s[A2.index(b)]=1
  if b in A3:
    A3s[A3.index(b)]=1
f = False
if sum(A1s)==3 or sum(A2s)==3 or sum(A3s)==3:
  f = True
if A1s[0]+A2s[0]+A3s[0]==3 or A1s[1]+A2s[1]+A3s[1]==3 or A1s[2]+A2s[2]+A3s[2]==3:
  f = True
if A1s[0]+A2s[1]+A3s[2]==3 or A1s[2]+A2s[1]+A3s[0]==3:
  f = True
if f:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.TreeSet;

public class Main {

  private static void solve() {
    int n = ni();
    int k = ni();

    if (n < k * 2 - 1) {
      System.out.println(-1);
      return;
    }

    int[][] ret = new int[n][3];
    for (int i = 0; i < n; i++) {
      ret[i][2] = k + 2 * n + i;
    }

    int ptr = 0;
    for (int i = 1; i < n; i += 2) {
      ret[ptr++][1] = k + n + i;
    }
    for (int i = 0; i < n; i += 2) {
      ret[ptr++][1] = k + n + i;
    }

    TreeSet<Integer> set = new TreeSet<>();
    for (int i = 0; i < n; i++) {
      set.add(k + i);
    }

    for (int i = 0; i < n; i++) {
      int x = ret[i][2] - ret[i][1];
      ret[i][0] = set.floor(x);
      set.remove(ret[i][0]);
    }

    for (int[] v : ret) {
      System.out.println(v[0] + " " + v[1] + " " + v[2]);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 65052
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
 
dp = [0] * (N+1)
dp[0] = 1
for i in range(1, N+1):
    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
    if i in a:
        dp[i] = 0
print(dp[N])

Measured memory_bytes: 56664
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=1000;
int n;long long Ans;
long long ans1,ans2,ans3,ans4;
struct node{int a,b;}s[MAXN+5];
bool cmp1(node A,node B){
	return A.a*1.0/A.b<B.a*1.0/B.b;
}
bool cmp2(node A,node B){
	return A.a*1.0/A.b>B.a*1.0/B.b;
}
long long h(long long x,long long y){
	if(x<y)swap(x,y);
	if(y==0)return x;
	return h(y,x%y);
}
void print(){
	puts("");
	for(int i=1;i<=n;i++)
		printf("%d %d\n",s[i].a,s[i].b);
	puts("");
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&s[i].a,&s[i].b);
		long long t=h(s[i].a,s[i].b);
		s[i].a/=t,s[i].b/=t;
	}	
	ans1=ans2=ans3=ans4=1;
	/*sort(s+1,s+n+1,cmp1);
	//print();
	for(int i=1;i<=n;i++){
		long long t=max(ans1/s[i].a,ans2/s[i].b);
		while(t*s[i].a<ans1||t*s[i].b<ans2)t++;
		ans1=t*s[i].a;ans2=t*s[i].b;
	}
	//sort(s+1,s+n+1,cmp2);
	print();*/
	for(int i=1;i<=n;i++){
		long long t=max(ans3/s[i].a,ans4/s[i].b);
		while(t*s[i].a<ans3||t*s[i].b<ans4)t++;
		ans3=t*s[i].a;ans4=t*s[i].b;
	}
	//Ans=min(ans1+ans2,ans3+ans4);
	Ans=ans3+ans4;
	printf("%lld\n",Ans);
}

Measured memory_bytes: 128
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            int d = Integer.parseInt(sc.next());
            int x = Integer.parseInt(sc.next());
            int ret = 0;
            
            for(int i=0; i<n; i++){
            	ret += (d-1)/Integer.parseInt(sc.next()) + 1;
            }
            
            //出力
            System.out.println(ret + x);
            sc.close();
        }
    }
	

Measured memory_bytes: 23764
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL rou(LL a,LL d){if((a*10/d)%10<5)return a/d;else return a/d+1;}
LL ten(LL a){return (LL)pow(10,(LL)log10(a));}
LL two(LL a){return (LL)pow(2,(LL)log2(a));}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}

int main(){
  LL N,i,j,c[10][10]={0},ans=0;
  scanf("%lld",&N);
  FOR(i,1,N+1)c[i/ten(i)][i%10]++;
  FOR(i,1,10)FOR(j,1,10)ans+=c[i][j]*c[j][i];

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
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; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<60
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 998244353;

inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
ll mod(ll a, ll m){
   a%=m;
   return (a>=0?a:a+m);
}

int main(){
   int n;
   string s;
   cin>>n>>s;
   vector<int>ans(n);
   for(int bits=0;bits<4;bits++){
      bool ok=true;
      if((bits>>1) & 1)ans[n-1]=0;
      else ans[n-1]=1;
      if(bits & 1)ans[0]=0;
      else ans[0]=1;
      rep(i,n){
         int a = (s[i]=='o'?0:1);
         int next=a^ans[mod(i-1,n)]^ans[i];
         if(i==n-2 || i==n-1){
            if(next!=ans[mod(i+1,n)])ok=false;
         }
         else ans[i+1]=next;
      }
      if(ok){
         rep(i,n)cout<<(ans[i]?'W':'S');
         cout<<endl;
         return 0;
      }
   }
   cout<<-1<<endl;
   return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10;
int n,m,f[MAXN];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		if(a!=1)f[a]++;
		if(b!=1)f[b]++;
	}
	bool flag = true;
	for(int i=2;i<=n;i++){
		flag &= ((f[i]&1)^1);
	}
	puts(flag?"YES":"NO");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  cin >> S;
  ;
}
void solve() {
  map<char, int> mp;
  for (auto x : S) {
    mp[x]++;
  }

  bool ans = true;
  for (auto x : mp) {
    if (x.second % 2) {
      ans = false;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  ll n, a, b;
  cin >> n >> a >> b;
  cout << min(n*a, b) << endl;
  return 0;
}


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

void printq(queue<int> que){
    while(!que.empty()){
        cout << que.front() << " ";
        que.pop();
    }
    cout << endl;
}

int main(void){
    int n, x, y;
    cin >> n >> x >> y;
    queue<int> que;
    vector<vector<int>> g(n+1);
    g[x].push_back(y); g[y].push_back(x);
    g[1].push_back(2); g[n].push_back(n-1);
    for(int i = 2; i <= n-1; i++){
        g[i].push_back(i-1);
        g[i].push_back(i+1);
    }
    vector<int> ans(n, 0);
    for(int i = 1; i <= n; i++){
        vector<bool> visit(n+1, false);
        visit[i] = true;
        que.push(i);
        vector<int> dist(n+1, 0);
        int count = 1;
        while(count < n){
            //printq(que);
            int v = que.front();
            //printf("v %d\n", v);
            que.pop();
            for(int j : g[v]){
                if((v == j+1 || v == j-1 || (v == x && j == y) || (v == y && j == x)) && !visit[j]){
                    //printf("visit %d from %d\n", j, v);
                    que.push(j);
                    visit[j] = true; count++;
                    dist[j] = dist[v] + 1;
                }
            }
        }
        while(!que.empty()) que.pop();
        for(int j = i+1; j <= n; j++){
            ans[dist[j]]++;
            //printf("%d -> %d : %d\n", i, j, dist[j]);
        }
    }
    for(int i = 1; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main() {
  ll x, y;
  cin >> x >> y;
  vector<ll> d;

  if (x <= y) {
    d.push_back(y - x);
  }
  if (-x <= y) {
    d.push_back(y - (-x) + 1);
  }
  if (x <= -y) {
    d.push_back(-y - x + 1);
  }
  if (-x <= -y) {
    d.push_back(-y - (-x) + 2);
  }
  ll ans = *min_element(d.begin(), d.end());
  cout << ans << endl;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
typedef long long int ll;
int main(){
    int N;
    cin>>N;
    vector<string>s(N);
    map <string,int>a;
    rep(i,N){
        cin>>s.at(i);
        if(a.count(s.at(i))){
            a.at(s.at(i))++;
        }else{
            a[s.at(i)]=1;
        }
    }

    int M;
    cin>>M;
    vector<string>t(M);
    rep(i,M){
        cin>>t.at(i);
         if(a.count(t.at(i))){
            a.at(t.at(i))--;
        }
    }
    int max=-100;
    rep(i,N){
        if(a.at(s.at(i))>max){
            max=a.at(s.at(i));
        }
    }

    if(max<0){
        cout<<0<<endl;
    }else{
        cout<<max<<endl;
    }




    return 0;
}

Measured memory_bytes: 256
L = 100005

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

arr = [[0]*L for j in range(c)]
for _ in range(n):
    s,t,col = map(lambda x:int(x)-1, input().split())
    arr[col][s] += 1
    arr[col][t] -= 1

imos = [0]*L

for i in range(c):
    for p in range(L):
        if arr[i][p] == 1: imos[p] += 1
        if arr[i][p] == -1: imos[p+1] -= 1

ans = 0
for i in range(1,L):
    imos[i] += imos[i-1]
    ans = max(ans, imos[i])

print(ans)


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve4ts()
{
    
    int x;
    cin>>x;
    int now=100;
    int cnt=0;
    while(now<x){
        cnt++;
        int risi=now/100;
        now+=risi;
    }
    cout<<cnt<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

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

int main(){
  string T; cin >> T;
  int N = T.size();
  vector<bool> A(N);
  rep(i, N) A[i] = (T[i] == '1');

  vector<vector<int>> r(2, vector<int>(N + 1, 0));
  for (int i = N - 1; i >= 0; i--) {
    r[0][i] = r[0][i + 1];
    r[1][i] = r[1][i + 1];
    if (A[i]) r[i % 2][i]++;
  }

  int now = 0, t = N, s = 0, p = 0;
  long long ans = r[0][0];
  bool check = false;
  while (t > 0) {
    if (check) {
      ans += t / 2;
      t--;
    } else {
      for (; now < N; now++) {
        if (now % 2 == p) {
          if (A[now]) s++;
          else break;
        }
      }
      if (now >= N) {
        check = true;
        continue;
      }
      now++;
      t--;
      p ^= 1;
      ans += s + r[p][now];
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 6032
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << p.first << " " << p.second;
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< std::string > vs(N);
  std::map<ll, bool> mc;

  ll in_cnt = 0LL;
  ll both_cnt = 0LL;
  ll pre_cnt = 0LL;
  ll post_cnt = 0LL;
  for (ll i = 0; i < N; i++) {
    std::cin >> vs[i];
    if (vs[i][0] == 'B' && vs[i][(ll)vs[i].size()-1] == 'A') {
      both_cnt++;
    }
    if (vs[i][0] == 'B' && vs[i][(ll)vs[i].size()-1] != 'A') {
      pre_cnt++;
    }
    if (vs[i][0] != 'B' && vs[i][(ll)vs[i].size()-1] == 'A') {
      post_cnt++;
    }
    for (ll j = 1; j < (ll)vs[i].size(); j++) {
      if (vs[i][j-1] == 'A' && vs[i][j] == 'B') {
	in_cnt++;
      }
    }
  }

  //print(both_cnt, pre_cnt, post_cnt);

  ll out_cnt = 0LL;
  if (both_cnt > 0) {
    out_cnt += both_cnt - 1 + std::min(pre_cnt, 1LL) + std::min(post_cnt, 1LL);
    pre_cnt--;
    post_cnt--;
  }
  out_cnt += std::min(std::max(pre_cnt, 0LL), std::max(post_cnt, 0LL));

  print(in_cnt + out_cnt);
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const long long INF = 1e18; 
const long long mod = 998244353;//200003;786433;1e9 + 7;
const double Pi = acos(-1);
  
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int root;
int dsu[100005];
long long mindis = INF;
long long d[100005], sz[100005], h[100005];
map <long long, int> M; 
vector <pair <int, int> > Edge;
vector <int> Adj[100005];

void DFS(int node, int p = -1)
{
	sz[node] = 1;
	for(auto x : Adj[node])
	{
		if(x == p)
		{
			continue;
		}
		h[x] = h[node] + 1;
		DFS(x, node);
		sz[node] += sz[x];
	}
}

int Root(int node)
{
	return dsu[node] == node ? node : dsu[node] = Root(dsu[node]);
}

signed main()
{
	Fastio();
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> d[i];
		sz[i] = 1;
		M[d[i]] = i;
		dsu[i] = i;
		if(d[i] < mindis)
		{
			root = i;
			mindis = d[i];
		}
	}
	while(M.size() > 1)
	{
		pair <long long, int> temp = *(prev(M.end()));
		long long realdis = temp.fi - n + sz[temp.se] * 2;
		if(M.count(realdis) == false)
		{
			cout << -1;
			return 0;
		}
		if(Root(temp.se) == Root(M[realdis]))
		{
			cout << -1;
			return 0;
		}
		dsu[Root(temp.se)] = Root(M[realdis]);
		Edge.eb(temp.se, M[realdis]);
		sz[M[realdis]] += sz[temp.se];
		M.erase(temp.fi);
	}
	if(Edge.size() != n - 1 || sz[root] != n)
	{
		cout << "-1";
		return 0;
	}
	for(auto x : Edge)
	{
		Adj[x.fi].eb(x.se);
		Adj[x.se].eb(x.fi);
	}
	DFS(root);
	mindis = 0;
	for(int i = 1; i <= n; i++)
	{
		mindis += h[i];
	}
	if(mindis != d[root])
	{
		cout << "-1";
		return 0;
	}
	for(auto x : Edge)
	{
		cout << x.fi << ' ' << x.se << endl;
	}
}

Measured memory_bytes: 19300
import numpy as np

N = int(input())
A = np.zeros(N)

for i in range(N):
    A[i] = int(input())

ind = A.argsort()[::-1][:2]

first_a = A[ind[0]]
second_a = A[ind[1]]

for i, a in enumerate(A):
    if i == ind[0]:
        print(int(second_a))
    else:
        print(int(first_a))



Measured memory_bytes: 17144
MOD = 1000000007

N = int(input())

S = ['A', 'C', 'G', 'T']
T = []

for i in range(4):
    for j in range(4):
        for k in range(4):
            s = S[i] + S[j] + S[k]
            T.append(s)

dp = [[0 for j in range(64)] for i in range(N)]

for j in range(64):
    sj = T[j]
    if sj == 'GAC' or sj == 'ACG' or sj == 'AGC':
        continue
    dp[2][j] = 1

for i in range(3, N):
    for j in range(64):
        sj = T[j]
        if sj == 'GAC' or sj == 'ACG' or sj == 'AGC':
            continue
        for k in range(64):
            sk = T[k]
            if sj[2] == 'C' and sk[0] == 'A' and sk[2] == 'G':
                continue
            if sj[2] == 'C' and sk[:2] == 'AG':
                continue
            if sj[:2] == sk[1:]:
                dp[i][j] += dp[i - 1][k]
                dp[i][j] %= MOD

print(sum(dp[N - 1])%MOD)

Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	m := iScan()
	sw := make([]int, m)
	for i := 0; i < m; i++ {
		k := iScan()
		s := iSScan(k)
		for _, v := range s {
			sw[i] += (1 << uint(v-1))
		}
	}
	p := iSScan(m)
	ans := 0
	for i := 0; i < (1 << uint(n)); i++ {
		f := true
		for idx, v := range sw {
			c := 0
			for j := 0; j < n; j++ {
				c += (v >> uint(j)) & (i >> uint(j))
			}
			if c%2 != p[idx] {
				f = false
			}
		}
		if f {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1780
from collections import Counter


def factorization(n):
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] += cnt

    if temp != 1:
        arr[temp] += 1

    if len(arr.keys()) == 0 and n != 1:
        arr[n] += 1


N = int(input())
arr = Counter()
for i in range(1, N + 1):
    factorization(i)

cnt = 1
MOD = 10 ** 9 + 7
for v in list(arr.values()):
    cnt *= (v + 1)
    cnt %= MOD

print(cnt)


Measured memory_bytes: 3316
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A&lang=ja
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q;
    cin >> N;
    unordered_set<int> st;
    st.insert(0);
    REP(i, N) {
        int t;
        cin >> t;
        auto cp = st;
        for (auto &x : cp) {
            st.insert(x + t);
        }
    }
    cin >> Q;
    while (Q--) {
        int t;
        cin >> t;
        if (st.count(t)) {
            cout << "yes\n";
        } else {
            cout << "no\n";
        }
    }

    return 0;
}



Measured memory_bytes: 3244
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let n = read::<i64>();
  let mut ans = 1;
  let MOD = 1000000007;

  for i in 2..n + 1 {
    ans = ans * i;
    ans %= MOD;

  }

  println!("{}", ans);
}



Measured memory_bytes: 4352
n=int(input())
count=0
if n<10:
    print(n)
else:
    count +=9
    if n<100:print(count)
    elif 100<=n<1000:
        count +=n-100+1
        print(count)
    else:
        count +=900
        if n<10000:print(count)
        elif 10000<=n<100000:
            count +=n-10000+1
            print(count)
        else:
            count +=90000
            print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll a,b,c,d,x;
    cin >> a >> b >> c >> d >> x;
    cout << max(0ll, (c-a)*60+(d-b)-x) << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> cnt(N, 0);
  vector<vector<int>> graph(N);
  for (int i = 0; i < N + M - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].emplace_back(b);
    cnt[b]++;
  }

  queue<int> que;
  vector<int> parent(N, -1);
  for (int i = 0; i < N; i++) {
    if (cnt[i] == 0) {
      que.push(i);
      parent[i] = 0;
    }
  }

  while (!que.empty()) {
    int u = que.front();
    que.pop();

    for (int v : graph[u]) {
      if (cnt[v] > 1) {
        cnt[v]--;
        continue;
      }

      parent[v] = u + 1;
      que.push(v);
    }
  }

  for (int i = 0; i < N; i++) {
    cout << parent[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 7040
N,M,K = list(map(int,input().split()))

A = list(map(int,input().split()))

B = list(map(int,input().split()))

C = [0]
c = 0
for i in range(N):
    c+=A[i]
    C.append(c)

D = [0]
d = 0
for i in range(M):
    d+=B[i]
    D.append(d)

ans = 0

def bisect(m):
    if m>=D[M]:
        return M
    if m==0:
        return 0
    r = M
    l = 0
    while r-l>1:
        if m>=D[(r+l)//2]:
            l = (r+l)//2
        else:
            r = (r+l)//2
    return l

for i in range(N+1):
    if K<C[i]:
        break
    ans = max(i+bisect(K-C[i]),ans)
print(ans)

Measured memory_bytes: 129360