akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a <= 1){ return 1; } else{ return a * fact(a - 1); } }
template<class T> inline ll comb(T a, T b){ return a == 0 ? 0 : fact(a) / fact(b) / fact(a - b); }

int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll CD = lcm(C, D);

    ll minC = A / C;
    ll maxC = B / C;
    ll cntC = (A % C == 0) ? maxC - minC + 1 : maxC - minC;
    ll minD = A / D;
    ll maxD = B / D;
    ll cntD = (A % D == 0) ? maxD - minD + 1 : maxD - minD;
    ll minCD = A / CD;
    ll maxCD = B / CD;
    ll cntCD = (A % CD == 0) ? maxCD - minCD + 1 : maxCD - minCD;

    ll ans = B - A + 1 - (cntC + cntD - cntCD);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int q;
	cin >> q;
	while (q--) {
		ll a, b;
		cin >> a >> b;
		if (a > b)
			swap(a, b);
		ll ans = 2 * (a - 1);
		ll l = 0;
		ll r = b - a + 1;
		while (r - l > 1) {
			ll mid = (l + r) >> 1;
			ll x = a;
			ll y = a + mid;
			ll x1 = (x + y) / 2;
			ll y1 = (x + y) - x1;
			if (x1 * y1 < a * b)
				l = mid;
			else
				r = mid;
		}
		ans += l;
		cout << ans << "\n";
	}
	return 0;
}



Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool cmp(pii a,pii b)
{
	if(a.F==b.F) return a.S>b.S;
	return  a.F<b.F;
}

int solve()
{
	ll n;cin>>n;
	vpii a(n),b(n);
	rep(i,0,n)
	{
		ll x,l;cin>>x>>l;
		a[i].F = x-l;
		a[i].S = x+l;
		b[i].F = a[i].S;
		b[i].S = a[i].F;
	} 
	sort(a.begin(), a.end());
	sort(b.begin(), b.end(),cmp);

	vi larg_l(n);
	rep(i,0,n)
	{
		if(i==0) larg_l[0]=0;
		else 
		{
			if(b[i].S>=b[larg_l[i-1]].S) larg_l[i] = i;
			else larg_l[i] = larg_l[i-1];
		}
	}

	// rep(i,0,n) cout<<b[i].F<<" "<<b[i].S<<"\n";
	// rep(i,0,n) cout<<a[i].F<<" "<<a[i].S<<"\n";


	vvi dp(n,vi (2,-1));
	rep(i,0,n)
	{
		rep(j,0,2)
		{
			if(i==0) dp[i][j]=j;
			else
			{
				if(j==0) dp[i][j] = max(dp[i-1][0],dp[i-1][1]);
				else 
				{
					ll val = a[i].F;
					ll idx = upper_bound(b.begin(), b.end(),mp(val,inf))-b.begin();
					idx--;
					if(idx!=-1)
					{
						idx  = larg_l[idx]; 
						// whatis(i);
						// whatis(idx);
						idx = lower_bound(a.begin(), a.end(),mp(b[idx].S,b[idx].F))-a.begin();
						dp[i][j] = max(dp[idx][1],dp[idx][0])+1;
					} 
					else dp[i][j]=1;
				}
			}

		}
	}

	// rep(i,0,n) cout<<dp[i][0]<<" "<<dp[i][1]<<"\n";
	cout<<max(dp[n-1][0],dp[n-1][1]);

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


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

bool parity(int n){
  if(n*n*n*n%10 == 1)
    return true;
  else
    return false;
}

long long power(long long x, int y){
  long long n = 1ll;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}



int main() {
  
  int a, b, x;
  cin >> a >> b >> x;
  
  double ans;
  if(a*a*b <= 2*x)
    ans = atan2(2.0*(a*a*b-x),1.0*a*a*a);
  else
    ans = atan2(1.0*a*b*b,2.0*x);
  
  ans *= 180.0/3.141592653589;
  cout << fixed << setprecision(10);
  cout << ans << endl;
  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int sum=0;
  int a,pf=1,mf=0,kf=0,wf=0;
  char c[1];
  while(1){
    cin >> a >> c[0];
    if(pf == 1){
      sum+=a;
      pf=0;
    } else if(mf == 1){
      sum-=a;
      mf=0;
    } else if(kf == 1){
      sum*=a;
      kf=0;
    } else if(wf == 1){
      sum/=a;
      wf=0;
    }
    if(c[0] == '=') break;
    if(c[0] == '+'){
      pf=1;
    } else if(c[0] == '-'){
      mf=1;
    } else if(c[0] == '*'){
      kf=1;
    } else if(c[0] == '/'){
      wf=1;
    }
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3032
using System;
using System.Linq;

class Problem {
    public static void Main() {
        while (int.Parse(Console.ReadLine()) != 0) {
            var dat = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var avr = dat.Average();
            var v = 0.0;
            foreach (var n in dat) v += (n - avr) * (n - avr);
            v /= (double)dat.Length;
            Console.WriteLine(Math.Sqrt(v));
        }
    }
}


Measured memory_bytes: 9856
local K, S = io.read("*n", "*n")

---x >= y >= z
local x, y, z = 0, 0, 0
if K >= S then
	x = S
elseif 2*K >= S then
	x, y = K, S - K
else
	x, y, z = K, K, S - 2*K
end

local count = 0
local sub_y, sub_z = y, z
while x >= y and y >= z do
	while y >= z do
		if x == y and y == z then
			count = count + 1
		elseif x == y or y == z then
			count = count + 3
		else
			count = count + 6
		end
		y, z = y - 1, z + 1
	end
	y, z = sub_y, sub_z
	if x == y + 1 then
		x, z = x - 1, z + 1
	elseif x == y then
		x, y, z = x - 1, y - 1, z + 2
	else
		x, y = x - 1, y + 1
	end
	sub_y, sub_z = y, z
end

print(count)

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s ; cin >> s ;
	reverse(s.begin(),s.end()) ;
	int n = s.size() ;
	s += "xxxxxxxxxxx" ;
	bool ok = true ;
	for(int i=0;i<n;i++){
		if(s.at(i)=='m'){
			i++ ;
			if(s.at(i)!='a') ok = false ;
			i++ ;
			if(s.at(i)!='e') ok = false ;
			i++ ;
			if(s.at(i)!='r') ok = false ;
			i++ ;
			if(s.at(i)!='d') ok = false ;
		}else if(s.at(i)=='e'){
			i++ ;
			if(s.at(i)!='s') ok = false ;
			i++ ;
			if(s.at(i)!='a') ok = false ;
			i++ ;
			if(s.at(i)!='r') ok = false ;
			i++ ;
			if(s.at(i)!='e') ok = false ;
		}else if(s.at(i)=='r'){
			i++ ;
			if(s.at(i)!='e') ok = false ;
			i++ ;
			if(s.at(i)=='m') i-- ;
			else if(s.at(i)=='s') i -= 2 ;
			else ok = false ;
		}else ok = false ;
	}
	YorN(ok) ;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	string S;
	cin >> S;

	int N = S.size();
	long long ans = 0;
	int a = 0;
	for( int i = 0; i < N - 1; i++ ) {
		if( S[i] == 'A' ) a++;
		else if( S[i] == 'B' && S[i + 1] == 'C' ) {
			ans += a;
			i++;
		}
		else a = 0;
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;

typedef unsigned int uint;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> ii;
typedef pair<int64, int64> int64int64;
typedef vector<int> vint;
typedef vector<int64> vint64;
typedef vector<uint64> vuint64;
typedef vector<vint> vvint;
typedef vector<vint64> vvint64;
typedef vector<vuint64> vvuint64;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;

#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define fori(n) for(int i = 0; i < n; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)
#define INF9 (int64)(1e9)
#define INF18 (int64)(1e18)

template<typename T>
struct compF{
	bool operator()(const pair<T, T> &a, const pair<T, T> &b){
		return a.first < b.first;
	}
};

template<typename T>
struct compS{
	bool operator()(const pair<T, T> &a, const pair<T, T> &b){
		return a.second < b.second;
	}
};

template<typename T>
void printMatrix(const string &txt, vector<vector<T>> &a){
	cout << txt;
	fori(a.size()){
		forj(a[i].size())
			cout << a[i][j] << ' ';

		cout << endl;
	}
}

template<typename T>
void printVector(const string &txt, vector<T> &a){
	cout << txt;
	for (int i = 0; i < a.size(); ++i)
		cout << a[i] << ' ';
	cout << endl;
}

template<typename T>
void readVector(int n, vector<T> &a){
	if (a.size() < n)
		a.resize(n);

	fori(n) cin >> a[i];
}

template<typename T1, typename T2>
bool exist(map<T1, T2> &m, T1 x){
	if (m.find(x) == m.end())
		return false;

	return true;
}

int64 gcd(int64 a, int64 b){
	while (a != 0 && b != 0){
		if (b > a)
			b %= a;
		else
			a %= b;
	}

	return a + b;
}

int64 minFactor(int64 x){
	for (int64 i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return i;

	return x;
}

int64 allFactors(int64 x, vint64 &prms, vint64 &prm_cnt){
	prms.clear();
	prm_cnt.clear();
	while (x > 1){
		int64 t = minFactor(x);
		prms.push_back(t);
		int s = prms.size() - 1;
		prm_cnt.push_back(0);
		while (x % t == 0){
			x /= t;
			++prm_cnt[s];
		}
	}

	return 0;
}

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie();
	
	map<string, int> cnt;
	int n;
	cin >> n;

	fori(n){
		string s;
		cin >> s;

		++cnt[s];
	}

	cout << "AC" << " x " << cnt["AC"] << endl;
	cout << "WA" << " x " << cnt["WA"] << endl;
	cout << "TLE" << " x " << cnt["TLE"] << endl;
	cout << "RE" << " x " << cnt["RE"] << endl;

	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i=0; i<(int)(n); i++)
#define REP2(i,x,n) for(int i=x; i<(int)(n); i++)
using ll = long long;
int main(){
    ll N=0;
    cin >> N;

    vector<ll> button(N);
    REP(i,N){
        cin >> button.at(i);
    }

    ll count=0;
    ll read=1;
    ll j=0;
    bool finished = false;

 while(j<N){
    if(button.at(read-1)==2){
        count++;
        finished = true;
        break;
    }
    else{
        read=button.at(read-1);
        count++;
    }
    j++;
 }

    if(finished){
        cout << count << endl;
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 1024
import sys
n, y = map(int, input().split())

flag = bool(0)
for i in range(n + 1):
    for j in range(n + 1):
        k = n - i - j
        if k >= 0 and i * 10000 + j * 5000 + k * 1000 == y:
            print(i, j, k)
            sys.exit()

print(-1, -1, -1)


Measured memory_bytes: 40812
#include <stdio.h>
int n,d,i,ans;
int main(void)
{
    scanf("%d%d",&n,&d);
    for(i=0;i<30;i++){
      if(n<=0){
            printf("%d",ans);
            return 0;
        }
        n -= (d*2+1);
        ans += 1;
        
    }
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>K;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll sum, plus, minus;
    sum = plus = minus = 0;
    rep(i,N) sum += max(0LL, a[i]);
    ll ans = 0;
    rep(i,K){
        (a[i] >= 0 ? plus : minus) += abs(a[i]);
    }
    ans = max({ans, sum - plus, sum - minus});
    reps(i,K,N){
        (a[i-K] >= 0 ? plus : minus) -= abs(a[i-K]);
        (a[i] >= 0 ? plus : minus) += abs(a[i]);
        ans = max({ans, sum - plus, sum - minus});
        //if(i == N - 1) cout<<sum<<' '<<plus<<' '<<minus<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int a;
string s;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> a >> s;
   if (a < 3200) cout << "red";
   else cout << s;
}                                     

int main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin>>N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	LL MaxVal = *max_element(ALL(a));
	LL Sum = accumulate(ALL(a), 0LL);
	if (MaxVal < Sum - MaxVal) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
"use strict";


var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );

var data = "";
readable.on( 'data', function( chunk ) {
		data += chunk;
});


readable.on( 'end', function() {
		var data2 = data.split( '\n' );

		var output = [];
		var cnt = data2.length;
		for( var i=0; i<cnt; i++ ) {
			if( 0 != data2[i] ) {
				output.push( 'Case '+(i+1)+': '+data2[i] );
			}
		}
		console.log( output.join( '\n' ) );
});




Measured memory_bytes: 19672
let rec for_fold a b v f = if a >= b then v else for_fold (a+1) b (f v a) f
let for_filter a b f =
  for_fold a b [] (fun s i -> if f i then i::s else s) |> List.rev

let () =
  Scanf.scanf "%d %d" @@ fun h w ->
  let a = Array.init h (fun _ -> Scanf.scanf " %s" (fun x -> x)) in
  let rows = for_filter 0 h (fun i ->
    for_fold 0 w false (fun b j -> b || a.(i).[j] = '#'))
    |> Array.of_list in
  let columns = for_filter 0 w (fun j ->
    for_fold 0 h false (fun b i -> b || a.(i).[j] = '#'))
    |> Array.of_list in
  Array.iter (fun i ->
    String.init (Array.length columns) (fun j -> a.(i).[columns.(j)])
    |> print_endline) rows


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
ll INF = 10010001010;

ll lcm(ll a,ll b)
{
    return a * b / __gcd(a, b);
}
typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}

ll findSumOfDigits(ll n)
{
    ll digit = 0;
    while (n > 0)
    {
        digit++;
        n /= 10;
    }
    return digit;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    string S;
    cin >> S;
    if (S[S.size() - 1] == '0' || S[S.size() - 1] == '1'||S[S.size() - 1] == '6'||S[S.size() - 1] == '8')
    {
        cout << "pon" << endl;
    }
    else if(S[S.size()-1] == '3'){
        cout << "bon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }
}


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

int main() {

    ll K, N;
    cin >> K >> N;

    vl A, B;
    ll a;
    for (int i = 0; i < N; ++i) {
        cin >> a;
        A.push_back(a);
        if (i > 0) B.push_back(A[i]-A[i-1]);
    }
    B.push_back(K-A[N-1]+A[0]);

    cout << K - *max_element(B.begin(), B.end()) << endl;

    return 0;
}


Measured memory_bytes: 3564
#include<iostream>

using namespace std;

int main(void){
	
	int N;
	int A[4];
	
	cin >> N ;
	
	for(int i = 0; i < 4; i++){
		A[i] = N % 10 ;
		N = N /10 ;
	}
	
	if(A[0] == A[1] && A[1] == A[2] ) cout << "Yes" << endl;
	else if (A[1] == A[2] && A[2] == A[3] ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
n = int(input())
p = [int(i) for i in input().split()]
counter = 0
for i in range(n-2):
    if p[i] < p[i+1] < p[i+2] or p[i+2] < p[i+1] < p[i]:
        counter += 1
print(counter)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) arr[i] = in.nextInt();
        for (int i = 0; i < 105; i++) {
            boolean poss = true;
            for (int j = 0; j < n; j++) {
                if (arr[j] == x - i) {
                    poss = false;
                }
            }
            if (poss) {
                System.out.println(x - i);
                return;
            }
            poss = true;
            for (int j = 0; j < n; j++) {
                if (arr[j] == x + i) {
                    poss = false;
                }
            }
            if (poss) {
                System.out.println(x + i);
                return;
            }
        }
    }
}


Measured memory_bytes: 35936
def main():
    N = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)
    i = 0
    d = []
    while N - 1 > i:
        if len(d) == 2:
            break
        if A[i] == A[i + 1]:
            d.append(A[i])
            i += 1
        i += 1
    if (len(d) == 2):
        print(d[0] * d[1])
    else:
        print(0)


main()


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int 
#define pb push_back
#define mp make_pair
#define endl "\n"
#define mem(x) memset(x, -1, sizeof(x))
const int MOD = 1e9+7;

template <typename T>
void print(T AA[], int nn){for(int ii=0; ii<nn; ii+=1){cout<<AA[ii]<<" ";}cout<<endl;}
template <typename T> inline void print(T nn){ cout << nn << endl;}
/* ----------------------------------------------------------------------------------- */

const int N = 1e5+5;
vector<int> g[N];
int n, cache[N][2], vis[N];

int dfs(int root, int color){
    int &ans = cache[root][color];
    if(ans != -1) return ans;
    vis[root] = 1;
    ans = 1;
    for(auto &it: g[root]){
        if(vis[it]== -1 && color == 0){
            ans *= dfs(it, 0) + dfs(it, 1);
        }
        if(vis[it]==-1 && color == 1){
            ans *= dfs(it, 0);
        }
        if(ans >= MOD) ans %= MOD;
    }
    vis[root] = -1;
    return ans;
}

int32_t main(){

    IOS

    mem(cache);
    mem(vis);
    cin >> n;
    for(int i=0; i<n-1; i+=1){
        int u, v; cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    print((dfs(1, 0) + dfs(1, 1))%MOD);
    return 0;
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){

  int a[5];
  rep(i,5) cin >> a[i];
  
  rep(i,5){
    if(a[i]==0){
      cout << i+1;
    }
  }

  return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        double result = 0;
        double x = sc.nextDouble();
        double y = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();

        result = Math.sqrt((x2 - x)*(x2 - x) + (y2 - y)*(y2 - y));
        System.out.println(result);
    }
}



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

int main(void){
  int n;
  cin>>n;
  while(n--){
    int x,y,w,h;
    cin>>x>>y>>w>>h;
    int m;
    cin>>m;
    int xx,yy;
    int r = 0;
    while(m--){
      cin>>xx>>yy;
      if(x <= xx && xx <= x+w && y <= yy && yy <= y+h)r++;
    }
    cout<<r<<endl;
  }
}

Measured memory_bytes: 1160
#include <stdio.h>

#define MAX_N 100
#define INF 1e8

int main(){
  int N,i,j,k,l,q,r[MAX_N],c[MAX_N],p[MAX_N+1];
  int dp[MAX_N+1][MAX_N+1];
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d%d",&r[i],&c[i]);
  }
  p[0] = r[0];
  for(i = 1 ; i <= N ; i++){
    p[i] = c[i-1];
  }
  N++;
  for(i = 0 ; i < N ; i++){
    dp[i][i] = 0;
  }
  for(l = 2 ; l < N ; l++){
    for(i = 1 ; i < N-l+1 ; i++){
      j = i + l - 1;
      dp[i][j] = INF;
      for(k = i ; k <= j-1 ; k++){
        q = dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j];
        if(q < dp[i][j]){
          dp[i][j] = q;
        }
      }
    }
  }
  printf("%d\n",dp[1][N-1]);
  return 0;
}



Measured memory_bytes: 2768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
int main(){
	int a,b,c;
	cin>>c;
	if(c==1)printf("Hello World") ;
	if(c==2){
		cin>>a>>b;
		printf("%d",a+b);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	int cnt=0;
	int i=0, j=n-1;
	while(i <= j){
		if(s[i] == 'W'){
			while(j>i && s[j] == 'W')--j;
			if(j == i)break;
			swap(s[i], s[j]);
			cnt++;
		}
		++i;
	}
	for( ; i<n ; ++i){
		if(s[i] == 'R')cnt++;
	}
	
	cout << cnt;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


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

int main(){
    int N;
    int D;
    cin >> N >> D;
    int X[N][D];
    double distance;
    double sum;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }
    int count=0;
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            sum = 0;
            for(int k = 0; k < D; k++){
                sum += pow(X[i][k]-X[j][k], 2);
            }
            distance = sqrt(sum);
            if(ceil(distance) == floor(distance)) count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
int dx[]={0,1};
int dy[]={1,0};
int edge[16][16][16][16]={0};
main(){
  int te;
  cin>>te;
  while(te--){
  int gx,gy,p;
  while(cin>>gx>>gy>>p){
    long long dp[gy+1][gx+1];
    rep(i,16)rep(k,16)rep(j,16)rep(l,16)edge[i][j][k][l]=0;
    fill(&dp[0][0],&dp[gy][gx+1],0);
    dp[0][0]=1;
    for(int i=0;i<p;i++){
      int x1,x2,y1,y2;
      cin>>x1>>y1>>x2>>y2;
      edge[y1][x1][y2][x2]=1;
      edge[y2][x2][y1][x1]=1;
    }
    for(int i=0;i<=gy;i++){
      for(int j=0;j<=gx;j++){
	for(int k=0;k<2;k++){
	  int nex=j+dx[k],ney=i+dy[k];
	  if (nex>gx||ney>gy||
	      edge[i][j][ney][nex]||edge[ney][nex][i][j])continue;
	  dp[ney][nex]+=dp[i][j];
	}
      }
    }
    if ( dp[gy][gx] == 0){
      puts("Miserable Hokusai!");
    }else cout <<dp[gy][gx] << endl;

  }
  return false;
}
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    vector<int> a;
    int idx = 0;
    long long total = 0;
    for(int i=0; i<s.length(); ++i){
        if(s[i]=='A') ++idx;
        else if(i+1<s.length() && s[i]=='B' && s[i+1]=='C'){
            a.push_back(idx);
            idx = 0;
            ++i;
        }
        else{
            for(int j=0; j<a.size(); ++j){
                total += a[j]*((long long)a.size()-j);
            }
            idx = 0;
            a.resize(0);
        }
    }
    for(int j=0; j<a.size(); ++j){
        total += a[j]*((long long)a.size()-j);
    }
    cout << total << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
string str,tmp;
int solve(string judge){
      int t = judge.length();
      for(int i=0;i<t;i++){
            if(str[0]!=judge[i])continue;
            for(int j=i+1;j<t;j++){
                  if(str[1]!=judge[j])continue;
                  for(int k=2;;k++){
                        if(k==str.length())return 1;
                        if(i+(j-i)*k>=t || str[k]!=judge[i+(j-i)*k])break;
                  }
            }
      }
      return 0;
}
int main(){
      int x,ctn = 0;
      cin>>x>>str;
      for (int i = 0;i < x ; i++){
            cin >> tmp;
            ctn += solve(tmp);
      }
      cout << ctn << endl;
      return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
int main()
{
	int i,j,n,h[100],count=1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	for(i=1;i<n;i++){
		for(j=0;j<i;j++){
			if(h[j]>h[i]){
				break;
			}
		}
		if(j==i){
			count+=1;
		}
	}
	printf("%d",count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,n,r,c,a,b;
  cin >>h>>w>>n;
  map<pair<ll,ll>,ll> mp;
  set<pair<ll,ll> > index;
  for (int i=0;i<n;i++) {
    cin>>r>>c;
    r--;c--;
    for (ll dy=-1;dy<=1;dy++) {
      for (ll dx=-1;dx<=1;dx++) {
        a=r+dy;b=c+dx;
        if (a<=0||h-1<=a||b<=0||w-1<=b)continue;
        mp[make_pair(a,b)]++;
        index.insert(make_pair(a,b));
      }
    }
  }
  vector<ll> v(10,0);
  v[0]=(h-2)*(w-2);
  for (set<pair<ll,ll> > ::iterator itr=index.begin();itr!=index.end();itr++){
    v[mp[*itr]]++;
    v[0]--;
  }
  for (int i=0;i<10;i++)cout<<v[i]<<endl;
  return 0;
}


Measured memory_bytes: 112768
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;

int main(void){
    int n;
    cin>>n;
    vector<int> D(n);
    int sum=0;
    rep(i,n){
        cin>>D[i];
        sum+=D[i];
    }
    long long ans=0;
    rep(i,n) ans+=D[i]*(sum-D[i]);
    cout<<ans/2<<endl;
    return 0;
}

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

int main(){
  string s;
  string p;
  cin >> s >> p;
  bool flag = true;
  for (int i = 0; i < s.length(); i++){
    flag = true;
    for (int v = 0; v < p.length(); v++){
      if (i + v >= s.length()){
        if(s[i + v - s.length()] != p[v]){
          flag = false;
          break;
        }
      }else{
        if(s[i + v] != p[v]){
          flag = false;
          break;
        }
      }
    }
    if (flag){
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3208
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1, 0);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(26 + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        ans -= c[t[i]] * (i - last[t[i]]) * (i - last[t[i]] - 1) / 2;
        last[t[i]] = i;
    }

    for (int i = 1; i <= 26; i++)
    {

        ans -= c[i] * (d - last[i] + 1) * (d - last[i]) / 2;
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    double BestScore = scoring(BestT);
    double score;

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1, 1);

    double T0 = 1e6;
    double T1 = 1e3;
    double TL = 1980;

    ll count = 0;

    while (1)
    {
        ll msec;

        if (count % 100 == 0)
        {
            msec = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count();
        }

        if (msec >= TL)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        score = scoring(t);

        double p = exp((score - BestScore) / T);

        if (p > 1)
        {
            BestT = t;
            BestScore = score;
        }

        count++;
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }
}


Measured memory_bytes: 4324
# AOJ ITP1_11_C

# サイコロ。

command = " SSESS"  # すべての面を総当たり。
check = []  # 側面チェック用。
check.append([2, 3, 5, 4])
check.append([3, 5, 4, 2])
check.append([5, 4, 2 ,3])
check.append([4, 2, 3, 5])

def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

class dice:
    def __init__(self):
        self.data = [0 for i in range(8)]
        a = intinput()
        for i in range(1, 7): self.data[i] = a[i - 1]  # 1, 2, 3, 4, 5, 6.
        for i in range(6): self.data[0] += a[i]  # 各位の和を0に。
        self.data[7] = a[0] * a[5] + a[1] * a[4] + a[2] * a[3]  # 対面同士の積の和を7に。
        # dataの1, 2, 3, 4, 5, 6というindexが位置を示す。
        # 回転するとそれらの位置にある数が変化するイメージ。

    def d_read(self, a):
        # aはたとえば5, 1, 2, 6のような配列
        b = []
        for i in range(len(a)): b.append(self.data[a[i]])
        return b

    def d_write(self, b, c):
        # cはたとえば1, 2 ,6, 5のような配列で、そこにbの中身を落とす。
        if len(b) != len(c): return     # 要求と異なる。
        for i in range(len(b)): self.data[c[i]] = b[i]

    def roll(self, direction):
        # directionが'S', 'E', 'W', 'N'.
        # 'S', 'N'では3と4が不変。 'E'と'W'では2と5が不変。
        if direction == ' ': return
        if direction == 'S':
            self.d_write(self.d_read([5, 1, 2, 6]), [1, 2, 6, 5])
            
        elif direction == 'N':
            self.d_write(self.d_read([2, 6, 5, 1]), [1, 2, 6, 5])
            
        elif direction == 'W':
            self.d_write(self.d_read([3, 6, 4, 1]), [1, 3, 6, 4])
            
        elif direction == 'E':
            self.d_write(self.d_read([4, 1, 3, 6]), [1, 3, 6, 4])

    def get_label(self, i):  # i番の面の数を返す。
        return self.data[i]

    def get_index(self, n):  # nが書かれた面のindexを返す。
        for i in range(1, 7):
            if self.data[i] == n: return i
        return -1  # 見つからない場合。

def side_check(d1, d2):
    # 上面と下面が合ってる場合の側面チェック。
    for i in range(4):
        j = 2
        while j < 6:
            if d2.get_label(check[0][j - 2]) != d1.get_label(check[i][j - 2]): break
            j += 1
        if j == 6: return True
    return False

def is_equal(d1, d2):
    if d1.get_label(0) != d2.get_label(0): return False
    if d1.get_label(7) != d2.get_label(7): return False
    # SSESSの順にまわしていけばすべての面が上面に来る。
    for i in range(6):
        d2.roll(command[i])  # 最初だけ何もしない。
        if d2.get_label(1) != d1.get_label(1): continue
        if d2.get_label(6) != d2.get_label(6): continue
        if side_check(d1, d2): return True
    return False

def main():
    d1 = dice()
    d2 = dice()
    if is_equal(d1, d2): print("Yes")
    else: print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

	int max_cnt = 0;
	int ans;
	for (int i = 1; i <= n; i++) {

		int tmp = i;
		int tmp_cnt = 0;
		while (true) {

			if (tmp % 2 != 0) break;
			tmp_cnt++;
			tmp /= 2;
		
		}
		
		if (chmax(max_cnt, tmp_cnt)) ans = i;
		
	}

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// longest increasing subsequence
template <typename T>
int lis(vector<T> &v, T inf) {
    vector<T> a(v.size(), inf);
    for (int i = 0; i < v.size(); ++i) {
        *lower_bound(a.begin(), a.end(), v[i]) = v[i];
    }
    return lower_bound(a.begin(), a.end(), inf) - a.begin();
}

int main() {
    int n;
    cin >> n;
    vi p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        p[i]--;
    }
    ll ret = n;
    vi q(n);
    for (int i = 0; i < n; ++i) {
        q[p[i]] = i;
    }
    ll maxi = 1;
    chmin(ret, n - maxi);
    for (int i = 1; i < n; ++i) {
        if (q[i] > q[i - 1])
            maxi++;
        else
            maxi = 1;
        chmin(ret, n - maxi);
    }
    cout << ret << "\n";
    return 0;
}

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

int main(void){
    ll N,ans=0;
    cin >> N;

    for(int i = 1; i <= N; i++){
        if(i%3 == 0 || i%5 == 0) continue;
        if(i%3 == 0 && i%5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    use std::collections::HashSet;
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let a: Vec<Vec<usize>> = vec(3, |_| vec(3, |_| scan(tokens)));
    let n: usize = scan(tokens);
    let b: HashSet<usize> = (0..n).map(|_| scan(tokens)).collect();
    let hit: Vec<Vec<bool>> = vec(3, |i| vec(3, |j| b.contains(&a[i][j])));
    for i in 0..3 {
        if hit[i][0] && hit[i][1] && hit[i][2] {
            println!("Yes");
            return;
        }
        if hit[0][i] && hit[1][i] && hit[2][i] {
            println!("Yes");
            return;
        }
    }
    if hit[0][0] && hit[1][1] && hit[2][2] {
        println!("Yes");
        return;
    }
    if hit[0][2] && hit[1][1] && hit[2][0] {
        println!("Yes");
        return;
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)
#define f first
#define se second
#define M 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<long long, long long>
#define vi vector<int>
#define ll long long

vector<pair<pair<ll,ll>,ll>>seg;
int inf=1e9;

pair<pair<ll,ll>,ll> find(int st,int l,int r,int l1,int r1){
    if(l1>r||r1<l){
        return mp(mp(0,0),0);
    }
    if(l1<=l&&r1>=r){
        return seg[st];
    }
    if(l==r){
        //cout<<seg[st].first.second<<" "<<seg[st].first.first<<" "<<seg[st].second<<endl;
        return seg[st];
        
    }
    
    int mid=(l+r)/2;
    pair<pair<ll,ll>,ll> v1=find(st*2,l,mid,l1,r1);
    pair<pair<ll,ll>,ll> v2=find(st*2+1,mid+1,r,l1,r1);
    ll k=min(v1.first.first,v2.first.second);
    v1.second=v2.second+v1.second+2*k;
    v1.first.first=v1.first.first+v2.first.first-k;
    v1.first.second=v1.first.second+v2.first.second-k;
    //cout<<v1.second<<" "<<l<<" "<<r<<endl;
    return v1;

}
void update(int st,int pos,int l,int r,char val){
    if(l==r){
        if(val=='('){
            seg[st].first.first=1;
        }else {
            seg[st].first.second=1;
        }
        
        return;
    }
    int mid=(l+r)/2;
    if(pos<=mid){
        update(st*2,pos,l,mid,val);
        
    }else {
        update(st*2+1,pos,mid+1,r,val);
        //seg[st]=min(seg[st*2+1],seg[st*2+2]);
    }
    ll k=min(seg[st*2].first.first,seg[st*2+1].first.second);
    seg[st].second=seg[st*2].second+seg[st*2+1].second+2*k;
    seg[st].first.first=seg[st*2].first.first+seg[st*2+1].first.first-k;
    seg[st].first.second=seg[st*2].first.second+seg[st*2+1].first.second-k;
}


int main(){
   string s;
   cin>>s;
   for(int i=0;i<3;i++){
       if(s[i]=='7'){
           cout<<"Yes";
           return 0;
       }


   }
   cout<<"No";
    
} 


Measured memory_bytes: 3604
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int t = n + m;
		int sum = ((t * (t-1)) / 2) - (n * m);
		System.out.println(sum);
		
	}
	
	}

Measured memory_bytes: 22996
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;
const int maxn = 100005;
typedef pair<int, int> pii;
int N, f[maxn];
set<int> st[maxn];
queue<pii> q;
int find(int x) {
	return f[x] == x ? x : f[x] = find(f[x]);
}
bool merge(int x, int y) {
	// printf("%d %d\n", x, y);
	x = find(x), y = find(y);
	if(x == y) return false;
	if(st[x].size() < st[y].size()) swap(x, y);
	f[y] = x;
	for(set<int>::iterator it = st[y].begin(); 
		it != st[y].end(); ++it) {
		int t = find(*it);
		if(x == t) continue;
		if(st[x].count(t)) q.push(pii(x, t));
		else {
			st[x].insert(t), st[t].insert(x);
			st[t].erase(y);
		}
	}
	st[y].clear(), st[x].erase(y);
	return true;
}
int main() {
	scanf("%d", &N);
	for(int i = 1, u, v; i < N + N - 1; ++i) {
		scanf("%d%d", &u, &v);
		if(st[u].count(v)) q.push(pii(u, v));
		st[u].insert(v), st[v].insert(u);
	}
	for(int i = 1; i <= N; ++i) f[i] = i;
	int cnt = 0;
	while(!q.empty()) {
		pii x = q.front(); q.pop();
		cnt += merge(x.first, x.second);
	}
	puts(cnt == N - 1 ? "YES" : "NO");
	getchar(), getchar();
	return 0;
}

Measured memory_bytes: 24064
n = int(input())
*l, = map(int, input().split())
#print(l)
l.sort()
#print(l) 
mod = 10**9+7
A = 2**(n//2)%mod
for i in range(n):
  if i + (i-n+1)%2 != l[i]:
    A = 0
print(A)

Measured memory_bytes: 14004
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int n,x,y;
  cin>>n>>x>>y;
  map<int,vector<int>> mp;
  for(int i=1;i<n;i++)
  {
      mp[i].push_back(i+1);
      mp[i+1].push_back(i);
  }
  mp[x].push_back(y);
  mp[y].push_back(x);
  map<int,int> m;
  for(int i=1;i<n;i++)
  {
    queue<int> q;
    vector<int> visited(n+1,0);
    visited[i]=1;
    q.push(i);
    int dis=0;
    int ans;
    while(!q.empty())
    {
        int k=q.size();
        m[dis]+=(k-ans);
        ans=0;
        while(k--)
        {
            int f=q.front();
            q.pop();
            for(auto it:mp[f])
            {
                if(!visited[it])
                {
                    q.push(it);
                    visited[it]=1;
                    if(it<i)
                    ans++;
                }
            }    
        }
        dis++;
    }
  }
  for(int i=1;i<n;i++)
  {
      if(m.find(i)==m.end())
      cout<<0<<" ";
      else cout<<m[i]<<" ";
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef pair<ii, int> pii;
int dy[] = {1, -1, 0, 0};
int dx[] = {0, 0, 1, -1};
const int MAX = 1e3+3;
int dist[MAX][MAX];
char m[MAX][MAX];
int N, M;

bool check(int i, int j) {
	return (i >= 0 && i < N && j >= 0 && j < M);
}

int bfs(ii s, ii e) {
	deque<pii> dq;
	dq.push_front(mk(s, 0));
	rep(i, 0, N) rep(j, 0, M)
		dist[i][j] = (1<<30);
	dist[s.F][s.S] = 0;
	while(!dq.empty()) {
		ii u = dq.front().F;
		int d = dq.front().S;
		dq.pop_front();
		if(u == e) return d;
		rep(k, 0, 4) {
			ii v = mk(u.F+dy[k], u.S+dx[k]);
			if(!check(v.F, v.S) || dist[v.F][v.S] <= d || m[v.F][v.S] == '#') continue;
			dq.push_front(mk(v, d));
			dist[v.F][v.S] = d;
		}
		REP(i, -2, 2) REP(j, -2, 2) {
			ii v = mk(u.F+i, u.S+j);
			if(!check(v.F, v.S) || dist[v.F][v.S] <= d+1 || m[v.F][v.S] == '#') continue;
			dq.push_back(mk(v, d+1));
			dist[v.F][v.S] = d+1;
		}
	}
	return -1;
}

int main(int argc, char ** argv) {
	ii s, e;
	scanf("%d%d", &N, &M);
	scanf("%d%d", &s.F, &s.S);
	scanf("%d%d", &e.F, &e.S);
	rep(i, 0, N) scanf(" %s", m[i]);
	s.F--; s.S--; e.F--; e.S--;
	printf("%d\n", bfs(s, e));
	return 0;
}


Measured memory_bytes: 8772
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        h_vec: [usize; n]
    }

    let ans: &str = if n == 1 {
        "Yes"
    } else {
        let mut tmp_ans = "Yes";
        let mut threshold = h_vec[0];

        for i in 0..n-1 {
            if h_vec[i] > h_vec[i+1] + 1 {
                tmp_ans = "No";
                break;
            } else {
                threshold = std::cmp::max(threshold, h_vec[i] - 1);
                if h_vec[i+1] < threshold {
                    tmp_ans = "No";
                    break
                }
            }
        }

        tmp_ans
    };

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

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 3764