akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int n = in.nextInt(), m = in.nextInt(), d = in.nextInt();
		String colors = "RYGB";
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int k = (i + j) % (2 * d);
				int l = (i - j) % (2 * d);
				l = (l + 2 * d) % (2 * d);
				int col = (k / d) * 2 + (l / d);
				out.print(colors.charAt(col));
			}
			out.println();
		}
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
int main(){
    int n,m;
    cin >>n >>m;
    vector<int> a(m);
    for(auto &e:a) cin >>e;

    if( n >= accumulate(a.begin(),a.end(),0)){
        cout << n - accumulate(a.begin(),a.end(),0) <<endl;
    }else{
        cout << -1<<endl;
    }

}

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

int main() {
	int P, Q, R, a, b, c;
	cin >> P >> Q >> R;
	vector<int> S(3);
	S[0] = P + Q;
	S[1] = Q + R;
	S[2] = R + P;
	a = P + Q;
	b = Q + R;
	c = R + P;
	sort(S.begin(), S.end());

	if (a == S[0]) {
		cout << a << endl;
	}
	else if (b == S[0]) {
		cout << b << endl;
	}
	else {
		cout << c << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def main():
    N, M = map(int, input().split())
    if abs(N-M) > 1:
        print(0)
        exit()

    p = 10**9 + 7
    ans = 1
    if N == M:
        ans *=2
    
    for i in range(N):
        ans = ans * (i+1) % p
    for j in range(M):
        ans = ans * (j+1) % p
    
    print(ans)

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

const ll M = 200001;
ll facto[M], inv[M], factoinv[M];

int modpow(ll a, ll n) {
  if (n == 0) return 1;
  if (n == 1) return a % mod;
  if (n % 2 == 1) return (a * modpow(a, n - 1)) % mod;
  ll t = modpow(a, n / 2);
  return (t * t) % mod;
}

void nCrmod() {
    facto[0] = facto[1] = 1; inv[1] = 1, factoinv[0] = factoinv[1] = 1;
    
    for (int i = 2; i < M; i++) {
        facto[i] = i * facto[i - 1] % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        factoinv[i] = inv[i] * factoinv[i - 1] % mod;
    }
}

int main() {
    ll n, a, b; cin >> n >> a >> b;
    nCrmod();
    const ll Max = max(a, b) + 1;
    ll niko[Max];
    niko[0] = 1;
    niko[1] = n;
    for (int i = 2; i < Max; i++) {
        niko[i] = ((n - i + 1) * niko[i - 1]) % mod;
        niko[i] = niko[i] * inv[i] % mod;
        
    }
    ll ans = modpow(2, n);
    ans--;
    if (ans < 0) ans += mod;
    ans -= niko[a];
    if (ans < 0) ans += mod;
    ans -= niko[b];
    if (ans < 0) ans += mod;
    cout << ans << endl;
    return 0;
}

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

int main(){
    int x, n;
    cin >> x >> n;
    vector<int> d(102);
    rep(i,n){
        int p;
        cin >> p;
        d[p] = 1;
    }
    P ans(99999, -1);
    for(int i=0; i<=101; i++){
        if(d[i] == 1) continue;
        int dif = abs(x-i);
        ans = min(ans, P(dif,i));
    }
    cout << ans.second << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

int main() {
    string str;
    cin >> str;

    int top = (str[0] - '0') * 10 + (str[1] - '0');
    int low = (str[2] - '0') * 10 + (str[3] - '0');

    bool top_mm = 1 <= top && top <= 12;
    bool low_mm = 1 <= low && low <= 12;

    if (!top_mm && !low_mm) {
        cout << "NA" << endl;
        return 0;
    }

    if (top_mm && low_mm) {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }

    if (top_mm && !low_mm) {
        cout << "MMYY" << endl;
    } else
        cout << "YYMM" << endl;

    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n = I()
    r = (n-1) * n // 2

    return r


print(main())



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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i], arr[i]--;
	vi dp (N);
	for (int x : arr) {
		if (x == 0) dp[x] = 1;
		else {
			dp[x] = dp[x-1]+1;
		}
	}
	int best = 0;
	for (int x : dp) best = max(best, x);
	print(N - best);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string n;
  cin >>n;
  for(int i=0;i<n.length();i++){
    if(n[i]=='9')
      n[i]='1';
    else if(n[i]=='1')
      n[i]='9';
  }
  cout << n << endl;
  return 0;
}

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

int Max(int &a,int b){return a = max(a,b);}

int dp[2][1001][1001];
int check(const string &a,const string &b){
  int n = a.size();
  int m = b.size();
  assert(n==m);
  int res = 0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      Max(res,dp[0][i][j]);
      Max(res,dp[1][i][j]);
      if(j<n) Max(dp[1][i][j+1],dp[1][i][j]);
      if(i<n)Max(dp[0][i+1][j],dp[1][i][j]+1);
      if(i<n&&j<n&&a[i]==b[j])Max(dp[1][i+1][j+1],dp[0][i][j]+1);
    }
  }
  return res>=n;
}

int main(){
  string a,b;
  cin>>a>>b;
  bool ans = check(a,b);
  cout<<(ans? "Yes":"No")<<endl;
  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

// Description: ??°??????????????????(?????????????°??????¨???)
// Verifyed: Many Diffrent Problem 

//Appropriately Changed
using edge=struct{int to;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to){ 
	graph[from].push_back({to});
}

// Description: ??¨????????????????°???±????\????  
// TimeComplexity: Init $ \mathcal{O}(N) $ Query:$ \mathcal{O}(\log V)$
// Verifyed: AOJ GRL_5_C
 
auto init(const G& graph){
    const int n=graph.size(),logn=32-__builtin_clz(n);
    vector<vector<int>> par(logn,vector<int>(n));
    vector<int> depth(n);

    auto dfs=[&](int v,int p,int d){
        auto func=[&](int v,int p,int d,auto func)->void{
            par[0][v]=p,depth[v]=d;
            for(auto &e:graph[v]) if(e.to!=p) func(e.to,v,d+1,func);
        };
        return func(v,p,d,func);
    };

    dfs(0,-1,0);
    rep(k,logn-1)rep(v,n){
        par[k+1][v]=-1;
        if(par[k][v]!=-1) par[k+1][v]=par[k][par[k][v]];
    }
    return make_tuple(par,depth);
}

int lca(const auto &par,const auto &depth,int u,int v){
    const int logn=par.size();
    if(depth[u]<depth[v]) swap(u,v);
    rrep(k,logn) if((depth[u]-depth[v])>>k&1) u=par[k][u];
    if(u==v) return u;
    rrep(k,logn) if(par[k][u]!=par[k][v])u=par[k][u],v=par[k][v];
    return par[0][u];
}

int main(void){
	int n;
	cin >> n;
	G graph(n);

	rep(v,n){
        int k;
        cin >> k;
        rep(j,k){
            int c;
            cin >> c;
            add_edge(graph,v,c);
        }
	}

    auto info=init(graph);

    int q;
    cin >> q;
    rep(loop,q){
        int a,b;
        cin >> a >> b;
        cout << lca(get<0>(info),get<1>(info),a,b) << endl;
    }
	return 0;
}

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

using namespace std;


int main() {
    int N, M, C;
    int B[20];
    int A[20][20];
    int tmp;
    int res = 0;

    cin >> N >> M >> C;

    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < N; i++) {
        tmp = 0;
        for (int j = 0; j < M; j++) {
            tmp += A[i][j] * B[j];
        }
        tmp += C;
        if (tmp > 0) {
            res += 1;
        }
    }

    cout << res;

    return 0;
}

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

int main(){
  int N,K,X,Y,S;
  cin >>N >>K >>X >>Y;
     if(N >= K){
      S = X*K+Y*(N-K);
      cout <<S;
     }
     else{
         S = X*N;
         cout <<S;
     }

}

Measured memory_bytes: 256
program prob4
    implicit none
    integer::N, i, ans, l, j, k
    character(len=200005)::S,T
    integer::c(26), d(26)
    read(*,*) S, T
    l = len_trim(S)
    c = 0
    d = 0

    do i = 1, l
        j = ichar(S(i:i)) - 96
        k = ichar(T(i:i)) - 96
        if(c(j) > 0) then
            if(k .ne. c(j)) then
                write(*,'(a)') "No"
                stop
            end if
        else
            c(j) = k
        end if
        if(d(k) > 0) then
            if(j .ne. d(k)) then
                write(*,'(a)') "No"
                stop
            end if
        else
            d(k) = j
        end if
    end do
    write(*,'(a)') "Yes"
    stop
end program

Measured memory_bytes: 3368
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}

ll dp[100001];
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  // memset(dp, INF, sizeof(dp));
  int arr[n];
  fi(0, n)
    cin >> arr[i];
  dp[0] = 0;
  dp[1] = abs(arr[1] - arr[0]);
  fi(2, n) {
    dp[i] = min(dp[i - 2] + abs(arr[i] - arr[i - 2]), dp[i - 1] + abs(arr[i] - arr[i - 1]));
  }
  cout << dp[n - 1];
  // cout << ans << endl;
  return 0;
}



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

using namespace std;

int main()
{
    long int N,D,i,c=0,x[200000]={0},y[200000]={0};
    cin>>N>>D;
    D=D*D;
    for(i=0;i<N;i++)
    {
    cin>>x[i]>>y[i];
    if((x[i]*x[i]+y[i]*y[i])<=D)
    {
        c++;
    }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  double N,K; cin>>N>>K; 
  cout << ceil( (N-1)/(K-1) );
}


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

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      pair<int,int> data[n];
      data[0]=make_pair(0,0);
      int min_x=0,min_y=0;
      int max_x=0,max_y=0;
      for(int i=1;i<n;i++)
	{
	  int nn,d; 
	  cin>>nn>>d;
	  int dx[]={-1,0,1,0};
	  int dy[]={0,-1,0,1};
	  data[i]=make_pair(data[nn].first+dx[d],data[nn].second+dy[d]);
	  min_x=min(min_x,data[i].first);
	  min_y=min(min_y,data[i].second);
	  max_x=max(max_x,data[i].first);
	  max_y=max(max_y,data[i].second);
	}
      cout<<1-(min_x)+max_x<<" "<<1-(min_y)+max_y<<endl;
    }
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
 int A[100],N,v,i,j,k;

 scanf("%d",&N);

 for(i=0;i<N;i++){
  scanf("%d",&A[i]);
 }

 for(i=1;i<N;i++){

  for(k=0;k<N-1;k++){
   printf("%d ",A[k]);
  }
  printf("%d\n",A[N-1]);

  v=A[i];
  j=i-1;

  while( j>=0 && A[j]>v ){
   A[j+1]=A[j];
   j--;
  }
  A[j+1]=v;

 }

  for(k=0;k<N-1;k++){
   printf("%d ",A[k]);
  }
  printf("%d\n",A[N-1]);


 return 0;

}
 

Measured memory_bytes: 1800
#include <iostream>
using namespace std;
typedef long long ll;
ll D;

int main(){
  ll G; cin >> D >> G;
  ll p[D];
  ll c[D];
  for(int i=0; i<D; i++) cin >> p[i] >> c[i];
  
  ll ans=0;
  int temp=0;
  int count=10000;
  for(int bit=0; bit<(1<<D); bit++){
    int frag=0;
    for(int i=D-1; i>=0; i--){
      if(bit & (1<<i)){
        for(int j=0; j<p[i]; j++){
          ans += (i+1)*100;
          temp++;
          if(ans >= G){
            frag=1;
            break;
          }
        }
        if(!frag) ans+=c[i];
      }
      if(ans>=G) break;
    }
    if(ans>=G) count = min(count, temp);
    ans=0;
    temp=0;
  }
  cout << count << endl;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    double t = (double) v[0];
    repl(i, 1, n){
        t = (double) (t + v[i]) / 2;
    }
    cout << setprecision(15) << t << endl;
    return 0;
}

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

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	for(int i = 1; i < 100000; i++){
      	int r = i*0.08;
     	int s = i*0.1;
		if(r == a && s == b){
			return cout << i, 0;
		}
	}
	cout << -1;
	return 0;
}


Measured memory_bytes: 256
N=input()
N=int(N)
ls=[int(s) for s in input().split()]
ls=sorted(ls,reverse=True)
A=0
B=0
i=0
while i<N:
  if i%2==0:
    A=A+ls[i]
  if i%2==1:
    B=B+ls[i]
  i=i+1
print(A-B)

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

int main() {

int sx,sy,tx,ty;
cin >> sx >> sy >> tx >>ty;

for(int i = sy; i < ty; i++){
  cout << "U";
}

for(int i = sx; i < tx; i++){
  cout << "R";
}

for(int i = ty; i > sy; i--){
  cout << "D";
}

for(int i = tx; i > sx; i--){
  cout << "L";
}

cout << "L";

for(int i = sy; i <= ty; i++){
  cout << "U";
}

for(int i = sx; i <= tx; i++){
  cout << "R";
}

cout << "D" << "R";

for(int i = ty; i >= sy; i--){
  cout << "D";
}

for(int i = tx; i >= sx; i--){
  cout << "L";
}

cout << "U";

return 0;
}

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

const int N = (int)1e6;

pair<int,int> dat[N+5];
int dp[N+5];

int main() {
    int n,t; scanf("%d %d", &n, &t);

    for (int i=0; i<N+3; i++) dp[i] = -1;
    dp[0] = 0;
    int res = 0;
    for (int i=1; i<=n; i++) {
        int a,b; scanf("%d %d", &a, &b);
        dat[i] = make_pair(a,b);

        for (int j=t-1+a; j>=a; j--) {
            if (dp[j-a] != -1) {
                dp[j] = max(dp[j], dp[j-a] + b);
                res = max(res, dp[j]);
            }
        }
    }

    sort(dat+1, dat+1+n);

    for (int i=0; i<N+3; i++) dp[i] = -1;
    dp[0] = 0;
    int resa = 0;
    for (int i=1; i<=n; i++) {
        int a = dat[i].first;
        int b = dat[i].second;
        for (int j=t-1+a; j>=a; j--) {
            if (dp[j-a] != -1) {
                dp[j] = max(dp[j], dp[j-a] + b);
                resa = max(resa, dp[j]);
            }
        }
    }

    printf("%d\n", resa);
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;

int main(){
	cin>>n;
	int M=0,S=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		M=max(M,x);
		S+=x;
	}
	if(S>2*M) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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





int main()
{
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);*/

    long long int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;


    vector <long long int> v1,v2;

    cin>>n>>m>>k;

    s=0;
    b=-1;
    c=-1;
    for(i=0;i<n;i++)
    {
        cin>>a;
        s+=a;
        if(s<=k)
            b=i;
        v1.push_back(s);
    }

    s=0;
    for(i=0;i<m;i++)
    {
        cin>>a;
        s+=a;
        if(s<=k)
            c=i;
        v2.push_back(s);
    }

    m=0;
    b=upper_bound(v2.begin(),v2.end(),k)-v2.begin();
    if(b>0)
        m=max(m,b);
    for(i=0;i<n && v1[i]<=k;i++)
    {
        b=upper_bound(v2.begin(),v2.end(),k-v1[i])-v2.begin();
        if(b>0)
        m=max(m,i+1+b);
        else
            m=max(m,i+1);
    }

    cout<<m<<"\n";


    return 0;


}


Measured memory_bytes: 7936
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <utility>
#include <set>
#include <unordered_set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>
#include <complex>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int vis[100000];

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios::sync_with_stdio(0); cin.tie(0);
    
    int k; cin >> k;
    
    deque<i2> d;
    d.push_front({0,0});
    
    while (!d.empty())
    {
        auto node = d.front(); d.pop_front();
        int cur = node.first;
        int dist = node.second;
        
        if (vis[cur]) continue;
        vis[cur] = dist;
        
        assert(cur < k);
        
        if (cur != 0) d.push_front({(cur*10)%k, dist});
        if (cur%10 != 9) d.push_back({(cur+1)%k, dist+1});
        
    }
    
    cout << vis[0] << '\n';
    
    return 0;
    
}




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

#define justinlaiorz ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e5 + 2;
int n, a[N], pre[N], suf[N];

inline int abs(int a){
	return a < 0 ? -a : a;
}
int main(){
	justinlaiorz
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	for(int i = 1; i <= n; ++i) pre[i] = pre[i-1] + abs(a[i] - a[i-1]);
	for(int i = n; i >= 1; --i) suf[i] = suf[i+1] + abs(a[i] - a[i+1]);
	for(int i = 1; i <= n; ++i){
		cout << pre[i-1] + suf[i+1] + abs(a[i-1] - a[i+1]) << '\n';
	}
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    int n, x, t;
    cin >> n >> x >> t;
    int ans = n / x;
    if (n % x != 0) ans++;
    cout << ans * t << endl;
}

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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */

int main()
{
    _fastio
    ll n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
        cout<<(n/x)*t<<en;
    else
        cout<<((n/x)+1)*t<<en;
}


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

ll gcd(ll x,ll y){
  if(y==0) return x;
  return gcd(y,x%y);
}

int main(){
  ll a,b; cin>>a>>b;
  ll ans=a*b;
  ll div=gcd(a,b);
  cout<<ans/div<<endl;
}

Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>) {
    var MOD = (1e9 + 7).toInt()
    var dp = TreeMap<Long, TreeMap<Long, Long>>()
    fun func(S: Long, X: Long): Long {
        if (S == 0L) return 1
        var d = dp[S]
        if (d == null) {
            d = TreeMap<Long, Long>()
            dp[S] = d
        } else {
            val ans = d!![X]
            if (ans != null) return ans
        }
        var ans = func(S / 2, X / 2) % MOD
        ans = (ans + func((S - 1) / 2, (X - 1) / 2)) % MOD
        if (S >= 2) ans = (ans + func((S - 2) / 2, X / 2)) % MOD
        d!![X] = ans
        return ans
    }
    val N = nextLong()
    val ans = func(N, N)
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()


Measured memory_bytes: 31692
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

typedef long long LL;
const int N = 101;
const int V = 100001;

LL dp[N][V], w[N], v[N];

int main() {
    // freopen("a.txt", "r", stdin);
    int N, mod = 1e9 + 7;
    string s;
    cin >> N >> s;

    vector<vector<int> > dp(N + 1, vector<int>(N + 1, 0));
    dp[1][1] = 1;
    for(int i = 2; i <= N; ++i) {
        if(s[i - 2] == '<') {
            for(int j = 2; j <= i; ++j) {
                dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1]) % mod;
            }
        }
        else {
            for(int j = i - 1; j >= 1; --j) {
                dp[i][j] = (dp[i][j + 1] + dp[i - 1][j]) % mod;
            }
        }
    }

    int res = 0;
    for(int j = 1; j <= N; ++j) {
        res = (res + dp[N][j]) % mod;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 35584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC088B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            a = a.OrderBy(x => x).ToArray();
            int Alice = 0;
            int Bob = 0;
            bool AliceTurn = true;

            for(int i = n - 1; i >= 0; i--)
            {
                if (AliceTurn)
                {
                    Alice += a[i];
                }
                else
                {
                    Bob += a[i];
                }

                AliceTurn = !AliceTurn;
            }

            Console.WriteLine(Alice - Bob);
        }
    }
}

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

#define INF64 1LL << 60;
#define INF32 1 << 29;

using namespace std;

void execute()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << (A - B) % C << endl;
	return;
}

int main()
{
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
typedef pair<int, int> P;

int main(){
    int n, h;
    cin >> n >> h;
    vector<P> kougeki(n);
    REP(i, n) cin >> kougeki[i].second >> kougeki[i].first;
    sort(kougeki.begin(), kougeki.end());

    int kaisu = 0;
    int a_max = 0;
    REP(i, n) {
        a_max = max(a_max, kougeki[i].second);
    }

    REP_REV(i, n) {
        if(a_max < kougeki[i].first) {
            h -= kougeki[i].first;
            kaisu++;
            if(h <= 0) {
                cout << kaisu << endl;
                return 0;                
            }
        }
    }

    if(h % a_max == 0) {
        kaisu += h/a_max;
    } else {
        kaisu += h/a_max + 1;
    }

    cout << kaisu << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
 
int main() {
    int n,w;
    cin >> n;
    vector<int> W;
    rep(i,n) {
        cin >> w;
        W.pb(w);
    }
    int _abs = 0;
    int abb = 1000;
    rep(i,n) {
        int b = 0;
        int a = 0;
        for(int j=0; j<=i; ++j) {
            b+=W[j];
        }
        for (int k=i+1; k<n; ++k) {
          a += W[k];
        }
        _abs = abs(b-a);
        if (_abs < abb) {
            abb = _abs;
        }

    }
    cout << abb << "\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n, s = 0, h[100];
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    for(int i = 0; i < n; i++)
    {
        int k = 0;
        for(int j = 0; j <= i; j++)
        {
            if(h[j] > h[i])
                k++;
        }
        if(k == 0)
            s++;
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3684
#include <cstdio>

const int MN = 200005;

int N, M, A[MN];

inline bool check(int x) {
	int l = 1, r = M;
	for (int i = N; i > 1; --i)
		if ((A[i] >= x) == (A[i - 1] >= x)) { l = i; break; }
	for (int i = N; i < M; ++i)
		if ((A[i] >= x) == (A[i + 1] >= x)) { r = i; break; }
	return N - l <= r - N ? A[l] >= x : A[r] >= x;
}

int main() {
	scanf("%d", &N), M = 2 * N - 1;
	for (int i = 1; i <= M; ++i) scanf("%d", &A[i]);
	int l = 3, r = M - 1, mid, ans = 2;
	while (l <= r) {
		mid = (l + r) / 2;
		if (check(mid)) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2492
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_133
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nds = ReadInts();
            int n = nds[0];
            int d = nds[1];
            int[][] xs = new int[n][];
            for(int i=0;i<n;i++)xs[i]= ReadInts();
            int res = 0;
            for(int i = 0; i < n; i++)
            {
                for(int j = i + 1; j < n; j++)
                {
                    int val = 0;
                    for(int k = 0; k < d; k++)
                    {
                        val += (xs[i][k] - xs[j][k]) *(xs[i][k] - xs[j][k]);
                    }

                    for (int k = 0; k < 200; k++)
                    {
                        if (val == k * k)
                        {
                            res++;
                            break;
                        }
                    }
                }
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

typedef long long ll;
const double eps=1e-6,pi=acos(-1);
const int N=1e5+5,M=1e9+7,SEGM=4*N,OO=0x3f3f3f3f;
int n,m,a[N],b[N],c[N];
int mem[N];

int solve(int i=0){
    if(i>=n) return 1e9;
    if(i==n-1) return 0;
    int &ret=mem[i];
    if(~ret) return ret;
    ret=1e9;
    for(int j=1;j<=m&&j+i<n;++j)
        ret=min(ret,solve(i+j)+abs(a[i]-a[i+j]));
    return ret;
}

int main(){
    //freopen("myfile.txt","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i)
        scanf("%d",a+i);
    memset(mem,-1,sizeof mem);
    printf("%d",solve());
    return 0;
}


Measured memory_bytes: 10748
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    char a, b;
    cin >> a >> b;
    string aa, bb;

    for (int i = 0; i < (b - '0'); i++) {
        aa += a;
    }
    for (int i = 0; i < (a - '0'); i++) {
        bb += b;
    }
    if (a < b) {
        cout << aa << endl;
    } else {
        cout << bb << endl;
    }

    return 0;
}

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

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

    if(a > b) swap(a, b);
    if(b > c) swap(b, c);
    if(a > b) swap(a, b);

    cout << a << ' ' << b << ' ' << c << endl;
}


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

int main(){
    long long K;
    string S;
    cin >> K;
    cin >> S;
    long long i;
    if(S.length()<=K){
        cout << S << endl;
    }else{
        for(i=0; i<K; i++){
            cout << S[i];
        }
        cout << "..." << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int v[3005][3005];
int main()
{
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; i++)
        v[1][i] = 1;
    for(int i = 2; i <= n; i++)
    {
        int a = 0;
        if(s[i - 2] == '<')
            for(int j = 0; j <= n - i; j++)
                a = (a + v[i - 1][j]) % mod, v[i][j] = (v[i][j] + a) % mod;
        else
            for(int j = n - i; j >= 0; j--)
                a = (a + v[i - 1][j + 1]) % mod, v[i][j] = (v[i][j] + a) % mod;
    }
    cout << v[n][0];
    return 0;
}


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

void solve() {
    ll H, W;
    string cs = "#.";
    while(cin >> H >> W, H) {
        for(int r = 0; r < H; r++) {
            for(int c = 0; c < W; c++) {
                cout << cs[(c + r) % 2];
            }
            cout << endl;
        }
        cout << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.setf(ios::fixed);
    cout.precision(20);
    solve();
    return 0;
}


Measured memory_bytes: 3232
def f(as,c1)
	if c1.nil? then
		return as.size-1
	elsif c1>0 then
		return c1-1
	else 
		return nil
	end
end

a,b,q=gets.split(" ")
as=[]
bs=[]

a.to_i.times{
	as<<(gets.to_i)
}
b.to_i.times{
	bs<<(gets.to_i)
}
as.sort!
bs.sort!
q.to_i.times{
	c= gets.to_i
	r1=as.bsearch_index{|x| x >= c}
	r2=bs.bsearch_index{|x| x >= c}
	l1=f(as,r1)
	l2=f(bs,r2)
	#p [c,l1,r1,l2,r2]
	ans=[]
	[l1,r1].each{|e1|
		[l2,r2].each{|e2|
			if e1.nil? == false && e2.nil? == false then
				c1=as[e1]
				c2=bs[e2]
				#p [c,c1,c2]
				ans<<((c1-c).abs+(c1-c2).abs)
				ans<<((c2-c).abs+(c2-c1).abs)
			end
		}
	}
	puts ans.min
}

Measured memory_bytes: 5928
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000000

int main(){
	int h,w,n;cin>>h>>w>>n;//n:塗り分ける色の種類   h*wマス
	
	priority_queue<int> que;
	for(int i=0;i<n;i++){
		int a;cin>>a;
		for(int j=0;j<a;j++){
			que.push(i);
		}
	}//queに色iをa個push

	vector<vector<int>> c(h,vector<int>(w,0));

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int num=que.top();
			que.pop();
			if(i%2==0){
				c[i][j]=num;
			}else{
				c[i][w-1-j]=num;
			}
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<c[i][j]+1<<" ";
		}
		cout<<endl;
	}

	return 0;
}

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

char al[]={'I','V','X','L','C','D','M'};
#define REP(i,n) for(int i=0; i<n; ++i)

int getv(char a)
{
	int ret=1;
	REP(i,7)
	{
		if(a==al[i]) return ret;
		
		if(i%2==0) ret*=5;
		else ret*=2;

	}
}

int main()
{
	string s;
	while(cin >> s)
	{
		s+='I';
		int ret=0;
		REP(i,s.size()-1)
		{
			ret+=getv(s[i])*(getv(s[i]) >= getv(s[i+1]) ? 1:-1);
		}
		cout << ret << endl;
	} 
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
using ll =long long;
using namespace std;



int main(){
    int k,s;
    cin>>k>>s;
    int c=0;
    rep(i,k+1){
        rep(j,k+1){
            if(s-i-j>=0&&s-i-j<=k){
                c++;
            }
        }
    }
    cout<<c<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define scan(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;


signed main()
{
	ios_base::sync_with_stdio(false);   
    cin.tie(NULL);

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	int n;
    	cin>>n;
    	int rem=n%10;
    	if(rem==3)
    	{
    		cout<<"bon"<<endl;
    	}
    	else if(rem==0 || rem==1 || rem==6 || rem==8)
    	{
    		cout<<"pon"<<endl;
    	}
    	else
    		cout<<"hon"<<endl;
    	
    	
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="SUN")
        cout<<"7"<<endl;
    else if(s=="MON")
        cout<<"6"<<endl;
    else if(s=="TUE")
        cout<<"5"<<endl;
    else if(s=="WED")
        cout<<"4"<<endl;
    else if(s=="THU")
        cout<<"3"<<endl;
    else if(s=="FRI")
        cout<<"2"<<endl;
    else
        cout<<"1"<<endl;
        return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int lastin[1111];
int blessed[1111];
bool manin[1111];
bool valkyria_in;
int valkyria_time;
int n;
string s;
int ans;
int hr,mi;
char move;
int inde;
void solve(){
	int t=hr*60+mi;
	if(move=='I'){
		if(inde==0){
			valkyria_in=true;
			valkyria_time=t;
		}
		else{
			manin[inde]=true;
			lastin[inde]=t;
		}
	}
	else{
		if(inde==0){
			valkyria_in=false;
			for(int i=1;i<1111;i++){
				if(manin[i])blessed[i]+=t-max(lastin[i],valkyria_time);
			}
		}
		else{
			manin[inde]=false;
			if(valkyria_in)blessed[inde]+=t-max(lastin[inde],valkyria_time);
		}
	}
}
int main(){
	while(cin>>n&&n>0){
		ans=0;
		memset(manin,0,sizeof(manin));
		memset(blessed,0,sizeof(blessed));
		valkyria_in=false;
		while(n--){
			cin>>s>>hr>>move>>mi>>move>>inde;
			solve();
		}
		for(int i=1;i<1111;i++)ans=max(ans,blessed[i]);
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 1208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int Q = Integer.parseInt(st.nextToken());
		String S = br.readLine();
		int[] a = new int[N];
		for (int i = 0; i < N-1; i++) {
			if (S.charAt(i) == 'A' && S.charAt(i+1) == 'C') a[i+1]++;
		}
		int[] psa = new int[N];
		psa[0] = a[0];
		for (int i = 1; i < N; i++) {
			psa[i] = psa[i-1] + a[i];
		}
		while (Q-->0) {
			st = new StringTokenizer(br.readLine());
			int l = Integer.parseInt(st.nextToken()), r = Integer.parseInt(st.nextToken());
			System.out.println(psa[r-1]-psa[l-1]);
		}
	}
	
}

Measured memory_bytes: 59204
def examC():
    N = I()
    A = [0]*N; xy = [[] for _ in range(N)]
    for i in range(N):
        A[i] = I()
        for j in range(A[i]):
            s1,s2 = LI()
            xy[i].append([s1,s2])
#    print(xy)
    loop = 2**N; differ = 2**4
    ans = 0
    for i in range(loop):
        uso = [False]*N
        honto = [False]*N
        cur = 0
        for j in range(N+1):
            if i&(2**j)==(2**j):
                cur +=1
#        print(i,cur)
        for j in range(N):
            if i&(2**j)==(2**j):
                for k in xy[j]:
                    if k[1]==0:
                        uso[k[0]-1] = True
                    elif k[1]==1:
                        honto[k[0]-1] = True
#チェック
        for j in range(N):
            if uso[j] and i&(2**j)==(2**j):
                cur = 0
                break
            if honto[j] and i&(2**j)==0:
                cur = 0
                break
        ans = max(ans,cur)
    print(ans)

    return

def examD(mod):
    N = I(); A = LI()
    d = defaultdict(int)
    for i in range(N):
        cur = A[i]
        j = 1
        while(cur>0):
            if cur&1==1:
                d[j] +=1
            j +=1
            cur >>=1
    ans = 0
    for i,j in d.items():
        ans += j*(N-j) * 2**(i-1)
        ans %=mod
    print(ans)
    return

def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	ll t;
	rep(i,n){
		cin >> t;
		a[i] = t-(i+1);
	}
	sort(a.begin(),a.end());
	ll ans(0);
	if(n % 2 == 1){
		ll b = a[n/2];
		rep(i,n){
			ans += abs(a[i] - b);
		}
	}else{
		ll ans1(0),ans2(0);
		ll b1 = a[n/2 - 1];
		rep(i,n){
			ans1 += abs(a[i] - b1);
		}
		ll b2 = a[n/2];
		rep(i,n){
			ans2 += abs(a[i] - b2);
		}
		if(ans1 < ans2) ans = ans1;
		else ans = ans2;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	int d;
	cin >> d;
	string c = "Christmas";
	string e = "Eve";
	cout << c;
	for(int i = 0; i < 25-d; i++)
		cout << " " << e;
	cout << endl;


	return 0;
}

Measured memory_bytes: 256
from sys import stdin

n, m, c = [int(x) for x in stdin.readline().rstrip().split()]
b = [int(x) for x in stdin.readline().rstrip().split()]
a = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(n)]
ans = 0

for i in range(n):
    s = 0
    for j in range(m):
        s += a[i][j] * b[j]
    s += c
    if s > 0:
        ans += 1

print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main() {
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1, dy = y2 - y1;
	int x3, y3, x4, y4;
	swap(dx, dy); dx = -dx;
	x3 = x2 + dx, y3 = y2 + dy;
	swap(dx, dy), dx = -dx;
	x4 = x3 + dx, y4 = y3 + dy;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
 	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x,a,b,answer;
  
  scanf("%d",&x);
  scanf("%d",&a);
  scanf("%d",&b);
  
  answer=x-a;
  
  while(answer>=0)
    answer-=b;
  
  if(answer==0)
  printf("%d",answer);
  
  if(answer<0)
  printf("%d",answer+b);
  
    
    return 0;
}

Measured memory_bytes: 128