akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
const long long MOD=1000000;
int X(char*p,char*q)
{
	for(int i=0;q[i];++i)if(p[i]==q[i])return 1;
	return 0;
}
int Y(int r,int x)
{
	while(x--)r*=2,r%=MOD;
	return r;
}
int F(char*p)
{
	if(p[0]=='1')return 0;
	int x=0,i;
	for(i=1;i<8;++i)if(p[i]=='x')++x;
	return 1<<x;
}
int G(char*p,char*q)
{
	if(X(p,"001")||X(q,"01"))return 0;
	int x=0,y=0,f=0,i;
	for(i=3;i<7;++i){if(p[i]=='1')f=1;if(p[i]=='x')++y;}
	x=(p[7]=='x');
	for(i=2;i<8;++i)x+=(q[i]=='x');
	return Y((f?1<<y:(1<<y)-1), x);
}
int H(char*p,char*q,char*r)
{
	if(X(p,"0001")||X(q,"01")||X(r,"01"))return 0;
	int x=0,y=0,f=0,i;
	if(q[2]=='1')f=1;if(q[2]=='x')++y;
	for(i=4;i<8;++i){if(p[i]=='1')f=1;if(p[i]=='x')++y;}
	for(i=3;i<8;++i)if(q[i]=='x')++x;
	for(i=2;i<8;++i)if(r[i]=='x')++x;
	return Y((f?1<<y:(1<<y)-1),x);
}
int I(char*p,char*q,char*r,char*s)
{
	if(X(p,"00001")||X(q,"01")||X(r,"01")||X(s,"01"))return 0;
	int x=0,y=0,f=0,i;
	for(i=5;i<8;++i){if(p[i]=='1')f=1;if(p[i]=='x')++y;}
	for(i=2;i<4;++i){if(q[i]=='1')f=1;if(q[i]=='x')++y;}
	for(i=4;i<8;++i)if(q[i]=='x')++x;
	for(i=2;i<8;++i)if(r[i]=='x')++x;
	for(i=2;i<8;++i)if(s[i]=='x')++x;
	return Y((f?1<<y:(1<<y)-1),x);
}
int n;
long long memo[1000];
char a[1000][16];
long long A(int i)
{
	if(i>=n)return 1;
	if(memo[i]>=0)return memo[i];
	long long r = 0;
	r += F(a[i])*A(i+1);r%=MOD;
	if(i+1<n)r+=G(a[i],a[i+1])*A(i+2),r%=MOD;
	if(i+2<n)r+=H(a[i],a[i+1],a[i+2])*A(i+3),r%=MOD;
	if(i+3<n)r+=I(a[i],a[i+1],a[i+2],a[i+3])*A(i+4),r%=MOD;
	return memo[i]=r;
}
int main()
{
	while(scanf("%d",&n),n)
	{
		memset(memo,-1,sizeof(memo));
		for(int i=0;i<n;++i)scanf("%s",a[i]);
		printf("%d\n",(int)A(0));
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{   
    int a,b;
    while (cin>>a>>b && (a||b))
    {   
        if(a>b)
            cout<<b<<' '<<a<<endl;
        else
            cout<<a<<' '<<b<<endl;
    }
    return 0;
}


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

int main(){	
	int n;
	cin >> n;
	ll ans = 1;
	bool over=0, is0=0;
	rep(i,n){ 
		ll a;
		cin >> a;
		if(a == 0){ is0=1; ans=0; continue;}
		if(ans > 1000000000000000000/a){over = 1;}
		ans*=a;
	}
	if(over && !is0){ans = -1;}

	cout << ans << endl;
	return 0;

}




Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    ll A,B,C;
    cin >> A >> B >> C;
    ll K;
    cin >> K;
    ll ans ;
    if( K % 2 == 0){
        ans = (A - B);
    }
    else{
        ans = (B - A);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,M = LI()
LR = [LI() for _ in range(M)]
a = 0
b = float('INF')
for x in LR:
    a = max(x[0],a)
    b = min(x[1],b)
print(b-a+1 if b-a+1>=0 else 0)


Measured memory_bytes: 36320
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int A, B;
    int K;
    cin >> K >> A >> B;
    
    if (A%K == 0 || B/K - A/K > 0) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    string a, b;
    cin >> a >> b;
    //cout << a << endl;
    //cout << b << endl;
    int lena = a.length();
    int lenb = b.length();
    if(lena<lenb){
        for(int i=0; i<lenb-lena; i++){
            a = "0" + a;
        }
    }else if(lenb<lena){
        for(int i=0; i<lena-lenb; i++){
            b = "0" + b;
        }
    }
    //cout << a << endl;
    //cout << b << endl;
    if(a<b){
        cout << "LESS" << endl;
    }else if(b<a){
        cout << "GREATER" << endl;
    }else{
        cout << "EQUAL" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sqrtts sqrt(3)/2
struct point{double x;double y;};
using namespace std;
point uepoint(point p1,point p2){
    point p3;
    p3.x=(p1.x+p2.x)/2-(p2.y-p1.y)*sqrtts;
    p3.y=(p1.y+p2.y)/2+(p2.x-p1.x)*sqrtts;
    return p3;
}

void koch(int n,point p1,point p2){
    if(n==0)return;
    point p3,p4,p5;
    p3.x=(2*p1.x+p2.x)/3;
    p3.y=(2*p1.y+p2.y)/3;
    p4.x=(p1.x+2*p2.x)/3;
    p4.y=(p1.y+2*p2.y)/3;
    p5=uepoint(p3,p4);
    koch(n-1,p1,p3);
    printf("%.8lf %.8lf\n",p3.x,p3.y);
    koch(n-1,p3,p5);
    printf("%.8lf %.8lf\n",p5.x,p5.y);
    koch(n-1,p5,p4);
    printf("%.8lf %.8lf\n",p4.x,p4.y);
    koch(n-1,p4,p2);
}

int main(void){
    int n;
    cin>>n;
    point p1,p2;
    p1.x=0;
    p1.y=0;
    p2.x=100;
    p2.y=0;
    printf("%.8lf %.8lf\n",p1.x,p1.y);
    koch(n,p1,p2);
    printf("%.8lf %.8lf\n",p2.x,p2.y);
}


Measured memory_bytes: 3136
def main():
    l, r = map(int, input().split())
    rng = r - l
    ans = float("inf")
    if rng >= 2018:
        ans = 0
    else:
        for i in range(l, r):
            for j in range(i + 1, r + 1):
                ans = min(ans, (i * j) % 2019)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vint vector<int> 
#define for(i,a,n) for(i=a;i<n;i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int i,int n,vint &a){
    for(i,0,n){
        cin>>a.at(i);
    } 
} 

int addall(vint &A,vint &sum,int i){ //累積わ求める
    int res=0;
    if(i==0){
        res=A.at(0);
    }
    else{
        res=A.at(i)+sum.at(i-1);
    }
    return res;
}

signed main() {
    int i;
    int N;
    cin>>N;
    vint A(N);
    fin(i,N,A);
    sort(A.begin(),A.end());
    vint sum(N); //累積わ
    vint sum2(N); //累積和*2
    for(i,0,N){
        sum.at(i)=addall(A,sum,i);
    }
    for(i,0,N){
        sum2.at(i)=sum.at(i)*2;
    }

    int count=0;
/*
for(i,0,N){
    cout<<sum2.at(i)<<endl;
}
*/

    for(i,0,N-1){
        if(A.at(i+1)>sum2.at(i)){
            count=0;
        }
        else{
            count++;
        }
    }
    cout<<count+1<<endl;
return 0;
}

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

using namespace std;

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

    int n = s.length();
    int m = t.length();
    int ans = m;
    for (int i = 0; i <= n - m; i++) {
        int changes = 0;
        for (int j = 0; j < m; j++) {
            if (s[i + j] != t[j]) {
                changes++;
            }
        }
        ans = min(ans, changes);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	bool ans = false;
	if(a[0] == a[1] && a[1] != a[2]) ans = true;
	if(a[1] == a[2] && a[0] != a[1]) ans = true;
	cout << (ans ? "Yes" : "No") << endl;
}


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

int main(){
    int n,t;
    cin >> n >> t;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long count = t;
    for(int i = 0; i < n-1; i++){
        count += min(a[i+1]-a[i],t);
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 
/* 
  date | time : 3/22/2020 9:57:02 AM 
*/    
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+7;  
int tests(){ 
	int i,j ;
	int H,W;
	cin >> H  >> W ;
	vector <vector <char>> B(H,vector <char> (W,'*')); 
	vector <vector <int>> L (H,vector <int> (W,0));
	vector <vector <int>> R (H,vector <int> (W,0));
	int k ; 
	forn(i,0,H)
		forn(j,0,W)
			cin >> B[i][j] ; 

	forn(i,0,H){
		j = 0 ;
		while(j < W )
			{   
				if(B[i][j] == '#'){
					j++ ;
					continue ; 
				}
				int c = 0 ;
				int Start  = j; 
				while(Start < W && B[i][Start] == '.')
					c++ ,Start++; 

				forn(k,j,Start)
					L[i][k] = c ; 
				j = Start ;	
			}	
	} 	
	forn(i,0,W) { 
		j = 0 ;
		while(j < H ){
			if(B[j][i] == '#')
			{
				j++ ;
				continue ;
			}
			int c = 0; 
			int Start = j ; 
			while(Start < H && B[Start][i] == '.')
				c++,Start++ ;
			forn(k,j,Start)
				R[k][i] = c ;
			j = Start ;	
		}		
	}   
	int ans  = 0; 
	forn(i,0,H)
		forn(j,0,W)
			if(B[i][j] == '.')
				ans  = max(ans,L[i][j]+R[i][j]-1) ;
	cout << ans << '\n' ;			
	return 0; 
} 
int main(){
    I__O ;          
    int cases = 1 ; 
    // cin >> cases ; 
    for(int i = 1 ; i <= cases ; i++ ){
      // cout << "Case #" << i << ": " ;  	
      tests(); 
    }
    return 0 ; 
}


Measured memory_bytes: 35712
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;

ll N, C, K, temp, ans = 0;
vector<ll> T;
bool fir = true, go = false;

int main() {
	scanf("%lld%lld%lld", &N, &C, &K);
	REP(i, N) {
		scanf("%lld", &temp);
		T.push_back(temp);
	}
	sort(T.begin(), T.end());
	T.push_back(MOD);
	ll count = 1;
	temp = T[0] + K;
	REP(i, N) {
		if (i == 0) { continue; }
		count++;
		if (go) { go = false; }
		//        cout<<"Ti"<<T[i]<<":"<<temp<<endl;
		if (count>C || T[i] > temp/* || i == N - 1*/) {
			//        cout<<"OK"<<endl;
			ans++;
			count = 1;
			go = true;
			temp = T[i] + K;
		}



	}
	cout << ans+1;
	return 0;
}

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

typedef pair <int, int> ii;

const int Inf = 1000000000;
const int Maxn = 52;
const int Maxd = 4;
const int dy[Maxd] = {-1, 0, 1, 0};
const int dx[Maxd] = {0, -1, 0, 1};

int H, W;
char B[Maxn][Maxn];
int dist[Maxn][Maxn];
vector <ii> Q;
int white;

int main()
{
	scanf("%d %d", &H, &W);
	for (int i = 0; i < H; i++) {
		scanf("%s", B[i]);
		for (int j = 0; j < W; j++)
			if (B[i][j] == '.') white++;
	}
	fill((int*)dist, (int*)dist + Maxn * Maxn, Inf);
	dist[0][0] = 1; Q.push_back(ii(0, 0));
	for (int i = 0; i < Q.size(); i++) {
		ii v = Q[i];
		int d = dist[v.first][v.second];
		if (v.first == H - 1 && v.second == W - 1) { printf("%d\n", white - d); return 0; }
		for (int j = 0; j < Maxd; j++) {
			ii u = ii(v.first + dy[j], v.second + dx[j]);
			if (0 <= u.first && u.first < H && 0 <= u.second && u.second < W && B[u.first][u.second] == '.' && d + 1 < dist[u.first][u.second]) {
				dist[u.first][u.second] = d + 1;
				Q.push_back(u);
			}
		}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
int N,a,b;
int countp=0;int countq=0;int count=0;int num=1;
cin >> N;
vector<int> P(N);
vector<int> Q(N);
vector<int> order(N);
for(int i=0;i<N;i++)
{
cin >> P.at(i);
order.at(i)=i+1;
}
for(int i=0;i<N;i++)
{
cin >> Q.at(i);
}
for(int i=N;i>0;i--){num*=i;}
do{
countp=0;countq=0;
count++;
for(int i=0;i<N;i++){if(order.at(i)==P.at(i))countp++;}
for(int i=0;i<N;i++){if(order.at(i)==Q.at(i))countq++;}
if(countp==N)a=num-count-1;
if(countq==N)b=num-count-1;
}while(next_permutation(order.begin(),order.end()));
cout << abs(a-b);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N,M;
  cin>>N>>M;
  map<int,vector<int> > data;
  for (int i = 0; i < N; i++)
  {
    int A,B;cin>>A>>B;
    data[A].push_back(B);
  }
  priority_queue<int> pq;
  int ANS = 0;
  for (int i = 0; i <= M; i++)
  {
    while(!data[i].empty())
    {
      pq.push(data[i].back());
      data[i].pop_back();
    }
    if(pq.empty())continue;
    ANS += pq.top();
    pq.pop();
  }
  cout<<ANS<<endl;
  


    
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 10880
#!/usr/bin/env python2
from __future__ import division, print_function

import os
import sys
from atexit import register
from io import BytesIO

range = xrange

sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))

input = lambda: sys.stdin.readline().rstrip('\r\n')

n = int(input())
a = [float(i) for i in input().split()]

pref_sums = [0.0] * (n + 1)
for i in range(n):
    pref_sums[i + 1] = pref_sums[i] + a[i]

dp = [[0.0] * n for _ in range(n)]


def solve(start, end):
    if (dp[start][end] == 0.0) and (start != end):
        dp[start][end] = min(
            solve(start, i) + solve(i + 1, end) + pref_sums[end + 1] - pref_sums[start] for i in range(start, end))
    return dp[start][end]


print(int(solve(0, n - 1)))


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

long long n, a, B[200010];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		B[i] = a - (i + 1);
	}
	sort(B, B + n);
	int b;
	long long ans = 0;
		b = B[n / 2];
		for (int i = 0; i < n; i++) {
			ans += abs(B[i] - b);
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int cnt[10010];

int calc(int N){
    //int cnt=0;
    int comp = sqrt(N);
    //cout<<"s"<<endl;
    for(ll x=1;x<=comp;++x){
        for(ll y=1;y<=comp;++y){
            for(ll z=1;z<=comp;++z){
                ll val = x*x+y*y+z*z+x*y+y*z+z*x;
                if(val>N) break;
                cnt[val]++;
            }
        }
    }
    return 0;
}

int main() {
    int N; cin>>N;
    calc(N);
    for(int i=1;i<=N;++i){
        cout<<cnt[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3588
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include <iomanip>
//#include<cstring>
//#include<string>
#include<cmath>
#include<queue>
//#include<stack>
#include<algorithm>
#define ll long long
#define eps 1e-9
#define endl "\n"
#define PI acos(-1)
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    fast;
    map<int,int>m;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int num;
        cin>>num;
        m[num]++;
    }
    int f=0;
    for(auto it=m.begin();it!=m.end();it++)
    {
        if(it->second>1)
        {
            f=1;

            break;
        }
    }
    if(f==1)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }


    return 0;
}


Measured memory_bytes: 13028
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;



int main(){

    string s;
    cin>>s;

    int n= (int)s.size();

    int c=0;

    for(int i=0,j=n-1;i<n/2;i++,j--){

        if(s[i]!=s[j]){
            c++;
        }
    }

    cout<<c<<endl;





return 0;
}


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

typedef vector<int> vi; 
typedef long long ll;
#define F first 
#define S second 
#define PB push_back 
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define pmod 1000000007
#define INF 1000000000000000000
#define pi atan(1)*4
#define modi 1000000

void solve(){
	
	ll n;
	
	cin >> n;
	
	if(n >= 30){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
		
}

int main(){
	
	ifstream fin ("text.in");
    ofstream fout ("text.out");   
	
	ll t = 1;
					
	while(t--) solve();
	
	return 0;
}

Measured memory_bytes: 3632
import java.io.DataInputStream;
	import java.io.FileInputStream;
	import java.io.IOException;
	import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.PriorityQueue;
	import java.util.*;
	
	public class Main {
		public static class pair implements Comparable<pair> {
			int id;
			int ans;
	
			pair(int x, int y) {
	
				id = x;
				ans = y;
	
			}
	
			public pair() {
	
			}
	
			public int compareTo(pair o) {
				// TODO Auto-generated method stub
	
				return this.ans - o.ans;
			}
		}
	
	//	static int mod = (int) 998244353.;
		static int mod=(int)1e9+7;
		static ArrayList<Integer> gr[];
		static int  ar[];
		static Scanner sc = new Scanner(System.in);
		static int pri[] = new int[(int) 1e6 + 5];
		static StringBuilder out = new StringBuilder();
	
		static int[] dp;
	
		public static void main(String[] args) throws IOException {
			int t =1;// sc.nextInt();
			
			while (t-- > 0) {
				int k=sc.nextInt();
				String s=sc.next();
				if(s.length()>k) {
					out.append(s.substring(0,k)+"...");
				}
				else out.append(s);
				
			}
			
			System.out.println(out);
		}

    }

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

int main(){
    int N;
    cin >> N;
    int amax = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        if (a >= amax) {
            ans = a+b;
            amax = a;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll; 
typedef long double ld;

int main() {
	
	// make input and output more efficient
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	
	
	// to read whole line
	//string s;
	//getline(cin, s);
	
	ll N;
	
	cin >> N;
	
	map<int, char> mapping;
	
	for(int i = 0; i <26; i++) {
		mapping[i] = 'a' + i;
	}

	string answer = "";
	
	while(N>0) {
		N--;
		int r = N % 26;		
		N /= 26;
		answer.insert(answer.begin(), mapping[r]);
	}
	
	cout << answer << "\n";
	
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

char Types(char x[12][11]);

int main () {
    char x[100];
    for(int i=0; i<100; i++){
        x[i]='0';
    }


    while(cin>>x[0]>>x[1]>>x[2]>>x[3]>>x[4]>>x[5]>>x[6]>>x[7]>>x[8]>>x[9]>>x[10]>>x[11]>>x[12]>>x[13]>>x[14]>>x[15]>>x[16]>>x[17]>>x[18]>>x[19]>>x[20]>>x[21]>>x[22]>>x[23]>>x[24]>>x[25]>>x[26]>>x[27]>>x[28]>>x[29]>>x[30]>>x[31]>>x[32]>>x[33]>>x[34]>>x[35]>>x[36]>>x[37]>>x[38]>>x[39]>>x[40]>>x[41]>>x[42]>>x[43]>>x[44]>>x[45]>>x[46]>>x[47]>>x[48]>>x[49]>>x[50]>>x[51]>>x[52]>>x[53]>>x[54]>>x[55]>>x[56]>>x[57]>>x[58]>>x[59]>>x[60]>>x[61]>>x[62]>>x[63]){

//        for(int i=0; i<64; i++){
//            cin>>x[i];
////            if(x[i]==EOF){
////                flag=0;
////                break;
////            }
//        }
////        if(flag!=1){
////            break;
////        }
//        
        int first=-1;
        for(int i=0; i<64; i++){
            if(x[i]=='1'){
                first=i;
                break;
            }
        }
//        if(first==-1){
//            break;
//        }
        
        if(x[first+1]=='1'){
            if(x[first+2]=='1'){
                cout<<"C"<<endl;
            }else if(x[first+7]=='1'){
                cout<<"G"<<endl;
            }else if(x[first+10]=='1'){
                cout<<"E"<<endl;
            }else{
                cout<<"A"<<endl;
            }
        }else{
            if(x[first+7]=='1'){
                cout<<"D"<<endl;
            }else if(x[first+9]=='1'){
                cout<<"F"<<endl;
            }else{
                cout<<"B"<<endl;
            }
        }
        
        
    }
    
    return 0;
}

Measured memory_bytes: 1140
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int n,m;
	cin >>n>>m;
	if(n==0){
		if(m<=1911) cout <<"M"<<m-1867<<endl;
		else if(m<=1925&&m>=1912) cout <<"T"<<m-1911<<endl;
		else if(m<=1988&&m>=1926) cout <<"S"<<m-1925<<endl;
		else if(m<=2016&&m>=1989) cout <<"H"<<m-1988<<endl;
	}else if(n==1){
		cout << 1867+m <<endl;
	}else if(n==2){
		cout << 1911+m <<endl;
	}else if(n==3){
		cout << 1925+m <<endl;
	}else if(n==4){
		cout << 1988+m <<endl;
	}
	return 0;
}


Measured memory_bytes: 3136
/*
  This C++ Source Is
  Writen By syksykCCC
  (After July, 2019)
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i < y; i++)
#define REP(i, x, y) for(int i = x; i <= y; i++)
#define per(i, x, y) for(int i = x; i > y; i--)
#define PER(i, x, y) for(int i = x; i >= y; i--)
#define LLL __int128
#define int128 __int128
#define DEBUG(x) cerr << #x << " : " << x << endl
using namespace std;
typedef unsigned int uint;
typedef long long int64;
typedef long long LL;
typedef unsigned long long uint64;
typedef long long ULL;
typedef long double LLF;
template<typename T> inline void read(T &val)
{
	val = 0; char c = getchar(); int f = 1;
	while(!isdigit(c))
	{
		if(c == '-') f = -1;
		c = getchar();
	}
	while(isdigit(c))
	{
		val = (val << 3) + (val << 1) + (c ^ 48);
		c = getchar();
	}
	val *= f;
}
template<typename T> void write_(T val)
{
	if(!val) return;
	write_(val / 10);
	putchar(val % 10 + 48);
}
template<typename T> inline void write(T val)
{
	if(val == 0) putchar(48);
	else if(val < 0)
	{
		putchar('-');
		write_(-val);
	}
	else write_(val);
}

const int N = 2005;
int n, l[N], ans;

int main()
{
#ifdef LOCAL
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin >> n;
	REP(i, 1, n) cin >> l[i];
	sort(l + 1, l + n + 1);
	REP(i, 1, n) REP(j, i + 1, n)
	{
		int k = lower_bound(l + j + 1, l + n + 1, l[i] + l[j]) - l;
//		cerr << k << endl;
		ans += k - 1 - j;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli mod=1e9+7ll;
lli INF=1e17;
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,q,z,y,k,m;
const double pi1=3.14159265358979323846;
//matrix exponentiation is associative and distributive
lli me(lli a,lli b)
{
    lli res=1;
    while(b)
    {
        if(b&1)
        res=(res%mod*a%mod)%mod;
        a=a*a;
        a%=mod;
        b=b>>1;
    }
    return res;
}
lli mI(lli a)
{
    return (me(a,mod-2)%mod+mod)%mod;
}
bool cmp(ll a,ll b)
{
    if(a.first==b.first)
    return a.second<b.second;
    return a.first<b.first;
}
lli dp[2005][2005];
void compb()
{
    dp[0][0]=1;
    for(int i=1;i<=2000;i++)
    {
        dp[i][i]=dp[i][0]=1;
        for(int j=1;j<i;j++)
        {
            dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
            dp[i][j]%=mod;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>k;
    compb();
    for(int i=1;i<=k;i++)
    {
        lli ans=dp[n-k+1][i] * dp[k-1][i-1];
        ans%=mod;
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 30208
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto _i:x) cout << _i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-7
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

int n, val, cnt[100005];

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  REP (i, n) cin >> val, cnt[val]++, cnt[val + 1]++, cnt[val + 2]++;
  int ans = 0;
  REP (i, 100005) ans = max(ans, cnt[i]);
  cout << ans;
}

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

const int MAX_N = 100005;
const int mod = 1e9+7;
int n, a[MAX_N];

int pow_mod(int a, int k, int mod) {
	int r=1;
	while(k > 0) {
		if(k&1) {
			r=(r*a%mod+mod)%mod;
		}
		a=(a*a%mod+mod)%mod;
		k>>=1;
	}
	return r;
}

void solve() {
	LL ans = 1;
	sort(a, a+n);
	if(n % 2) { // 0, 2, 2, 4, 4
		if(a[0] != 0) {
			printf("0\n");
			return;
		}
		for(int i=1; i<n; i+=2) {
			if(a[i] != a[i+1] && a[i] != i+1) {
				printf("0\n");
				return;
			}
			(ans*=2)%=mod;
		}
	} else {
		for(int i=0; i<n; i+=2) {
			if(a[i] != a[i+1] && a[i] != i+1) {
				printf("0\n");
				return;
			}
			(ans*=2)%=mod;
		}
	}
	printf("%lld\n", ans);
}

int main() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	solve();
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int i,t,s,r=10;
  for (i=0;i<5;i++){
    cin >> t;
    s+=(t+9)/10;
    if (t%10 && r>t%10) r=t%10;
  }
  cout << s*10-10+r << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {

    val sc = new Scanner(System.in)
    val k = sc.nextInt()
    val s = sc.next()

    if (s.length > k) {
      println(s.substring(0, k) + "...")
    } else {
      println(s)
    }

  }

}


Measured memory_bytes: 55380
import java.util.*;

class Main
{
	public static void main(String[] args) {
  		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0) {
            System.out.println("Even");
        } 
        else {
            System.out.println("Odd");
    	} 
	}
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
using namespace std;

const int INF = 1e9;

int main(){
  int m,n;
  cin >> m >> n;
  vector<int> p(m),c(n),e(n);
  rep(i,m)cin >> p[i];
  sort(p.begin(),p.end(),greater<int>());
  rep(i,n)cin >> c[i] >> e[i];
  
  vector<int> dp(m+1,INF);
  dp[0] = 0;

  rep(i,n){
    for(int j=m;j>=0;j--){
      if(j<m)chmin(dp[j], dp[j+1]);
      chmin(dp[j], dp[max(0,j-c[i])] + e[i]);
    }
  }

  int ans = 0, sum = 0;
  rep(i,m){
    sum += p[i];
    chmax(ans, sum-dp[i+1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1296
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n)
    {
        cin >> l[i];
    }

    int ans = 0;
    for(int i = 0; i < n - 2; ++i)
    {
        for(int j = i + 1; j < n - 1; ++j)
        {
            for(int k = j + 1; k < n; ++k)
            {
                auto a = l[i];
                auto b = l[j];
                auto c = l[k];
                if(a == b || a == c || b == c)
                {
                    continue;
                }
                if(a + b > c && a + c > b && b + c > a)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int a[3];
int sol = 1e9;

int main(){

    cin >> a[0] >> a[1] >> a[2];

    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++){
                if (i == j || i == k || j == k) continue;
                sol = min(sol, abs(a[j]-a[i]) + abs(a[k]-a[j]));
            }

    cout << sol;

}

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

int main(){
  int k;
  cin >> k;
  vector<ll> a = {1,2,3,4,5,6,7,8,9};
  
  k--;
  int i = 0;
  while(1){
    //cout << i << " " << a.at(i) << endl;
    if (i == k){
      cout << a.at(i) << endl;
      break;
    }
    if(a.at(i)%10 != 0) a.push_back(a.at(i)*10+a.at(i)%10-1);
    a.push_back(a.at(i)*10+a.at(i)%10);
    if (a.at(i)%10 != 9) a.push_back(a.at(i)*10+a.at(i)%10+1);
    i++;
  }
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int solve(ll a, ll b, ll c){
    if(a%2 == 1 || b%2 == 1 || c%2 == 1) return 0;
    if(a == b && a == c) return -1;
    return 1 + solve((b+c)/2, (a+c)/2, (a+b)/2);
}

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    cout << solve(a, b, c) << endl;    
}

Measured memory_bytes: 256
#include <iostream>
#define MAX_N 100
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int64_t gcd(int64_t m, int64_t n) {
  int64_t tmp;
  while (m % n != 0) {
    tmp = n;
    n = m % n;
    m = tmp;
  }
  return n;
}
int64_t lcm(int64_t a, int64_t b) { return a / gcd(a, b) * b; }

int main(void) {
  int N;
  cin >> N;

  int64_t T[MAX_N];

  rep(i, N) {
    cin >> T[i];
  }

  int64_t tmp = T[0];
  for (int i = 1; i < N; i++) {
    tmp = lcm(tmp, T[i]);
  }
  cout << tmp << endl;

  return 0;
}

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

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n){
    cin>>a[i];
    a[i]--;
  }
  int cur=0;
  int ans=0;
  while(cur!=1 && ans<n){
    cur=a[cur];
    ans++;
  }
  if(ans==n) cout<<-1<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mxN = 2*(1e5);
vector<int> heights;


int main()
{
    int n,x;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        heights.push_back(x);
    }
    int curr_max = heights[0];
    ll ans = 0;
    for(int i=0;i<n;i++){
        curr_max = max(curr_max,heights[i]);
        ans+=(curr_max-heights[i]);
    }
    cout<<ans;

}


Measured memory_bytes: 4240
p = 1000000007

X, Y = map(int, input().split())

if (X + Y) % 3 != 0:
    print(0)
    exit()

a = (2 * Y - X) // 3
b = (2 * X - Y) // 3

if a < 0 or b < 0:
    print(0)
    exit()

n = a + b
fac = [0] * (n + 1)
fac[0] = 1
for i in range(n):
    fac[i + 1] = fac[i] * (i + 1) % p


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], p - 2, p) * pow(fac[k], p - 2, p) % p


print(mcomb(n, a))


Measured memory_bytes: 29300
N,S,a;
v[1<<17];
main()
{
  scanf("%d",&N);
  for(;~scanf("%d",&a);)v[a]++;
  for(a=1;a<1e5;a++)
  {
    S=fmax(S,v[a-1]+v[a]+v[a+1]);
  }
  printf("%d\n",S);
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n, m, X, Y;
	cin >> n >> m >> X >> Y;
	vector<int> x(n), y(m);
	rep(i, n) cin >> x[i];
	rep(i, m) cin >> y[i];

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	int a = x[x.size() - 1];
	int b = y[0];

	bool ok = false;
	if (Y > X and b > a) {
		for (int i = X + 1; i <= Y; i++) {
			if (a < i and i <= b) {
				ok = true;
			}
		}
	}
	puts(ok ? "No War" : "War");

	return 0;
}

Measured memory_bytes: 3600
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class CHonestOrUnkind2 {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int n;cin >> n;
        vector<pair<int,int>> G[20];
        rep(i,n){
            int a;cin >> a;
            rep(j,a){
                int x,y;cin >> x >> y;
                G[i].pb(mp(x-1,y));
            }
        }
        int ans = 0;
        for(int i = 0;i < (1 << n);i++){
            bool ok = true;
            vector<int> check(n,0); //1:honest
            rep(j,n){
                if((i >> j&1)){
                    for(auto k : G[j]){
                        if(((i >> k.ff) & 1) != k.ss){ok = false;break;}
                    }
                }
            }
            if(ok){
                int cnt = 0;
                rep(j,20)if(i >> j & 1)cnt++;
                maxs(ans,cnt);
            }
        }
        cout << ans << endl;
    }
};


int main() {
	CHonestOrUnkind2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
import Data.IORef
import Control.Monad(forM_, when)
import qualified Data.ByteString.Char8 as BC
import Data.Maybe(fromJust)
  
main :: IO()
main = BC.getLine >> BC.getContents >>= solve.map (fst.fromJust.BC.readInt).BC.lines >>= print
  
solve :: [Int] -> IO Int
solve (x : y : xs) = do
                a <- newIORef (y - x)
                b <- newIORef (if x < y then x else y)
                forM_ xs $ \z -> do
                    a' <- readIORef a
                    b' <- readIORef b
                    when (z - b' > a') $ writeIORef a (z - b')
                    when (z < b')      $ writeIORef b z
                readIORef a

Measured memory_bytes: 5892
#input
n, k = map(int, input().split())

#output
mod = pow(10, 9) + 7

n_ = 4*10**5 + 5
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod
def cmb(n,r):
    if n <= 0 or r < 0 or r > n: return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod

if n <= k-1:
    print(cmb(2*n-1, n))
else:
    answer = 0
    for m in range(k+1):
        answer += cmb(n, m)*cmb(n-1, m) % mod
        answer %= mod
    print(answer)

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

namespace _1_1_a
{
    class Program
    {
        static void Main()
        {
                string[] i = Console.ReadLine().Split(' ');
                int a = int.Parse(i[0]);
                int b = int.Parse(i[1]);

            int d = a / b;
            int r = a % b;
            double f = (double)a / b;

            Console.WriteLine("{0} {1} {2}",d,r,f.ToString("f5"));
        }
    }
}


Measured memory_bytes: 18004
from collections import deque

N=int(input())
adj=[[] for i in range(N+1)]
for i in range(N-1):
    a,b,c=map(int,input().split())
    adj[a].append((b,c))
    adj[b].append((a,c))
# print(adj)
Q,K=map(int,input().split())
d=[-1 for i in range(N+1)]
q=deque()
q.append(K);d[K]=0
while q:
    u=q.popleft()
    for v,c in adj[u]:
        if d[v]==-1:
            d[v]=d[u]+c
            q.append(v)
# print(d)
for i in range(Q):
    x,y=map(int,input().split())
    print(d[x]+d[y])

Measured memory_bytes: 83932
package main

import (
	"fmt"
	"math"
)

func main() {
	var s string
	fmt.Scan(&s)
	count0 := 0
	count1 := 0
	for i := range s {
		if s[i] == '0' {
			count0++
		} else if s[i] == '1' {
			count1++
		}
	}
	fmt.Println(math.Min(float64(count0), float64(count1)) * 2)

}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    cout << "Christmas";
    rep(i,abs(25-n)){
        cout << " Eve"; 
    }
    cout << endl;
}

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


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

const int N = 200500;
char st[N];

char buf[N];

int main() {
    scanf("%s", buf);
    int len = strlen(buf);
    int pt = 0;
    for (int i = 0; i < len; i++) {
        char c = buf[i];
        if (pt != 0 && st[pt - 1] == 'S' && c == 'T')
            --pt;
        else
            st[pt++] = c;
    }
    printf("%d\n", pt);
}


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

using namespace std;

struct Node
{
    int key;
    Node *next,*prev;
};

Node *nil;

void PrintList()
{
    Node* cur=nil->next;
    int isf=0;
    while(1)
    {
        if(cur==nil)
        {
            break;
        }
        if(isf++>0)
        {
            cout<<" ";
        }
        cout<<cur->key;
        cur=cur->next;
    }
    cout<<endl;
}
void init()
{
    nil=(Node*)malloc(sizeof(Node));
    nil->next=nil;
    nil->prev=nil;
}

void Insert(int key)
{
    Node* x=(Node*)malloc(sizeof(Node));
    x->key=key;
    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}

Node* listSearch(int key)
{
    Node* cur=nil->next;
    while(cur->key!=key&&cur!=nil)
    {
        cur=cur->next;
    }
    return cur;
}

void Delete(Node* t)
{
    if(t==nil)
    {
        return;
    }
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void DeleteFirst()

{
    Delete(nil->next);
}

void DeleteLast()
{
    Delete(nil->prev);
}

void DeleteKey(int key)
{
    Delete(listSearch(key));
}

int main()
{
    int n,key,i;
    char com[20];

    cin>>n;

    init();

    for(i=0;i<n;++i)
    {
        scanf("%s",com);
        if(strlen(com)<=6)
        {
            cin>>key;
        }
        if(com[0]=='i')
        {
            Insert(key);
        }
        else if(com[0]=='d')
        {
            if(strlen(com)>6)
            {
                if(com[6]=='F')
                {
                    DeleteFirst();
                }
                else if(com[6]=='L')
                {
                    DeleteLast();
                }
            }
            else
            {
                DeleteKey(key);
            }
        }
    }
    PrintList();

    return 0;
}


Measured memory_bytes: 34408
#include<stdio.h>

int main()
{
    int a[11000],n,x,sum=0;

    scanf("%d",&n);
    for(x=0;x<n;x++){
        scanf("%d",&a[x]);
    }

    for(x=0;x<n;x++){
        while(1){
            if(a[x]%2==0){
                sum++;
                a[x]/=2;
            }
            else{
                break;
            }
        }
    }
    printf("%d",sum);



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N; cin >> N;
	vector<int> A(N),B(N),C(N-1);
	rep(i,N) cin >> A[i];
	rep(i,N) cin >> B[i];
	rep(i,N-1) cin >> C[i];
	int ans = 0;
	rep(i,N){
		ans += B[A[i]-1];
		if(i >= 1){
			if(A[i] == A[i-1]+1) ans += C[A[i-1]-1];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256