akhauriyash/Code-Regression huggingface dataset:
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	int n,m;cin>>n>>m;
	cout << n*(n-1)/2+m*(m-1)/2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scn =new Scanner(System.in);
		int n =scn.nextInt();
	    int []arr =new int[n+1];
	     for(int i=1;i<=100;i++){
	    	 for(int j=1;j<=100;j++){
	    		 for(int k=1;k<=100;k++){
	    			 int ans = res(i,j,k);
	    			 if(ans<arr.length){
	    				 arr[ans]++;
	    			 }
	    		 }
	    	 }
	     }
	     StringBuilder sb=new StringBuilder();
	     for(int i=1;i<=n;i++){
	    	 sb.append(arr[i]+"\n");
	     }
	     System.out.println(sb);
		
//		 
	}
	public static int res(int x ,int y ,int z){
		return x*x+y*y+z*z+z*y+x*y+x*z;
	}

}

Measured memory_bytes: 39516
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    
    int a = s.indexOf("A");
    int z = s.lastIndexOf("Z");
    
    System.out.println(z-a+1);
  }
}

Measured memory_bytes: 27368
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b


using namespace std;



int main()
{
	Nayon;
	int x;
	cin>>x;
	if(x>=30){
		cout<<"Yes"<<nl;
	}
	else{
		cout<<"No"<<nl;
	}
	return 0;
}
//Happy Coding.....


Measured memory_bytes: 3644
N, K, C = map(int, input().split())
S = [1 if a == "o" else 0 for a in input()]

c = 0
X = [0] * N
Y = [0] * N

i = 0
while i < N:
    if S[i]:
        c += 1
        X[i] = 1
        i += C + 1
    else:
        i += 1

if c > K:
    exit()

i = N - 1
while i >= 0:
    if S[i]:
        Y[i] = 1
        i -= C + 1
    else:
        i -= 1

for i in range(N):
    if X[i] and Y[i]:
        print(i + 1)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int A,B,C;
	cin>>A>>B>>C;
	if((A-C)*(B-C)>0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<vector<int>>A(N,vector<int>(N-1));
  for(int i=0;i<N;i++)for(int j=0;j<N-1;j++)cin>>A[i][j];
  for(int i=0;i<N;i++){
    for(int j=0;j<N-1;j++)A[i][j]--;
    reverse(rng(A[i]));
  }
  vector<pii>q;

  auto check=[&](int i){
    if(A[i].size()==0)return;
    int j=A[i].back();
    if(A[j].size()==0)return;
    if(A[j].back()==i){
      if(i>j)swap(i,j);
      q.push_back({i,j});
    }
  };

  for(int i=0;i<N;i++)check(i);

  int ans=0;
  while(q.size()>0){
    ans++;
    sort(rng(q));
    q.erase((unique(rng(q))),q.end());
    vector<pii>Q;
    swap(Q,q);
    for(auto it:Q){
      int i=it.first;
      int j=it.second;
      A[i].pop_back();
      A[j].pop_back();
      check(i);
      check(j);
    }
  }

  bool ok=true;
  for(int i=0;i<N;i++)if(A[i].size()>0)ok=false;
  if(ok)cout<<ans<<endl;
  else cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
const int mod=1e9+7;
ll Pow(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)res=res*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return res;
}
int n,m,a,b;
ll fac[max_n],inv[max_n];
void init(int n){
    fac[0]=1;
    for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
    inv[n]=Pow(fac[n],mod-2);
    for(int i=n-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(int n,int m){
    if(n<m||m<0)return 0;
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
ll way(int n,int m){
    return C(n+m-2,n-1);
}
int main(){
    scanf("%d%d%d%d",&n,&m,&a,&b);
    init(n+m);
    ll ans=way(n,m);
    for(int i=1;i<=b;i++){
        ans-=way(n-a,i)*way(a,m-i+1)%mod;
    }
    ans=ans%mod+mod,ans%=mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    int n; cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    int ans = 0;
    int res = 0;
    rep(i, n-1) {
        if (h[i] >= h[i + 1]) res++;
        else {
            ans = max(ans, res);
            res = 0;
        }
    }
    ans = max(ans, res);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n; cin >> n;
    vector<string> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    set<string> s;
    int c = v[0][v[0].size() - 1];
    s.insert(v[0]);
    for(int i = 1; i < n; i++){
        if(s.find(v[i]) != s.end()){
            cout << "No" << endl;
            return 0;
        }

        s.insert(v[i]);
        if(c != v[i][0]){
            cout << "No" << endl;
            return 0;
        }

        c = v[i][v[i].size() - 1];
    }

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

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

int main(){
    string s;
    cin >> s;
    vector<int> rl;
    vector<int> lr;
    lr.push_back(-1);
    for(int i = 0; i < s.length() - 1; i++){
        if(s[i] == 'R' && s[i + 1] == 'L') rl.push_back(i);
        else if(s[i] == 'L' && s[i + 1] == 'R') lr.push_back(i);
    }
    lr.push_back(s.length() - 1);
    int out[s.length()] = {};
    for(int i = 0; i < rl.size(); i++){
        int l = lr[i];
        int m = rl[i];
        int r = lr[i + 1];
        out[m] = (m - l + 1) / 2 + (r - m) / 2;
        out[m + 1] = (r - l) - out[m];
    }
    for(int i = 0;  i < s.length(); i++){
        cout << out[i] << endl;
    }
}

Measured memory_bytes: 1532
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

a, b, x = rl()

y = 2/(a**2)*x-b
if 0 <= y <= b:
	print(math.atan((b-y)/a) / math.pi * 180)
	exit()

y = 2/(a*b)*x
if 0 <= y <= a:
	print(math.atan(b/y) / math.pi * 180)
	exit()


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

int main(int argc,char** argv)
{
	int n, a, b, c=0, count=0;
	cin >> n >> a >> b;
	for(int i = 1; i <= n; i++){
		c = i%10 + i/10%10 + i/100%10 +i/1000%10 +i/10000%10;
		if( a <= c && c <= b){
			count += i;
		}
	}
	cout << count <<endl;


	return 0;

}


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

int main() {
    char a, b;
    cin >> a >> b;
    if (a == b) cout << "H" << endl;
    else cout << "D" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int table[10][2000];
int len[10];

int rec(vector<vint>& cost, int p, int k)
{
	if(p == 10) return 0;
	
	if(0 <= table[p][k]) return table[p][k];
	
	int res = 0;
	rep(t, min(k, len[p]) + 1)
	{
		chmax(res, (t == 0 ? 0 : cost[p][t - 1] + (t - 1) * t) + rec(cost, p + 1, k - t));
	}
	
	return table[p][k] = res;
}

int main()
{
	memset(table, -1, sizeof(table));
    int n, k;
	cin >> n >> k;
	
	vector<vint> cost(10);
	rep(i, n)
	{
		int c, g;
		cin >> c >> g;
		
		cost[g-1].push_back(c);
	}
	
	rep(i, 10)
	{
		len[i] = cost[i].size();
		sort(ALL(cost[i]), greater<int>());
		partial_sum(ALL(cost[i]), cost[i].begin());
	}
	
	cout << rec(cost, 0, k) << endl;
}

Measured memory_bytes: 0
#include <stdio.h>

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    int i;
    int count = 0;
    for(i=0; i<N; i++) {
        int temp;
        scanf("%d", &temp);
        if(temp >= K) count++;
    }
    printf("%d\n", count);
    return 0;
}

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

int dp[100001];

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> ht(n, 0);
	for (int i = 0; i < n; i++)
		cin >> ht[i];
	// Base case
	dp[0] = 0;

	//Fill states using O(k) time
	for (int i = 1; i < n; i++) {
		dp[i] = INT_MAX;
		for (int j = 1; j <= k && (i - j) >= 0; j++) {
			dp[i] = min(dp[i], dp[i - j] + abs(ht[i] - ht[i - j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 4048
N = int(input())
A = list(map(int,input().split()))

dp = [1000]*(N+1)

for i in range(2,N+1):
  for j in range(1,i):
    dp[i] = max(dp[i-1],dp[j] + (dp[j]//A[j-1])*(A[i-1]-A[j-1]))
    
print(dp[-1])

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

#define lli long long int
#define ld long double
#define DEFO(n) lli n = 0;
#define MAX(n) lli n = 9000000000000000000;
#define MIN(n) lli n = 9000000000000000000;
#define MAX_D(n) ld n = 4500;
#define MIN_D(n) ld n = -4500;
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LD(n) \
  ld n;       \
  cin > n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define LLIV2(a, b, n)         \
  vector<lli> a(n), b(n);      \
  for (lli i = 0; i < n; i++)  \
  {                            \
    cin >> a.at(i) >> b.at(i); \
  };
#define LLIV3(a, b, c, n)         \
  vector<lli> a(n), b(n), c(n);      \
  for (lli i = 0; i < n; i++)  \
  {                            \
    cin >> a.at(i) >> b.at(i) >> c.at(i); \
  };
#define LDV(a, n)             \
  vector<ld> a(n);            \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define STRV(a, n)             \
  vector<string> a(n);            \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define SUM(n) accumulate(n.begin(), n.end(), 0);
#define SORT(n) sort(n.begin(), n.end());
#define REVE(n) reverse(n.begin(), n.end());
#define yes              \
  cout << "Yes" << endl; \
  return 0;
#define no              \
  cout << "No" << endl; \
  return 0;
#define none            \
  cout << "None" << endl; \
  return 0;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

//数値反転
bool KReve(lli n)
{
  int reverse = 0;
  int remaind;
  int tmp = n;
  while (tmp != 0)
  {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }
  if (reverse == n)
    return true;
  else
    return false;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(N) LLI(R) DEFO(flag)
  while(N!=0) {
    N /= R;
    flag++;
  }
  OUT(flag)
}


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

using namespace std;

vector<int> graph[100005];

int length[100005];

int dfs(int v){

	if(length[v]!=-1)
		return length[v];
	int ans=0;
	for(int i=0;i<graph[v].size();i++){
		ans = max(ans, dfs(graph[v][i])+1);
	}
	length[v] = ans;
	return length[v];


}

int main(){

	int N,M;
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int v1, v2;
		cin >> v1 >> v2;
		graph[v1].push_back(v2);
	}
	for(int i=1;i<=N;i++)
		length[i]=-1;
	int ans=0;
	for(int v=1;v<=N;v++){
		if(length[v]==-1)
			length[v] = dfs(v);
		ans = max(ans, length[v]);
	}
	cout << ans;
	



}

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

int main() {
	int n;
	cin >> n;
	for (int i = 0; i <= n/7; i++) {
		for(int j=0; j<=n/4; j++)
			if (7 * i + 4 * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};

signed main()
{
    ll n;
    cin >> n;
    vector<ll> v(1<<n);
    rep(i,siz(v))cin>>v[i];
    sort(all(v));

    vector<ll> now(0),p;
    now.pb(v.back());
    v.back()=-1;

    rep(i,n){
        p=now;
        sort(all(p));

        ll ind=siz(v)-1;
        //大きい親から見ているのでindは線形でいい
        while(siz(p)>0 && 0<=ind){
            if(v[ind]==-1){
                ind--;
                continue;
            }

            if(v[ind]<p.back()){
                now.pb(v[ind]);
                v[ind]=-1;
                p.pop_back();
            }
            ind--;
        }

        if(siz(p)!=0){
            puts("No");
            return 0;
        }

    }
    puts("Yes");

}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int H,W,M;
pv<int,int> mine;
intvec h,w;

void input() {
	cin>>H>>W>>M;
	h.resize(H,0), w.resize(W,0);
	mine.resize(M);
	for(int i=0; i<M; i++) {
		cin>>mine[i].fi>>mine[i].se;
		mine[i].fi--, mine[i].se--;
		h[mine[i].fi]++, w[mine[i].se]++;
	}
}

void solve() {
	sort(all(mine));
	int mxh=-1;
	intvec hm,wm;
	for(int i=0; i<H; i++) {
		if(mxh<h[i]) {
			mxh=h[i];
			hm.clear();
		}
		if(mxh==h[i]) hm.pushb(i);
	}
	int mxw=-1;
	for(int i=0; i<W; i++) {
		if(mxw<w[i]) {
			mxw=w[i];
			wm.clear();
		}
		if(mxw==w[i]) wm.pushb(i);
	}

	int ans=-1;
	for(int i=0; i<hm.size(); i++) for(int j=0; j<wm.size(); j++) {
		auto itr=lower_bound(all(mine),intpair({hm[i],wm[j]}));
		if(itr!=mine.end() && *itr==intpair({hm[i],wm[j]})) ans=mxh+mxw-1;
		else {
			ans=mxh+mxw;
			cout<<ans<<endl;
			return;
		}
	}

	cout<<ans<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 12048
#include<bits/stdc++.h>
using namespace std;
const long long M =2e5+7,MOD=1234567;
typedef long long ll;
#define pb push_back
#define Y printf("YES\n")
#define N printf("NO\n")
#define O printf("-1\n")
bool f_2,vis[M]={false};
string s,p,q,ok,ch;
vector<ll>v,v_1,v_2;
map<ll,ll>mp,mp_2;
set<ll>st;
ll parent[M],Rank[M],dis[M];
ll cnt=0,cost=0;
deque<ll>Q;
//vector< pair<string,ll >v,v_1;
struct node
{
    ll pa,ran,visit;

};
node X[M];
int main()
{
    ios::sync_with_stdio(false);//ISHWAR
    cin.tie(0);//Tourist_Twin
    ll a,b,c=0,n,t,sum=0,mx=MOD,l,x,y,i=0,j=0,r,d=0,e,chk,largest,smallest=999999;
    cin>>t>>a>>b;
    cout<<min(t*a,b)<<endl;

    return 0;
}


Measured memory_bytes: 2304
const Main = input => {
  const cnt = Array(parseInt(input.split('\n')[0].trim(), 10))
    .fill(0)
    .filter((_, i) => (i + 1).toString().length % 2 === 1)
    .length

  console.log(cnt)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, C;
  cin >> n >> C;
  
  vector<vector<int>> x(n, vector<int>(3));
  for (int i = 0; i < n; i++) {
    cin >> x.at(i).at(1) >> x.at(i).at(2) >> x.at(i).at(0);
  }
  
  vector<int> z(200002);
  for (int i = 1; i <= C; i++) {
    vector<int> y(200002);
    for (int j = 0; j < n; j++) {
      if (x.at(j).at(0) == i) {
        y.at(x.at(j).at(1) * 2 - 1)++;
        y.at(x.at(j).at(2) * 2)--;
      }
    }
    for (int j = 0; j < 200002; j++) {
      if (j) y.at(j) += y.at(j - 1);
      if (y.at(j) > 0) z.at(j)++;
    }
  }
  
  int ans = 0;
  for (int i = 0; i < 200002; i++) ans = max(ans, z.at(i));
  cout << ans << '\n';
}

Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
int n,a[200010];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) a[i]=a[i]-i;
	sort(a+1,a+n+1);
	int x=a[(n+1)>>1];
	ll ans=0;
	for (int i=1;i<=n;i++) ans+=abs(a[i]-x);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = list(input())
c = [[0 for i in range(3)] for _ in range(N)]
if T[0] == 'r':
    c[0][0] = 0
    c[0][1] = 0
    c[0][2] = P
elif T[0] == 's':
    c[0][0] = R
    c[0][1] = 0
    c[0][2] = 0
elif T[0] == 'p':
    c[0][0] = 0
    c[0][1] = S
    c[0][2] = 0
# for i in range(n):
#     for j in range(3):
#         for k in range(3):
#             if j == k:
#                 continue
#             c[i][j]
def change(s):
    l = []
    for i in range(len(s)):
        if s[i] == 'r':
            v = 'p'
        elif s[i] == 's':
            v = 'r'
        elif s[i] == 'p':
            v = 's'
        l.append(v)
    return l
new = change(T)
point = 0
for i in range(len(new)-K):
    if new[i] == new[i+K]:
        new[i+K] = 'stop'
for i in new:
    if i == 'p':
        point += P
    elif i == 'r':
        point += R
    elif i == 's':
        point += S
print(point)


Measured memory_bytes: 64264
from math import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
g = gcd(n, m)
ans = n*m//g
sp_a, sp_b = m//g, n//g
jud = True
for i in range(ans//sp_a):
    if i*sp_a % sp_b == 0:
        if s[i % n] != t[i*sp_a//sp_b]:
            jud = False

if jud:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 73892
from collections import defaultdict

while True:
    n = int(input())
    if n == 0:
        break

    dv = defaultdict(int)
    for _ in range(n):
        e, p, q = list(map(int, input().split()))
        dv[e] += p * q
    
    count = 0
    for k, v in dv.items():
        if v >= 1000000:
            print(k)
            count += 1
    if count == 0:
        print("NA")


Measured memory_bytes: 6216
#include<stdio.h>

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#define stmin(a,b) ((a)<(b)?(a):(b))
typedef unsigned long long ull;
int main(void){
	int n;
	long long x;
	int i;
	scanf("%d %lld",&n,&x);
	long ar[n<<1];
	for(i = 0;i < n;i++)scanf("%ld",&ar[i]);
	for(i = 0;i < n;i++)ar[i+n] = ar[i];
	long timmin[n];
	for(i = 0;i < n;i++)timmin[i] = ar[i];
	ull minans = 1llu<<63;
	ull tmp = 0;
	for(int emc = 0;emc < n;emc++){
		tmp = 0;
		for(i = 0;i < n;i++)tmp += (timmin[i] = stmin(timmin[i],ar[i+emc]));
		minans = stmin(minans,emc*x + tmp);
	}
	printf("%llu",minans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld float
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
const ll N = 1e5 + 4 ;
vector<ll> fact(N,0) , invFac(N,0) ;
ll powMod( ll base , ll expo )
{
    ll ans = 1 ;
    while( expo > 0 ){
        if( expo & 1 ){

            ans = ( ans * base ) % hell ;
        }
        base = ( base * base ) % hell ;
        expo >>= 1 ;
    }
    return ans ;
}
ll add( ll x , ll y ){
    return ( x + y ) % hell ;
}
ll sub( ll x , ll y ){
    ll ans = x ;
    ans = ( x - y + hell ) % hell ;
    ans = ( ans + hell ) % hell ;
    return ans; 
}
ll mult( ll x , ll y ){
    ll ans = ( x * y ) % hell ;
    ans = ( ans + hell ) % hell ;
    return ans ;
}
ll inv( ll x ){
    return powMod( x , hell -2 ) ;
}
ll C( ll x , ll y )
{
    if( x < y || y < 0 )return 0 ;
    ll ans = mult( fact[x] , mult( invFac[y] , invFac[x-y] ) ) ;
    cout << "x :  " << x << " y : " << y << " C(x,y) : " << ans << "\n" ;
    return ans ;
}
void solve()
{
    string s ;
    cin >> s ;
    ll cur = 0 , i = 0 , n = sz(s) , ans = 0 ;
    rep( i , 0 , 5 )
        s.pb('#');
    while( i < n ){
        if( s[i] == 'A' ){
            cur++;
        }
        else if( s[i] == 'B' and s[i+1] == 'C' ){
            ans += cur ;
            //cur = 0 ;
            i++;
        }
        else
            cur = 0 ;
        i++;
    }
    cout << ans ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    fact[0] = 1 ;
    rep( i , 1 , N )
        fact[i] = ( fact[i-1] * i ) % hell ;
    invFac[N-1] = inv(fact[N-1]) ;
    for( ll i = N - 2 ; i >= 0 ; i-- ){
        invFac[i] = ( invFac[i+1] * (i+1) ) % hell ;
    }
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


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

using namespace std;

const int MaxN = 3005;
const long long Mod = 1000000007;

int n;
string s;
long long dp[MaxN][MaxN], ps[MaxN][MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cin >> s;
    dp[1][1] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            ps[i - 1][j] = (ps[i - 1][j - 1] + dp[i - 1][j]) % Mod;
        }
        if (s[i - 2] == '<')
        {
            for (int j = 1; j <= i; j++)
            {
                dp[i][j] = ps[i - 1][j - 1];
            }
        }
        else
        {
            for (int j = 1; j <= i; j++)
            {
                dp[i][j] = (ps[i - 1][i - 1] - ps[i - 1][j - 1] + Mod) % Mod;
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans = (ans + dp[n][i]) % Mod;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 95920
//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define sz(a) ((int)(a).size())
#define all(n) (n).begin(),(n).end()
#define clr(v,val) memset(v , val , sizeof v)
#define EPS 1e-6
#define OO 1e9
#define PI acos(-1.0)
#define ll long long
#define endl "\n"

void file(){
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}


ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int dx[] = { -1, 0, 1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
char dir[] = { 'U', 'R', 'D', 'L' };
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
//474,365
//7000
const int N = 2e5 + 5, mod = 1e9 + 7;
vector<int> a;
bool mem[4005][16005], vis[4005][16005];
int n;
bool ok;
bool solve(int i, int num){
	if (i == a.size())return num == n;
	bool&ret = mem[i][num];
	if (vis[i][num])return ret;
	vis[i][num] = 1;
	ret = solve(i + 1, num + a[i]);
	if (i||ok)ret|= solve(i + 1, num - a[i]);
	return ret;
}
int main()
{
	/***  بسم الله الرحمن الرحيم   ***/
	//file();
	fast();

	string s;
	cin >> s;
	vector<int> v(1, 0);

	for (int i = 0; i < s.size(); i++)
	if (s[i] == 'T')v.push_back(0);
	else
		v.back()++;

	int x, y;
	cin >> x >> y;
	n = x + 8001;

	for (int i = 0; i < v.size(); i++)
	if (i % 2 == 0)
		a.push_back(v[i]);
	if (!solve(0, 8001))return cout << "No", 0;

	memset(vis, 0, sizeof vis);
	a.clear();
	n = y + 8001;
	ok = 1;
	for (int i = 0; i < v.size(); i++)
	if (i % 2)
		a.push_back(v[i]);
	if (!solve(0, 8001))return cout << "No", 0;

	cout << "Yes";

}

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

int main() {
  int colo[9]={};
  int n;
  cin>>n;
  int arr[n];
  for (int i=0; i<n; i++){
    cin >> arr[i];
  }
  for (int i=0; i<n; i++){
    for(int j = 0; j <=7;j++){
      if(400 * j <=arr[i] && arr[i] < 400 * (j + 1))colo[j]++;
    }
if(arr[i] >= 3200)colo[8]++;
  }
  int total=0;
  for (int i=0; i<8; i++){
    if (colo[i]>0) total++;
  }
  if ( total>0 ) cout << total << ' ' << total+colo[8] << endl; 
  else cout << 1 << ' ' << colo[8] << endl; 
return 0;
}



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

int getPosx(int a) { return (a-1)%3; }
bool isValid(int f[2]) { return getPosx(f[0]) <= getPosx(f[1]); }

int main() {
  string line;
  while(getline(cin, line) && line != "#") {
    int ans = 1<<24;
    for(int i = 0; i < 2; ++i) {
      int foot[2];
      int cnt = 0;
      foot[i] = line[0] - '0';
      foot[1-i] = line[1] - '0';
      if(!isValid(foot)) continue;
      for(int j = 2; j < line.size(); ++j) {
	int move = (i+j+cnt)%2;
	int nfoot[2];
	nfoot[move] = line[j] - '0';
	nfoot[1-move] = foot[1-move];
	if(!isValid(nfoot)) {
	  ++cnt;
	  swap(nfoot[0], nfoot[1]);
	}
	foot[0] = nfoot[0];
	foot[1] = nfoot[1];
      }
      ans = min(ans, cnt);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;

char ans[101][101];

int main() {
  int a, b; cin >> a >> b;
  REP(i,100) REP(j,50) ans[i][j] = '#';
  REP(i,100) REP(j,50) ans[i][j+50] = '.';
  REP(i,a-1) ans[i/25*2][i%25*2] = '.';
  REP(i,b-1) ans[i/25*2][i%25*2+51] = '#';
  cout << 100 << " " << 100 << endl;
  REP(i,100) {
    REP(j,100) cout << ans[i][j];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,k;
    cin>>n>>k;

    vi arr(n+1,0);
    int d,x;
    for(int i=0;i<k;++i)
    {
        cin>>d;

        for(int j=0;j<d;++j)
        {
            cin>>x;
            ++arr[x];
        }
    }

    int cnt=0;
    for(int i=1;i<=n;++i)
    {
        if(!arr[i])
            ++cnt;
    }

    cout<<cnt;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3640
while True:

    (m, f, r) = [int(i) for i in input().split()]

    if m == f == r == -1 :
        break

    sum = m + f

    if m == -1 or f == -1 or sum < 30 :
        print('F')
    elif sum < 50 and r < 50 :
        print('D')
    elif sum < 65 :
        print('C')
    elif sum < 80 :
        print('B')
    else :
        print('A')

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmax(T& ref, const T value) {
	if (ref < value) ref = value;
}

const ll mod = 1000000007;

class modint {
	static constexpr std::int_fast64_t Modulus = 1e9 + 7;
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
};

ostream& operator<<(ostream& stream, const modint& data) {
	stream << data.a;
	return stream;
}

int main() {
	ll n;
	cin >> n;
	vector<vector<bool>> match(n, vector<bool>(n, false));
	rep(i, n) {
		rep(j, n) {
			int ok;
			cin >> ok;
			match[i][j] = ok;
		}
	}
	vector<vector<modint>> dp(n+1, vector<modint>(1LL << n, 0));
	dp[0][0] = 1;
	//dp[i][j]...i番目までみてj状態になる組み合わせの数
	rep(i, n) {
		rep(j, 1LL << n) {
			auto p = __builtin_popcountll(j);
			if (p != i) continue;
			rep(a, n) {
				if (!match[i][a]) continue;
				if (j & (1LL << a)) continue;
				dp[i + 1][j | (1LL << a)] += dp[i][j];
			}
		}
	}
	cout << dp[n][(1LL << n) - 1LL] << endl;

    return 0;
}


Measured memory_bytes: 380228
#include <bits/stdc++.h>
using namespace std;
int main() {
int A,B,C,D,E,F,sum,hajime,saigo;
cin >> A >> B;
  
sum = 0;
C = A; //Cは取り出す回文数、入力した最初の数Aを代入して各桁を調べる
  
while (C <= B) {

  	D = C /10000;   //万の位
 	E = C /1000 - D*10;   //千の位 
  	F = C /100 - 100 * D - 10 * E;   //百の位
 	C = 10000*D + 1000*E + 100*F + 10 * E + D;
  
  	if (C < A) { //最初の回文数がAよりも小さかったら、合計から-1
      sum --;
    }
    sum ++;
    C += 100;
}
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    ll N, M;
    cin >> N >> M;

    vector<vector<ll>> ss(M);
    for (int i = 0; i < M; i++)
    {
        ll k;
        cin >> k;
        vector<ll> s(k);
        for (int j = 0; j < k; j++)
        {
            ll tmp;
            cin >> tmp;
            s[j] = tmp;
        }
        ss[i] = s;
    }
    vector<ll> p(M);
    for (int i = 0; i < M; i++)
    {
        ll ps;
        cin >> ps;
        p[i] = ps;
    }

    ll ans = 0;
    for (int i = 0; i < pow(2, N); i++)
    {
        bool isAns = true;
        for (int j = 0; j < M; j++)
        {
            vector<ll> tmps = ss[j];
            int cnt = 0;
            for (auto &&tmp : tmps)
            {
                tmp--;
                if ((ll)pow(2, tmp) & i)
                    cnt++;
            }
            if (cnt % 2 == p[j])
            {
            }
            else
            {
                isAns = false;
            }
        }

        if(isAns){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
l = [*map(int, input().split())]
adj = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)
cnt = 0
for i in range(n):
    cnt += all(l[i] > l[j] for j in adj[i])
print(cnt)

Measured memory_bytes: 29436
_, _, x, y = gets.split(' ').map(&:to_i)
xn = gets.split(' ').map(&:to_i).sort.last
y1 = gets.split(' ').map(&:to_i).sort.first
war = false
-100.upto 100 do |z|
  if x < z && z <= y && xn < z && y1 >= z
    war = true
  end
end
if war
  puts 'No War'
else
  puts 'War'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cout << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define lSOne(x)(x&-x)
#define EPS 1e-20
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 2e6 + 7;

ll x,  y, z;

int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> x >> y >> z;
    cout << max(0LL , z - (x-y));
    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 256
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
//#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
/*---------------------------------------------------------------------*/
#define FAST        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ff          first
#define ss          second
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int,int>
#define mp          make_pair
#define psb         push_back
#define psf         push_front
#define ppb         pop_back
#define ppf         pop_front
#define all(x)      x.begin(),x.end()
#define TESTS       int test;cin>>test;for(int tcase=1;tcase<=test;tcase++)
#define ordered_set tree< int, null_type, less_equal< int >, rb_tree_tag, tree_order_statistics_node_update>
/*--------------------------------------------------------------------*/
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v)
{ os << '{'; string sep;for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T> ostream& operator<<(ostream &os, const set<T> &v)
{ os << '{'; string sep;for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T> ostream& operator<<(ostream &os, const multiset<T> &v)
{ os << '{'; string sep;for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p)
{ return os << '(' << p.first << ", " << p.second << ')'; }
void dbg_out() { cerr << " "; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifndef ONLINE_JUDGE
#define cc(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
#define ccm(x)  cerr << "(" << #x <<") : "<<endl;for(auto i : x){ cerr<<"["<<i.ff<<"] = "<<i.ss<<endl;}
#define OK      cerr << "LINE "<<__LINE__<<" :"<<endl;
#define ee      cout<<endl;
#else
#define cc(...)
#define OK
#define ccm(x)
#endif
/*---------------------------------------------------------------------*/
#define MXN (ll)(1e6)
#define MOD (ll)(1e9+7)
#define INF (ll)(4e18)
#define inf (int)(2e9)
vector <vector<int>> V;
int main()
{
    FAST
    int a,b;cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}
/*--------------------------------------------------------------------*/
/*
>Check Corner Cases (n==1 or T==1)
>Overflow issues?
>LB / UB !!not found!! check?
>slow multi-set operations?try without multi-set
*/
/*--------------------------------------------------------------------*/
/* ---INPUT---
--------(1)------


-------(2)-------



-------(3)-------


-------(4)-------



--------------
*/
/*-----------------------MEHEDI HASAN,CSE-JU--------------------------*/



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//const int mod=998244353;
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
const int N=100005;
int n;
LL a[N];
LL suf[N];
int main(){
	n=read();
	For(i,0,n)
		a[i]=read();
	if (n==0)
		return puts(a[0]==1?"1":"-1"),0;
	if (a[0]!=0)
		return puts("-1"),0;
	Fod(i,n,1)
		suf[i]=suf[i+1]+a[i];
	LL v=1,ans=1;
	For(i,1,n){
		v=min(v*2,suf[i]);
		ans+=v;
		v-=a[i];
		if (v<0)
			return puts("-1"),0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5204