akhauriyash/Code-Regression huggingface dataset:
s = list(input())
x, y = map(int, input().split())
a = [[], []]
b = [0, 0]
j = 0
cnt = 0
for i in s:
    if i == "F":
        if j == 0:
            x -= 1
        else:
            cnt += 1
    else:
        if cnt > 0:
            a[j % 2].append(cnt)
            b[j % 2] += cnt
        j += 1
        cnt = 0
if cnt > 0:
    a[j % 2].append(cnt)
    b[j % 2] += cnt
x, y = abs(x), abs(y)
lx, ly = len(a[0]), len(a[1])
if b[0] < x or b[1] < y:
    print("No")
    exit()
if lx > 0:
    dp = [[0] * (2 * b[0] + 1) for _ in range(lx + 1)]
    dp[0][b[0]] = 1
    for i in range(lx):
        for j in range(2 * b[0] + 1):
            if dp[i][j] == 1:
                dp[i + 1][j + a[0][i]] = 1
                dp[i + 1][j - a[0][i]] = 1
    if dp[lx][b[0] + x] == 0:
        print("No")
        exit()
if ly > 0:
    dp = [[0] * (2 * b[1] + 1) for _ in range(ly + 1)]
    dp[0][b[1]] = 1
    for i in range(ly):
        for j in range(2 * b[1] + 1):
            if dp[i][j] == 1:
                dp[i + 1][j + a[1][i]] = 1
                dp[i + 1][j - a[1][i]] = 1
    if dp[ly][b[1] + y] == 0:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 188264
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(a: usize, b: usize, c: usize, d: usize);

    let ab: u128 = (b - (a - 1)) as u128;

    let cd = yukuriddo(c, d) as u128;

    let abcd = b as u128 / cd - (a - 1) as u128 / cd;

    let ans = (b / c - (a - 1) / c) as u128 + (b / d - (a - 1) / d) as u128 - abcd;

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

fn yukuriddo(a_: usize, b_: usize) -> usize {
    let mut a = a_;
    let mut b = b_;
    let x = a * b;
    let tmp;

    /* 自然数 a > b を確認・入替 */
    if a < b {
        tmp = a;
        a = b;
        b = tmp;
    }
    /* ユークリッドの互除法 */
    let mut r = a % b;
    while r != 0 {
        a = b;
        b = r;
        r = a % b;
    }

    return x / b;
}


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

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

const int MAXN = 1000005;
int num[MAXN];

int main() {
  for(int i = 0; i < MAXN; ++i) {
    num[i] = isPrime(i);
  }
  for(int i = 1; i < MAXN; ++i) {
    num[i] += num[i-1];
  }
  int n;
  while(cin >> n) {
    cout << num[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 5068
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define N 5002
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n;
string s;
ll dp[N][N];
ll getpw(ll a, ll b) {
  ll res =1LL;
  while(b) {
    if (b&1) res = res*a % mod;
    a = a*a % mod;
    b /= 2;
  }
  return res;
}
int main() {
  cin>>n>>s;
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1LL;
  int m = s.size();
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      dp[i+1][j+1] = (dp[i+1][j+1] + 2LL*dp[i][j]) % mod;
      if (j) {
        dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j]) % mod;
      } else {
        dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
      }
    }
  }
  ll ans = dp[n][m];
  //cout<<"ans="<<ans<<endl;
  ll res = getpw(2LL, m) % mod;
  res = getpw(res, mod-2) % mod;
  ans = ans*res%mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 195840
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp!
memo = []
count = 0

t.split('').each_with_index do |e, i|
  case e
  when 'r'
    if i < k || memo[i - k] != 'p'
      count += p
      memo << 'p'
    else
      memo << 'x'
    end
  when 's'
    if i < k || memo[i - k] != 'r'
      count += r
      memo << 'r'
    else
      memo << 'x'
    end
  when 'p'
    if i < k || memo[i - k] != 's'
      count += s
      memo << 's'
    else
      memo << 'x'
    end
  end
end

puts count


Measured memory_bytes: 14076
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  int A, P;
  cin >> A >> P;
  int total = (A * 3 + P) / 2;
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 764
n, k = [int(_) for _ in input().split()]
s = input()
c = 0
ans = 0
new_s = '' + s[0]
for i in range(1, n):
    if s[i] == s[i - 1]:
        c += 1
    else:
        ans += c
        c = 0
        new_s += s[i]
if c != 0:
    ans += c

length = len(new_s)
l = []
if length == 2:
    l = [1]
if length >= 3:
    if length % 2 == 1:
        l = [2] * (length // 2)
    else:
        l.append(1)
        l += [2] * ((length // 2) - 1)

if len(l) >= k:
    for i in range(k):
        ans += l.pop()
else:
    for i in range(len(l)):
        ans += l.pop()
print(ans)


Measured memory_bytes: 3956
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

ll A;
float B;

int main() {
    ll a;
    double b;
    cin >> a >> b;
    ll tb = b * 100 + 0.01;

    ll ans = a * tb;

    ans /= 100;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3724
using System;

public class ABC162C {
	private static void Main(string[] args) {
		var k = ReadInt();
		var answer = 0;

		for (int a = 1; a <= k; a++)
			for (int b = 1; b <= k; b++)
				for (int c = 1; c <= k; c++)
					answer += CalcGCD(a, b, c);

		Console.WriteLine(answer);
	}

	private static int ReadInt() => int.Parse(Console.ReadLine().Trim());
	private static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
	private static int CalcGCD(int a, int b) => a > b ? GCD(a, b) : GCD(b, a);
	private static int CalcGCD(int a, int b, int c) => CalcGCD(CalcGCD(a, b), c);
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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 main(void){
    int N; cin >> N;
    REP(i,26)REP(j,16){
        if(4*i + 7*j == N){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
map<int,int>vis;
int n,ans,k,a[200005];
int tmp[50]={1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824};
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]++;
	}
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--)
	{
		int pos=upper_bound(tmp,tmp+30,a[i])-tmp;
		k=tmp[pos]-a[i];
		if((k!=a[i]&&vis[k]||k==a[i]&&vis[k]>1)&&pos<31&&vis[a[i]])
		{
			ans++;
			vis[k]--; vis[a[i]]--;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19712
import math

n = input()

p = input().split(" ")
q = input().split(" ")

n = int(n)
p = [int(i) for i in p]
q = [int(i) for i in q]

def dictoder(x):
  r = 0
  t = list(range(len(x)))
  t = [i + 1 for i in t]
  
  for i in range(len(x)):
    r = r + math.factorial(n - 1 - i) * t.index(x[i])
    t.remove(x[i])
    
  return(r + 1)

print(abs(dictoder(p) - dictoder(q)))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3636
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<ld,int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
    int rize; cin>>rize;
        vector<pii>ujimatu;
        ld maxi=-INF;
        ld hoge=0;
        rep(i,n){
        int b,r,t;cin>>b>>r>>t;
        ld ans=0;
        if(t==1)
            ans=1+rize*(ld)r/100;
        else
            ans=pow(1+(ld)r/100,rize);
            if(ans>maxi){maxi=ans;hoge=b;}
            
        }
        cout<<hoge<<endl;
    
    }
}

Measured memory_bytes: 3428
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pri(a) cout<<a<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int n,a,x,y,ans=0;
    cin>>n;
    int li[15][15];
    rep(i,15){
        rep(j,15){
            li[i][j]=-1;
        }
    }
    rep(i,n){
        cin>>a;
        rep(j,a){
            cin>>x;
            cin>>li[i][x-1];            
        }
    }
    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n){
            if(i>>j&1){
                d[j]=1;
            }
        }
        bool check=true;
        rep(j,n){
            if(d[j]==1){
                rep(k,n){
                    if(li[j][k]==-1)continue;
                    else if(li[j][k]!=d[k])check=false;
                }
            }
        }
        if(check==true)ans=max(ans, __builtin_popcount(i));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
i = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[i - 1])

Measured memory_bytes: 3060
s = gets.chomp.split("")
t = gets.chomp.split("")

flag = 0
for i in 1..s.length do
  if s == t
    flag = 1
    break
  else
    s0 = s[0]
    s.delete_at(0)
    s << s0
  end
end

if flag == 1
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

def main():
	N = int(input())
	L1 = []
	L2 = []	
	for i in range(N):
		x, y = getlist()
		L1.append(x + y)
		L2.append(x - y)
	L1.sort()
	L2.sort()
	ans1 = L1[-1] - L1[0]
	ans2 = L2[-1] - L2[0]
	ans = max(ans1, ans2)
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 95020
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }


// マイナスn進数
// 下の桁から確定させていく
// x = 0 なら {0} を返す
vector<int> negativeRadix(int x, int base) {
	if (x == 0)return vector<int>(1); 
	vector<int> digits;
	while (x != 0) {
		int r = x % base;
		x /= base;
		if (r < 0) {
			r += -base;
			x++;
		}
		digits.push_back(r);
	}
	reverse(digits.begin(), digits.end());
	return digits;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> res = negativeRadix(N, -2);
	string s;
	for (auto d : res)s.push_back(d + '0');
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=2000+19;
const int oo=(1<<30)-1;

char s[N][N];
int A[N][N],B[N][N],h[N],stk[N],l[N],r[N];
int n,m,ans,top;

void Work(){
	For(i,1,n+1){
		For(j,1,m+1){
			if (A[i][j]) h[j]=0;else h[j]++;
		}
		h[0]=h[m+1]=-1;
		stk[top=1]=0;
		for (int j=1;j<=m;j++){
			while (h[j]<h[stk[top]]) top--;
			l[j]=stk[top];
			stk[++top]=j;
		}
		stk[top=1]=m+1;
		for (int j=m;j>=1;j--){
			while (h[j]<=h[stk[top]]) top--;
			r[j]=stk[top];
			stk[++top]=j;
		}
		For(j,1,m+1){
			ans=max(ans,(h[j]+1)*(r[j]-l[j]));
		}
	}
}

int main(){
	n=IN(),m=IN();
	For(i,1,n+1) scanf("%s",s[i]+1);
	ans=max(n,m);
	For(i,1,n+1) For(j,1,m) B[i][j]=(s[i][j]=='#')^(s[i][j+1]=='#');
	For(i,1,n) For(j,1,m) A[i][j]=B[i][j]^B[i+1][j];
	n--,m--;
	Work();
	printf("%d\n",ans);
}

Measured memory_bytes: 36096
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
  if A[i] == 0:
    ans += 1
if ans >= 1:
  ans = 0
  print(ans)
else:
  ans = 1
  k = 0
  while ans <=10**18 and k<N:
    ans *= A[k]
    k += 1
  if k == N and ans <= 10**18:
    print(ans)
  else:
    print('-1')

Measured memory_bytes: 21588
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        for(int i=0;i<s.length();i+=2){
            System.out.print(s.charAt(i));
        }
        System.out.println();
    }
 
    
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n,m,v,p;
  cin>>n>>m>>v>>p;
  vector<ll> a(n);
  cin>>a;

  sort(rbegin(a),rend(a));

  auto check = [&](ll idx)->ll{
    auto b = a;
    ll key = a[idx]+m;
    rep(i,n){
      if(b[i]<=key)b[i]=min(b[i]+m,key);
      else if(b[i]>key)b[i]+=m;
    }
    vector<ll>d(n);
    rep(i,n)if(b[i]-a[i]<m)d[i]=m-(b[i]-a[i]);
    sort(rbegin(d),rend(d));
    ll cnt = 0;
    rep(i,n)cnt+=b[i]-a[i];
    sort(rbegin(b),rend(b));
    auto itr = lower_bound(b.begin(),b.end(),key,greater<>());
    int id = itr-begin(b);
    for(int i=0;i+id+1<p;++i){
      cnt += d[i];
    }
    return id+1<=p && cnt>=m*v;
  };

  ll loweq = 0;
  ll high = n;
  while(high-loweq>1){
    ll mid = high+loweq>>1;
    if(check(mid))loweq=mid;
    else high=mid;
  }

  cout<<(high)<<endl;

}

Measured memory_bytes: 2648
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> mask(m);
  for (int i = 0; i < m; ++i) {
    int len;
    scanf("%d", &len);
    while (len--) {
      int x;
      scanf("%d", &x);
      --x;
      mask[i] |= 1 << x;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) scanf("%d", &p[i]);
  int ret = 0;
  for (int k = 0; k < (1 << n); ++k) {
    int cnt = 0;
    for (int i = 0; i < m; ++i) {
      int len = 0;
      for (int j = 0; j < n; ++j) {
        if ((k & (1 << j)) && (mask[i] & (1 << j))) {
          ++len;
        }
      }
      // trace(k, i, len);
      if (len % 2 == p[i]) ++cnt;
    }
    // trace(k, cnt);
    if (cnt == m) ++ret;
  }
  printf("%d\n", ret);
  return 0;
}


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

s_lists = []
for i in range(M):
  ss = list(map(int,input().split()))
  s_lists+= [ss[1:]]
  
P = list(map(int,input().split()))

def check(number,s_list,p):
    string = list(map(int,reversed("{:010b}".format(number))))
    cnt = 0
    for s in s_list:
        if string[s-1] == 1:
            cnt += 1
    if cnt % 2 == p:
        return True
    else:
        return False

cnt= 0
for i in range(2**N):
  if   all([check(i, s_lists[j],P[j]) for j in range(M)]):
    cnt += 1
print(cnt)    

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int N;
    vector<int> h(101,0);
    int i; //for loop
    int ans=0;

    cin >> N;
    for(i=0;i<N;i++)cin >> h[i]; 

    i = 0;
    while(i!=N){
        if(h[i] > h[i+1]){
            ans = ans + h[i] - h[i+1];
        }
        i++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
count=0
ans=0
for i in range(1,n):
    a=set(s[:i])
    b=set(s[i:])
    for i in a:
        if i in b:
            count+=1
            if count>ans:
                ans=count
    count=0
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#define N 100

int array[N];
int cnt = 0;

void change(int *n, int *i){
int d;
d = *i;
*i = *n;
*n = d;

cnt++;
}

void sort(int p){
int i, c = 0, min;

 while(c <= p - 1){
   min = c;
 for(i = c; i <= p - 1; i++){
  if(array[i] < array[min])
   min = i;

 }
 if(c != min){
 change(&array[c], &array[min]);
 }
  c++;
 }

}

int main(){
int p, i;
scanf("%d", &p);
for(i = 0; i <= p - 1; i++) scanf("%d", &array[i]);
sort(p);
for(i = 0; i <= p - 1; i++){
 if(i > 0) printf(" ");

printf("%d", array[i]);
}
printf("\n%d\n", cnt);
return 0;

}

Measured memory_bytes: 604
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;
#define ll signed long long 

int main() {
  int Q;
  cin >> Q;
  for (int q = 0; q < Q; ++q) {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    --x1; --y1; --x2; --y2;

    ll ans = -1;
    for (ll i = pow(3ll, 30ll); i > 1; i /= 3) {
      if (x1 / i == x2 / i &&
          i / 3 <= x1 % i && x1 % i < i / 3 * 2 &&
          i / 3 <= x2 % i && x2 % i < i / 3 * 2) {
        if (y1 / (i / 3) < y2 / (i / 3) - 1 ||
            y2 / (i / 3) < y1 / (i / 3) - 1) {
          ans = abs(y2 - y1);
          ans += min((x1 % i) - (i / 3 - 1) + (x2 % i) - (i / 3 - 1),
                     i / 3 * 2 - (x1 % i) + i / 3 * 2 - (x2 % i));
          break;
        }
      }

      
      if (y1 / i == y2 / i &&
          i / 3 <= y1 % i && y1 % i < i / 3 * 2 &&
          i / 3 <= y2 % i && y2 % i < i / 3 * 2) {
        if (x1 / (i / 3) < x2 / (i / 3) - 1 ||
            x2 / (i / 3) < x1 / (i / 3) - 1) {
          ans = abs(x2 - x1);
          ans += min((y1 % i) - (i / 3 - 1) + (y2 % i) - (i / 3 - 1),
                     i / 3 * 2 - (y1 % i) + i / 3 * 2 - (y2 % i));
          break;
        }
      }
      if (ans >= 0) {
        break;
      }
    }
    if (ans >= 0) {
      cout << ans << endl;
    } else {
      cout << abs(x2 - x1) + (abs(y2 - y1)) << endl;
    }
  }
  return 0;
}


/*
...........................
.*..*..*..*..*..*..*..*..*.
...........................
...***......***......***...
.*.***.*..*.***.*..*.***.*.
...***......***......***...
...........................
.*..*..*..*..*..*..*..*..*.
...........................
.........*********.........
.*..*..*.*********.*..*..*.
.........*********.........
...***...*********...***...
.*.***.*.*********.*.***.*.
...***...*********...***...
.........*********.........
.*..*..*.*********.*..*..*.
.........*********.........
...........................
.*..*..*..*..*..*..*..*..*.
...........................
...***......***......***...
.*.***.*..*.***.*..*.***.*.
...***......***......***...
...........................
.*..*..*..*..*..*..*..*..*.
...........................
*/


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D)
    cout << "Left" << endl;
  else if (A + B == C + D)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}


Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    val S = Array(N) { next().toCharArray().sorted().joinToString(separator = "") }
    val A = S.groupBy{ it }.mapValues { it.value.size.toLong() }.toList()
    var ans = A.sumByLong { (it.second * (it.second - 1)) / 2 }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
inline fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long {
    var sum = 0L
    for (element in this) {
        sum += selector(element)
    }
    return sum
}

Measured memory_bytes: 81520
import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
arr = np.full(n, k-q, dtype=np.int64)

for i in range(q):
  a_i = int(input()) 
  arr[a_i-1] += 1

for j in range(n):
  if arr[j] > 0:
    print("Yes")
  else:
    print("No")


Measured memory_bytes: 15200
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	int seel[10];

	while( cin >> n && n != 0 ){
		for( int i = 0;i < 10;i++ ) seel[i] = 0;
		for( int i = 0;i < n;i++ ){
			int a;
			cin >> a;
			++seel[a];
		}

		for( int i = 0;i < 10;i++ ){
			if( seel[i] == 0 ) cout << '-' << endl;
			else {for( int j = 0;j < seel[i];j++ ) cout << '*';cout << endl;}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<array>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define 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 llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/
typedef tuple<int,int,int> tpl;

template <typename T> bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

int main() {

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

	int n;
    cin >> n;
    int cnt = 0;
    for(int i = 0;i < n;i++){
        int c;
        cin >> c;
        if(c%2)continue;
        if(!(c%3==0 || c%5==0)){
            cout << "DENIED" << endl;
            return 0;
        }
    }

    cout << "APPROVED" << endl;
	return 0;
}






Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  string s;
  cin >> s;
  if (s == "A")
    cout << "T" << endl;
  else if (s == "T")
    cout << "A" << endl;
  else if (s == "C")
    cout << "G" << endl;
  else if (s == "G")
    cout << "C" << endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n; cin >> n;
    cout << n*2*pi << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7916
def main():
    N = int(input())
    zorome_count = 0
    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            zorome_count += 1
        else:
            zorome_count = 0
        
        if zorome_count == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
  int a,b;
  cin >> a >> b;
  if(a <= 9 && b <= 9) cout << a*b << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    ans := "Yes"
    var w string
    fmt.Scan(&w)
    a := w[len(w)-1]
    m := make(map[string]int)
    m[w]++
    for i:=0; i<n-1; i++{
        fmt.Scan(&w)
        if w[0]!=a || m[w]>0{
            ans = "No"
        }
        m[w]++
        a = w[len(w)-1]
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


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

int main() {
    int N;
    cin>>N;
    
    ll A[N+1];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    A[N]=0;
    ll ans=0;
    
    for(int i=0;i<N;i++){
        ans+=A[i]/2;
        A[i]%=2;
        
        if(A[i]>0 && A[i+1]>0){
            ans++;
            A[i]--;
            A[i+1]--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;

int solution(){
    int n; cin>>n;
    vector<double> p(n);
    cout<<fixed;
    cout<<setprecision(10);
    for(int i = 0;i < n;i++) cin>>p[i];
    
    vector<vector<double> > dp(n+1, vector<double> (n+1, 0.0) );
    dp[0][0] = 1;
    for(int i = 1;i < n+1;i++) dp[i][0] = dp[i-1][0] * (1-p[i-1]);
    
    for(int i = 1; i < n+1;i++){
        for(int j = 1; j <= i;j++){
                dp[i][j] = dp[i-1][j] * (1-p[i-1]) + dp[i-1][j-1] * (p[i-1]);
        }
    }
    double sum = 0.0;
    for(int i = n;i > n/2;i--) sum += dp[n][i];
    cout<<sum<<"\n";
    return 0;
}

int main(){
    FAST_IO;
    int T = 1; //cin>>T;
    while(T--)
        solution();
    return 0;
}

Measured memory_bytes: 73744
using System;

namespace Atcoder0121_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if(a * b %2 == 0){
                Console.WriteLine("Even");
            }else{
                Console.WriteLine("Odd");
            }

        }
    }
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll waru = 1;
    ll N = n;
    for(ll i = 2;i<sqrt(n)+2;i++){
        if(N % i == 0){
            waru = i;
        }
    }
    cout << waru + n/waru - 2 << endl;
}

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

int main() {
 int x;
 cin>>x;
 int ans=x;
 int lim=(int)(sqrt(100003)+1);
 int j=1;
 while(j){
   int cnt=0;
   rep2(i,2,lim){
     if(ans%i!=0 || ans==i) cnt++;
     if(cnt==lim-2){
       j=0;
       cout<<ans<<endl;
       break;
     }
   }
   ans++;
 }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
set<P<int,int> > s; 
V<int> v,p;
int a[300000];
int main(){
	int n;
	cin>>n;
	int m=(1<<n);
	FOR(i,1,m)cin>>a[i];
	sort(a+1,a+m+1,greater<int>());
	FOR(i,2,m){
		s.insert(MP(a[i],i));
	}
	v.PB(a[1]);
	rep(t,0,n){
		p.clear();
		for(auto u:v){
			auto iter=s.lower_bound(MP(u,0));
			if(iter==s.begin()){
				cout<<"No";RE 0;
			}
			iter--;
			if((*iter).F>=u){
				cout<<"No";RE 0;
			}
			p.PB((*iter).F);
			s.erase(iter);
		}
		for(auto u:p)v.PB(u);
	}
	cout<<"Yes";
	RE 0;
}



Measured memory_bytes: 13568
#include <stdio.h>
int main(){
 short n,a;
  scanf("%hu",&n);
  a=n%10;
  if(a==2||a==4||a==5||a==7||a==9)printf("hon\n");
  if(a==0||a==1||a==6||a==8)printf("pon\n");
  if(a==3)printf("bon\n");
}

Measured memory_bytes: 1640
import java.io.*;
import java.util.HashSet;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] input = br.readLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int k = Integer.parseInt(input[1]);
        int[] w = new int[n];
        int maxWeight = 0;
        int sum = 0;

        for (int i = 0; i < n; i++) {
            w[i] = Integer.parseInt(br.readLine());
            if (maxWeight < w[i]) {
                maxWeight = w[i];
            }
            sum += w[i];
        }

        int load;
        int capacity;
        int min = Math.max(maxWeight, sum / k);
        int max = sum;
        int i, j;

        outside: while (max > min) {
            load = 0;
            j = 0;

            capacity = (min + max) / 2;

            for (i = 0; i < k; i++) {
                load = 0;
                while (load <= capacity) {
                    load += w[j];
                    j++;
                    if (j == w.length && load <= capacity) {
                        max = capacity;
                        continue outside;
                    }
                }
                j--;
            }
            min = capacity + 1;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 35372
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    string s;
    cin >> s;
    if (s.back() == '1' || s.front() == '0') {
        cout << -1 << endl;
        return 0;
    }

    int n = s.size();
    for (int i = 0; i < n - 1; i++) {
        if (s[i] != s[n - 2 - i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    vi rem;
    for (int i = 2; i <= n / 2; i++) {
        if (s[i - 1] == '1') {
            rem.push_back(i);
        }
    }

    int p = 1;
    for (int r: rem) {
        for (int i = p + 1; i <= r; i++) {
            cout << p << " " << i << endl;
        }
        cout << p << " " << r + 1 << endl;
        p = r + 1;
    }
    for (int i = p + 1; i <= n; i++) {
        cout << p << " " << i << endl;
    }
}

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

bool winning[200][200];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	long long X, Y;
	cin >> X >> Y;
	cout << (abs(X-Y) <= 1 ? "Brown" : "Alice") << '\n';
	return 0;
	for (int s = 0; s < 200; s++) {
		for (int a = 0; a <= s; a++) {
			int b = s - a;
			winning[a][b] = false;
			for (int i = 1; 2*i <= a; i++) {
				if (!winning[a-2*i][b+i]) winning[a][b] = true;
			}
			for (int i = 1; 2*i <= b; i++) {
				if (!winning[b-2*i][a+i]) winning[a][b] = true;
			}
			if (!winning[a][b]) cerr << a << ' ' << b << '\n';
		}
	}

	return 0;
}


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

int n;
void dfs(string &s, char Max)
{
  if (s.length() == n)
  {
    cout << s << endl;
    return;
  }
  for (char c = 'a'; c <= Max; ++c)
  {
    s.push_back(c);
    dfs(s, Max);
    s.pop_back();
  }
  s.push_back(Max + 1);
  dfs(s, Max + 1);
  s.pop_back();
}

int main()
{
  cin >> n;
  string s;
  dfs(s, 'a' - 1);
  return 0;
}


Measured memory_bytes: 1536
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    H, W = readnums()
    a = [list(readstr()) for _ in range(H)]
    p = list()
    for i, aa in enumerate(a):
        if all([x == '.' for x in aa]):
            p.append(i)

    for i in reversed(p):
        a.pop(i)

    p = list()
    for i in range(W):
        c = [x[i] for x in a]
        if all([x == '.' for x in c]):
            p.append(i)

    for i in reversed(p):
        for aa in a:
            aa.pop(i)

    for aa in a:
        print(''.join(aa))


if __name__ == "__main__":
    main()


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

int main()
{
  int A,B,C;
  cin >> A >> B >> C;
  
  int ans;
  int res;
  res = A-B;
  ans = C-res;
  
  if(ans<0)
    ans=0;
  
  cout << ans;
  
  return 0;
}


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

int N, C, K;
vector<int> T;

int main(void)
{
  cin >> N >> C >> K;
  for(int i = 0; i < N; i++){
    int t;
    cin >> t;
    T.push_back(t);
  }
  sort(T.begin(), T.end());
  // 2 6 6 7 8 10
  int ans = 0;
  for(int i = 0; i < N; i++){
    ans++;
    int t = T[i];
    int n = 0; 
    for(int j = 1; j < C; j++){
      if((i+j < N) && (T[i+j] <= t + K)){
        n++;
      } else{
        break;
      }
    }
    i += n;
  }
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 892
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (ll i=0; i<n; ++i) in(a[i])
#define viin(a, n) for (ll i=0; i<n; ++i) in2(a[i].first, a[i].second);
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto &i : a)
const int mod = (int)(1e9) + 7;
//endregion


int main() {
    io();
    string s;
    in(s);
    int count = 0;
    int n = s.length();
    foris (i, 1, n) {
        if (s[i] == s[i-1]) {
            s[i] = (s[i] == '1' ? '0' : '1');
            count++;
        }
    }
    out(count);
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solveA();
    }

    private void solveA() {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int result = N * A;
        if (result <= B){
        	System.out.println(result);
        }else{
        	System.out.println(B);
        }

    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using point = pair<double, double>;

point protate90(point v) {
    return point(-v.second, v.first);
}

point pplus(point v1, point v2) {
    return point(v1.first + v2.first, v1.second + v2.second);
}

point pminus(point v1, point v2) {
    return point(v1.first - v2.first, v1.second - v2.second);
}

point pmult(point v, double c) {
    return point(v.first * c, v.second * c);
}

void computeKoch(point p1, point p2, vector<pair<point, point>> &edges) {
    point s, t, u;
    point v = pminus(p2, p1);
    s = pplus(p1, pmult(v, 1.0 / 3.0));
    t = pplus(p1, pmult(v, 2.0 / 3.0));
    u = pplus(p1, pplus(pmult(v, 1.0 / 2.0), protate90(pmult(v, sqrt(3) / 6.0))));
    edges.push_back(pair<point, point>(p1, s));
    edges.push_back(pair<point, point>(s, u));
    edges.push_back(pair<point, point>(u, t));
    edges.push_back(pair<point, point>(t, p2));
}

void koch(vector<pair<point, point>> &edges, int n) {
    int i, j;
    rep(i, n) {
        vector<pair<point, point>> new_edges;
        rep(j, edges.size()) {
            computeKoch(edges[j].first, edges[j].second, new_edges);
        }
        edges = new_edges;
    }
}

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

    int n;
    cin>>n;
    vector<pair<point, point>> edges = {pair<point, point>(point(0.0, 0.0), point(100.0, 0.0))};
    koch(edges, n);
    rep(i, edges.size()) printf("%.10f %.10f\n", edges[i].first.first, edges[i].first.second);
    printf("%.10f %.10f\n", edges[edges.size() - 1].second.first, edges[edges.size() - 1].second.second);
}


Measured memory_bytes: 3376