akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll h, w, k;
    cin >> h >> w >> k;

    string s;
    vvll a(h, vll(w));
    REP(i, h) {
        cin >> s;
        REP(j, w) {
            a[i][j] = int(s[j] - '0');
        }
    }
    ll res = 1e18;
    // 横割りを全探索
    REP(bi, 1LL << h) {
        ll mem = 0; // 縦横の合計分割数
        vll hc(h - 1); // 横割りの位置
        REP(i, h - 1) {
            if ((bi >> i) & 1) {
                mem++;
                hc[i] = 1;
            }
        }
        // ccc[hid] : hid 番目のブロックに含まれるホワイトチョコの個数
        // wpre : 最後に縦に割った位置
        // ng : 1列で K を超過した場合を検出
        vll ccc(h);
        ll wpre = 0, ng = 0;
        REP(j, w) {
            ll hid = 0;
            REP(i, h) {
                ccc[hid] += a[i][j];
                if (hc[i]) hid++;
            }
            REP(i, h) {
                if (ccc[i] > k) {
                    if (j == wpre) ng = 1;
                    else {
                        mem++;
                        wpre = j;
                        REP(i, h) ccc[i] = 0;
                        j--;
                    }
                    break;
                }
            }
            if (ng) break;
        }
        if (ng == 0) chmin(res, mem);
    }
    cout << res << endl;
    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=924844033;
int fact[10000];

int N,K;
int dp[2][2010][2][2];
int d[2010];

int dp2[2010];
int tmp[2010];

inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
    if(a<0)a+=mod;
}

void C(int n){
    memset(dp,0,sizeof(dp));
    dp[0][0][0][0]=1;
    rep(i,n){
        rep(j,i+1){
            rep(k,2){
                rep(l,2){
                    if(i&&k==0){
                        add(dp[(i+1)&1][j+1][l][0],dp[i&1][j][k][l]);
                    }
                    if(i+1!=n){
                        add(dp[(i+1)&1][j+1][l][1],dp[i&1][j][k][l]);
                    }
                    add(dp[(i+1)&1][j][l][0],dp[i&1][j][k][l]);
                    dp[i&1][j][k][l]=0;
                }
            }
        }
    }
    memset(d,0,sizeof(d));
    rep(i,n+1){
        rep(j,2)rep(k,2)add(d[i],dp[n&1][i][j][k]);
    }
}

signed main(){
    fact[0]=1;
    for(int i=1;i<10000;i++)fact[i]=fact[i-1]*i%mod;

    cin>>N>>K;

    dp2[0]=1;
    for(int i=0;i<K;i++){
        int cnt=(N-1-i)/K+1;
        C(cnt);
        memset(tmp,0,sizeof(tmp));
        rep(j,N+1){
            rep(k,cnt+1){
                if(j+k>N)break;
                add(tmp[j+k],dp2[j]*d[k]%mod);
            }
        }
        rep(j,N+1)dp2[j]=tmp[j];
    }

    for(int i=0;i<=N;i++){
        dp2[i]=dp2[i]*fact[N-i]%mod;
    }

    int ans=0;
    rep(i,N+1){
        if(i&1)add(ans,-dp2[i]);
        else add(ans,dp2[i]);
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 640
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        
        
        
        
        
        
        public static void main(String[]args){
                int N=sc.nextInt();
                String[]moji=new String[N];
                boolean hantei=false;
                for(int i=0;i<N;i++){
                        moji[i]=sc.next();
                        String a=moji[i];
                        for(int j=0;j<i;j++){
                                if(a.equals(moji[j])){
                                        hantei=true;
                                }
                        }

                }
                if(hantei){
                        System.out.println("No");
                }else{
                        boolean hanteii=false;
                        for(int i=0;i<N-1;i++){
                                if(moji[i].charAt(moji[i].length()-1)==moji[i+1].charAt(0)){
                                        
                                }else{
                                        hanteii=true;
                                        
                                }
                        }
                        if(hanteii){
                                System.out.println("No");
                        }else{
                                System.out.println("Yes");
                        }
                }
                

                


                
        }
        
        
        

		
	
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll p[N];
int main()
{
	ll n;
	cin >> n;
	ll c = 1;
	p[0] = 1;
	p[1] = 26;
	while(n > p[c])
		n -= p[c],
		c ++,
		p[c] = p[c-1]*26;
	string ans(c, 'a');
	for(int i = 0; i < c; i ++)
	{
		ans[i] = 'a';
		char ii = 'a';
		ll trash = 0;
		for(int j = 'a'; j < 'z'; j ++)
		{
			ll q = p[c - i - 1] * (j-'a' + 1);
			if(q < n)
				trash = q,
				ii = j+1;
		}
		n -= trash;
		ans[i] = ii;
	}
	cout << ans;
	





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

int n;
using ll = long long int;
ll L[100];

ll lucas(int i) {
  if (L[i] > 0) return L[i];
  if (i == 0) return 2;
  else if (i == 1) return 1;
  else {
    return L[i] = lucas(i - 1) + lucas(i - 2);
  }
}

int main(void){
    // Here your code !
    scanf("%d", &n);
    ll ans = lucas(n);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)

int main(){
    int a;
    cin >>a;
cout << (a*(a+1))/2 <<endl;
    return 0;
}


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

posibilities = []

for _ in range(n):
    book = list(map(int, input().split()))
    b = posibilities[:]
    for i in b:
        posibilities.append([z+y for z, y in zip(i, book)])
    posibilities.append(book)

posibilities.sort(key=lambda i: i[0])

for i in posibilities:
    for j in i[1:]:
        if j < x:
            break
    else:
        print(i[0])
        break
else:
    print(-1)


Measured memory_bytes: 11572
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <stdio.h>
#include <algorithm>
#define INF 100000000
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)


int main(){
    int n;
    cin >> n;
    int ans = INF;
    rep(i, n){
        ll x;
        cin >> x;
        int ret = 0;
        while (x % 2 == 0){
            x /= 2;
            ret += 1;
        }
        ans = min(ans, ret);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
#define ll long long
using namespace std;
typedef pair<int,int>P;
signed main() {
    int r, g, b, n;
    int ans = 0;
    cin >> r >> g >> b >> n;
    rep(i, 3000 / r + 1) {
        rep(j, 3000 / g + 1) {
            if ((n - (r * i + g * j)) % b == 0 && (n - (r * i + g * j)) >= 0) {
                ans++;
            }
        }
    }
    cae
    r0
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const int mod = 1000000007;

struct Combination {
  std::vector<long long> fac, finv, inv;
  int mod;

  Combination(int max_n, int _mod) {
    fac = finv = inv = std::vector<long long>(max_n + 10, 0);
    mod = _mod;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_n + 10; i++) {
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }

  long long mod_comb(int n, int k) {
    if (n < k || n < 0 || k < 0) {
      return 0;
    }
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
};

long long mod_pow(long long x, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  int K;
  string S;

  std::cin >> K >> S;

  int N = S.length();

  Combination comb(N + K + 100, mod);

  long long ans = 0;
  for (int i = N; i <= N + K; i++) {
    ans += comb.mod_comb(i - 1, N - 1) * mod_pow(25, i - N, mod) % mod * mod_pow(26, N + K - i, mod) % mod;
    ans %= mod;
  }
  std::cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 51144
from collections import Counter

n,k=map(int,input().split())
a=list(map(int,input().split()))
c=Counter(a)

tmp=[]
for key,v in c.items():
    tmp.append(v)
tmp.sort()

ans=0
for i in range(len(tmp)-k):
    ans+=tmp[i]
print(ans)


Measured memory_bytes: 32568
#include<iostream>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int,int>;

void solve_A(){
   string s, t;
   cin >> s >> t;
   bool result = true;
    for (size_t i = 0; i < s.size(); i++)
    {
        if(s[i] != t[i]){
            result = false;
        }
    }
    cout << (result ? "Yes" : "No") << endl;
    
}

void solve_B(){
    
}

void solve_C(){
    
}

void solve_D(){
    
}

void solve_E(){
    
}

void solve_F(){
    
}

int main(){
    solve_A();
    //solve_B();
    //solve_C();
    //solve_D();
    //solve_E();
    //solve_F();
    return 0;
}

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

int main(){
   
   int N,b_num=0,ans=0,i=0;
   cin >> N;
   int data[N];
   
   for(int i=0;i<N;i++) cin >> data[i];
   for(int i=0;i<N;i++) data[i]--;
  
   while(1){
       ans++;
       if(data[b_num] == 1) break;
       int next = data[b_num];
       //if(data[next] == b_num){ans = -1; break;}
       if(i > 1000000){ans = -1; break;}
       b_num = next;
       i++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 3948
#pragma gcc optimize("Ofast")
#include <cstdio>
#include <queue>
#include <bitset>
using namespace std;

bitset <100> maskdiv[100], invmaskdiv[100], full;
int n;
vector <int> a;
long long ans=0;
//mulai dari pos=1, bukan pos=0 because smashing first gem --> ans=0 --> already considered
//"return bruteForcePrune(something)" actually returns nothing (void)
void bruteForcePrune(long long potential, long long curr=0, bitset <100> currmask=full, int pos=1) {
	//potential is an upperbound for the answer
	if(potential<=ans){//prune
		return;
	}
	//base case
	if(pos==n){
		ans=curr;
		return;
	}
	//gem already smashed
	if(!currmask[pos]){
		return bruteForcePrune(potential, curr, currmask, pos+1);
	}
	//tidak ada gunanya smash gem yg non-negative
	if(a[pos]>=0){
		return bruteForcePrune(potential, curr+a[pos], currmask, pos+1);
	}
	//keep the bad gem
	bruteForcePrune(potential+a[pos], curr+a[pos], currmask, pos+1);
	//smash the bag gem (and some other gems after)
	//maskdiv and invmaskdiv are precomputed so no time is wasted on ~ operator
	bitset <100> toDelete=currmask&maskdiv[pos];
	for(int i = pos+1;i < n;i ++){
		if(toDelete[i]){
			//potential goes down when a positive gem is smashed
			if(a[i]>0){
				potential-=a[i];
			}
		}
	}
	return bruteForcePrune(potential, curr, currmask&invmaskdiv[pos], pos+1);
}
int main(){
	//precompute masks
	for(int i = 0;i < 100;i ++){
		for(int j = i+1;j <= 100;j += i+1){
			maskdiv[i][j-1]=true;
		}
		invmaskdiv[i]=~maskdiv[i];
	}
	//cuma kepake sekali sih ini
	full.set();
	//input
	scanf("%d", &n);
	a.resize(n);
	long long fullPotential=0;
	for(int&i:a){
		scanf("%d", &i);
	}
	//if gems numbered 51-100 are negative, they definitely won't be considered
	for(int i = n/2;i < n;i ++){
		a[i]=max(a[i], 0);
	}
	for(int i = 1;i < n;i ++){
		fullPotential+=max(a[i], 0);
	}
	bruteForcePrune(fullPotential);
	printf("%lld\n", max(ans+a[0], 0ll));
}

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

using namespace std;

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int m, d;
	cin >> m >> d;
	
	int ans = 0;
	
	for(int i = 1; i <= m; i++)
	{
		for(int j = 10; j <= d; j++)
		{
			int p1 = j / 10;
			int p2 = j % 10;
			
			if(p1 * p2 == i && p1 >= 2 && p2 >= 2 && p1 <= 9 && p2 <= 9)
				ans++;
		}
	}
	
	cout << ans;
}

Measured memory_bytes: 256
s = gets.chomp.split("")
digit = s.length - 1

plus_num = 2 ** digit

plus_ary = Array.new
plus_num.times do |i|
  ary = ("%0#{digit}b" % i).split("")
  plus_ary << ary
end

answer = 0
plus_ary.each do |a|
  formula = ""
  s.length.times do |i|
    formula += s[i]
    if a[i] == "1"
      formula += "+"
    end
  end
  answer += eval(formula)
end

puts answer

Measured memory_bytes: 2556
import itertools

H,W,K = map(int,input().split())

mas = [input() for i in range(H)]

mas_int = [[0 for i in range(W)] for j in range(H)]
for i in range(H):
    for j in range(W):
        if mas[i][j] == '.':
            mas_int[i][j]= 0
        else:
            mas_int[i][j] = 1

H_pers = itertools.product([0,1],repeat=H)

count = 0
for H_per in H_pers:
    W_pers = itertools.product([0, 1], repeat=W)
    for W_per in W_pers:
        mas_ex = mas_int
        mas_sum = 0
        for i in range(H):
            for j in range(W):
                if (H_per[i] == 0) & (W_per[j]==0):
                    mas_sum += mas_int[i][j]

        if mas_sum == K:
            count += 1

print(count)

Measured memory_bytes: 73408
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int a,b,c;
int main()
{
	read(a);
	read(b);
	read(c);
	int mx=max(a,max(b,c));
	if((3*mx-a-b-c)&1)	mx++;
	printf("%d\n",(3*mx-a-b-c)/2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int,int> Pa;

int main(){
    int M;
    cin >> M;
    vector<int> X(M),Y(M);
    for(int i=0;i<M;i++) cin >> X[i] >> Y[i];
    auto islinear = [&](Pa& p1,Pa& p2){
        int dx1 = X[p1.second]-X[p1.first];
        int dy1 = Y[p1.second]-Y[p1.first];
        int dx2 = X[p2.second]-X[p2.first];
        int dy2 = Y[p2.second]-Y[p2.first];
        return dx1*dy2==dx2*dy1;
    };
    vector<int> used(M,0);
    vector<pair<int,int>> P;
    int ans = 0;
    int c = 0;
    const auto dfs = [&](auto& self,int dep) -> void{
        if(P.size()==M/2){
            int cnt = 0;
            c++;
            for(int i=0;i<M/2;i++) for(int j=i+1;j<M/2;j++) cnt += islinear(P[i],P[j]);
            ans = max(ans,cnt);
            return;
        }
        vector<int> v;
        for(int i=0;i<M;i++) if(!used[i]) v.push_back(i);
        for(int i=0;i<M-1-2*dep;i++){
            P.push_back({v[0],v[i+1]});
            used[v[0]] = used[v[i+1]] = 1;
            self(self,dep+1);
            P.pop_back();
            used[v[0]] = used[v[i+1]] = 0;
        }
    };
    dfs(dfs,0);
    cout << ans << endl;
}


Measured memory_bytes: 3148
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;

int main(){
	
	long long t;
	cin>>t;
	int cnt=0;
	long long cur=100;
	while(cur<t){
		cur=(long long)(cur*(1.01));
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


	


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	// ?????????????????°??????????????????
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r ;
	if (x < r || y < r || x >(w - r) || y >(h - r)) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


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

int main() 
{
	int a, b, c;

	cin >> a >> b >> c;

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

	if ((a == b && b == c - 1) || (a == b - 1 && b - 1 == c) || (a - 1 == b && b == c))
	{
		cout << 1 << endl;
		return 0;
	}
	else if ((a == b && b == c + 2) || (a == b + 2 && b + 2 == c) || (a + 2 == b && b == c))
	{
		cout << 1 << endl;
		return 0;
	}

	int min, token, ans = 0;
	while (1)
	{
		min = a;
		token = 1;
		if (b < min) min = b, token = 2;
		if (c < min) min = c, token = 3;

		if (token == 1) a += 2;
		if (token == 2) b += 2;
		if (token == 3) c += 2;

		ans++;

		//cout << a << " " << b << " " << c << endl;

		if ((a == b && b == c - 1) || (a == b - 1 && b - 1 == c) || (a - 1 == b && b == c))
		{
			ans++;
			break;
		}

		else if ((a == b && b == c + 2) || (a == b + 2 && b + 2 == c) || (a + 2 == b && b == c))
		{
			ans++;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

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

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;

/** /////////// ** Code ** /////////// **/

const int N=100100;
int a[N];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0 ; i<n ; i++)
        scanf("%d",&a[i]);


    int ans=0 , cnt=1;
    for(int i=1 ; i<n ; i++){
        if(a[i] == a[i-1]) cnt++;
        else{
            ans+=cnt/2;
            cnt=1;
        }
    }

    ans+=cnt/2;

    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,m;
  cin >>n>>m;
  ll k,l,p[m];
  ll s[m][n];
  for(ll i=0;i<m;i++) for(ll j=0;j<n;j++) s[i][j]=0;
  for(ll i=0;i<m;i++){
    cin >>k;
    for(ll j=0;j<k;j++){
      cin >>l;
      s[i][l-1]=1;
    }
  }
  for(ll i=0;i<m;i++) cin >>p[i];
  ll fl,ans=0;
  for(ll i=0;i<(1<<n);i++){
    fl=0;
    for(ll k=0;k<m;k++){
      ll sum=0;
     for(ll j=0;j<n;j++){
       if(i&(1<<j)){
         if(s[k][j]==1) sum++;
       }
     }
     if(sum%2!=p[k]) {
       fl=1;
       break;
     }
    }
    if(fl==0) ans++;
  }
  cout <<ans<<endl;
}


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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1, 0);
    int mn = INT_MAX;
    int idx = -1;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(mn > a[i]){
            mn = a[i];
            idx = i;
        }
    }
    int ans = 0;
    for(int i = 1; i < n; i += k - 1){
        ans++;
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    int k = 0;

    cin >> n;

    vector<int> p(n), p1(n);

    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        p1[i] = p[i];
    }

    sort(p.begin(), p.end());

    for (int i = 0; i < n; i++)
    {
        if (p[i] != p1[i])
        {
            k++;
        }
    }

    if (k <= 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const double EPS = 1e-9;

class Point{
    public: 
    long double x,y;
    
    Point(long double x = 0.0, long double y = 0.0): x(x), y(y) {}
    
    Point operator + (Point p) {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (long double a) {
        return Point(x*a, y*a);
    }
    Point operator / (long double a) {
        return Point(x/a, y/a);
    }
    bool operator < (const Point &p) const {
        return (x != p.x ? x < p.x : y < p.y);
    }
    bool operator == (const Point &p) const {
        return fabsl(x - p.x) < EPS && fabsl(y - p.y) < EPS;
    }
    
    long double abs() {
        return sqrt(norm());
    }
    
    long double norm() {
        return x*x + y*y;
    }
    
    long double dot(Point p) {
        return x*p.x + y*p.y;
    }
    
    long double cross(Point p) {
        return x*p.y - y*p.x;
    }
};

class Segment{
    public: 
    Point p,q;
    long double grad;
    
    Segment(Point p, Point q) {
        this->p = p;
        this->q = q;
        this->grad = (q.y-p.y)/(q.x-p.x);
    }
    
};

Point projection(Segment s, Point p){
    Point base = s.q - s.p;
    long double t = base.dot(p-s.p) / base.abs();
    return s.p + base * (t / base.abs());
}

int main(){
    int n;
    long double x,y;
    Point p[2];
    rep(2){
        scanf("%Lf %Lf", &x, &y);
        p[i] = Point(x, y);
    }
    Segment s = Segment(p[0], p[1]);

    cin >> n;

    rep(n){
        scanf("%Lf %Lf", &x, &y);
        Point q = Point(x, y);
        Point ans = projection(s, q);
        printf("%.10Lf %.10Lf\n", ans.x, ans.y);
    }

}



Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String O = sc.next();
		String E = sc.next();
		int N1 = O.length();
		int N2 = E.length();
		String word = "";
		if(N1 == N2) {
			for(int i = 0 ; i < N1 ; i++) {
				word += String.valueOf(O.charAt(i));
				word += String.valueOf(E.charAt(i));
			}
		} else {
			for(int i = 0 ; i < N1 ; i++) {
				word += String.valueOf(O.charAt(i));
				if(i < N1 - 1) {
					word += String.valueOf(E.charAt(i));
				}
			}
		}
		System.out.println(word);
	}
}

Measured memory_bytes: 20948
#include<iostream>
#include<map>

using namespace std;

int main(){
        int ticket;
        int num[4];
        cin >> ticket;
        for(int i=0;i<4;i++){
                num[3-i] = ticket%10;
                ticket /= 10;
        }
        int sum = num[0];
        char op[3];
        for(int bit=0;bit< 1<<3;bit++){
                sum = num[0];
                for(int i=0;i<3;i++){
                        if(bit & 1<<i){
                                op[i] = '+';
                                sum += num[i+1];
                        }else{
                                op[i] = '-';
                                sum -= num[i+1];
                        }
                }
//              cout << sum << endl;
                if(sum == 7){
                        for(int i=0;i<3;i++){
                                cout << num[i] << op[i];
                        }
                        cout << num[3] << "=7" << endl;
                        return 0;
                }

        }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

vector<bool> primeno(100010, true);
void Eratosthenes(int N) {
    primeno.at(0) = primeno.at(1) = false;
    int limit = sqrt(N);
    for(int i = 2; i < limit; ++i) {
        if(primeno.at(i)) {
            for(int j = 0; i*(j+2) < N; ++j) {
                primeno.at(i*(j+2)) = false;
            }
        }
    }
}

int MAX = 100000;

int main() {
    int n; cin >> n;
    Eratosthenes(MAX);
    vector<int> A(n, 0);
    int now = 0;
    for(int i = 0; i <= 55555; ++i) {
        if(primeno.at(i)) {
            if((i%5)==1) {
                A.at(now) = i;
                now++;
            }
        }
        if(now == n) break;
    }

    for(int i = 0; i < n; ++i) {
        if(i == n-1) cout << A.at(i) << endl;
        else cout << A.at(i) << " ";
    }
}

Measured memory_bytes: 256
#include"iostream"
#include"algorithm"
using namespace std;

long dp[60][60];

long combination(int n, int r)
{
	if (n == r) return dp[n][r] = 1;
	if (r == 0) return dp[n][r] = 1;
	if (r == 1) return dp[n][r] = n;
	if (dp[n][r]) return dp[n][r];
	return dp[n][r] = combination(n - 1, r) + combination(n - 1, r - 1);
}

int main()
{
	int n, p;
	cin >> n >> p;
	int a[60];
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] = a[i] % 2;
		sum += a[i];
	}

	long long ans0 = 1;
	long long ans1 = 0;
	for (int i = 0; i < n - sum; i++)ans0 *= 2;
	if (p == 0)
	{
		for (int i = 0; i < sum / 2 + 1; i++)	ans1 += combination(sum, 2 * i);
	}
	else
	{
		for (int i = 0; i < (sum + 1) / 2; i++)ans1 += combination(sum, 2 * i + 1);
	}
	cout << ans0 * ans1 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Program
{
	public static void Main()
	{
		var s = Console.ReadLine();
		int g = 0, p = 0;
		int score = 0;
		for (int i = 0; i < s.Length; i++)
		{
			if (s[i] == 'g')
			{
				if (g >= p + 1)
				{
					++p;
					++score;
				}
				else
				{
					++g;
				}
			}
			else
			{
				if (g >= p + 1)
				{
					++p;
				}
				else
				{
					++g;
					--score;
				}
			}
		}
		Console.WriteLine(score);
	}
}

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

std::string O;        //奇数番目の文字列
std::string E;        //偶数番目の文字列
int i=0;                //カウント変数

int main()
{
  std::getline(std::cin, O);
  std::getline(std::cin, E);

  while(true){
    std::cout << O.at(i) << E.at(i);
    ++i;
    if(i==(E.length()))
      break;
  }
  if(O.length() > E.length())
    std::cout << O.at(i);

  std::cout << '\n';
  return (0);
}


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

int main()
{
	string a, b;
	cin >> a >> b;
	if (a[0] == b[2] && b[0] == a[2]&& a[1] == b[1])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int j=0; j<n; j++){
    cin >> b[j];
  }
  for(int k=0; k<n-1; k++){
    cin >> c[k];
  }
  
  int sum=0;
  for(int m=0; m<n; m++){
    sum += b[a[m]-1];
    if(a[m+1]-a[m]==1){
      sum += c[a[m]-1];
    }
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,m,q,a[2010][2010],snode[2010][2010],sedge[2010][2010],le[2010][2010],up[2010][2010];
int main(){
	n=read();m=read();q=read();int i,j,l1,l2,r1,r2;char s[2010];
	for(i=1;i<=n;i++){
		scanf("%s",s);
		for(j=1;j<=m;j++){
			a[i][j]=(s[j-1]=='1');
			snode[i][j]=snode[i][j-1]+snode[i-1][j]-snode[i-1][j-1]+a[i][j];
			sedge[i][j]=sedge[i][j-1]+sedge[i-1][j]-sedge[i-1][j-1];
			if(a[i][j]) sedge[i][j]+=a[i][j-1]+a[i-1][j];
			up[i][j]=up[i][j-1]+(a[i][j]&a[i-1][j]);
			le[i][j]=le[i-1][j]+(a[i][j]&a[i][j-1]);
//			cout<<i<<' '<<j<<' '<<snode[i][j]<<' '<<sedge[i][j]<<'\n';
		}
	}
	while(q--){
		l1=read();r1=read();l2=read();r2=read();
		printf("%d\n",snode[l2][r2]-snode[l1-1][r2]-snode[l2][r1-1]+snode[l1-1][r1-1]-(sedge[l2][r2]-sedge[l1-1][r2]-sedge[l2][r1-1]+sedge[l1-1][r1-1])+(up[l1][r2]-up[l1][r1-1])+(le[l2][r1]-le[l1-1][r1]));
	}
}

Measured memory_bytes: 80640
//In the name of God
//SMani24
#include<bits/stdc++.h>
using namespace std;

int n, ans;
string s;

int main() {
	cin >> n >> s;
	for (int i = 0; i <= n - 3; i++) {
		string t;
		for (int j = i; j < i + 3; j++)
			t += s[j];
		if (t == "ABC")
			ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define inf 1e17
#define f(i,a,b) for(i=a;i<b;i++)
ll m = 1e9+7;
using namespace std;
//cout<<setprecision(9)<<m/(1<<q);
//__builtin_popcount();
//next_permutation(abc.begin(), abc.end());
//(string(n, abc[0]);
//str.find(s);
//ll a[1000001];
ll dp[(1<<21)];
ll umin(ll a,ll b)
{
  if(a<b)
    return a;return b;
}
string toBinary(ll n)
{
    string r;
    while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
    return r;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n;cin >> n;
	ll a[n][n];
	for(ll i=0;i<n;i++)
		for(ll j=0;j<n;j++)
			cin >> a[i][j];
		//cout << (1<<n);
		
		for(ll i=0;i<(1<<n);i++)dp[i]=0;
		dp[0]=1;
		for(ll i = 1;i<(1<<n);i++)
		{
			
			//cout << i << "\n";
			ll g=__builtin_popcount(i);
			//cout << "g " << g << "\n";
			
			for(ll j=0;j<n;j++)
			{
				if(a[g-1][j] and (i&(1<<(n-j-1))))
				{
					//cout << "a : " << g-1 << " " << j << "is true \n";
					//cout << "dp[" << (i^(1<<(n-j-1))) << "]is" << dp[i^(1<<(n-j-1))];
					dp[i]+=dp[i^(1<<(n-j-1))];
					dp[i]%=m;
					//cout << "dp[" << i << "]is " << dp[i];
				}
			}
		}
		/*cout << "\n dp table :\n";
		for(ll i=0;i<(1<<n);i++)
			cout << dp[i] << " ";
		cout << "\n";*/
		cout << dp[(1<<n)-1];
	return 0;
}


Measured memory_bytes: 16640
#include <iostream>

long long int Fibo(int n)
{
    long long int a = 1;
    long long int pre = 1;
    long long int prepre = 1;
    for(int i = 2; i <= n; ++i){
        a = pre + prepre;
        prepre = pre;
        pre = a;
    }
    return a;
}
int main(){
    int n;
    std::cin >> n;
    std::cout << Fibo(n) << std::endl;
    return 0;
}

Measured memory_bytes: 3096
#pragma G++ optimize(3)
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
int main(){
	int a, b, c;
	int t = 0;
	int x;
	cin >> a >> b >> c >> x;
	for(int i = 0; i <= a; i++){
		for(int j = 0; j <= b; j++){
			for(int k = 0; k <= c; k++){
				if(i*500 + j*100 + k*50 == x) t++;
			}
		}
	}
	cout << t;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int n, a, b;

    n = sc.nextInt();
    a = sc.nextInt();
    b = sc.nextInt();
	
    int train = n*a;
    if(train <= b){
      System.out.println(train);
    }
    else{
      System.out.println(b);
    }
  }
}

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

int main(){
   int m,f,r;
   while(1){
      cin >> m >> f >> r;
      if(m==-1 && f==-1 && r==-1) break;

      if(m==-1 || f==-1) printf("F\n");
      else if(m+f>=80) printf("A\n");
      else if(m+f>=65) printf("B\n");
      else if(m+f>=50) printf("C\n");
      else if(m+f>=30){
         if(r>=50) printf("C\n");
         else printf("D\n");
      }
      else printf("F\n");
   }

   return 0;
}



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

int main() {
  double x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  double kyori=0;
  kyori=sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
  cout << fixed<<setprecision(12)<<kyori<<endl;
  return 0;
}


Measured memory_bytes: 3276
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
    long n = long.Parse(Console.ReadLine());
    long[][] nums = new long[n][];//値、位置
    long answer = 0;
    
		for(int i = 0; i < n; i++)
    {
      nums[i] = new long[10];
      nums[i][0] = long.Parse(Console.ReadLine());
      nums[i][1] = i;
    }
    Array.Sort(nums, (a, b) => a[0].CompareTo(b[0]));//ソート
    for(int i = 0; i < n; i+=2)
    {
      if(nums[i][1] % 2 == 1) answer++;
    }

    Console.WriteLine(answer);
	}
  
}

Measured memory_bytes: 30808
#include <stdio.h>

int main(void)
{
	int sec;
	int h;
	int m;
	int s;
	
	scanf("%d", &sec);
	
	h = sec / 3600;
	m = (sec - h * 3600) / 60;
	s = sec - h * 3600 - m * 60;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return (0);
}

Measured memory_bytes: 592
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys
    import heapq
    # from math import *
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)
    INF = int(1e9)
    mod = int(1e9)+7

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    dp = [[0] * (k + 1) for _ in range(n + 1)]
    dp[0][0] = 1

    for i in range(n):
        dpsum = [0] * (k + 2)
        for l in range(k + 1):
            dpsum[l + 1] = dpsum[l] + dp[i][l]
            dpsum[l + 1] %= mod
        for j in range(k + 1):
            dp[i + 1][j] = (dpsum[j + 1] - dpsum[max(0, j - a[i])]) % mod
    print(dp[n][k])
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 175132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

const int INF = 1e9;

using pii = pair<int,int>;

using Graph = vector<vector<pii>>;
int n, m, Q;
Graph g;

int u[200010], v[200010], er[200010];
pii dist[100010];
int ans[200010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> n >> m >> Q;
    g.assign(n, {});
    rep(i, m){
        cin >> u[i] >> v[i];
        --u[i]; --v[i];
        er[i] = INF;
    }

    rep(i, Q){
        int r;
        cin >> r;
        --r;
        er[r] = i;
    }

    rep(i, m){
        int &u = ::u[i], &v = ::v[i], &e = er[i];
        g[u].emplace_back(v, e);
        g[v].emplace_back(u, e);
    }

    using state = tuple<int,int,int>;
    priority_queue<state> q;
    rep(i, n) dist[i] = pii(INF, -INF);
    dist[0].first = 0;
    dist[0].second = INF;
    q.emplace(0, INF, 0);
    while(q.size()){
        int cd, ct, cv;
        tie(cd, ct, cv) = q.top();
        cd = -cd;
        q.pop();
        if(dist[cv].first < cd) continue;
        for(auto &e : g[cv]){
            int nd = cd + 1, nt, nv;
            tie(nv, nt) = e;
            nt = min(ct, nt);
            if(dist[nv].first > nd || (dist[nv].first == nd && dist[nv].second < nt)){
                dist[nv] = pii(nd, nt);
                q.emplace(-nd, nt, nv);
            }
        }
    }

    rep(i, n){
        if(dist[i].second != INF) ++ans[dist[i].second];
    }

    int cur = 0;
    rep(i, Q){
        cur += ans[i];
        cout << cur << '\n';
    }
}

Measured memory_bytes: 15776
#include<bits/stdc++.h>
 
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
using namespace std;
 
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
LL w,h,x,y;
int main(){
	ios::sync_with_stdio(false);
	cin>>w>>h>>x>>y;
 
	if(x==0&&y==0){
		cout<<1.0*w*h/2<<' '<<0<<endl;
 
		return 0;
	}
	if(x==0&&y==h){
		cout<<1.0*w*h/2<<' '<<0<<endl;
 
		return 0;
	}
	if(x==w&&y==h){
		cout<<1.0*w*h/2<<' '<<0<<endl;
		return 0;
	}
	if(x==w&&y==0){
		cout<<1.0*w*h/2<<' '<<0<<endl;
		return 0;		
	}
	if(w%2==0&&h%2==0&&x==w/2&&y==h/2){
		cout<<w*h/2<<' '<<1<<endl;
	}else if(w%2==0&&x==w/2){
		cout<<w*h/2<<' '<<0<<endl;
	}else if(h%2==0&&y==h/2){
		cout<<w*h/2<<' '<<0<<endl;
	}else{
		double mx=1.0*w/2,my=1.0*h/2;
		double k=(my-y)/(mx-x);//Y-y=k*(X-x)
		double up=(h-y)/k+x;
		double down=(0-y)/k+x;
		double le=k*(-x)+y;
		double ri=k*(w-x)+y;
		double ans=1e19;
		if(y<mx){
			if(x<mx){
				ans=min((down+up)*h/2,(2*w-down-up)*h/2);
			}else{
				ans=min((down+up)*h/2,(2*w-down-up)*h/2);
			}
		}else{
			ans=min((le+ri)*w/2,(2*h-le-ri)*w/2);
		}
		cout<<ans<<' '<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = input()

i = 0
li = list()
while i < len(s):
    lc = 0
    while i < len(s) and s[i] == '<':
        lc += 1
        i += 1
    gc = 0
    while i < len(s) and s[i] == '>':
        gc += 1
        i += 1
    li.append((lc, gc))

ans = 0
for e in li:
    g = max(e)
    l = min(e)
    l = l - 1 if l > 0 else 0
    ans += int(g * (g + 1) / 2 + l * (l + 1) / 2)
print(ans)

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


int main() {
  string s_; cin>>s_;
  int n=s_.size();
  int ans=n;
  if(count(s_.begin(),s_.end(),s_.at(0))==n||s_.size()==1){ans=0;}
  else{
  rep(i,(n+1)/2){
    string s=s_;
    
    while(true){
    
      rep(j,s.size()){
        if(s.at(j)==s.at(i) && j>0){s.at(j-1)=s.at(i);}
      }
      s.erase(s.size()-1);//cout<<s<<endl;
      int m=s.size();
      
      if(count(s.begin(),s.end(),s.at(i))==m){
        ans=min(ans,n-m);
        break;
      }
    
    }
  }
  }
  cout<<ans;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,v;
    cin>>n;
    int x[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>v;
        x[v]=i;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<x[i]<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 1152
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

a = ns()
n = len(a)

cnt = Counter(a)

eqs = 0
for k,v in cnt.items():
    eqs += v*(v-1)//2
    
print(1 + n*(n-1)//2 - eqs)

Measured memory_bytes: 3880
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

an = [a, b, c, d, e]
an.sort()

if an[4] - an[0] > k:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
 #define int long long
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;};



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

  int a, b;
  cin >> a >> b;
  if(a > 9 || b > 9) cout << -1 << endl;
  else cout << a * b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <map>
#include <math.h>
#include <stack>
#include <math.h>
using namespace std;
typedef long long int ll;

ll a,b,c,d;
map<ll,ll> mp;

ll solve(ll n){
	if(n==0)return 0;
	if(mp.count(n)){
		return mp[n];
	}
	ll &res=mp[n];
	if(1e18/n>d)res=n*d;
	else res=1e18;
	res=min(res,solve(n/2)+a+(n%2)*d);
	res=min(res,solve(n/2+1)+a+(2-n%2)*d);
	res=min(res,solve(n/3)+b+(n%3)*d);
	res=min(res,solve(n/3+1)+b+(3-n%3)*d);
	res=min(res,solve(n/5)+c+(n%5)*d);
	res=min(res,solve(n/5+1)+c+(5-n%5)*d);
	return res;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int q; cin >> q;
	while(q--){
		ll n;
		cin >> n >> a >> b >> c >> d;
		mp.clear();
		printf("%lld\n",solve(n));
	}
}


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

int v[(int)1e5+5], n;

int main(){
  cin>>n;
  int c=1, s=0;

  cin>>v[0];
  for(int i=1;i<n;i++){
    cin>>v[i];
    if(v[i-1]>=v[i])
        c++;
    else{
        s=max(s, c);
        c=1;
    }
  }

  cout<<max(s, c)-1;
}


Measured memory_bytes: 640
/*
 * Author       : YangDavid
 * Created Time : 2019年09月21日 星期六 20时03分06秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 1111;
int h, w, A, B;
set<pii, greater<pii> > cols;
char s[maxn][maxn];
int main() {
    scanf("%d%d%d%d", &h, &w, &A, &B);
    memset(s, '0', sizeof s);
    bool solved = false;
    for(int ca = 0; ca <= h && !solved; ++ca) {
        for(int cb = 0; cb <= w && !solved; ++cb) {
            if(ca*A+(h-ca)*(w-A) != cb*B+(w-cb)*(h-B)) continue;
            for(int i = 1; i <= cb; ++i) cols.emplace(B, i);
            for(int i = cb + 1; i <= w; ++i) cols.emplace(h-B, i);

            for(int i = 1; i <= ca; ++i) {
                set<pii> nxt;
                rep(j, A) {
                    assert(!cols.empty());
                    s[i][cols.begin()->second] = '1';
                    nxt.emplace(cols.begin()->first-1, cols.begin()->second);
                    cols.erase(cols.begin());
                }
                for(auto g : nxt) cols.insert(g);
            }
            for(int i = ca + 1; i <= h; ++i) {
                set<pii> nxt;
                rep(j, w - A) {
                    assert(!cols.empty());
                    s[i][cols.begin()->second] = '1';
                    nxt.emplace(cols.begin()->first-1, cols.begin()->second);
                    cols.erase(cols.begin());
                }
                for(auto g : nxt) cols.insert(g);
            }
            solved = true;
        }
    }
    if(!solved) { puts("-1"); exit(0); }
    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j)
            printf("%c", s[i][j]);
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int count=Integer.valueOf(sc.nextLine());
		List<Integer> numbers=Arrays.asList(sc.nextLine().split(" "))
				.parallelStream()
				.map(Integer::parseInt)
				.collect(Collectors.toList());
		int result=0;
		while(numbers.parallelStream().allMatch(i->i%2==0)) {
			result++;
			numbers=numbers.parallelStream().map(i->i/2).collect(Collectors.toList());
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 29140