akhauriyash/Code-Regression huggingface dataset:
//Optional FAST
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
 
//Required Libraries
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
//Required namespaces
 
using namespace std;
using namespace __gnu_pbds;
//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
//#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll z[1001][11]={0};
int main()
{
    /*
   #ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif 
    */
    fio;
    ll n,m;
    cin>>n>>m;
    ll m1=m;
    ll n1=n;
    ll a=0,b=0;
    while(m1--)
    {
        a=a*10;
        a+=n;
    }
    while(n1--)
    {
        b=b*10;
        b+=m;
    }
    cout<<max(a,b)<<endl;
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
n_operation = 0
while(1):
    even_len = len([a for a in a_list if a % 2 == 0])
    if len(a_list) != even_len:
        print(n_operation)
        exit()
    else:
        a_list = [a / 2 for a in a_list]
        n_operation += 1

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  int n, m, i, j;

  while(true){
    string cb[200];
    string ca[200];
    string out;
    cin >> n;
    if(!n){ break; }
    for(i = 0; i < n; i++){
      cin >> cb[i] >> ca[i];
    }
    cin >> m;
    for(i = 0; i < m; i++){
      string ic;
      cin >> ic;
      for(j = 0; j < n; j++){
        if(ic == cb[j]){
          ic = ca[j];
          break;
	}
      }
      out = out	+ ic;
    }
    cout << out << endl;

  }
  return 0;
}

Measured memory_bytes: 1596
import math
def prime(x):
    if x == 2:
        return 1
    elif x < 2 or x % 2 == 0:
        return 0
    i = 3
    while(i <= math.sqrt(x)):
        if x % i == 0:
            return 0
        i += 2
    return 1

n = int(input())
x = []
for i in range(n):
    x.append(int(input()))
s = 0
for i in range(n):
    if prime(x[i]) == 1:
        s += 1
print(s)
        


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

bool f(double x) {
	 if (x == 0) return false;
	 int s=0;
	 rep(i,n) {
		 int know = int(ceil((double)a[i]/x))-1;
		 s += know;
	 }
	 if (s <= k) return true;
	 else return false;
}

int main() {
	cin >> n >> k;
	rep(i,n) cin >> a[i];
	double amax = *max_element(a.begin(),a.end());
	double amin = 0;
	while ((int(ceil(amax))-int(ceil(amin))) >= 1) {
		double amid = (amax + amin)/2;
		if (f(amid)) amax = amid;
		else amin = amid;
	}
	cout << int(ceil(amax)) << endl;
	return 0;
}


Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
string str;
void solve()
{
    int ans=0;
    for (int i=0;i<str.length();i++)
        if (str[i]=='1') ans++;
    cout<<ans<<endl;
}
int main()
{
    while(cin>>str)
        solve();
}

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


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

    vector<int> memo(b-a);

    rep(i,b-a+1) memo[i] = (i*(i+1))/2;

    cout << memo[b-a] - b << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <deque>
#define ll long long

using namespace std;

ll getKey(string s) {
	ll out = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			out = 10 * out + 1;
		}
		else if (s[i] == 'C') {
			out = 10 * out + 2;
		}
		else if (s[i] == 'G') {
			out = 10 * out + 3;
		}
		else if (s[i] == 'T') {
			out = 10 * out + 4;
		}
	}
	return out;
}

#define M 1046527
string table[M];


void insert(string q) {
	int h1 = getKey(q) % M;
	int h2 = getKey(q) % (M - 1) + 1;
	int cursor = h1;
	while (table[cursor].size() != 0 && cursor < M) {
		cursor += h2;
		cursor %= M;
	}
	if (cursor >= M) {
		cerr << "#ERROR" << endl;
		exit(1);
	}
	table[cursor] = q;
	return;
}

bool find(string q) {
	int h1 = getKey(q) % M;
	int h2 = getKey(q) % (M - 1) + 1;
	int cursor = h1;
	while (table[cursor].size() != 0 && cursor < M) {
		if (table[cursor] == q) return true;
		else cursor = (cursor + h2) % M;
	}
	return false;
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		string cmd, q; cin >> cmd >> q;
		if (cmd[0] == 'i') {
			insert(q);
		}
		else {
			if (find(q)) {
				cout << "yes" << endl;
			}
			else cout << "no" << endl;
		}
	}


	return 0;

}





Measured memory_bytes: 41680
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

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

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

int h, w;
vector<string> maze;

int bfs(int r, int c) {
	vector<vector<int>> dist(h, vector<int>(w, INT_MAX));
	dist[r][c] = 0;

	queue<pair<int, int>> q;
	q.push({r, c});

	int mx_dist = 0;
	while (!q.empty()) {
		pair<int, int> par = q.front();
		q.pop();

		for (int dir = 0; dir <= 3; dir++) {
			int nx = par.ff + dx[dir];
			int ny = par.ss + dy[dir];

			if (nx >= 0 and ny >= 0 and nx < h and ny < w and maze[nx][ny] == '.' and dist[nx][ny] == INT_MAX) {
				dist[nx][ny] = dist[par.ff][par.ss] + 1;
				mx_dist = max(mx_dist, dist[nx][ny]);
				q.push({nx, ny});
			}
		}
	}
	return mx_dist;

}

int main() {

	cin >> h >> w;
	maze.resize(h);
	for (int i = 0; i <= h - 1; i++) cin >> maze[i];

	int ans = INT_MIN;

	for (int i = 0; i <= h - 1; i++) {
		for (int j = 0; j <= w - 1; j++) {
			if (maze[i][j] == '#') continue;
			ans = max(ans, bfs(i, j));
		}
	}

	cout << ans;

	return 0;
}

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

#define int long long

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int x;
	cin>>x;
	if(x == 0){
		cout<<1<<endl;
	}
	else if(x == 1){
		cout<<0<<endl;
	}
	return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

const int MAX_N = 50, MAX_X = 50;
int N, A, x[MAX_N];
ll dp[MAX_N + 1][MAX_N * MAX_X + 1][MAX_N + 1];

ll solve(){
    REP(i, N + 1) dp[0][0][0] = 1;
    REP(i, N){
        REP(j, MAX_N * MAX_X + 1){
            REP(k, N + 1){
                dp[i + 1][j][k] += dp[i][j][k];
                if(j + x[i] > MAX_N * MAX_X) continue;
                dp[i + 1][j + x[i]][k + 1] += dp[i][j][k];
            }
        }
    }
    ll ret = 0;
    FOR(k, 1, N + 1) ret += dp[N][k * A][k];
    return ret;
}

signed main(){
    cin >> N >> A;
    REP(i, N) cin >> x[i];
    PRINT(solve());
    return 0;
}

Measured memory_bytes: 50048
"""Colorful Subsequence"""
N=int(input())
S=input()
result = 1
"""英小文字は26個あるのでaをord()でUnicode変換し、26文字分繰り返す。
        その後chr()でUnicodeから文字に変換し直しているのをcに入れている"""
for c in [chr(ord('a') + i) for i in range(26)]:
    result = (result * (S.count(c) + 1)) % (10**9 + 7)
result = (result - 1) % (10**9 + 7)
print(result)

Measured memory_bytes: 3316
import std.stdio, std.algorithm, std.range, std.conv, std.string;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

const int INF = 1_000_000_007;

void main() {
	int n;
	scanf("%d", &n);
	int[] a = new int[n];
	foreach (i; 0..n) scanf("%d", &a[i]);
	int p = 0, m = -INF; long val = -INF;
	foreach (parity; 0..2) {
		long sum = 0;
		int mx = -INF;
		foreach (i; 0..n) {
			if ((i&1) != parity) continue;
			if (a[i] > 0) sum += a[i];
			else mx = max(mx, a[i]);
		}
		if (sum == 0) sum = mx;
		if (val < sum) {
			p = parity;
			val = sum;
			if (sum == mx) m = mx;
			else m = -INF;
		}
	}
	writeln(val);
	int[] ans;
	int len = n;
	int head = 0;
	foreach_reverse (i; 0..n) {
		if ((i&1) != p) continue;
		if (a[i] <= 0) {
			if (a[i] == m) {
				m = -INF;
			} else {
				ans ~= i+1;
				if (i == n-1) len--;
				else if (i == 0) len--, head = 1;
				else len -= 2;
			}
		}
	}
	if (p != head) ans ~= 1, len--;
	foreach (i; 0..len/2) ans ~= 2;
	writeln(ans.length);
	foreach (i; ans) writeln(i);
}



Measured memory_bytes: 256
n=int(input(""))
c0=0
c1=0
c2=0
c3=0
for i in range(n):
    s=input("")
    if (s=="AC"):
        c0+=1
    elif(s=="WA"):
        c1+=1
    elif(s=="TLE"):
        c2+=1
    elif(s=="RE"):
        c3+=1
print("AC x "+str(c0))
print("WA x "+str(c1))
print("TLE x "+str(c2))
print("RE x "+str(c3))

        
    
    

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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<int> numbers(n);
    rep(i, n) cin >> numbers[i];

    int ma = *max_element(numbers.begin(), numbers.end());

    multiset<int> ps;
    for (int i : numbers) ps.insert(i);

    rep(i, ma + 1) {
        int j = max(i, ma - i);
        auto it = ps.find(j);
        if (it == ps.end()) {
            cout << "Impossible" << endl;
            ret();
        }
        ps.erase(it);
    }

    for (int i : ps) {
        int b = ma % 2 == 0 ? ma / 2 + 1 : (ma + 1) / 2 + 1;
        if (i >= b) continue;
        cout << "Impossible" << endl;
        ret();
    }
    cout << "Possible" << endl;

}


Measured memory_bytes: 256
import numpy as np
n, m, q = map(int, input().split())
cnt = [[0]*(n+1)for _ in range(n+1)]
for _ in range(m):
    L, R = map(int, input().split())
    cnt[L][R] += 1

S = np.cumsum(cnt, axis=0).cumsum(axis=1)

for _ in range(q):
    L, R = map(int, input().split())
    ans = S[R][R]-S[R][L-1]-S[L-1][R]+S[L-1][L-1]
    print(ans)


Measured memory_bytes: 22428
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<map>
using namespace std;
typedef long long LL;

bool vis[100005];
int cnt[100005];

int main(){
	memset(vis, 0, sizeof(vis));
	vis[1] = 1;
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cnt[i] = 1;
	int ans = n;
	while(m--){
		int x, y;
		cin >> x >> y;
		cnt[x]--;cnt[y]++;
		if(vis[x]) vis[y] = 1;
		if(!cnt[x]) vis[x] = 0;
	}
	for(int i = 1; i <= n; i++){
		if(cnt[i] == 0 || vis[i] == 0) ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define ST stack<int>
#define MS multiset<int>
#define scan(n) cin>>n
#define scann(a,b) cin>>a>>b
#define scannn(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define first fi
#define second se
#define REP(i,n) for(int i=0;i<n;++i)
 
void m1(){
  long long n; scan(n);
  string res = "";
  while(n > 0){
    if(n%26==0){
      res = 'z' + res;
      n /= 26;
      --n;
    }
    else{
      res = (char)('a'+n%26-1) + res;
      n /= 26;
    }
  }
  print(res);
}
/* 
void m2(){
  int t; scan(t);
  while(t--) m1();
}
*/
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}

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

using namespace std;

int main(void) {
    long n,k;
    cin >> n >> k;

    vector<long> a(n), f(n);
    for(auto &x: a) cin >> x;
    for(auto &x: f) cin >> x;
    sort(a.begin(), a.end());
    sort(f.begin(), f.end());

    long ng=-1, ok=1e15;
    while(ok - ng > 1) {
        long m = (ok+ng)/2;
        long kk = k;
        for(int i=0; i<n; i++) {
            // (x - t) * y <= m;
            // x - t <= m/y
            // x - m/y <= t
            long t = a[i] - m/f[n-1-i];
            kk -= max(0l, t);
            if(kk < 0) {
                ng = m;
                break;
            }
        }
        if(ng == m) continue;
        ok = m;
    }
    cout << ok << endl;
}


Measured memory_bytes: 3328
//https://atcoder.jp/contests/dp/tasks/dp_k
//shauryakr
#include<bits/stdc++.h>
using namespace std;
int arr[110], n;
int dp[100010][2];
int solve(int K, int player)
{
    if(K < arr[0])
    {
        return 1 - player;
    }

    if(dp[K][player] != -1)
        return dp[K][player];

    int ans = 1 - player;
    if(player)
    {
        for(int i=0; i<n && arr[i] <= K; i++)
        {
            ans = ans | solve(K - arr[i], 1 - player);
        }
    }
    else
    {
        for(int i=0; i<n && arr[i] <= K; i++)
        {
            ans = ans & solve(K - arr[i], 1 - player);
        }
    }
    
    dp[K][player] = ans;
    return ans;
}

int main()
{
    int k;
    cin >> n >> k;
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }

    memset(dp, -1, sizeof dp);
    if(solve(k, 0))
    {
        cout << "Second" << endl;
    }
    else
    {
        cout << "First" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 9344
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main(){
      
  fastio();
  int n,m,i,x,y,t;
  cin>>n>>m>>x>>y;
  int a[n],b[m];

  for(i=0;i<n;i++)
  	cin>>a[i];
  for(i=0;i<m;i++)
  	cin>>b[i];

  
  
  if(x<y)
  {
  	
  	bool w=1;
  	sort(a,a+n);
  	sort(b,b+m);
  	for(i=x+1;i<=y;i++)
  	{
  		if(i>a[n-1] && i<=b[0])
  		{
  			w=0;
  		}
  	}
  	if(w)
  		cout<<"War";
  	else
  		cout<<"No War";	
  }
  else
  	cout<<"War";
  return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

export function Main(input: string) {
    input = parseInt(input).toString();   // ?
    const last = input[input.length - 1];   // ?

    let result = '';
    if (new Set(['2', '4', '5', '7', '9']).has(last)) {
        result = 'hon';
    } else if (new Set(['0', '1', '6', '8']).has(last)) {
        result = 'pon';
    } else {
        result = 'bon';
    }


    //output

    console.log(result);
}

// Don't edit this line!
Main(fs.readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29616
#include <bits/stdc++.h>
     
    using namespace std;
     
    int dp[100001];
    int h[100001];
     
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
     
        int n,k;
        cin>> n >> k;
     
        for(int i = 0; i < n; i++)
        {
            cin>>h[i];
        }
     
        int mini = INT_MAX;
     
     
     
        dp[0] = 0;
        dp[1] = abs(h[0]-h[1]);
        mini = INT_MAX;
     
        for(int i = 2; i<n; i++)
        {
            //dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
            int pom = 0;
            for(int j = 1; j<=k; j++)
            {
                if(i-j>=0)
                {
                    pom = dp[i-j]+abs(h[i]-h[i-j]);
                    if(pom<mini) mini = pom;
                }
            }
     
            dp[i] = mini;
            mini = INT_MAX;
        }
     
        cout<< dp[n-1];
     
     
        return 0;
    }

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
struct node{
char name[20];
int fen;
int id;
}a[105];
char cmp1(node a,node b){
if(strcmp(a.name,b.name)!=0)
    return strcmp(a.name,b.name)<0;
else
    return a.fen>b.fen;
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
    cin>>a[i].name>>a[i].fen;
    a[i].id=i;
}
sort(a+1,a+n+1,cmp1);
for(int i=1;i<=n;i++){
    cout<<a[i].id<<endl;
}
return 0;
}

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

int main(){
  string s, t; cin >> s >> t;

  int len = s.size();
  s = s + s;
  
  vector<int> pos[26];

  for(int i=0; i<s.size(); ++i){
    pos[(int)(s[i] - 'a')].push_back(i+1);
  }

  for(auto x : pos){
    sort(x.begin(), x.end());
  }
  
  long long ans = 0;
  int now = 0;
  for(int i=0; i<t.size(); ++i){
    char next = t[i] - 'a';
    auto itr = upper_bound(pos[next].begin(), pos[next].end(), now);

    if(itr == pos[next].end()){
      cout << -1 << endl;
      return 0;
    }else{
      ans += *itr - now;
      now = *itr;
      if(now > len) now -= len;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 2292
#include<stdio.h>
int main()
{
    int n,x;
    scanf("%d%d",&n,&x);

    int l=x;
    int r=x+n-1;
    int eat;

    if(r<=0)eat=r;
    else if(l>=0)eat=l;
    else eat=0;
    int answer=(l+r)*(r-l+1)/2-eat;
    printf("%d\n",answer);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int sumdig(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N,A,B;
    int counter = 0;
    cin >> N >> A >> B;
    for(int i = 1;i <= N;++i){
        int sum = sumdig(i);
        if(sum >=A && sum <= B){
            counter += i;
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 256
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi 	 vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;

ll fact[1000005]={0};

ll mod(ll a,ll m=MOD){
        a%=m;
        if(a<0)a+=m;
        return a;
}

ll sum_of_first_n(ll a){
	ll ans=0;
	ans=1ll*(a)*(a+1)/2;
	return mod(ans);
}

ll power(ll a,ll b,ll m=MOD){
        ll res=1;
        while(b){
                if(b%2)res=mod(1ll*res*a),b--;
                else a=mod(1ll*a*a),b/=2;
        }
        return res;
}

int main()
{
	#ifndef ONLINE_JUDGE
	//freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	#endif
	ll i,j,k,l,n,test_case,m,r;
	test_case=1;
	//cin>>test_case;

	fact[0]=fact[1]=1;
	rep(i,2,1000005){
		fact[i]=mod(i*fact[i-1]);
	}


	while(test_case--){
		cin>>n>>m>>k;
		ll ans=0;
		ll can;
		reqp(i,1,n){
			ll temp=mod(1ll*m*m);
			ll t1=0;
			ll t2;
			// t1=sum_of_first_n(i-1);
			// t1=mod(1ll*t1*temp);
			t2=sum_of_first_n(n-i);
			t2=mod(1ll*t2*temp);
			ans=mod(ans+mod(t1+t2));
			// cout<<(t1+t2)<<".\n";
		}
		// cout<<ans<<"\n";
		reqp(i,1,m){
			ll temp=mod(1ll*n*n);
			ll t1=0;
			ll t2;
			// t1=sum_of_first_n(i-1);
			// t1=mod(1ll*t1*temp);
			t2=sum_of_first_n(m-i);
			t2=mod(1ll*t2*temp);
			ans=mod(ans+mod(t1+t2));
		}

		// cout<<ans<<"\n";
			ll temp;
			temp=fact[n*m-2];
			ll inv_t=power(fact[k-2],MOD-2);

			ll inv_t2=power(fact[n*m-2-(k-2)],MOD-2);
			ll temp2=mod(1ll*inv_t*temp);
			temp2=mod(1ll*temp2*inv_t2);
			cout<<mod(1ll*ans*temp2);


	}
	
	return 0;
}

Measured memory_bytes: 8064
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N, D = ri_()
ans = 0
for _ in range(N):
    p, q = ri_()
    if p ** 2 + q ** 2 <= D ** 2:
        ans += 1
print(ans)

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

typedef long long LL;
inline LL read(){
	register LL x=0,f=1;register char c=getchar();
	while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
	while(c>=48&&c<=57)x=(x<<3)+(x<<1)+(c&15),c=getchar();
	return f*x;
}
inline char readc(){
	register char c=getchar();
	while(c==' '||c=='\n'||c=='\t')c=getchar();
	return c;
}

const int MAXN=45;
const int INF=1e9;

int ice[MAXN][MAXN],f[MAXN][MAXN][MAXN][MAXN];
int n,m,hx,hy,ans=INF;

inline int poi(int lx,int ly,int rx,int ry){
	if(lx>rx||ly>ry) return 0;
	return ice[rx][ry]-ice[rx][ly-1]-ice[lx-1][ry]+ice[lx-1][ly-1];
}

int main(){
	n=read(),m=read();
	memset(f,0x3f,sizeof f);
	f[1][1][n][m]=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char c=readc();
			if(c=='P') hx=i,hy=j;
			ice[i][j]=ice[i-1][j]+ice[i][j-1]-ice[i-1][j-1]+(c=='#');
		}
	}
	for(int i=1;i<=hx;i++)
	for(int j=1;j<=hy;j++)
	for(int o=n;o>=hx;o--)
	for(int p=m;p>=hy;p--){
		ans=min(ans,f[i][j][o][p]+min(min(poi(i,j,hx,hy),poi(i,hy,hx,p)),min(poi(hx,j,o,hy),poi(hx,hy,o,p))));
		for(int s=i;s<=o;s++)
		for(int t=j;t<=p;t++){
			if(s>=hx&&t>=hy)
				f[i][j][s][t]=min(f[i][j][s][t],f[i][j][o][p]+poi(s+1,j,o,t)+poi(i,t+1,s,p));
			if(s>=hx&&t<=hy)
				f[i][t][s][p]=min(f[i][t][s][p],f[i][j][o][p]+poi(i,j,s,t-1)+poi(s+1,t,o,p));
			if(s<=hx&&t<=hy)
				f[s][t][o][p]=min(f[s][t][o][p],f[i][j][o][p]+poi(s,j,o,t-1)+poi(i,t,s-1,p));
			if(s<=hx&&t>=hy)
				f[s][j][o][t]=min(f[s][j][o][t],f[i][j][o][p]+poi(i,j,s-1,t)+poi(s,t+1,o,p));
		}
	}
	printf("%d\n",ans);
}

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

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

#ifdef LOCAL
  #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

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

  vector<int> nums;
  REP(i, n) {
    int l, r;
    scanf("%d %d", &l, &r);
    nums.push_back(r - l + 1);
  }

  int ans = accumulate(nums.begin(), nums.end(), 0);
  cout << ans;

  return 0;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol a, b; cin >> a >> b;
    vector<string> str(2, "");
    REP(i, b)
    {
        str[0] += to_string(a);
    }
    REP(i, a)
    {
        str[1] += to_string(b);
    }
    sort(ALL(str));

    cout << str[0] << endl;
    return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    if(n==1){
        cout << 0 <<"\n";
        return;
    }
    sort(a+1,a+n+1,greater<ll>());
    ll ans=a[1];
    ll cnt=2;
    ll i=2;
    while(cnt<n){
        if(cnt+2<=n){
            ans+=2*a[i];
            i++;
            cnt+=2;
        }
        else {
            ans+=a[i];
            i++;
            cnt++;
        }
        //cout << cnt <<" "<<ans<<"\n";
    }
    cout <<ans<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 5220
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"36
24"# => r#"GREATER"#,
r#"850
3777"# => r#"LESS"#,
r#"9720246
22516266"# => r#"LESS"#,
r#"123456789012345678901234567890
234567890123456789012345678901"# => r#"LESS"#,
r#"1234567890123456789
23456789012345678901"# => r#"LESS"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: chars,
        b: chars,
    }

    if a.len() > b.len() {
        "GREATER"
    } else if a.len() < b.len() {
        "LESS"
    } else {
        let mut s = "EQUAL";
        for i in 0..a.len() {
            // println!("{} {}", a[i], b[i]);
            if a[i] > b[i] {
                s = "GREATER";
                break;
            } else if a[i] < b[i] {
                s = "LESS";
                break;
            }
        }
        s
    }.to_string()
}

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

int main(){
  int n;
  std::cin >> n;
  int sum=0;
  int sum_v2=0;
  for(int i = 0 ; i < n ; i++){
    int t;
    std::cin >> t;
    sum += t;
    sum_v2 += t*t;
  }
  std::cout << (sum*sum-sum_v2)/2 << std::endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    string graph[n];
    for (int i = 0; cin >> graph[i]; i++) {
    }
    auto bipartite = [&]() {
        int color[n] = {};
        color[0] = 1;
        stack<int> stack;
        stack.emplace(0);
        do {
            auto top = stack.top();
            stack.pop();
            for (int i = 0; i < n; i++) {
                if (graph[top][i] == '1') {
                    if (color[i] == 0) {
                        color[i] = 3 - color[top];
                        stack.emplace(i);
                    } else if (color[i] == color[top]) {
                        return false;
                    }
                }
            }
        } while (!stack.empty());
        return true;
    };
    if (!bipartite()) {
        cout << -1;
    } else {
        int diameter = 0, dist[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (graph[i][j] == '1') {
                    dist[i][j] = 1;
                } else {
                    dist[i][j] = n;
                }
            }
            dist[i][i] = 0;
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        for (int i = 0; i <  n; i++) {
            for (int j = 0; j < n; j++) {
                diameter = max(diameter, dist[i][j]);
            }
        }
        cout << diameter + 1;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int x;
    cin >> x;
    int five_hundred = x / 500;
    x -= 500 * five_hundred;
    int five = x / 5;
    out(five_hundred*1000 + five*5);
}

Measured memory_bytes: 256
// AOJ 2001: Amida, the City of Miracle
// 2017.8.12 bal4u@uu
// 2017.11.7 retry

#include <stdio.h>
#include <stdlib.h>

typedef struct { int h, p, q; } T;
T t[1003];

char buf[30], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int cmp(T *a, T *b) { return b->h - a->h; }

int main()
{
	int n, m, a;
	T *p, *e;

	while (fgets(bp=buf, 30, stdin) && *buf != '0') {
		n = getint(), bp++, m = getint(), bp++, a = getint();
		for (p = t, e = p + m; p < e; p++) {
			fgets(bp=buf, 30, stdin);
			p->h = getint(), bp++, p->p = getint(), bp++, p->q = getint();
		}
		qsort(t, m, sizeof(T), cmp);
		for (p = t, e = p + m; p < e; p++) {
			if      (p->p == a) a = p->q;
			else if (p->q == a) a = p->p;
		}
		printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,k;
	cin >> n >> k;
	vector<double> e(n,0.0), sum(n+1,0.0);
	REP(i,n){ 
		int p;
		cin >> p;
		FOR(j,1,p+1){
			e[i] += (double)j / p;
		}
		sum[i+1] = sum[i] + e[i];
	}
	double ans = 0.0;
	REP(i,n-k+1){
		ans = max(ans, sum[i+k] - sum[i]);
	}
	
	cout << fixed << setprecision(15) << ans << '\n';
	return 0;
}



Measured memory_bytes: 3328
program prob6
    implicit none
    integer(8) :: K, A, B, ans, tmp
    read(*,*) K, A, B
    if(A + 2 >= B) then
        ans = 1+K
    else
        if(1+K <= A) then
            ans = 1+K
        else
            tmp = K - A + 1
            ans = A + mod(tmp, 2)
            ans = ans + tmp / 2 * (B - A)
        end if
    end if
    write(*,*) ans
    stop
contains
end program prob6

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

int main()
{
    int H, N;
    cin >> H >> N;

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

    int sum = 0;
    for (size_t i = 0; i < N; i++)
    {
        sum += A[i];
    }

    if (H - sum <= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back

double L;

int main(){
	
	scanf("%lf",&L);
	double d = L / 3;
	printf("%.10lf\n",d*d*d);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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

  ll N ; cin >> N ;
  ll D , X; cin >> D >> X;
  vector<ll> A;
  rep(i,N){
    ll inp; cin >> inp;
    A.pb(inp);
  }

  rep(i,N){
    X+= (D/A[i]);
    if(D%A[i] == 0) X--;
    X++;
  }

  cout << X << endl;
  
  

  
  //cout << fixed << setprecision(16) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  D2(x)       { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  all(x)      (x).begin(), (x).end()
#define  mem(a)      memset(a , 0 ,sizeof a)
#define  deb(x)      cout << #x << " - " << x << "\n";
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)  __builtin_popcountll(x)
#define  deb2(x,y)   cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b)  for(int i=a ; i>=b ; --i)
 
#define PI 3.141592653589793
const ll p = 5;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

void solve(){
    int t; cin >> t;
    vector<pair<int,int>>adj[t+2];
    
    int n,p,s;
    rep(i,1,t+1){
        cin >> n;
        rep(j,0,n){
            cin >> p >> s;
            adj[i].pb({p,s});
        }
    }
    
    int range = (1<<t),ans = 0;
    rep(i,0,range){
        int j = 0, num = i;
        vi v(t);
        while(num && j<t){
            v[j] = (num&1);
            num >>= 1 , ++j;
        }
        bool flag = true;
        
        for(int k=0;k<t;++k){
            if(v[k] == 0) continue;
            for(auto x:adj[k+1]){
                int person = x.first, status = x.second;
                if(v[person-1] != status){
                    flag = false;
                    break;
                }
            }
        }
        
        if(flag) ans = max(ans , accumulate(all(v),0));
    }
    
    cout << ans;
}

int main() {
    IOS;
    // int t; cin >> t;
    int t = 1;
    while(t--) solve();
}

Measured memory_bytes: 3660
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;



int main() {
	ll i, j, k;
	ll N, M, K;

	cin >> N;
	vector<int> A, B;

	rep(i, 0, N) {
		int a;
		cin >> a;
		A.push_back(a);

	}
	rep(i, 0, N) {
		int a;
		cin >> a;
		B.push_back(a);

	}
	ll ans = 0;
	if (A < B) {
		while (A < B) {
			ans++;
			next_permutation(A.begin(), A.end());
		}

	}
	else {
		while (B < A) {
			ans++;
			next_permutation(B.begin(), B.end());
		}

	}
	cout << ans;;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n-1);
    rep(i, n-1) cin >> a[i];
    map<int, int> mp;
    rep(i, n-1) mp[a[i]]++;

    rep(i, n) {
        cout << mp[i+1] << endl;
    }
    return 0;
}

Measured memory_bytes: 13500
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
string s;
int l;
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(i%2==0)
		{
			cout<<s[i];
		}
	}
 	return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int a;
    cin >> a;
    put(a/3);
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
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> P;
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);
const long long INF = 1000000007;
//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;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int a,b,c; cin >> a >> b >> c;
    if(max(a,max(b,c)) == a+b+c-max(a,max(b,c))) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
  char str[7];

  scanf("%s", str);

  if(str[2] == str[3] && str[4] == str[5]){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 256