akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 25

typedef struct{
	int left,right;
}Node;

Node T[N];

int check(int a[],int n){
	int i;
	for(i=0;i<n;i++){
		if(a[i]==0)return 0;
	}
	return 1;
} 

void searchRoot(int v[],int id){
	if(id==-1)return;
	v[id]=1;
	searchRoot(v,T[id].left);
	searchRoot(v,T[id].right);
}

void preorder(int u){
	if(u==-1)return;
	printf(" %d",u);
	preorder(T[u].left);
	preorder(T[u].right);
}

void inorder(int u){
	if(u==-1)return;
	inorder(T[u].left);
	printf(" %d",u);
	inorder(T[u].right);
}

void Postorder(int u){
	if(u==-1)return;
	Postorder(T[u].left);
	Postorder(T[u].right);
	printf(" %d",u);
}


int main(void){
	int i,n,id,l,r;
	int root;
	int visit[N];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&id,&l,&r);
		T[id].left=l;
		T[id].right=r;
		visit[id]=0;
	}
	
	for(i=0;i<n;i++){
		searchRoot(visit,i);
		if(check(visit,n)==1){
			root=i;
			break;
		}
	}
	
	printf("Preorder\n");
	preorder(root);
	printf("\n");
	printf("Inorder\n");
	inorder(root);
	printf("\n");
	printf("Postorder\n");
	Postorder(root);
	printf("\n");
	return 0;
}

Measured memory_bytes: 1800
#include<stdio.h>

int main(void){

    int p,q,r;

    int s1,s2,s3;
    int min;


    scanf("%d%d%d",&p,&q,&r);

    s1=p+q;
    s2=p+r;
    s3=q+r;

    if(s1<s2){
        min=s1;
    }
    else{
        min=s2;
    }

    if(min>s3){
        min=s3;
    }
    
    printf("%d",min);
    
    



    return 0;
}

Measured memory_bytes: 128
import math

if __name__ == "__main__":
    A, B, H, M = list(map(int, input().split()))
    s_ang_vel = 0.5
    l_ang_vel = 6
    time = H*60 + M
    theta = abs(s_ang_vel*time%360 - l_ang_vel*time%360)
    print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta))))


Measured memory_bytes: 9564
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    int n, k;
    int ans;
    cin>>n>>k;
    ans = (int)(log((double)n) / log((double)k)) + 1;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p[300000],min=1000000,ans=1;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>p[i];
  min=p[0];
  for(int i=1;i<n;i++){
      if(min>p[i]){
        ans++;
        min=p[i];
      }
  }
  cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;

int main(){
  long long n, i, j, ans=0;
  cin >> n;
  vector<string> s(n);
  vector<long long> count(n, 0);

  for(i=0; i<n; i++){
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(), s.end());

  for(i=0; i<n-1; i++){
    if(s[i] == s[i+1]) count[i+1] = count[i] + 1;
    ans += count[i+1];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<int> a(n+2);
    rep(i,m) {
        int l,r; cin>>l>>r;
        l--;
        a[l]++, a[r]--;
    }
    rep(i,n) {
        a[i+1] += a[i];
    }

    int ans = 0;
    rep(i,n+2) if (a[i] == m) ans++;

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 640
/**
 *      ABC 110 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-23 21:01:09
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, C; cin >> A >> B >> C;

    if (A >= B && A >= C){
        cout << 10 * A + B + C << endl;
    }
    else if (B >= A && B >= C){
        cout << 10 * B + A + C << endl;
    }
    else if (C >= A && C >= B){
        cout << 10 * C + A + B << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEsL 2e9
#define PIE 3.1415a926535

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 T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int a, b;
    cin >> a >> b;
    rep(i,1010){
        if (i * 2 / 25 == a && i / 10 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
x = list(map(int, input().split()))
first = True
for l, r in zip(range(0, n - k + 1), range(k - 1, n)):
    if  0 >= x[r]:
        if first:
            min_time = -x[l]
            first = False
        else:
            time =-x[l]
            if time < min_time:
                min_time = time
    elif 0 <= x[l]:
        if first:
            min_time = x[r]
            first = False
        else:
            time = x[r]
            if time < min_time:
                min_time = time
    else:
        if first:
            min_time = (x[r] - x[l]) + min(-x[l], x[r])
            first = False
        else:
            time =  2 * (x[r] - x[l]) - max(-x[l], x[r])
            if time < min_time:
                min_time = time
print(min_time)

Measured memory_bytes: 14564
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, K = map(int, readline().split())

    cnt = (N + 1) // 2

    if cnt >= K:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61828
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n,k;
  cin>>n>>k;
  int ans =1;
  REP(i,0,n){
    ans=min(ans*2,ans+k);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#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())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
	vector<long> array;
	vector<long> array2;
	
	long n, m;
	cin >> n;
	m = 0;
	REP(i, n)
	{
		long a;
		cin >> a;
		array.push_back(a);
		// debug(array[i]);
		m = max(m, a);
	}
	SORT(array);
	long j = array[0];
	long k = 0;
	array2.push_back(0);
	REP(i, n)
	{
		if(array[i]>j){
			array2.push_back(0);
			j = array[i];
			k++;
		}
		array2[k]++;
	}
	array.erase(std::unique(array.begin(), array.end()), array.end());
	// REP(i, array.size())
	// {
	// 	debug(array[i]);
	// }
	// REP(i, array2.size()){
	// 	debug(array2[i]);
	// }
	long ans;
	REP(i, array.size())
	{
		if(array2[i]>=array[i]){
			ans += array2[i] - array[i];
		}
		else{
			ans += array2[i];
		}
	}
	cout << ans << endl;
	return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

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

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = static_cast<LL>(1e9+7);
const LL N = 2e6+1;

LL fac[N] = {0};

LL modinv_fac[N] = {0};

LL binpow(LL x, LL p, LL mod) {
	LL res = 1;
	x %= mod;
	while (p) {
		if (p & 1) {
			res *= x;
			res %= mod;
		}
		x *= x;
		x %= mod;
		p >>= 1;
	}
	return res;
}

LL binom(LL n, LL r, LL mod) {
	if (r < 0 || r > n) {
		return 0;
	}
	else {
		LL term = fac[n];
		//LL den = binpow(fac[n-r], mod-2, mod)*binpow(fac[r], mod-2, mod) % mod;
		LL den = modinv_fac[n-r]*modinv_fac[r] % mod;
		return (term*den)%mod;
	}
}

int main() {
	fastio();

	// compute fac array
	fac[0] = 1;
	for (LL i = 1; i < N; ++i) {
		fac[i] = i*fac[i-1]%MOD;
	}

	// precompute modinv_fac and use this in binpow
	modinv_fac[N-1] = binpow(fac[N-1], MOD-2, MOD);

	for (LL i = N-2; i >= 0; --i) {
		modinv_fac[i] = (i+1)*modinv_fac[i+1] % MOD;
	}

	LL k;
	cin >> k;
	string s;
	cin >> s;

	LL res = 0;

	LL S = s.size();
	for (LL x = 0; x <= k; ++x) {
		LL term = (binpow(25, k-x, MOD) * binpow(26, x, MOD) % MOD);
		term = term * binom(S + k - 1 - x, S - 1, MOD) % MOD;
		res = (res + term) % MOD;
	}

	cout << res << "\n";

}

Measured memory_bytes: 35500
#include<stdio.h>
#include<string.h>
char c[101];
int main(){
	while(scanf("%s",c)){
		if(c[0]=='0')return 0;
		int count=0;
		int a=0;
		int b=0;
		for(int i=1;i<strlen(c);i++){
			if(c[i]=='A')a++;
			else b++;
		}
		if(a>b)a++;
		else b++;
		printf("%d %d\n",a,b);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace  std;
#define mp make_pair
#define pb push_back
const long double pi=3.1415926535897932384626433832;
const long long mod=1e9+7;
//long long primeset[5000000]={};
typedef complex<double> cd;
typedef long long ll;
//#define For(i,0,n) for(int i = 0 ; i<n ;i++) 
cd fast_exp(cd a, long long b)
{
	if (b == 0)
		return 1;
	
	cd res = fast_exp(a, b / 2);
	
	res = res * res;
	
	if (b % 2 == 1)
		res = res * a;
	
	return res;
}
int b[6000][6000];
long long fastexpon(long long a,long long b,long long mod)
{
	if(b==0)
		return 1;
	
	long long res=fastexpon(a,b/2,mod);
	
	res=(res*res)%mod;
	if(b%2==1)
		res= (res * a)%mod;

	return res;
}
//long long freq[(long long)1e7*3]={};
ll a[100];
ll v[100];
ll maxval[100][(int)1e5+1];
int n,w;
long long maxvalfind(int x, int cap)
{
	if(x==n || cap==0)
		return 0;
	if(maxval[x][cap]>-1)
		return maxval[x][cap];
	else
	{
		ll c1,c2=-1;
		c1= maxvalfind(x+1,cap);
		if(cap-a[x]>=0)
		c2= maxvalfind(x+1,cap-a[x])+v[x];

		maxval[x][cap]=max(c1,c2);
		return maxval[x][cap];
	}
}
int main()
{
	//memset(ncandidate,0,sizeof(ncandidate));	
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 cin>>n>>w;
	 memset(maxval,-1,sizeof(maxval));
	 for(int i=0;i<n;i++)
	 	cin>>a[i]>>v[i];

	 cout<<maxvalfind(0,w);
	 

	 	//	cerr<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}

Measured memory_bytes: 80128
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
d1, d2, d3 = 0, 0, 0
dm = []
for i in range(n):
    d1 += abs(x[i] - y[i])
    d2 += (abs(x[i] - y[i])) ** 2
    d3 += (abs(x[i] - y[i])) ** 3
    dm.append(abs(x[i] - y[i]))
print(d1)
print(d2 ** 0.5)
print(d3 ** (1/3))
print(max(dm))



Measured memory_bytes: 5644
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法
#define JUUHATI 1000000000000000000 
#define JUUHATIPLUS 1000000000000000001 

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll r,D,x;
    cin >> r >> D >> x;

    for(int i = 0;i < 10;i++){
        x = r * x - D;
        cout << x << endl;
    }

    
    
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  ll H[N+2];
  H[0] = -3;
  H[N+1] = 999999999999989999;
  for (int i = 1; i <= N; i++) {
    cin >> H[i];
  }
  bool ans = true;
  for (int i = 1; i <= N; i++) {
    if (H[i-1] <= H[i]-1 && H[i]-1 <= H[i+1]) {
      H[i]--;
    } else if (H[i-1] <= H[i] && H[i] <= H[i+1]) {
      
    } else {
      ans = false;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define PRINTARR(a,b) for(int i=0;(a+i)!=(b);i++){cout << *(a+i) << " ";}PN();
#define MP make_pair
#define PB push_back
#define EB emplace_back

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RLL(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 105
int grid[MAX_N][MAX_N];

int main()
{
    int h, w, n, cnt = 0;
    RI(h, w, n);
    REP(i, n) {
        int a;
        RI(a);
        REP(j, a) {
            grid[cnt / w][cnt % w] = i + 1;
            cnt++;
        }
    }
    REP(i, h) {
        REP(j, w) {
            if(i % 2 == 0) {
                printf("%d ", grid[i][j]);
            } else {
                printf("%d ", grid[i][w-j-1]);
            }
        }
        PN();
    }
    return 0;
}


Measured memory_bytes: 384
S = input()
T = input()
dis = {}
dit = {}
for s, t in zip(S,T):
    if s in dis:
        if dis[s]!=t:
            print('No')
            break
    else:
        dis[s] = t
    if t in dit:
        if dit[t]!=s:
            print('No')
            break
    else:
        dit[t] = s
else:
    print('Yes')

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

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

    int n,m;
    cin>>n>>m;
    if(n<m){
    for(int i=0;i<m;i++)
        cout<<n;
     }
    else{
        for(int i=0;i<n;i++)
        cout<<m;
    }
    cout<<"\n";

    return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

int N, A;

void input()
{
    cin >> N >> A;
}

void solve()
{
    cout << N * N - A << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    input();
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>
const int mxN=2e5;

int main()
{
    int n;
    cin >> n;
    int c=0;
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<n;j++)
        {
            if(i*j<n)
                c++;
            else
                break;
        }
    }
    cout << c;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
    SS(ll,w,h,n)
    ll sx=0,sy=0;
    rep(i,n){
        SS(ll,x,y,a)
        if(a==1){
            chmax(sx,x);
        }
        if(a==2){
            chmin(w,x);
        }
        if(a==3){
            chmax(sy,y);
        }
        if(a==4){
            chmin(h,y);
        }
    }
    p(max(0LL,w-sx)*max(0LL,h-sy));
}

Measured memory_bytes: 256
n, k = map(int, input().split())
li = []
for i in range(k):
    d = int(input())
    li.append([d, list(map(int, input().split()))])
c = 0
for i in range(1, n+1):
    for j in li:
        if i in j[1]:
            break
    else:
        c += 1
print(c)

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

using namespace std;

using ll=long long ;

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    vector<ll> pre(n+1), suf(n+1);
    pre[0] = 0;
    for (int i = 0; i < n; i++) {
        pre[i+1] = pre[i] + a[i];
    }
    suf[0] = 0;
    for (int i = 0; i < n; i++) {
        suf[i+1] = suf[i] + a[n-1-i];
    }
    ll res = 1e15;
    auto upd = [&](int p,int i,int k,int j){
        ll tmp = max({pre[p], pre[i]-pre[p], suf[k], suf[j]-suf[k]}) - min({pre[p], pre[i]-pre[p], suf[k], suf[j]-suf[k]});
        res = min(res, tmp);
    };
    for (int i = 2; i <= n-2; i++) {
        int j = n-i;
        int p = lower_bound(pre.begin()+1, pre.begin()+i, pre[i]/2) - pre.begin();
        int k = lower_bound(suf.begin()+1, suf.begin()+j, suf[j]/2) - suf.begin();
        if (p == i) p--;
        if (k == j) k--;
        upd(p,i,k,j);
        if (p>1) upd(p-1,i,k,j);
        if (k>1) upd(p,i,k-1,j);
        if (p>1 && k>1) upd(p-1,i,k-1,j);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define pii pair<int, int>
#define pll pair<LL, LL>
#define F first
#define S second
#define B begin()
#define E end()
#define MOD 1000000007
#define itt iterator
#define ritt reverse_iterator
#define LL long long

#define PI (4 * atan(1))

using namespace std;

int n, k, l, x, y, p;
bool ch[200005];
queue<int> mq;
list<int> path[200005];
pii par[200005];
map<pii, int> mmap;

int main()
{
	// freopen("D:\\Computer\\test.in", "r", stdin);
	// freopen("D:\\Computer\\test.out", "w", stdout);

    scanf("%d %d %d", &n, &k, &l);
    for(int i = 0; i < k; ++i)
    {
    	scanf("%d %d", &x, &y);
    	--x;
    	--y;
    	path[x].push_back(y);
    	path[y].push_back(x);
    }
    for(int i = 0; i < n; ++i)
    {
    	if(ch[i])
    		continue;
    	mq.push(i);
    	p = i;
    	while(!mq.empty())
    	{
    		x = mq.front();
    		mq.pop();
    		ch[x] = true;
    		par[x].F = p;
    		for(list<int>::itt it = path[x].B; it != path[x].E; ++it)
    		{
    			if(!ch[*it])
    			{
    				ch[*it] = true;
    				mq.push(*it);
    			}

    		}
    	}
    }

    for(int i = 0; i < n; ++i)
    	path[i].clear();
    memset(ch, 0 , sizeof(ch));

    for(int i = 0; i < l; ++i)
    {
    	scanf("%d %d", &x, &y);
    	--x;
    	--y;
    	path[x].push_back(y);
    	path[y].push_back(x);
    }
    for(int i = 0; i < n; ++i)
    {
    	if(ch[i])
    		continue;
    	mq.push(i);
    	p = i;
    	while(!mq.empty())
    	{
    		x = mq.front();
    		mq.pop();
    		ch[x] = true;
    		par[x].S = p;
    		for(list<int>::itt it = path[x].B; it != path[x].E; ++it)
    		{
    			if(!ch[*it])
    			{
    				ch[*it] = true;
    				mq.push(*it);
    			}

    		}
    	}
    }
    for(int i = 0; i < n; ++i)
    	++mmap[par[i]];
    for(int i = 0; i < n; ++i)
    	printf("%d ", mmap[par[i]]);
    return 0;
}



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;

  vector<int> a(n), b(n);
  rep(i, n) {
    a[i] = 20000 * (i + 1);
    b[i] = 20000 * (n - i);
  }

  rep(i, n) {
    int p;
    cin >> p;
    b[p - 1] += i;
  }

  rep(i, n) cout << a[i] << ' ';
  cout << endl;
  rep(i, n) cout << b[i] << ' ';
  cout << endl;
}


Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define MOD 2019
typedef long long int ll;

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

int main() {
    string s;
    cin>>s;
    int n=s.size();
    vector<int> mod(n);
    mod[0]=(int)s[n-1]-(int)'0';
    vector<int> a(2019,0);
    a[mod[0]]++;
    for (int i = 1; i < n; i++){
        mod[i]=mod_pow(10,i);
        mod[i]=mod[i]*((int)s[n-i-1]-(int)'0')+mod[i-1];
        mod[i]%=MOD;
        a[mod[i]]++;
    }
    int ans=a[0]*(a[0]+1)/2;
    for (int i = 1; i < 2019; i++){
        ans+=(a[i]-1)*a[i]/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4392
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int N;
ll a[500], sum[500];

ll dp[500][500];

ll solve(int l, int r) {
  if (l >= r) return 0;
  ll& res = dp[l][r];
  if (res != -1) return res;
  res = 1ll << 60;
  for (int m = l; m < r; m++) {
    ll cost = solve(l, m) + solve(m + 1, r);
    res = min(res, cost);
  }
  res += sum[r + 1] - sum[l];
  return res;
}

int main() {
  while (cin >> N) {
    for (int i = 0; i < N; i++) cin >> a[i];
    sum[0] = 0;
    for (int i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i];
    memset(dp, -1, sizeof(dp));
    cout << solve(0, N - 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <atcoder/all>
#define F first
#define S second
using namespace std;
using namespace atcoder;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
ll Mod = 1000000007;
int main() {
  int N,Q;
  cin >> N >> Q;
  dsu G(N);
  for (int i = 0; i < Q; i++) {
    int t,u,v;
    cin >> t >> u >> v;
    if (t == 0) {
      G.merge(u,v);
    } else {
      if (G.same(u,v)) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }
  return 0;
}

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

int main () {
  int n,m;
  cin >> n >> m;
  int count=0;
  for (int i=n;n>1;) {
    n--;
    count+=n;
  }
  for (int i=m;m>1;) {
    m--;
    count+=m;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  int n = s.size();
  bool well = true;
  REP(i, n) {
    if (i % 2 == 0) {
      if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
        well = false;
        break;
      }
    } else {
      if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
        well = false;
        break;
      }
    }
  }
  if (well) cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int n;
    cin >> n;

    vector<int> total;
    for(int i = 0; 4*i <= 100; i++){
        for(int j = 0; 4*i+7*j <= 100; j++){
            total.push_back(4*i+7*j);
        }
    }
    sort(total.begin(),total.end());
    for(int i = 0; i < total.size(); i++){
        if(n==total[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
  vector <string> c(3);
  for(int i=0;i<3;i++){
    cin >> c.at(i);
  }
  string s="";
  for(int i=0;i<3;i++){
    s+=c.at(i).at(i);
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define sortDecending(X) sort(all(X), greater<ll>()) //降順
#define sortAscending(X) sort(all(X))                //昇順
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl
#define printDouble(x) cout << fixed << setprecision(13) << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef priority_queue<ll, vl> decendingQueue;              //降順
typedef priority_queue<ll, vl, greater<ll>> ascendingQueue; //昇順
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int INF = 1e8;

struct point {
  int x, y;
};

void solve(int H, int W, int K, std::vector<std::string> A) {
  int sx, sy;
  rep(i, 0, H) {
    rep(j, 0, W) {
      if (A[i][j] == 'S') {
        sx = i;
        sy = j;
      }
    }
  }

  // 移動できるところに移動
  vector<vi> dp(H, vi(W, INF));
  queue<pair<point, int>> q;

  dp[sx][sy] = 1;
  q.push(mp((point){sx, sy}, 0));

  while (!q.empty()) {
    point p = q.front().first;
    int c = q.front().second;
    q.pop();

    rep(k, 0, 4) {
      int nx = p.x + dx[k];
      int ny = p.y + dy[k];

      if (nx >= 0 && nx < H && ny >= 0 && ny < W && A[nx][ny] == '.' &&
          dp[nx][ny] > c + 1) {
        dp[nx][ny] = c + 1;
        q.push(mp((point){nx, ny}, c + 1));
      }
    }
  }

  // そこから端までの最小距離を求める
  int ans = INF;
  rep(i, 0, H) {
    rep(j, 0, W) {
      if (dp[i][j] <= K) {
        chmin(ans, i);
        chmin(ans, j);
        chmin(ans, W - j - 1);
        chmin(ans, H - i - 1);
      }
    }
  }
  print((ans + K - 1) / K + 1);
}

int main() {
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  long long K;
  scanf("%lld", &K);

  vector<string> A(H);
  for (int i = 0; i < H; i++) {
    cin >> A[i];
  }
  solve(H, W, K, std::move(A));
  return 0;
}


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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

ll mPrime = 1000*1000*1000 + 7;
ll n, x;
vector<ll> s;
vector<ll> facts;
vector<ll> invFacts;
vector<int> tbl;

ll mAdd(ll x, ll y) {
  ll z = x + y;
  if (z < mPrime)  return z;
  else             return (z - mPrime);
}

ll mSub(ll x, ll y) {
  ll z = x - y;
  if (z >= 0)  return z;
  else         return (z + mPrime);
}

ll mMul(ll x, ll y) {
  return (x * y) % mPrime;
}

ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

ll mInv(ll x) {
  ll s, t;
  eGCD(x, mPrime, s, t);
  return s < 0 ? s + mPrime : s;
}


int main() {
  cin >> n >> x;
  s.resize(n);
  for (ll i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  facts.resize(n+1);
  invFacts.resize(n+1);
  facts.at(0) = invFacts.at(0) = 1;
  for (ll i = 1; i <= n; i++) {
    facts.at(i) = mMul(i, facts.at(i-1));
    invFacts.at(i) = mInv(facts.at(i));
  }
  sort(s.begin(), s.end());

  tbl.resize(x+1, 0);
  tbl.at(x) = 1;
    
  ll lim = x;
  for (ll k = n; k >= 1; k--) {
    ll newLim = 0;
    for (ll r = 1; r <= lim; r++) {
      ll weight = tbl.at(r);
      if (weight == 0)  continue;
      newLim = r;
      ll rem = k;
      for (ll t : s) {
	if (r < t)  break;
	rem--;
	ll newR = r % t;
	tbl.at(newR) = mAdd(tbl.at(newR), weight);
      }
      tbl.at(r) = mMul(tbl.at(r), rem);
    }
    lim = newLim;
  }
  ll ans = 0;
  for (ll r = 1; r <= lim; r++) {
    ans = mAdd(ans, mMul(tbl.at(r), r));
  }
  cout << ans << endl;

  return 0;
}



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

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

    ll a = 0;
    ll b = 0;

    vector<ll> A(N + 1, 0);
    for (int i = 1; i < N + 1; i++) {
        ll tmp;
        cin >> tmp;
        a += tmp;
        A[i] = a;
    }

    vector<ll> B(M + 1, 0);
    for (int i = 1; i < M + 1; i++) {
        ll tmp;
        cin >> tmp;
        b += tmp;
        B[i] = b;
    }

    ll left;
    ll right;

    ll max = 0;
    ll point = 0;
    ll old_point;
    for (int i = 0; i < N + 1; i++) {
        left = 0;
        right = M + 1;
        point = 0;
        while (1) {
            old_point = point;
            point = (right + left) / 2;
            if (B[point] + A[i] < K) {
                left = point;
            } else if (B[point] + A[i] > K) {
                right = point;
            } else {
                // cout << "!!" << i << " " << point << endl;
                break;
            }
            // cout << i << " " << point << " " << left << " " << right << " "
            //   << A[i] + B[point] << " " << (right + left) / 2 << endl;
            if (point == old_point) {
                break;
            }
        }
        // cout << i << " " << point << " " << A[i] + B[point] << endl;
        if (i + point > max && A[i] + B[point] <= K) {
            // cout << i << " " << point << " " << A[i] + B[point] << endl;
            max = i + point;
        }
    }
    cout << max << endl;

    return 0;
}


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

int main() {
	int r, g, b;
	int x;
	cin >> r >> g >> b;
	
	x = r * 100 + g * 10 + b;
	if (x % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

int main(){
	int n;
	int a[200000];
	int b[200000];
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	for(int i=0;i<n;i++) b[i] = a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++){
		int ans;
		if(b[i]<=a[n/2-1]) ans = a[n/2];
		else ans = a[n/2-1];
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 3712
N = int(input())
R0 = int(input())
R1 = int(input())
max_profit = R1 - R0
min_R = min(R0, R1)

for i in range(N-2):
    R = int(input())
    max_profit = max(max_profit, R - min_R)
    min_R = min(min_R, R)

print(max_profit)

Measured memory_bytes: 7656
#include <iostream>
#include<cstdio>
using namespace std;
int fa[100],r[100];
int Find_Set(int x)
{
    if (x != fa[x])
    {
        fa[x] = Find_Set(fa[x]); //这个回溯时的压缩路径是精华
    }
    return fa[x];
}
void Union(int x, int y)
{
    x = Find_Set(x);
    y = Find_Set(y);
    if (x == y) return;
    if (r[x] > r[y])
    {
        fa[y] = x;
    }
    else
    {
        if (r[x] == r[y])
        {
            r[y]++;
        }
        fa[x] = y;
    }
}
int main()
{
    int n,m,i,j,a[2000][2],ans=0;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++)
        scanf("%d%d",&a[i][0],&a[i][1]);
    for(i=0;i<m;i++)
    {
        for(j=0;j<=n;j++)
        {fa[j]=j;r[j]=0;}
        for(j=0;j<m;j++)
        {
            if(i!=j)
            {
                Union(a[j][0],a[j][1]);
            }
        }
        int father=Find_Set(1);
        for(j=1;j<=n;j++)
        {
            if(Find_Set(j)!=father)
            {ans++;break;}
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    string tmp;
    unordered_set<string> s;
    while(n--) {
        cin >> tmp;
        s.insert(tmp);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 17732
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,ans=0;
	cin>>n;
	while(n>=500){
		n-=500;
		ans += 1000;
	}
	while(n>=5){
		n-=5;
		ans += 5;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())

evidences = [[] for _ in range(N)]
for i in range(N):
  A = int(input())
  for _ in range(A):
    x, y = map(int, input().split())
    evidences[i].append((x-1,y))

result = 0
for i in range(1,2**N):
  consistent = True
  honest = 0
  for j in range(N):
    if (i>>j) & 1 == 0:
      continue
    honest += 1
    for x,y in evidences[j]:
      if (i>>x) & 1 != y:
        consistent = False
        break
    if not consistent:
      break
  if consistent:
    result = max(result, honest)
print(result)

Measured memory_bytes: 3064
X,N = map(int,input().split(" "))
if N==0:
  print(X)
else:
  p = list(map(int,input().split(" ")))
  for k in range(200):
    temp = X-k
    if temp not in p:
      print(temp)
      break
    semp = X+k
    if semp not in p:
      print(semp)
      break


Measured memory_bytes: 9120
import bisect

n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))

ue = []
for i in range(n):
    ue.append(bisect.bisect_left(a,b[i]))

sita = []
for i in range(n):
    sita.append(n - bisect.bisect_right(c,b[i]))

ans = 0
for i in range(n):
    ans += ue[i]*sita[i]

print(ans)


Measured memory_bytes: 23860
#include<cstdio>
#include<complex>
#include<utility>



int main(){
    int A[3];
    for(int i=0;i<3;i++){
        scanf("%d",&A[i]);
    }
    
    if(A[0]<A[1])std::swap(A[0],A[1]);
    if(A[0]<A[2])std::swap(A[0],A[2]);
    if(A[1]<A[2])std::swap(A[1],A[2]);

    int AB = A[0]-A[1];
    int AC = A[0]-A[2];

    int ans=0; 
    ans += AB/2;
    ans += AC/2;
    if(AB%2==0&&AC%2==0){
        ans += 0;
    }else if(AB%2!=0&&AC%2!=0){
        ans++;
    }else{
        ans += 2;
    }

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



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define inf 1e9 
int solve(vector<int> a,int n)
{
    vector<int> dp(n+1,0);
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        int option1=abs(a[i]-a[i-1])+dp[i-1];
        int option2=(i==2)?inf:(abs(a[i]-a[i-2])+dp[i-2]);
        dp[i]=min(option1,option2);
    }
    return dp[n];
}
signed main()
{
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    cout<<solve(a,n)<<endl;
}

Measured memory_bytes: 5636
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong();
		long b = scan.nextLong();
		long x = scan.nextLong();
		scan.close();

		long cnt = 0;
		if (a % x == 0) cnt++;
		cnt += (b / x) - (a / x);
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cassert>

int main()
{
	int n;
	char str[10];
	
	scanf("%d", &n);
	
	printf("0\n");
	fflush(stdout);
	scanf("%s", str);
	
	if(str[0] != 'V')
	{
		int l = 0, r = n;
		int col = (str[0] == 'M' ? 0 : 1);
		bool found = false;
		
		while(l + 1 != r)
		{
			int mid = (l + r) >> 1;
			
			printf("%d\n", mid);
			fflush(stdout);
			scanf("%s", str);
			
			if(str[0] == 'V')
			{
				found = true;
				break;
			}
			else
			{
				int cnow = (str[0] == 'M' ? 0 : 1);
				
				if((col ^ (mid & 1)) == cnow) l = mid;
				else r = mid;
			}
		}
		
		if(!found)
		{
			printf("%d\n", r);
			fflush(stdout);
			scanf("%s", str);
			assert(str[0] == 'V');
		}
	}
	
	return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string s;
    cin >> s;
    if (s[1] == s[2] && (s[0] == s[1] || s[2] == s[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()

    counter = Counter(S)
    ans = counter['R'] * counter['G'] * counter['B']
    
    for w in range(1, (N - 1) // 2 + 1):
        for i in range(N - 2 * w):
            if S[i] != S[i + w] and S[i] != S[i + 2 * w] and S[i + w] != S[i + 2 * w]:
                ans -= 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74124
using System;
using System.Collections.Generic;
using System.Linq;

class Program{

  static int a, b, c, ans;
  static int[] tou = new int[999];

  static int Main() {

    tou[0] = 1;
    for (int i = 1; i < 999; i ++) {
      tou[i] = tou[i-1] + i + 1;
    }

    string[] nyu = new string[2];

    nyu = Console.ReadLine().Split(' ');
    a = int.Parse(nyu[0]);
    b = int.Parse(nyu[1]);
    c = b - a;

    ans = tou[c - 1] - b;

    Console.WriteLine("{0}", ans);

    return 0;
  }

}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

vector<ll> G[100005];

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

    ll N,M; cin >> N >> M;

    for (int i = 0;i < M;i++){
        ll a,b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    priority_queue<P,vector<P>,greater<P>> que;
    que.push(P(0,1));

    ll dist[100005], ans[100005];
    for (int i = 0;i <= N;i++){
        dist[i] = LLONG_MAX;
    }

    dist[1] = 0;

    while(que.size()){
        P p = que.top(); que.pop();
        ll now = p.second, d = p.first;
        if(dist[now] < d) continue;
        for (int i = 0;i < G[now].size();i++){
            ll to = G[now][i];
            if(dist[to] > d+1){
                dist[to] = d+1;
                ans[to] = now;
                que.push(P(d+1,to));
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 2;i <= N;i++){
        cout << ans[i] << endl; 
    }

    return 0;

}

Measured memory_bytes: 14912
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    string ans = "";
    rep(i, n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;

int M,N,ans=0;
char tbl[1100][1100];
char flag[2][2];
char k;
int kotae;
int a,b,c,d,e;


int hantei(int i,int j){
	if(i<0 || j<0) return 0;
	else if(tbl[i][j]==flag[0][0]&&tbl[i+1][j]==flag[1][0]&&tbl[i][j+1]==flag[0][1]&&tbl[i+1][j+1]==flag[1][1]){
		return 1;
	}
	else return 0;
}


int main(){
	cin>>M>>N;
	for(int i=0;i<M;i++){
		for(int j=0;j<N;j++){
			cin>>k;
			tbl[i][j]=k;
		}
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			cin>>k;
			flag[i][j]=k;
		}
	}
	for(int i=0;i<M-1;i++){
		for(int j=0;j<N-1;j++){
			if(tbl[i][j]==flag[0][0]&&tbl[i+1][j]==flag[1][0]&&tbl[i][j+1]==flag[0][1]&&tbl[i+1][j+1]==flag[1][1]){
				kotae ++;
			}
		}
	}
	for(int i=0;i<M;i++){
		for(int j=0;j<N;j++){
			k=tbl[i][j];

			a = hantei(i-1,j-1)+hantei(i-1,j)+hantei(i,j-1)+hantei(i,j);

			tbl[i][j]=flag[0][0];
			b = hantei(i-1,j-1)+hantei(i-1,j)+hantei(i,j-1)+hantei(i,j);
			tbl[i][j]=flag[0][1];
			b = max(b,hantei(i-1,j-1)+hantei(i-1,j)+hantei(i,j-1)+hantei(i,j));
			tbl[i][j]=flag[1][0];
			b = max(b,hantei(i-1,j-1)+hantei(i-1,j)+hantei(i,j-1)+hantei(i,j));
			tbl[i][j]=flag[1][1];
			b = max(b,hantei(i-1,j-1)+hantei(i-1,j)+hantei(i,j-1)+hantei(i,j));

			c = max(c,b-a);
			tbl[i][j]=k;
		}
	}
	cout << kotae+c << endl;
	return 0;
}
		
			
			
	

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

cnt=0

while 1:
    for i in range(len(h)-1,0,-1):
        if h[i]==h[i-1]:
            h.pop(i)

    if len(h)==1:
        break
    # mp:水やりポイント
    mp = h.index(max(h))

    if mp==0:
        cnt += h[mp] - h[mp+1]
    elif mp==len(h)-1:
        cnt += h[mp] - h[mp-1]
    else:
        cnt += h[mp] - max(h[mp-1],h[mp+1])

    h.pop(mp)

print(cnt+h[0])


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

int main(){
  string s;
  cin >> s;
  int l = s.size();
  char tmp = s.at(0);
  int ans = 0;
  for(int i = 1; i < l; i++){
    if(s.at(i)!=tmp){
      ans++;
      tmp = s.at(i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
a = [1, 3, 5 ,7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
x, y = map(int, raw_input().split())
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print 'Yes'
else:
    print 'No'


Measured memory_bytes: 2568