akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int ruijou (int A) {
  int ans = 0;
  while (true) {
    if (A % 2 == 1) break;
    A /= 2;
    ans ++;
  }
  return ans;
}
int main () {
  int N;
  cin >> N ;
  vector<int> k(N);
    for (int i = 0; i < N; i ++) {
      int A;
      cin >> A ;
      k[i] = ruijou (A);
    }
  sort (k.begin(), k.end());
  cout << k[0] << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

//----------BIT 0-index----------
int BIT_N = 10010;
int bit[10010];
void add(int a, int w)
{
	for (int x = a; x < BIT_N; x |= x + 1)
	{
		bit[x] += w;
	}
}
int sum(int a)
{
	int ret = 0;
	for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1)
	{
		ret += bit[x];
	}
	return ret;
}


int N;
char C[5000];
int A[5000];

int cost[5000][5000][2];

void MakeCost(char c, int k)
{
	for (int c1 = 0; c1 < N; c1++)
	{
		memset(bit, 0, sizeof(bit));

		int base = 0;
		int cnt = 0;
		for (int i = 0; i < N * 2; i++)
		{
			if (C[i] == c)
			{
				if (A[i] > c1 + 1)
				{
					base++;
				}
				else if (A[i] == c1 + 1)
				{
					break;
				}
			}
			else
			{
				add(A[i], 1);
				cnt++;
			}
		}

		for (int c2 = 0; c2 <= N; c2++)
		{
			if (c == 'B')
			{
				cost[c1][c2][k] = base + (cnt - sum(c2 + 1));
			}
			else
			{
				cost[c2][c1][k] = base + (cnt - sum(c2 + 1));
			}
		}
	}

}

int dp[5000][5000];

signed main()
{
	cin >> N;
	REP(i, N * 2)
	{
		cin >> C[i] >> A[i];
	}

	MakeCost('B', 0);
	MakeCost('W', 1);

	dp[0][0] = 0;
	for (int i = 1; i <= N; i++)
	{
		dp[i][0] = dp[i - 1][0] + cost[i - 1][0][0];
	}

	for (int j = 1; j <= N; j++)
	{
		dp[0][j] = dp[0][j - 1] + cost[0][j - 1][1];

		for (int i = 1; i <= N; i++)
		{
			int d1 = dp[i][j - 1] + cost[i][j - 1][1];
			int d2 = dp[i - 1][j] + cost[i - 1][j][0];
			dp[i][j] = MIN(d1, d2);
		}
	}

	cout << dp[N][N] << endl;
}







Measured memory_bytes: 236928
e=enumerate
n,a=open(0)
n=int(n)
d=[0]+[-9e18]*n
for j,(a,i)in e(sorted((int(a),i)for i,a in e(a.split()))[::-1]):d=[max(t+a*abs(~i-j+k+n),d[k-1]+a*abs(~i+k)if k else 0)for k,t in e(d)]
print(max(d))

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N;
int X[105];

signed main()
{
    cin >> N;
    rep(i, N) cin >> X[i];

    int mi = inf;

    rep1(i, 100) {
        int sum = 0;
        rep(j, N) {
            sum += (X[j] - i) * (X[j] - i);
        }

        chmin(mi, sum);
    }

    cout << mi << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.awt.geom.*;
import static java.util.Arrays.*;

class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		while(true){
			int w = Integer.parseInt(stdIn.next());
			int d = Integer.parseInt(stdIn.next());
			if(w==0 && d==0){
				break;
			}
			int count = 0;
			PriorityQueue<Integer> front = new PriorityQueue<Integer>();
			PriorityQueue<Integer> side = new PriorityQueue<Integer>();
			for(int i=0;i<w;i++){
				front.add(Integer.parseInt(stdIn.next()));
			}
			for(int i=0;i<d;i++){
				side.add(Integer.parseInt(stdIn.next()));
			}

			while(!front.isEmpty() || !side.isEmpty()){
				if(front.peek() == side.peek()){
					count += front.poll();
					side.poll();
				}
				else if(side.isEmpty() || (!front.isEmpty() && front.peek() < side.peek())){
					count += front.poll();
				}
				else if(front.isEmpty() || (!side.isEmpty() && side.peek() < front.peek())){
					count += side.poll();
				}
			}

			out.println(count);
			out.flush();
		}
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(i+1<N&&a[i]==a[i+1]){
      int cnt=1;
      while(i+1<N&&a[i]==a[i+1]){
        cnt++;
        i++;
      }
      ans+=(cnt/2);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main()
{
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  int ans =0;
    if(x == W/2 && y == H/2) {
      cout << W*H/2 << " 1" << endl;
    }
  else {
    cout << W*H/2 << " 0" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int n,c,t=0;
string itos(ll a)
{
	string s;
	while(a>0)
	{
		int e=a%10ll;
		s+=e+'0';
		a/=10ll;
	}
	reverse(s.begin(),s.end());
	return s;
}
/*int rev(int k)
{
	int res=0;
	while(k>0)
	{
		res+=k%10;
		k/=10;
		res*=10;
	}
	return res/10;
}*/
bool is_palindrome(ll p)
{
	string s=itos(p);
	if(s[n]!=(c+'0'))return false;
	for(int i=0;i<((int)s.size())/2;i++)
	{
		if(s[i]!=s[s.size()-1-i])return false;
	}
	return true;
}
bool is_prime(ll x)
{
	for(ll i=2;i*i<=x;i++)
	{
		if(x%i==0)return false;
	}
	return true;
}
int main()
{
	cin >> n >> c;
	if(c>=0)t=1;
	if(n==1&&c<0)
	{
		cout << 11 << endl;
		return 0;
	}
	if(c<0)
	{
		for(int i=0;i<2*n;i++)cout << 9;
		cout << endl;
		return 0;
	}
	int mx=((int)pow(10,2*n+t))-1,mi=((int)pow(10,2*n+t-1));
	for(int i=mx;i>=mi;i--)
	{
		//int v=i*100*mi+c*10*mi+rev(i);
		if(!is_palindrome(i))continue;
		if(!is_prime(i))continue;
		cout << i << endl;
		return 0;
	}
	/*cout << ((int)pow(10,n))-1;
	cout << c;
	cout << ((int)pow(10,n))-1;*/
	cout << ((int)pow(10,2*n+t))-1 << endl;
	return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m,k;
    cin>>n>>m>>k;
    string s[n];
    for(int i=0;i<n;i++){
    	cin>>s[i];
    }
    int ans=0;
    int x=n+m;
    for(int mask=0;mask<(1<<x);mask++){
    	string s1[n];
    	for(int i=0;i<n;i++)s1[i]=s[i];
        for(int i=0;i<x;i++){
    		if(mask&(1<<i)){
    			if(i<n){
    				for(int j=0;j<m;j++){
    					s1[i][j]='*';
                    }
                }
                else{
    	            for(int j=0;j<n;j++){
    		            s1[j][i-n]='*';
                   }
                }
            }
        }
        int y=0;
    
    for(int i=0;i<n;i++){
    	for(int j=0;j<m;j++){
    		if(s1[i][j]=='#')y++;
        }
        
    }
     if(y==k)ans++;
    }
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
int a[10005]={0};
int color[10005]={0};
int main()
{
	int n;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++)
	{
		scanf("%d",&color[i]);
		a[color[i]]++;
	}
	int instead;
	for(int i=0;i<n;i++)
	{
		if(a[i]==0)
		{
			instead=i;
			break;
		}
	}
	int cnt=0;
	for(int i=0;i<n-1;i++)
	{
		if(color[i]==color[i+1])
		{
			color[i+1]=instead;
			cnt++;
		}
	}
	printf("%d",cnt);
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)
	var ans int
	var aans int
	for _, v := range n {
		if v == 'R' {
			ans += 1
			if aans < ans {
				aans = ans
			}
		} else {
			ans = 0
		}
	}
	fmt.Println(aans)
}


Measured memory_bytes: 1772
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int cnt = 0;
		String[] s = new String[16];
		for(int a=0;a<2;a++){
			for(int b=0;b<2;b++){
				for(int c=0;c<2;c++){
					s[cnt] = a + "" + b + "" + c + "0";
					s[cnt+1] = a + "" + b + "" + c + "1";
					cnt+=2;
				}
			}
		}
		
		double[] u = new double[31];
		double v = 0.0078125;
		for(int i=0;i<31;i++){
			u[i] = v;
			v *= 2;
		}
		
		int n = sc.nextInt();
		for(int i=0;i<n;i++){
			String t = sc.next();
			StringBuilder sb = new StringBuilder();
			int id = -1;
			for(int j=0;j<8;j++){
				char c = t.charAt(j);
				if(Character.isDigit(c)) id = c-48;
				else id = c-87;
				sb.append(s[id]);
			}
			
			if(sb.charAt(0)=='1') System.out.print("-");
			int d = 0;
			for(int j=7;j<31;j++){
				id = sb.charAt(31-j)-48;
				d += id*u[j];
			}
			System.out.print(d + ".");
			double dd = 0;
			for(int j=0;j<7;j++){
				id = sb.charAt(31-j)-48;
				dd += id*u[j];
			}
			String ddd = Double.toString(dd);
			System.out.println(ddd.substring(2,ddd.length()));
		}
	}
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main()
{
  ll a,b,x;
  cin >> a >> b >> x;
  
  ll ans;
  if(a==0||b==0) ans = b/x+1;
  else ans = b/x - (a-1)/x;
  cout << ans;
}

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

int main() {
  int K, X;
  cin >> K >> X;
  
  for(int i=-1000000;i<1000001;i++){
    if(X-(K-1) <= i && i <= X + (K-1) && i<1000000){
      cout << i << " " ;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		int[] w = new int[N];
		long[] v = new long[N];
		for (int i=0;i<N;i++) {
			w[i]=sc.nextInt();
			v[i]=sc.nextLong();
		}

		long[][] dp = new long[N+1][W+1];
		for (int i=1;i<N+1;i++) {
			for (int j=1;j<W+1;j++) {
				if (j-w[i-1]>=0) {
					dp[i][j]=Math.max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
				}else {
					dp[i][j]=dp[i-1][j];
				}
			}
		}
		System.out.println(dp[N][W]);
	}
}

Measured memory_bytes: 127572
//mangesh2102000

#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long int 
#define ld long double
#define pb push_back
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define F first
#define S second
#define mod 1000000007

const int N = 405;
const int INF = 1e18L + 5;

int a[N];
int dp[N][N];
int pf[N];

int f(int l,int r)
{
	if(dp[l][r] != INF)
		return dp[l][r];

	if(l==r)
		return dp[l][r] = 0;

	int tmp = INF;
	for(int i=l;i<r;i++)
	{
		tmp = min(tmp,f(l,i)+f(i+1,r)+pf[r]-pf[l-1]);
	}

	return dp[l][r] = tmp;
}

void solve(int t)
{	
	int n;
	cin >> n;	
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
	}

	pf[1] = a[1];
	for(int i=2;i<=n;i++)
	{
		pf[i] = pf[i-1] + a[i];
	}

	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i][j] = INF;
		} 
	}

	cout << f(1,n);

	// for(int l=n;l>=1;l--)
	// {
	// 	for(int r=l;r<=n;r++)
	// 	{
	// 		if(l==r)
	// 		{
	// 			dp[l][r] = 0;
	// 		}
	// 		else
	// 		{
	// 			dp[l][r] = INF;
	// 			for(int i=l;i<r;i++)
	// 			{
	// 				dp[l][r] = min(dp[l][r] ,dp[l][i] + dp[i+1][r] + pf[r] - pf[l-1]);
	// 			}
	// 		}
	// 	}
	// }

	// cout << dp[1][n];

    //cout << "Case #" << t << ": ";    
}   


int32_t main()
{
    IOS;
    int t;
    t=1;
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }

    return 0;
}

Measured memory_bytes: 1536
import java.util.*;
import java.math.*;
import java.io.BufferedInputStream;
public class Main{
public static void main(String[] args){
        Scanner sc = new Scanner (new BufferedInputStream(System.in));
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[][] num = new int[n][2];
        for(int i = 0; i < n; ++i) {
            num[i][0] = sc.nextInt();
            num[i][1] = sc.nextInt();
        }
        int[] dp = new int[h + 1];
  		
        Arrays.fill(dp, Integer.MAX_VALUE);
  		dp[0] = 0;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j <= h; ++j) {
              	if(dp[j] == Integer.MAX_VALUE) continue;
                int index = j + num[i][0];
                if(index >= h) index = h;
                dp[index] = Math.min(dp[index], dp[j] + num[i][1]);
            } 
        }
        System.out.println(dp[h]);                       
      }
}

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

using namespace std;

int main()
{
    int k;
    string s;
    cin >> s >> k;

    vector<string> list;

    for (int i = 0; i < s.length(); i++)
    {
        for (int j = 1; j < 6; j++)
        {
            string q = s.substr(i, j);
            int c = count(list.begin(), list.end(), q);
            if (c == 0)
            {
                list.push_back(q);
            }
        }
    }
    sort(list.begin(), list.end());
    cout << list[k - 1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <deque>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; getline(cin,s);
    for(char c:s){
        if('a'<=c&&c<='z'){
            cout << (char)(c-'a'+'A');
        }
        else if('A'<=c&&c<='Z'){
            cout << (char)(c-'A'+'a');
        }
        else{
            cout << c;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3224
n = int(input())
w = [[[0]*10 for _ in range(3)] for _ in range(4)]
#[[[0]*10]*3 for i in range(4)]

for i in range(n):
    b, f ,r, v = map(int, input().split())
    w[b - 1][f - 1][r - 1] = w[b - 1][f - 1][r - 1] + v

cnt = 0
for i in w:
    cnt = cnt + 1
    for j in range(3):
        print(" " + " ".join(map(str, i[j])))
    
    if len(w) != cnt:
        print("#" * 20)


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

int main() {
  
  string alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  string S; vector<int> vec(26, 0);
  
  while (getline(cin, S)) {
    
    for (int i = 0; i < S.size(); i++) {
      for (int j = 0; j < alp.size(); j++) {
        if (S.at(i) == alp.at(j)) {
          vec.at(j % 26)++;
        }
      }
    }
    
  }
  
  for (int i = 0; i < vec.size(); i++) {
    cout << alp.at(i) << " : " << vec.at(i) << endl;
  }
  
}


Measured memory_bytes: 3180
#include<stdio.h>
int main()
{
	int h,w;
	scanf("%d %d",&h,&w);
		while(1){
			if(h==0&&w==0)break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)printf("#");
		printf("\n");
	}
	scanf("%d %d",&h,&w);
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1004
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++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())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  cout<<(N+1)/2<<endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

long V[] = {1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000,100000000000};

int func(long v){
	int M = sizeof(V) / sizeof(long);
	for( int i = 0; i < M; i++ ){
		if( v / V[i] == 0 ){ return i; }
	}
	return -1;
}

void run(){
	long N;
	std::cin >> N;
	long sN = sqrt(N) + 1;
	int m = 16, t;
	for( long A = 1; A <= sN; A++ ){
		long B = N / A;
		if( N != A * B ){ continue; }
		t = func(B);
		if( t < m ){
			m = t;
			if( func(A) == m ){ break; }
		}
	}
	std::cout << m << std::endl;
	return;
}

int main(){
	run();
	return 0;
}


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

struct UnionFind
{
  vector<int> rank, p;

  UnionFind(int n)
  {
    rank.resize(n, 0);
    p.resize(n);
    rep(i, n) p.at(i) = i;
  }

  int find(int x)
  {
    if (x != p.at(x))
    {
      p.at(x) = find(p.at(x));
    }
    return p.at(x);
  }

  bool same(int x, int y)
  {
    return find(x) == find(y);
  }

  void link(int x, int y)
  {
    if (rank.at(x) < rank.at(y))
      p.at(x) = y;
    else
    {
      p.at(y) = x;
      if (rank.at(x) == rank.at(y))
      {
        rank.at(x)++;
      }
    }
  }

  void unite(int x, int y)
  {
    link(find(x), find(y));
  }
};

int main()
{
  int n, q;
  cin >> n >> q;
  UnionFind uf(n);
  rep(i, q)
  {
    int com, x, y;
    cin >> com >> x >> y;
    if (com)
    {
      cout << uf.same(x, y) << endl;
    }
    else
    {
      uf.unite(x, y);
    }
  }
}


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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  ll x, y;
  cin >> x >> y;
  ll ans = 1;
  while (2*x <= y) {
    ans++;
    x*=2;
  }
  cout << ans;



  return 0;
}






// Coded by Z..

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S;
  cin >> S;
  string X = "CODEFESTIVAL2016";
  ll ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != X[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>

int n,head, tail;
char color[103];
int d[103];
int Q[104];
int G[103][103];

void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(int);
int dequeue(void);
void bfs(int);

int main()
{
  int i,u,k,j;
  int *U;

  /* 初期化 */
  for(i = 0;i < 103;i++){
    for(j = 0;j < 103;j++){
      G[i][j] = 0;
    }
  }

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&u);
    scanf("%d",&k);

    U = (int *)malloc(sizeof(int) * k);
    if(U == NULL) exit(0);

    for(j = 0;j < k;j++){
      scanf("%d",&U[j]);
      G[u][U[j]] = 1;
    }
  }

  bfs(1);

  /* 出力 */
  for(i = 1;i <= n;i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}

void bfs(int s)
{
  int u,v;

  for(u = s + 1;u <= n;u++){
    color[u] = 'W';    // WHITE 何もしていない
    d[u] = -1;
  }
  color[s] = 'G';  // GRAY 一度訪れて、現在キューに入っている */

  d[s] = 0;

  initialize(); // Q = empty
  enqueue(s);

  while(isEmpty() != 1){
    u = dequeue();
    
    for(v = 1;v <= n;v++){
      if(G[u][v] == 1){
	if(color[v] == 'W'){
	  color[v] = 'G';
	  d[v] = d[u] + 1;
	  enqueue(v);
	}
	else color[u] = 'B';
      }
    }
  }
}

void enqueue(int x){
  if(isFull() == 1){
    fprintf(stderr,"オーバーフロー\n");
    exit(1);
  }

  Q[tail] = x;

  if((tail + 1) == 104) tail = 0;
  else tail++;
}

int dequeue(void){
  int x;
  if(isEmpty() == 1){
    fprintf(stderr,"アンダーフロー\n");
    exit(1);
  }
   
  x = Q[head];

  if((head + 1) == 104) head = 0;

  else head++;

  return x;
}

void initialize(void)
{
  head  = 0;
  tail  = 0;
}

int isEmpty(void)
{
  if(head == tail) return 1;
  return 0;
}

int isFull(void)
{
  if(head == (tail + 1) % 104) return 1;
  return 0;
}

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

int main(){
    int k, s;
    int ans = 0;
    cin >> k >> s;
    for(int x = 0;x < k + 1;x++){
        for(int y = 0;y < k + 1;y++){
            if(0 <= s - x - y && s - x - y <= k)ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char aa,bb;
    cin >> aa >> bb;
    a = aa == 'H' ? 1 : 0;
    b = bb == 'H' ? 1 : 0;
    int ans = a ^ b;
    if(!ans){
        cout << "H" << endl;
    }
    else{
        cout << "D" << endl;
    }
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<limits.h>
#include<algorithm>
#include<queue>
#include<set>
#include<math.h>
#include<random>


#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}

struct SegmentTree {
private:
	int n;
	vector<long long int> node;
	int TANNI;

	long long int Func(long long int a, long long int b) {
		return min(a,b);
	}

public:
	//元配列ｖをセグメント木で表現する。
	SegmentTree(vector<long long int> v, long long int tanni) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪→これをｎとおく。
		//セグメント木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1;
		while (n < sz)n *= 2;

		TANNI = tanni;
		node.resize(2 * n - 1, TANNI);

		//最下段に値を入れた後に、下の段から順番に値を入れる。
		//値を入れるには、自分の子の２値を参照すればよい。
		for (int i = 0; i < sz; i++)node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)node[i] = Func(node[2 * i + 1], node[2 * i + 2]);
	}

	void update(long long int x, long long int val) {
		//最下段のノードにアクセスする。
		x += (n - 1);

		//最下段のノードを更新したら、あとは親に上って更新していく。
		node[x] = val;

		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = Func(node[2 * x + 1], node[2 * x + 2]);
		}
	}

	long long int getVal(int x) {
		x += (n - 1);
		return node[x];
	}

	long long int getAns(int a, int b, int k = 0, int l = 0, int r = -1) {
		//最初に呼び出された時の区間は[0,n)
		if (r < 0)r = n;

		//要求区間と対象区間が交わらない→単位元を返す。
		if (r <= a || b <= l) return TANNI;

		//要求区間が対象区間を完全に被覆する→対象区間を答えの計算に使う。
		if (a <= l && r <= b) return node[k];

		//要求区間が対象区間の一部を被覆→子をよびだす。
		//左の子をvl、右の子をvrとしている。
		//新しい対象区間は現在の対象区間を半分に割ったもの。
		int vl = getAns(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = getAns(a, b, 2 * k + 2, (l + r) / 2, r);
		return Func(vl, vr);


	}



};




int main()
{
	
	long long int n, k;
	cin >> n >> k;

	long long int syou = n / k;
	long long int kai1 = n % k;
	long long int kai2 = abs(kai1 - k);

	cout << min(kai1, kai2) << endl;




}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int N = 0;
	static int M = 0;
	static int[] L = null;
	static int[] R = null;
	static int[] D = null;

	static ArrayList<Integer>[] LL = null;
	static ArrayList<Integer>[] RR = null;

	static boolean[] check = null;
	static long[] x = null;
	static boolean[] visited = null;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		L = new int[M];
		R = new int[M];
		D = new int[M];

		LL = new ArrayList[N + 1];
		RR = new ArrayList[N + 1];
		for (int i = 0; i < M; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
			D[i] = sc.nextInt();

			if (LL[L[i]] == null) {
				LL[L[i]] = new ArrayList<Integer>();
			}
			LL[L[i]].add(i);
			if (RR[R[i]] == null) {
				RR[R[i]] = new ArrayList<Integer>();
			}
			RR[R[i]].add(i);
		}

		check = new boolean[M];
		Arrays.fill(check, false);
		x = new long[N + 1];
		Arrays.fill(x, 0L);
		visited = new boolean[N + 1];
		Arrays.fill(visited, false);
		boolean ans = true;
		for (int i = 0; i < M; i++) {
			if (check[i]) {
				continue;
			}
			x[L[i]] = 0L;
			x[R[i]] = D[i];
			visited[L[i]] = true;
			visited[R[i]] = true;
			check[i] = true;
			ans &= rec(i, true, true);
			if (!ans) {
				break;
			}
		}
		if (ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	static boolean rec(int i, boolean lcheck, boolean rcheck) {
		// Li
		if (LL[L[i]] != null && lcheck) {
			for (int j : LL[L[i]]) {
				if (check[j]) {
					continue;
				}
				check[j] = true;
				if (visited[R[j]]) {
					if (x[R[j]] - x[L[j]] != D[j]) {
						return false;
					}
				} else {
					visited[R[j]] = true;
					x[R[j]] = x[L[j]] + D[j];
					if (!rec(j, false, true)) {
						return false;
					}
				}
			}
		}
		if (RR[L[i]] != null && lcheck) {
			for (int j : RR[L[i]]) {
				if (check[j]) {
					continue;
				}
				check[j] = true;
				if (visited[L[j]]) {
					if (x[R[j]] - x[L[j]] != D[j]) {
						return false;
					}
				} else {
					visited[L[j]] = true;
					x[L[j]] = x[R[j]] - D[j];
					if (!rec(j, true, false)) {
						return false;
					}
				}
			}
		}

		// Ri
		if (LL[R[i]] != null && rcheck) {
			for (int j : LL[R[i]]) {
				if (check[j]) {
					continue;
				}
				check[j] = true;
				if (visited[R[j]]) {
					if (x[R[j]] - x[L[j]] != D[j]) {
						return false;
					}
				} else {
					visited[R[j]] = true;
					x[R[j]] = x[L[j]] + D[j];
					if (!rec(j, false, true)) {
						return false;
					}
				}
			}
		}
		if (RR[R[i]] != null && rcheck) {
			for (int j : RR[R[i]]) {
				if (check[j]) {
					continue;
				}
				check[j] = true;
				if (visited[L[j]]) {
					if (x[R[j]] - x[L[j]] != D[j]) {
						return false;
					}
				} else {
					visited[L[j]] = true;
					x[L[j]] = x[R[j]] - D[j];
					if (!rec(j, true, false)) {
						return false;
					}
				}
			}
		}
		return true;
	}
}


Measured memory_bytes: 189060
#include <bits/stdc++.h>
using namespace std;
int n,m;
bool was[30];
string s;
bool dfs(int x)
{
	if(x==n)
	{
		for(int i=0;i<26;i++)
		{
			if(!was[i])
			{
				s+=char(i+'a');
				return 1;
			}
		}
		return 0;
	}
	was[s[x]-'a']=1;
	bool ok=0;
	if(dfs(x+1))
		return 1;
	for(int i=(s[x]-'a')+1;i<26;i++)
	{
		if(!was[i])
		{
			s.erase(x,s.size()-x);
			s+=char(i+'a');
			return 1;
		}
	}
	was[s[x]-'a']=0;
	return 0;
}
int main()
{
	cin>>s;
	n=s.size();
	if(!dfs(0))
		cout<<"-1\n";
	else
		cout<<s<<"\n";
 	return 0;
}


Measured memory_bytes: 256
#include <cstdio> 
int main() 
{ 
    
    int A,B,C;
    
    scanf ("%d %d %d", &A,&B,&C);
    
    if (A>=B and B>=C)
    {
        printf("%d", B-C+A-B);
    }
    
    else if (A>=C and C>=B)
    {
        printf("%d", C-B+A-C);
    }

    else if (B>=A and A>=C)
    {
        printf("%d", A-C+B-A);
    }

    else if (B>=C and C>=A)
    {
        printf("%d", C-A+B-C);
    }
  
    else if (C>=B and B>=A)
    {
        printf("%d", B-A+C-B);
    }
    
    else if (C>=A and A>=B)
    {
        printf("%d", A-B+C-A);
    }
    
    

return 0;
}

Measured memory_bytes: 128
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val robots = Array.fill(N)((in.nextInt, in.nextInt)).sortBy(_._1)

  val (_, cnt) = robots.foldLeft((Int.MinValue, 0)){case ((right, count), (pos, len)) =>
    if (right <= pos - len) (pos + len, count)
    else (Math.min(right, pos + len), count + 1)
  }
  println(N - cnt)
}

Measured memory_bytes: 77132
#include<stdio.h>
#include<math.h>

//int inputdata[20000];

int isPrime(int );

int main(){

  int i,sumdata,data,count,answer;

  count = 0;

  scanf("%d",&sumdata);

  for(i = 0; i < sumdata; i++){

    scanf("%d",&data);

    answer =  isPrime(data);

   if(answer != -1){

     count = count + answer;

   }

  }

  printf("%d\n",count);

  return 0;

}

int isPrime(int data){

  int i;

  if(data ==  2){

    return 1;

  }

  if(data < 2 || data % 2 == 0){

    return -1;

  }

  i = 3;

  while((double)i <= sqrt(data)){

    if(data % i == 0){

      return -1;

    }

    i = i + 2;

  }

  return 1;

}

Measured memory_bytes: 596
N = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
count = a.min
sum = 0
ans = []
while (count <= a.max)
    a.each do |a|
       sum += (count - a) ** 2
    end
    ans << sum
    sum = 0
    count += 1
end

puts ("#{ans.min}")

Measured memory_bytes: 1788
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		R[][] rss=new R[3][8];
		for(int i=0; i<24; i++){
			R r=new R();
			r.id=sc.nextInt();
			r.time=(int)(sc.nextDouble()*100);
			rss[i/8][i%8]=r;
		}
		Arrays.sort(rss[0]);
		Arrays.sort(rss[1]);
		Arrays.sort(rss[2]);
		LinkedList<R> list=new LinkedList<R>();
		for(int i=2; i<8; i++){
			list.add(rss[0][i]);
			list.add(rss[1][i]);
			list.add(rss[2][i]);
		}
		R[] rs=list.toArray(new R[0]);
		Arrays.sort(rs);

		for(int j=0; j<3; j++){
			for(int i=0; i<2; i++){
				println(String.format("%d %.2f", rss[j][i].id,
						rss[j][i].time/100.));
			}
		}
		println(String.format("%d %.2f", rs[0].id, rs[0].time/100.));
		println(String.format("%d %.2f", rs[1].id, rs[1].time/100.));
	}

	class R implements Comparable<R>{
		int id;
		int time;

		@Override
		public int compareTo(R r){
			return time-r.time;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
h, w = list(map(int, input().split(' ')))

sl = []
for i in range(h):
    sl.append(input())

counter = [[0 for i in range(w + 2)] for j in range(h + 2)]
    
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if sl[i - 1][j - 1] == '#':
            counter[i - 1][j - 1] += 1
            counter[i - 1][j] += 1            
            counter[i - 1][j + 1] += 1
            counter[i    ][j - 1] += 1
            counter[i    ][j + 1] += 1
            counter[i + 1][j - 1] += 1
            counter[i + 1][j] += 1
            counter[i + 1][j + 1] += 1

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if sl[i - 1][j - 1] == '#':
            counter[i][j] = '#'
        else:
            counter[i][j] = str(counter[i][j])

for i in range(1, h + 1):
    print(''.join(counter[i][1:-1]))


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main()
{
    unsigned long int n,num[200000]={0},i,value;
    cin>>n;
    for(i=1;i<n;i++){
        cin>>value;
        num[value-1]++;
    }
    for(i=0;i<n;i++){
        cout<<num[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5100
N,A,B,C=input().split(" ")
N=int(N)
A=int(A)
B=int(B)
C=int(C)

L=[]
for i in range(N):
	L.append(int(input()))



#長さmの竹を作るのに必要なMPの表を作りたいが?
#長さ10以下の竹を繋げるくらいなら長くしたほうがいい





#距離
#まず, 絶対値の比較を行いたい
#そして, 


#操作の交換法則は成立する
#


def cal_cost(L_use):
	a=0
	b=0
	c=0
	na=0
	nb=0
	nc=0
	for i in range(len(L_use)):
		if(L_use[i]==0):
			0
		if(L_use[i]==1):
			a+=L[i]
			na+=1
		if(L_use[i]==2):
			b+=L[i]
			nb+=1
		if(L_use[i]==3):
			c+=L[i]
			nc+=1
	if(na==0 or nb==0 or nc==0):
		return -1
	return abs(a-A)+abs(b-B)+abs(c-C)+10*(na+nb+nc-3)
	

L_use=[]
for i in range(4**N):
	k=i
	tmp=[]
	for j in range(N):
		tmp.append(k%4)
		k//=4
	L_use.append(tmp)
costs=[]
for u in L_use:
	c=cal_cost(u)
	if(c!=-1):
		costs.append(c)
print(min(costs))
#print(costs)
#print(L_use)	




#Aの材料or Bの材料 or Cの材料 or Dの材料





#nはそんなに大きくないので, 自由にできそう





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

typedef long long ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
      cin.tie(0);
   
    ll a,b;
    cin>>a>>b;
    if(a%2==0 || b%2==0)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
AB = [ list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n-1,-1,-1):
    a = AB[i][0] + ans
    b = AB[i][1]
    #print(a,b)
    if a % b == 0:
        tmp = 0
    else:
        tmp = (a // b + 1) * b - a
    ans += tmp
print(ans)

Measured memory_bytes: 27380
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main() {
    string y;
    
    int z[12]={1,3,5,7,9,11,15,17,19,21,23,25};
    
    int affine[12*26][26]={0};
    for(int a=0; a<12; a++){
        for(int b=0; b<26; b++){
            for(int i=0; i<26; i++){
                    affine[a*26+b][(i*z[a]+b)%26]=i;
            }
        }
    }
    
    int temp;
    cin>>temp;
    getline(cin,y);
    for(int t=0; t<temp; t++){
        getline(cin,y);
        string x=y;
        
        
        for(int j=0; j<12*26; j++){

            for(int i=0; i<(int)y.length(); i++){
                if(y[i]==' '){
                    x[i]=y[i];
                }else{
                    x[i]=affine[j][y[i]-'a']+'a';
                }
            }
            if(x.find("this")!=-1 || x.find("that")!=-1){
                cout<<x<<endl;
                break;
            }
        }
    
        
        
    }
    
    
    
    return 0;
}

Measured memory_bytes: 1248
#include <iostream>
using namespace std;
int main()
{
    int n[3];
    cin >> n[0] >> n[1] >> n[2];
    if (n[1] < n[0]) swap(n[0], n[1]);
    if (n[2] < n[1]) swap(n[2], n[1]);
    if (n[1] < n[0]) swap(n[0], n[1]);
    cout << n[0] << " " << n[1] << " " << n[2] << "\n";
}



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

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0;i<N;++i) cin >> H[i];
    int tmp=H[0];
    for(int i=1;i<N;++i){
        if(H[i]<tmp) {
            cout << "No" << endl;
            return 0;
        }
        else if(H[i]==tmp);
        else tmp = H[i]-1;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
ans=0
k=[]
for i in range(m):
    k.append(list(map(int,input().split())))
p=list(map(int,input().split()))
for i in range(2**n):
    flg=True
    s=[False for i in range(n)]
    for j in range(n):
        if (i>>j)&1:
            s[j]=True
    for z in range(m):
        tmp=0
        for l in range(1,len(k[z])):
            if s[k[z][l]-1]:
                tmp+=1
        if tmp%2!=p[z]:
            flg=False
    if flg:
        ans+=1
print(ans)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll A, B, N;

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

  std::cin >> A >> B >> N;

  ll max_r = std::min(B - 1, N);
  ll res = A * max_r / B;
  std::cout << res << std::endl;
}


Measured memory_bytes: 3584
#include<cstdio>
int n,i,j,b[3],a=1,P=998244353;
char c;
int main(){
	scanf("%d\n",&n);
	for(i=1;i<=n;++i)a=1ll*a*i%P;
	for(i=1;i<=3*n;++i){
		scanf("%c",&c);
		int &t=b[(c>'B')+(c>'G')],m=1e7;
		for(j=0;j<3;++j)if(b[j]>t&&b[j]-t<m)m=b[j]-t;
		if(m<=n)a=1ll*a*m%P;
		++t;
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
S = input()

s = []

for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        s.append(i)

ans = 0
if len(s) == 1:
    ans = 1

count = 1
for i in range(len(s)-1):
    if s[i] + 1 == s[i+1]:
        count += 1
    else:
        count = 1
    if ans < count:
        ans = count
print(ans)

Measured memory_bytes: 9048
n = int(input())
x = list(map(int, input().split()))
p = int(sum(x)/len(x))
ans1 = sum(map(lambda a:(a-p)**2, x))
ans2 = sum(map(lambda a:(a-p-1)**2, x))

if ans1 > ans2:
    print(ans2)
else:
    print(ans1)


Measured memory_bytes: 3060
fn main() {
    let abt = read_vec::<usize>();
    let a = abt[0];
    let b = abt[1];
    let t = abt[2];
    println!("{}", (t / a) * b);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

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

int main()
{
  long int a[5],k;

  int i;

  scanf("%ld",&k);
  for(i=0;i<5;i++)
    scanf("%ld",&a[i]);

  long int num,min=a[0];

  for(i=1;i<5;i++)
    if(min > a[i])
      min = a[i];

  num = k/min +4;
  if(k%min != 0)
    num++;
  
      printf("%ld\n",num);
  
  return 0;
  
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void push(int);
int pop(void);

int main()
{
int  x, y, n;
char ch[100];

while(scanf("%s", ch) != EOF) {
if(ch[0]=='+'){
x=pop();
y=pop();
push(x+y);
}
else if(ch[0]=='-'){
y=pop();
x=pop();
push(x-y);
}
else if(ch[0]=='*'){
x=pop();
y=pop();
push(x*y);
}

else{
n = atoi(ch);
push(n);
}
}

printf("%d\n", pop());

return 0;
}

int S[100];
int top;

void push(int x){
if(top>=100-1){
  // printf("over flow\n");
}

++top;
S[top] = x;
}

int pop(void){
  if(top==0){
    // printf("under flow\n");
  }
--top;
return S[top+1];
}

Measured memory_bytes: 548
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min(a,b)+min(c,d))





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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(0));
  vector<pair<int, int>> br(m);
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--, b--;
    g.at(a).push_back(b);
    g.at(b).push_back(a);
    br.at(i) = {a, b};
  }
  
  int ans = 0;
  for(int i = 0; i < m; i++){
    vector<int> check(n);
    check.at(0) = 1;
    queue<int> bfs;
    bfs.push(0);
    int a = br.at(i).first, b = br.at(i).second;
    while(bfs.size() > 0){
      queue<int> ne;
      while(bfs.size() > 0){
        ne.push(bfs.front());
        bfs.pop();
      }
      while(ne.size() > 0){
        int now = ne.front();
        ne.pop();
        for(auto k : g.at(now)){
          if(now == a && k == b) continue;
          if(now == b && k == a) continue;
          if(check.at(k)) continue;
          bfs.push(k);
          check.at(k) = 1;
        }
      }
    }
    bool ok = 0;
    for(int j = 0; j < n; j++){
      if(check.at(j) == 0) ok = 1;
    }
    if(ok) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
n,m = map(int, input().split())

abcsl = []
for _ in range(m):
    a,b = map(int, input().split())
    cl = list(map(int, input().split()))
    abcsl.append((a,b,cl))

# dp = [ [10**9]*(2**n) for _ in range(m) ]
dp = [10**9]*(2**n)
dp[0] = 0
for a,b,cl in abcsl:
    b_bit = 0
    for c in cl:
        b_bit += 2**(c-1)
    for i in range(2**n):
        dp[i|b_bit] = min(dp[i]+a, dp[i|b_bit])

if dp[2**n-1] == 10**9:
    print(-1)
else:
    print(dp[2**n-1])

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    int N, count = 0;
    ll K;
    cin >> N >> K;
    vector<ll> Z(100001);


    for(int i=0; i<N; i++) {
        int a, b;
        cin >> a >> b;
        Z[a] += b;
    }
    for(int i=1; i<=100001; i++) {
        if(Z[i] >= K) {
            cout << i << endl;
            return 0;
        }
        K -= Z[i];
    }
}

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

using namespace std;
int n,m;
pair<int,int> ab[100005];
priority_queue<int> que;

bool cmp(const pair<int,int>&a,const pair<int,int>&b)
{
    if(a.first!=b.first) return a.first<b.first;
    return a.second>b.second;
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i)
        scanf("%d%d",&ab[i].first,&ab[i].second);
    sort(ab,ab+n,cmp);
    int j=0;long long ans = 0;
    for(int i=1;i<=m;++i){
        while(j<n&&ab[j].first<=i){
            que.push(ab[j].second);++j;
        }
        if(!que.empty()){
            ans+=que.top();que.pop();
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main(){

  int N;
  cin >> N;
  int A1[N],A2[N];
  for (int i = 0; i < N; i++)
  {
  	 cin >> A1[i];
  }
   for (int i = 0; i < N; i++)
  {
  	 cin >> A2[i];
  }

  int iturn,isum=0,isumprev=0,i;

  for (int iturn = 0; iturn < N; iturn++)
  {
  	isum=0;
  	for (int i = 0; i < iturn+1; i++)
  	{
  		isum += A1[i];
  	}
  	for (int i = iturn; i < N; i++)
  	{
  		isum +=A2[i];
  	}
  	if (isum > isumprev)
  	{
  		isumprev = isum;
  	}
  }

   cout << isumprev;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

static const int MAX = 1000000;

int N;
int K;
int D[10];

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

  for (int i = 0; i < K; i++) cin >> D[i];

  int m = 0;
  for (m = N; m < MAX; m++) {
    int n = m;
    int a;
    bool f = true;
    while (n != 0) {
      a = n % 10;
      n = n / 10;
      for (int j = 0; j < K; j++) {
        if (a == D[j]) {
          f = false;
          n = 0;
          break;
        }
      }
    }
    if (f) break;
  }

  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main() {

	double res;
	long N; cin >> N;
	long odd = 0, even = 0;
	for (int i = 1; i <= N; i++) if (i % 2 == 1) odd++; else even++;

	res = (double)odd / (double)N;

	cout << setprecision(20) << res << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define ll long long
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]==',')
			s[i]=' ';
	}
	cout<<s<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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; }

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

vector<vector<pair<int,int>>> al(100000);
vector<int> dist(100000,INF * -1);
vector<bool> visited(100000,false);

bool bfs(int i,int d){
    if(visited[i] && d!=dist[i]) return false;
    if(visited[i] && d==dist[i]) return true;

    visited[i]=true;
    dist[i]=d;
    REP(j,al[i].size()){
        if(!bfs(al[i][j].first, d+al[i][j].second)) return false;
    }
    return true;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m;
    cin>>n>>m;

    REP(i,m){
        int l,r,d;
        cin>>l>>r>>d;
        --l,--r;
        al[l].push_back(make_pair(r,d));
        al[r].push_back(make_pair(l,-1*d));
    }
    REP(i,n){
        if(!visited[i]){
            if(!bfs(i,0)){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 11136