akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,k,a[100010],ans;
signed main(){
	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
		if(a[i]>=k)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <unordered_set>
#include <vector>
typedef std::vector<int> vin;
const int MAXN = 1e5+5;
vin beg[MAXN], end[MAXN];
std::unordered_set<int> bad;
int a, b, M, N;

int main()
{
	scanf(" %d%d", &N, &M);
	bad.reserve(M);
	for(int i = 0; i < M; ++i)
	{
		scanf(" %d%d", &a, &b); --b;
		beg[a].push_back(i);
		end[b].push_back(i);
		bad.insert(i);
	}
	int ret = 0;
	for(int i = 1; i < N; ++i)
	{
		for(int edge: beg[i])
			bad.insert(edge);
		for(int edge: end[i])
			if(bad.count(edge))
			{
				bad.clear();
				++ret;
				break;
			}
	}
	printf("%d\n", ret);
	return 0;
}


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

using namespace std;

int main() {
	long long I,O,T,J,L,S,Z; cin >> I >> O >> T >> J >> L >> S >> Z;
	long long ans=(I/2+J/2+L/2)*4;
	if(I&&J&&L) ans=max(ans,6+((I-1)/2+(J-1)/2+(L-1)/2)*4);
	ans+=O*2;
	cout << ans/2 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N,i,ans;
  string A,B,C;
  
  cin >> N;
  cin >> A;
  cin >> B;
  cin >> C;
  
  ans = 0;
  for (i = 0;i < N;i++) {
    if (A[i] != B[i]) {
      if (C[i] == B[i])
        ans++;
      else if (C[i] == A[i])
        ans++;
      else
        ans += 2;
    }
    else {
      if (C[i] != B[i])
        ans++;
    }
  }
  
  cout << ans << "\n";
  
  return 0;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	ll a, b; cin >> a >> b;
	if (a == 1)a = 14;
	if (b == 1)b = 14;
	if (a > b) cout << "Alice" << endl;
	if (a == b) cout << "Draw" << endl;
	if (a < b) cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <stack>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)

typedef long long ll;

int main(){
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> sticks(n);
    rep(i,n){
        cin >> sticks[i];
    }
    sort(sticks.begin(), sticks.end());

    rep(i,n-2){
        repn(j,i+1,n-1){

            int target = sticks[i] + sticks[j];
            int index = lower_bound(sticks.begin(), sticks.end(), target) - sticks.begin();

            // Didn't find any triangle
            if( index == j ){
                continue;
            }
            // Find triangle.
            ans += index - j - 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
$\=8e18;($n,$k)=glob<>;@x=sort{$a-$b}<>;
for$i(0..$n-$k){
	@p=();/ /,push@p,$' for@x[$i..$i+$k-2];
	for$x(@x[$i+$k-1..$n-1]){
		$x=~$";@p=sort{$a-$b}@p,$';
		$\-=$-=$\-($p[$_+$k-1]-$p[$_])*($x-$x[$i])for 0..@p-$k
	}
}
print

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
  freopen("ip1.txt", "r", stdin);
  freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
  return (a.second < b.second);
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int prime(int n) {
  int flag = 1;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {flag = 0; break;}
  }
  return flag;
}
int power(int x, int y)
{
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
  else
    return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}

int32_t main()
{
  k_007();
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3844
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

// https://betrue12.hateblo.jp/entry/2019/01/13/030527
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, q; cin >> n >> q;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<long long> accum(n+1, 0), even_odd(n, 0);
  REP(i, n) accum[i+1] = accum[i] + a[i];
  even_odd[0] = a[0];
  even_odd[1] = a[1];
  FOR(i, 2, n) even_odd[i] = even_odd[i-2] + a[i];
  REP(repeat, q) {
    int x; cin >> x;
    int left = -1, right = n-1; // (left, right]
    while (right - left > 1) {
      // a[mid] と書かれたカードをそれぞれ何枚目に取るか?
      // tmp = 青木くんが連続して取るカードにおける最も左の index
      int mid = (left + right) / 2, tmp = distance(a.begin(), lower_bound(ALL(a), x-(a[mid]-x)));
      // lhs = a[mid] と書かれたカードを取るまでに (それ自身を含む)
      //       青木くんが連続して取るカードの枚数
      // rhs = 高橋
      (mid-tmp+1 < n-mid? left : right) = mid;
    }
    long long ans = accum[n] - accum[right];
    // tmp = 2人の取るカードが数の大きいものから交互になるときの始点
    int tmp = n - 1 - (n - right) * 2;
    if (tmp >= 0) ans += even_odd[tmp];
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    if(s.length() != t.length()){
        cout << "No" << endl;
    }
    else{
        int flag = 0;
        for(int i = 0; i < t.length(); i++){
            if(s == t){
                flag = 1;
                break;
            }
            string tmp = "";
            tmp += s[s.length()-1];
            tmp += s;
            tmp.erase(tmp.length()-1);
            s = tmp;
        }
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(1000000)
n,q=map(int,input().split())
g=[[]for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

lis = [0 for i in range(n)]
for i in range(q):
    p,x=map(int,input().split())
    lis[p-1]+=x

def dfs(i,j):
    nex=g[i]
    for d in nex:
        if d==j: continue
        #print(d)
        lis[d]+=lis[i]
        dfs(d,i)

dfs(0,-1)
print(*lis)


Measured memory_bytes: 230920
#define DEBUG 0
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 7/20/2019, 9:01:11 PM
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a)
  {
    mint b{a};
    return *this *= b.power(MOD - 2);
  }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
class combination
{
public:
  vector<mint> inv, fact, factinv;
  static int MAX_SIZE;
  combination() : inv(MAX_SIZE), fact(MAX_SIZE), factinv(MAX_SIZE)
  {
    inv[1] = 1;
    for (auto i = 2; i < MAX_SIZE; i++)
    {
      inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
    }
    fact[0] = factinv[0] = 1;
    for (auto i = 1; i < MAX_SIZE; i++)
    {
      fact[i] = mint(i) * fact[i - 1];
      factinv[i] = inv[i] * factinv[i - 1];
    }
  }
  mint operator()(int n, int k)
  {
    if (n >= 0 && k >= 0 && n - k >= 0)
    {
      return fact[n] * factinv[k] * factinv[n - k];
    }
    return 0;
  }
};
int combination::MAX_SIZE = 1e6 + 10;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// constexpr double epsilon = 1e-10;
// constexpr ll infty = 1000000000000000LL;
// constexpr int dx[4] = {1, 0, -1, 0};
// constexpr int dy[4] = {0, 1, 0, -1};
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}

int main()
{
  int N, D;
  cin >> N >> D;
  int X = 2 * D + 1;
  cout << (N + X - 1) / X << endl;
}

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

bool isLower(char& c) {
  if (c >= 'a' && c <= 'z') return true;
  return false;
}

bool isUpper(char& c) {
  if (c >= 'A' && c <= 'Z') return true;
  return false;
}

void solve() {
  string instr;
  getline(cin, instr);
  for (char& c : instr) {
    char converted;
    int width = 'A' - 'a';

    if (isLower(c)) {
      converted = c + width;
    } else if (isUpper(c)) {
      converted = c - width;
    } else {
      converted = c;
    }
    cout << converted;
  }
  cout << endl;
}

int main() {
  solve();
  return 0;
}



Measured memory_bytes: 3204
use std::io;

fn get_line() -> i32 {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let ret: i32 = buf.trim().parse().unwrap();
    return ret;
}

fn main() {
    let a = get_line();
    let b = get_line();
    let c = get_line();
    let x = get_line();

    let mut sum;
    let mut cnt = 0;

    for i in 0..a+1{
        for j in 0..b+1 { 
            for k in 0..c+1{
                sum = i*500 + j*100 + k*50;
                if sum == x {
                    cnt += 1;
                }
            }
        }
    }

    println!("{}",cnt);
}

Measured memory_bytes: 4352
// ABC 154-F
// 2020.2.9 bal4u

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

typedef long long ll;

#define MOD 1000000007
#define MAX 2000005
int fact[MAX+2] = {1,1};
int inv[MAX+2] = {1,1};
int facinv[MAX+2] = {1,1};

int comb(int n, int k) {
    if (n < 0 || k < 0 || n < k) return 0;
	if (k == 0) return 1;
    return ((((ll)fact[n] * facinv[k]) % MOD) * facinv[n-k]) % MOD;
}

int main()
{
	int i, r, c, r1, r2, c1, c2;
	ll ans;

	for (i = 2; i < MAX; i++) {
		fact[i] = (ll)fact[i-1]*i % MOD;
		inv[i] = -(MOD/i)*(ll)inv[MOD%i] % MOD;
		facinv[i] = (ll)facinv[i-1]*inv[i] % MOD;
	}

	scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
	ans = 0;
	for (r = r1; r <= r2; ++r) {
		ans += comb(c2+1+r, r+1)-comb(c1+r, r+1);
		ans %= MOD;
	}
	if (ans < 0) ans += MOD;
	printf("%d\n", (int)ans);
	return 0;
}


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

using namespace std;

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

    if(n == 25){
        printf("Christmas\n");
    }else if(n == 24){
        printf("Christmas Eve\n");
    }else if(n == 23){
        printf("Christmas Eve Eve\n");
    }else if (n == 22){
        printf("Christmas Eve Eve Eve\n");

    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);

    for(int i = 0; i < n; i++) cin >> v[i];

    // mapで各数列での要素の出現数を記録する
    map<int, int> even, odd;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0) odd[v[i]]++;
        else even[v[i]]++;
    }

    // even1　→　最頻値：　e1　→　even1の個数
    // even2　→　二番目の最頻値：　e2　→　even2の個数
    int even_1=0, even_2=0, odd_1=0, odd_2=0;
	int e1=0, e2=0, o1=0, o2=0;
	int cnt = 0;

    for(auto itr = even.begin(); itr != even.end(); ++itr){
        if(itr->second > cnt){
            cnt = itr->second;
            even_1 = itr->first;
        }
    }

    e1 = cnt;
	cnt = 0;
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt && itr->first != even_1){
			cnt = itr->second;
			even_2 = itr->first;
		}
	}
	e2 = cnt;

	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			odd_1 = itr->first;
		}
	}
	o1= cnt;
	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt && itr->first != odd_1){
			cnt = itr->second;
			odd_2 = itr->first;
		}
	}
	o2=cnt;

	if(even_1 == odd_1){
		cout << min(n-e1-o2, n-e2-o1) << endl;
	}else{
		cout << n-e1-o1 << endl;
	}

	return 0;
}


Measured memory_bytes: 5376
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

from collections import Counter
c = Counter()

for di in D:
    c[di] += 1

for ti in T:
    c[ti] -= 1

# print(c)

r = True
for k, v in c.items():
    if v < 0:
        r = False

if r:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 41816
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int a[100000];

int main() {
    int n, l, i, j;
    
    scanf("%d %d", &n, &l);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n - 1; i++) {
        if (a[i] + a[i + 1] >= l) break;
    }
    
    if (i == n - 1) {
        puts("Impossible");
    } else {
        vector <int> ans;
        
        ans.push_back(i + 1);
        for (j = i - 1; j >= 0; j--) ans.push_back(j + 1);
        for (j = i + 1; j < n - 1; j++) ans.push_back(j + 1);
        
        reverse(ans.begin(), ans.end());
        
        puts("Possible");
        for (i = 0; i < ans.size(); i++) printf("%d\n", ans[i]);
    }
    
    return 0;
}


Measured memory_bytes: 1656
n,q=map(int,input().split())
ab=[]
for i in range(n-1):
	x,y=map(int,input().split())
	ab.append([x,y])
ab.sort()
ans=[0]*n
cnt=[0]*n
for i in range(q):
	x,y=map(int,input().split())
	ans[x-1]+=y
for i in range(n-1):
	ans[ab[i][1]-1]+=ans[ab[i][0]-1]
print(*ans)





Measured memory_bytes: 52700
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

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

template <class X>
void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }

double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;
int modulo = 1e9 + 7;

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin >> n;
    int arr[n];
    FOR(i,0,n) cin >> arr[i];
    int ans = 0;
    FOR(i,1,n-1)
    {
        int x[3];
        x[0] = arr[i-1];
        x[1] = arr[i];
        x[2] = arr[i+1];
        sort(x, x+3);
        if (arr[i] == x[1])
            ++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
S="012 345 678 036 147 258 048 246 "
A=[]
A.extend(list(map(int,input().split())) for i in range(3))
N=int(input())
for i in range(N):
  j=input()
  for l in range(3):
    for m in range(3):
      S=S.replace(str([9,l*3+m][A[l][m]==int(j)]),"")
print(["No","Yes"][S.find("  ")>-1])

Measured memory_bytes: 3064
a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp
 
 
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();
    int idx_a, idx_z;
    rep(i, n) if (s[i] == 'A') { idx_a = i; break;}
    rep(i, n) if (s[n-1-i] == 'Z') { idx_z = n-1-i; break;}
    cout << idx_z - idx_a + 1 << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b,q;
  cin>>a>>b>>q;
  ll s[a];
  ll is[a];
  ll t[b];
  ll it[b];
  ll x[q];
  rep(i,0,a){
    cin>>s[i];
    is[i]=-s[i];
  }
  rep(i,0,b){
    cin>>t[i];
    it[i]=-t[i];
  }
  rep(i,0,q) cin>>x[i];
  sort(s,s+a);
  sort(is,is+a);
  sort(t,t+b);
  sort(it,it+b);
  rep(i,0,q){
    ll l=1e15;
    ll r=1e15;
    int c=lower_bound(s,s+a,x[i])-s;
    int d=lower_bound(t,t+b,x[i])-t;
    if(c<a && d<b){
      if(s[c]<t[d]){
        int e=lower_bound(t,t+b,s[c])-t;
        if(e!=b) l=min(l,(s[c]-x[i])+(t[e]-s[c]));
        if(e!=0) l=min(l,(s[c]-x[i])+(s[c]-t[e-1]));
      }
      else{
        int e=lower_bound(s,s+a,t[d])-s;
        if(e!=a) l=min(l,(t[d]-x[i])+(s[e]-t[d]));
        if(e!=0) l=min(l,(t[d]-x[i])+(t[d]-s[e-1]));
      }
    }
    else if(c==a && d<b){
      int e=lower_bound(s,s+a,t[d])-s;
      if(e!=a) l=min(l,(t[d]-x[i])+(s[e]-t[d]));
      if(e!=0) l=min(l,(t[d]-x[i])+(t[d]-s[e-1]));
    }
    else if(c<a && d==b){
      int e=lower_bound(t,t+b,s[c])-t;
      if(e!=b) l=min(l,(s[c]-x[i])+(t[e]-s[c]));
      if(e!=0) l=min(l,(s[c]-x[i])+(s[c]-t[e-1]));
    }
    
    c--;
    d--;
    if(c>=0 && d>=0){
      if(s[c]>t[d]){
        int e=lower_bound(t,t+b,s[c])-t;
        if(e!=b) r=min(r,(x[i]-s[c])+(t[e]-s[c]));
        if(e!=0) r=min(r,(x[i]-s[c])+(s[c]-t[e-1]));
      }
      else{
        int e=lower_bound(s,s+a,t[d])-s;
        if(e!=a) r=min(r,(x[i]-t[d])+(s[e]-t[d]));
        if(e!=0) r=min(r,(x[i]-t[d])+(t[d]-s[e-1]));
      }
    }
    else if(c<0 && d>=0){
      int e=lower_bound(s,s+a,t[d])-s;
      if(e!=a) r=min(r,(x[i]-t[d])+(s[e]-t[d]));
      if(e!=0) r=min(r,(x[i]-t[d])+(t[d]-s[e-1]));
    }
    else if(c>=0 && d<0){
      int e=lower_bound(t,t+b,s[c])-t;
      if(e!=b) r=min(r,(x[i]-s[c])+(t[e]-s[c]));
      if(e!=0) r=min(r,(x[i]-s[c])+(s[c]-t[e-1]));
    }
    
    cout<<min(l,r)<<endl;
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++) {
        int a = dp[i-2] + abs(h[i]-h[i-2]);
        int b = dp[i-1] + abs(h[i]-h[i-1]);
        dp[i] = min(a,b);
    }
    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::collections::{HashSet,HashMap};
#[allow(unused_imports)]
use std::collections::{BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::collections::BinaryHeap;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
        a: i32,
        s: String,
    }
    if a >= 3200 {
        println!("{}", s);
    }else {
        println!("red");
    }
    
}

Measured memory_bytes: 4352
S = input()
if len(S)%2==0:
  check = 0
  for i in range(len(S)//2):
    if S[i]!=S[len(S)-1-i]:
      check+=1
if len(S)%2!=0:
  check = 0
  for i in range((len(S)-1)//2):
    if S[i]!=S[len(S)-1-i]:
      check+=1
print(check)

Measured memory_bytes: 3060
a,b,c,x,y= [int(i) for i in input().split()]
n=0
if c * 2 <= a + b:
  if x <= y:
    n = c * x *2 + min(b,c*2) * (y-x)
  else:
    n=c * y *2 + min(a,c*2)*(x-y)
else:
  n=x*a+y*b
print(n)

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

const ll oo = 1e18;
const int MOD = 1000000007;
const int N = 500002;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define cpx complex<double>

int n , m , mx[3010], dp[3010][3010], pre[3010];
string s;

int calc(int l , int r , int ones){
	if(ones < 0)return 0;
	if(l == n)return (ones == 0?1:0);
	if(l > r && ones != 0)return 0;
	if(r >= l && ones > (r-l+1))return 0;
	if(mx[l]>r){
		ones += pre[mx[l]]-(r==-1?0:pre[r]);
		r = mx[l];
	}
	int &ret = dp[l][ones];
	if(ret != -1)return ret;
	return ret = (1ll*calc(l+1,r,ones)+calc(l+1,r,ones-1))%MOD;
}
int main() {
	memset(dp,-1,sizeof dp);
	cin >> n >> m >> s;
	for (int i = 0 ; i < n ; ++i) {
		pre[i] = s[i] - '0';
		mx[i] = i;
		if (i)pre[i] += pre[i - 1];
	}
	for (int l , r , i = 0 ; i < m ; ++i) {
		cin >> l >> r;
		l--,r--;
		mx[l] = max(mx[l], r);
	}
	printf("%d\n", calc(0,-1,0));
	return 0;
}

Measured memory_bytes: 35968
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(string X, string Y) {
  cout << (X < Y ? "<" : X > Y ? ">" : "=") << endl;
}

int main() {
  string X;
  cin >> X;
  string Y;
  cin >> Y;
  solve(X, Y);
  return 0;
}


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

#define ALL(c) begin(c), end(c)

struct Event {
  int type, x1, x2, y;
  bool operator<(const Event& rhs) const { return y < rhs.y; }
};

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

  int n, r;
  while (cin >> n >> r, n | r) {
    vector<Event> events;
    int W = 0, H = 0;
    for (int i = 0; i < n; ++i) {
      int x1, y1, x2, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      ++x1; ++y1; ++x2; ++y2;
      events.push_back({+1, x1, x2, y1});
      events.push_back({-1, x1, x2, y2});
      W = max(W, x2 + 1);
      H = max(H, y2 + 1);
    }
    sort(ALL(events));

    vector<vector<int>> field(2, vector<int>(W));
    int area = 0, perimeter = 0;
    for (int y = 1, k = 0; y < H; ++y) {
      int curr = y % 2, prev = (y - 1) % 2;
      field[curr] = field[prev];
      for (; k < (int)events.size() && events[k].y == y; ++k) {
        auto& e = events[k];
        for (int x = e.x1; x < e.x2; ++x)
          field[curr][x] += e.type;
      }
      for (int x = 1; x < W; ++x) {
        int b = !!field[curr][x];
        area += b;
        perimeter += (!!field[curr][x-1] ^ b) + (!!field[prev][x] ^ b);
      }
    }

    if (r == 1)
      cout << area << endl;
    else
      cout << area << endl << perimeter << endl;
  }
}

Measured memory_bytes: 1876
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int num[110]={};
void soinsuu(int x){
	rep(i,1,x+1){
		int a=2;
		int y=i;
		while(1){
			if(y==1)break;
			if(y%a==0)y/=a,num[a]++;
			else a++;
		}
	}
}

int main(){
	int n,ans=0;
	cin>>n;
	soinsuu(n);
	int use[6]={};
	rep(i,1,n+1){
		if(num[i]>=2)use[0]++;
		if(num[i]>=4)use[1]++;
		if(num[i]>=14)use[2]++;
		if(num[i]>=24)use[3]++;
		if(num[i]>=74)use[4]++;
	}
	ans=use[4]+use[3]*(use[0]-1)+use[2]*(use[1]-1)+use[1]*(use[1]-1)*(use[0]-2)/2;
	if(ans<0?print(0):print(ans));
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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 / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)




int main() {
	ll K;
	string S;
	std::cin >> K >> S;
	if (S.size() <= K) {
		std::cout << S << endl;
	}
	else {
		std::cout << S.substr(0, K) << "..." << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
package main

import "fmt"

func count(i int, x int) int {
        if i < 0 {
                return 0
        }
        return i/x + 1
}

func main() {
        var a, b, x int
        fmt.Scan(&a, &b, &x)
        fmt.Println(count(b, x) - count(a-1, x))
}


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

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// printVec(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << *it << " ";
    if ((it - begin) % 20 == 19 || it == end - 1) { std::cout << std::endl; }
  }
}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N;
  std::cin >> N;

  std::vector<std::map<char, ll>> M(N);
  std::vector<std::string> vs(N, "");
  for (ll i = 0; i < N; i++) {
    std::cin >> vs[i];
    std::string::iterator it;
    for(it = vs[i].begin(); it != vs[i].end(); it++) {
      M[i][*it]++;
    }
  }

  std::string ans;
  for (ll c = 'a'; c <= 'z'; c++) {
    ll min_val = INF;
    for (ll i = 0; i < N; i++) {
      min_val = std::min(min_val, M[i][c]);
    }
    ans += std::string(min_val, c);
  }

  print(ans);
  return 0;
}


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

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

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 1;

int n, m;
vi adj[maxN];

int deg[maxN];
int dp[maxN];
bool flag[maxN];

void DFS(int u)
{
    flag[u] = 1;
    dp[u] = 0;
    for (auto &v: adj[u])
    {
        if (!flag[v])
        {
            DFS(v);
        }
        dp[u] = max(dp[u], dp[v] + 1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    while (m--)
    {
        int u, v;
        cin >> u >> v;
        adj[v].eb(u);
        ++deg[u];
    }
    for1(u, n)
    {
        if (!flag[u] && deg[u] == 0)
        {
            DFS(u);
        }
    }
    cout << *max_element(dp + 1, dp + n + 1);
    return 0;
}


Measured memory_bytes: 9728
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
dif = 700
for i in range(N):
    if abs((T - H[i] * 0.006) - A) < dif:
        ans = i + 1
        dif = abs((T - H[i] * 0.006) - A)
print(ans)


Measured memory_bytes: 3060
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b)
      cout << "a > b" << endl;
    else if (a < b)
      cout << "a < b" << endl;
    else
      cout << "a == b" << endl;    
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};
string k;
int d;
mint dp[10010][100][2];
int main()
{
  cin >> k >> d;

  dp[0][0][0].x = 1;

  int ks = k.size();
  
  rep(i,ks) rep(j,d) rep(l,2){
    int ki = k[i] - '0';
    rep(jj,(l?10:ki+1)){
      dp[i+1][(j+jj)%d][l||jj<ki] += dp[i][j][l];
    }
  }

  mint res = dp[ks][0][0] + dp[ks][0][1] - 1;

  cout << res.x << "\n";
  
  return 0;
}


Measured memory_bytes: 15872
#include<stdio.h>
int main(void)
{
	int i,j,temp,y[10];
	for(i=0;i<10;i++){
		scanf("%d",&y[i]);
	}
	for(i=0;i<10;i++){
		for(j=0;j<=10;j++){
			if(y[j]<=y[i]){
				temp=y[i];
				y[i]=y[j];
				y[j]=temp;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d\n",y[i]);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 1000000007
#define MAXN 100005
bool sortby1column(vector<ll> &v1,vector<ll> &v2){
 return v1[0]<v2[0];
}
int 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;
    for(int cc=1;cc<=t;cc++){
        //cout<<"Case #"<<cc<<":\n";
        ll n,ans=0;
        cin>>n;
        string s;
        cin>>s;
        vector<ll> r,g,b;
        for(int i=0;i<n;i++){
            if(s[i]=='R')
                r.push_back(i);
            else if(s[i]=='G')
                g.push_back(i);
            else
                b.push_back(i);
        }
        for(ll i=0;i<r.size();i++){
            for(ll j=0;j<g.size();j++){
                ans+=(ll)b.size();
                ll temp = abs(r[i]-g[j]) + max(r[i],g[j]);
                ll temp2 = -abs(r[i]-g[j]) + min(r[i],g[j]);
                if(temp<n&&s[temp]=='B')
                    ans--;
                if(temp2>=0&&s[temp2]=='B')
                    ans--;
                ll temp3 = r[i]+g[j];
                if((temp3)%2==0&&s[temp3/2]=='B')
                    ans--;
            }
        }
        cout<<ans<<endl;

    }
}

Measured memory_bytes: 3700
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math

n = input().rstrip()

if n[len(n)-1] == "3":
    print("bon")
elif n[len(n)-1] == "0" or n[len(n)-1] == "1" or n[len(n)-1] == "6" or n[len(n)-1] == "8":
    print("pon")
else:
    print("hon")


Measured memory_bytes: 8988
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
 
using namespace std;
 
#define MAX 50
 
int N, day;
bool ok[MAX][31];
bool G[MAX][MAX];
bool visited[MAX];
 
void init(){
  day = 0;
  memset(ok, false, sizeof(ok));
  memset(G, false, sizeof(G));
}
 
int solve(){
  int ans = -1;
  set<int> dp[MAX];

  for(int i = 0 ; i < N ; i++){
    dp[i].insert(i);
  }

  for(int i = 0 ; i <= day ; i++){
    for(int j = 0 ; j < N-1 ; j++){
      if(!ok[j][i]) continue;
      for(int k = j+1 ; k < N ; k++){
        if(ok[k][i]){
          dp[j].insert(k);
          dp[k].insert(j);
          set<int>::iterator it;
          for(it = dp[j].begin() ; it != dp[j].end() ; ++it){
            dp[k].insert(*it);
          }
          for(it = dp[k].begin() ; it != dp[k].end() ; ++it){
            dp[j].insert(*it);
          }
        }
      }
    }
    for(int j = 0 ; j < N ; j++){
      if(dp[j].size() == N) return i+1;
    }
  }
  return ans;
}
 
int main(){
  int K, in;
  while(cin >> N && N){
    init();
    for(int i = 0 ; i < N ; i++){
      cin >> K;
      for(int j = 0 ; j < K ; j++){
        cin >> in;
        ok[i][in-1] = true;
        day = max(day, in);
      }
    }
    cout << solve() << endl;
  }
 
  return 0;
}

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

int main(){
    string s;
    LL K;
    cin >> s >> K;
    set<string> a;
    for(LL i = 1;i <= K;i++){
        for(LL j = 0;j+i <= s.size();j++){
            a.insert(s.substr(j, i));
        }
    }
    auto p = a.begin();
    for(LL i = 0;i < K-1;i++)   p++;
    cout << *p << endl;
}

Measured memory_bytes: 1664
a, b, c, d = map(int,input().split())
chk = True

while (a > 0) and (c > 0):
    if chk:
        c = c - b
        chk = False
    else:
        a = a - d
        chk = True

if a > c:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 61796
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; string s, t;
    cin >> n >> s >> t;

    for(int i = 0; i < n; i++){
        cout << s[i] << t[i];
    }
}


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

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

    ll ans1 = 0;
    rep(i, 0, s.size())
        ans1 += s[i] - '0';
    
    ll ans2 = s[0] - '0' - 1;
    ans2 += 9 * (s.size() - 1);
    
    cout << max(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
input=sys.stdin.readline # for speed up

n,k=map(int,input().split())
k=min(k,n)
h=list(map(int,input().split()))

c=[0]*n
kn=np.arange(1,k)
h0=h[0]
c0=c[0]
for (ii,hii) in zip(kn,h[1:k]):
  #hii=h[ii]
  cii=c0+abs(hii-h0)
  for (cjj,hjj) in zip(c[1:ii],h[1:ii]):
    if cii>cjj:
      #cii=min(cii,cjj+abs(hii-hjj))
      if hii==hjj:
        #cii=min(cii,cjj)
        cii=cjj
      elif hii>hjj:
        if cii>cjj+hii-hjj:
          cii=cjj+hii-hjj
      elif cii>cjj-hii+hjj:
        cii=cjj-hii+hjj
  c[ii]=cii
"""
c[1]=c[0]+abs(h[1]-h[0])
c[2]=min(c[0]+abs(h[2]-h[0]),c[1]+abs(h[2]-h[1]))
c[3]=min(c[0]+abs(h[3]-h[0]),c[1]+abs(h[3]-h[1]),c[2]+abs(h[3]-h[2]))
"""
#print(c)
kn=np.arange(k,n)
for (ii,hii,hiik) in zip(kn,h[k:n],h[0:n-k]):
  #hii=h[ii]
  cii=c[ii-k]+abs(hii-hiik)
  for (cjj,hjj) in zip(c[ii-k+1:ii],h[ii-k+1:ii]):
    if cii>cjj:
      #cii=min(cii,cjj+abs(hii-hjj))
      if hii==hjj:
        #cii=min(cii,cjj)
        cii=cjj
      elif hii>hjj:
        if cii>cjj+hii-hjj:
          cii=cjj+hii-hjj
      elif cii>cjj-hii+hjj:
        cii=cjj-hii+hjj
  c[ii]=cii
  #print(c)
print(c[n-1])

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

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

    if (a >= 13) cout << b << endl;
    else if (a <= 12 && a >= 6) cout << b/2 << endl;
    else if (a < 6) cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3600
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = readInts()

ans = 0
for i in range(0,n,2):
	if a[i]%2==1:
		ans+=1

print(ans)

Measured memory_bytes: 9336
#include<iostream>
#include<string>

using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  string a[100];
  for(int i=0;i<H;i++){
    cin >> a[i];
  }
  for(int i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0;i<H;i++){
    cout<<"#"<<a[i]<<"#"<<endl;
  }
  for(int i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <functional>
#include <stack>
#include <fstream>
#include <bitset>
#include <iomanip>

using namespace std;

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

const int N = 2e5 + 7;
const int INF = 1e9 + 7;
const long long LONG_INF = 1e18 + 7;
const int MOD = 1e9 + 7;
const double PI = 3.1415926535;

const vector<int> dx = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
const vector<int> dy = { -1, -1, 0, 1, 1, 1, 0, -1, -1 };

vector<int> g[N];

int main() {

	int n, m;
	cin >> n >> m;

	int s = 0, t = n - 1;

	forn(i, m) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	for (int v : g[s])
		for (int to : g[v])
			if (to == t) {
				cout << "POSSIBLE" << endl;
				return 0;
			}

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

Measured memory_bytes: 12016
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
  ll n,k;cin >> n >>k;
  vl v(n);rep(i,n)cin >> v[i];
  bool check=false;
  ll last;
  rep(i,n-1)if(v[i]+v[i+1]>=k){
    check=true;
    last=i+1;
  }
  if(!check)cout <<"Impossible" <<endl;
  else{
    cout << "Possible" <<endl;
    rep(i,n-1){
      if(i+1==last)break;
      cout << i+1 <<endl;
    }
    per(i,n-1){
      if(i+1==last)break;
      cout << i+1 <<endl;
    }
    cout << last <<endl;
  }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
using namespace std;
const int INF=1e17+5;
const int maxn=1e5+5;
int n,m,a[maxn],b[maxn],ans,sum;
vector<int>T;
int32_t main()
{
    IOS;
    cin>>n;
    fu(i,1,n)
    {
        int x;
        cin>>x;
        T.push_back(x);
    }
    sort(T.begin(),T.end());
    int mid=n/2;
    cout<<T[mid]-T[mid-1];
    return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y  = sc.nextInt();
    if(x <= y)
    System.out.println("unsafe");
    else
    System.out.println("safe");
  }
}


Measured memory_bytes: 35580
#include<stdio.h>
int main(){
  int n,m,a,x[100010],y[100010],i;
  const int mod=1000000007;
  scanf("%d %d\n",&n,&m);
  for(i=0;i<=n;i++){
    x[i]=0;
    y[i]=0;
  }
  for(i=0;i<m;i++){
    scanf("%d",&a);
    x[a]=1;
  }
  y[0]=1;
  for(i=1;i<=n;i++){
    if(x[i]==1){
      continue;
    }
    if(i-2>=0 && x[i-2]==0){
      y[i]=(y[i]+y[i-2])%mod;
    }
    if(x[i-1]==0){
      y[i]=(y[i]+y[i-1])%mod;
    }
  }
  printf("%d\n",y[n]);
  return 0;
}

Measured memory_bytes: 896