akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
int h,n;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
	scanf("%d %d",&h,&n);

	vector<int>a(n),b(n);

	vector<int>dp(h+1,1e9);

	for(int i=0;i<n;i++)scanf("%d %d",&a[i],&b[i]);
	dp[0] = 0;
	for(int i=1;i<=h;i++){
		for(int j=0;j<n;j++){
			if(a[j]>i){
				dp[i]=min(dp[i],b[j]);
			}
			else	dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
		}
	}
	printf("%d\n",dp[h]);
}		


Measured memory_bytes: 256
N, X = map(int, input().split())
la = sorted(list(map(int, input().split())))

if X < la[0]:
    print(0)
elif X > sum(la):
    print(N-1)
elif X == sum(la):
    print(N)
else:
    j = 0
    while X > 0:
        X = X - la[j]
        j += 1
    if X < 0:
        print(j-1)
    else:
        print(j)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int N, t[60];
int ans;
string s[60], X;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> s[i] >> t[i];
  
  cin >> X;
  
  for (int i = N - 1; i >= 0; i--) 
  {
    if (s[i] == X) break;
    ans += t[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (a : b : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let (q, r) = divMod (a + b) 2
  if r == 0 then print q else putStrLn "IMPOSSIBLE"

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;

bool isok(string S) {
    for (int i = 0; i < S.size(); i++) {
        int step = i + 1;
        if (((step % 2 == 1) && (S[i] == 'L')) || ((step % 2 == 0) && (S[i] == 'R')))return false;
    }
    return true;
}

int main() {

    string S;
    cin >> S;
    
    if(isok(S))cout << "Yes";
    else cout << "No";

}

Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
bool left_large(string a, string b)
{
	ll alen = a.length();
	ll blen = b.length();
	if (alen > blen) { return true; }
	if (alen < blen) { return false; }
	if (a == b) { return false; }
	vector<string>sort_aft;
	sort_aft.pb(a);
	sort_aft.pb(b);
	Sort(sort_aft);
	if (a == sort_aft[0]) {
		return false;
	}
	return true;
}
vector<string>sort1(vector<string> a) {
	ll n = a.size();
	for (ll i = 1; i < n; i++) {
		string  v = a[i];
		ll j = i - 1;
		while (j >= 0 && left_large(a[j], v)) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	}
	return a;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<string, ll>a;
	ll n;
	cin >> n;
	vector<string>find_;
	while (n--) {
		string p;
		ll q;
		cin >> p >> q;
		a[p] += q;
		for (ll i = 0; i < find_.size(); i++) {
			if (find_[i] == p) { goto G; }
		}
		find_.pb(p);
	G: {}
	}find_ = sort1(find_);
	for (ll i = 0; i < find_.size(); i++) {
		cout << find_[i] << " " << a[find_[i]] << endl;
	}
	return 0;
}


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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"


int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	int n, A, B, C, D;
	scanf("%d%d%d%d%d", &n, &A, &B, &C, &D);

	int T = abs(B - A);

	for (int i = 0; i < n; ++i) {
		int j = n - 1 - i;
		ll rem = T - (1LL * i * -C + 1LL * j * C);
		if (rem <= 0 && abs(rem) <= 1LL * (D - C) * i) {
			puts("YES");
			return 0;
		}
		if (rem >= 0 && rem <= 1LL * (D - C) * j) {
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	
	return 0;
}


Measured memory_bytes: 256
def bubble_sort(a, n):
    j = 0
    is_loop = True
    count = 0
    
    while is_loop:
        is_loop = False
        for i in range(n - 1, j, -1):
            if a[i] < a[i - 1]:
                a[i], a[i - 1] = a[i - 1], a[i]
                count += 1
                is_loop = True
        j += 1
        
    return count


N = int(input())
A = list(map(int, input().split()))

count = bubble_sort(A, N)

print(*A)
print(count)



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

int N, M, X;
vector<int> C;
vector<vector<int>> A;
const int INF = 1e+9;

void dfs(vector<int> & bit, int & res) {

	if (static_cast<int>(bit.size()) == N) {
		int cost = 0;
		vector<int> skill(M);
		// 本を買ったらコストと理解度を加算する
		for (int i = 0; i < N; i++) {
			if (bit[i]) {
				cost += C[i];
				for (int j = 0; j < M; j++) {
					skill[j] += A[i][j];
				}
			}
		}
		bool ok = true;
		for (int i = 0; i < M; i++) {
			if (skill[i] < X) {
				ok = false;
				break;
			}
		}
		if (ok) res = min(res, cost);

		return;
	}

	for (int i = 0; i < 2; i++) {
		bit.push_back(i);
		dfs(bit, res);
		bit.pop_back();
	}
}

int main(void) {
	// 入力
	cin >> N >> M >> X;
	C.resize(N);
	A.resize(N, vector<int>(M));

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

	int res = INF;
	vector<int> bit;
	dfs(bit, res);

	if (res == INF) cout << -1 << endl;
	else cout << res << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main()
{
    arena
    ll n;
    cin>>n;
    ll bacteria=1;
    ll attack=0;
    while(n)
    {
        attack+=(bacteria);
        bacteria=bacteria*2;
        n=n/2;
    }
    cout<<attack;
}

Measured memory_bytes: 256
n=int(input())
dic={}
dic["AC"]=0
dic["WA"]=0
dic["TLE"]=0
dic["RE"]=0
for x in range(n):
  a=input()
  dic[a]=dic[a]+1
print("AC","x",dic["AC"])
print("WA","x",dic["WA"])
print("TLE","x",dic["TLE"])
print("RE","x",dic["RE"])

Measured memory_bytes: 9092
N = int(input())
S = input()
max = 0
for i in range(1,N):
    S1 = S[0:i]
    S2 = S[i:N]
    if len(set(S1)&set(S2)) > max:
        max = len(set(S1)&set(S2))
print(max)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] c=new int[3][3];
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				c[i][j]=sc.nextInt();
			}
		}
		int[][] dx=new int [3][2];
		int[][] dy=new int [2][3];
		for(int i=0;i<3;i++) {
			dx[i][0]=(c[i][0]-c[i][1]);
			dx[i][1]=(c[i][1]-c[i][2]);
		}
		for(int j=0;j<3;j++) {
			dy[0][j]=Math.abs(c[0][j]-c[1][j]);
			dy[1][j]=Math.abs(c[1][j]-c[2][j]);
		}
		for(int i=0;i<2;i++) {
			if(dy[i][0]!=dy[i][1]||dy[i][0]!=dy[i][2]) {
				System.out.println("No");
				return;
				}
		}
		for(int j=0;j<2;j++) {
			if(dx[0][j]!=dx[1][j]||dx[0][j]!=dx[2][j]) {
				System.out.println("No");
				return;
				}
		}
		System.out.println("Yes");
		}
}


Measured memory_bytes: 21972
import java.util.Scanner;

class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
// splitで文字列を分ける。("")まで必要
//splitを使うために文字列型にする
    String[] N = sc.next().split("");
//０から数えて何個目にあるかを指定する
//文字列は＝＝じゃなく.equals()
      if (N[0].equals(N[2])){
      System.out.println("Yes") ;
      }
      else {
      System.out.println("No") ;
      }
  }
}


Measured memory_bytes: 22356
#include <iostream>

using namespace std;

int main()
{
    int i,x=0;
    string s;
    cin>>s;
    for(i=0; i<s.length(); i++)
    {
        if((i+1)%2!=0)
        {
            if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')
            {
                x=1;
                cout<<"No"<<endl;
                break;
            }
        }
        else
        {
            if(s[i]!='L'&&s[i]!='U'&&s[i]!='D')
            {
                x=1;
                cout<<"No"<<endl;
                break;
            }
        }
    }
    if(x==0)
        cout<<"Yes"<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;

// a, bの最大公約数と， ax+by=gcd(a, b)となるx,yを求める
ll ext_gcd(ll a, ll b, ll &x, ll &y) {
    ll g = a;
    if(b != 0) {
        g = ext_gcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else {
        x = 1;
        y = 0;
    }

    return g;
}

// ax = gcd(a, m) (mod m) となるxを求める
// a, m が互いに素ならば関数値はmod m でのaの逆数となる
ll mod_inv(ll a, ll m) {
    ll x, y;
    ext_gcd(a, m, x, y);
    return (x % m + m) % m;
}

// 組合せ
ll comb(ll n, ll r) {
    if(n < r) return 0;
    if(n-r < r) r = n-r;

    ll ret = 1;
    for(int i=0; i<r; i++) {
        ret *= (n--);
        ret %= MOD;
        ret *= mod_inv(i + 1, MOD);
        ret %= MOD;
    }
    return ret;
}

std::pair<std::vector<ll>, std::vector<ll>> prime_factor_decomp(ll n) {
    std::vector<ll> p, e;
    ll m = n;
    for (ll i = 2; i * i <= n; i++) {
        if (m % i != 0) continue;
        int c = 0;
        while (m % i == 0) c++, m /= i;
        p.push_back(i);
        e.push_back(c);
    }
    if (m > 1) {
        p.push_back(m);
        e.push_back(1);
    }
    return std::make_pair(p, e);
}

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

    ll n, m;
    cin >> n >> m;

    ll res = 1;
    auto pf = prime_factor_decomp(m);
    for (auto k : pf.second)
        (res *= comb(k + n - 1, k)) %= MOD;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};



int main(void) {
    double a;
    cin >> a;
    cout << ceil(a/2) << endl;
}

Measured memory_bytes: 256
import sys
K = int(input())

if K % 2 == 0:
    print(-1)
    sys.exit()

if K % 5 == 0:
    print(-1)
    sys.exit()

if K % 7 == 0:
    L = 9 * K / 7
else:
    L = 9 * K

i = 1
mod = 10**i % L
while True:
    if mod == 1:
        print(i)
        sys.exit()

    mod = mod * 10 % L
    i += 1


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

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

    char c;
    cin >> c;
    if ('A' <= c && c <= 'Z') cout << 'A';
    else cout << 'a';
    cout << '\n';

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, K; cin >> N >> K;
    vec<lint> H_list(N);
    range(i, 0, N) cin >> H_list.at(i);
    sort(H_list.begin(), H_list.end(), greater<lint>());
    lint res = 0;
    range(i, K, N) res += H_list.at(i);
    cout << res << "\n";
}

Measured memory_bytes: 1792
main :: IO ()
main = do
    xs <- getLine
    putStrLn $ show $ pittan01 xs
    
pittan01 :: String -> Int
pittan01 [] = 0
pittan01 (x:xs) = pikosan x + pittan01 xs

pikosan :: Char -> Int
pikosan '1' = 1
pikosan _ = 0

Measured memory_bytes: 380
# coding: utf-8
# ハッシュ（Dictパターン）

hash_list = {}

if __name__ == "__main__":
    n = int(input())

    for _ in range(n):
        command, arg = input().split()

        if command == 'insert':
            hash_list[arg] = 1
        else:
            print('yes' if arg in hash_list else 'no')


Measured memory_bytes: 33116
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 1e9+7;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a;
	ll sum = 0;
	for(int i=0;i<n;++i){
		int val;
		cin>>val;
		sum += val;
		a.push_back(val);
	}
	ll ans = 0;
	for(int i=0;i<n;++i){
		sum -= a[i];
		ans += (((a[i]%INF) * (sum%INF))%INF);
		ans %= INF;
	}
	cout<<ans<<'\n';

}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll n;

ll bpow(ll a, ll b, ll m) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
    cin >> n;

    ll seq = 0;
    // What if all 7s or all 1s
    rep(i, 0, 1000001) {
        seq = (seq + 7ll * bpow(10, i, n)) % n; 
        if (seq == 0) {
            cout << i + 1;
            return 0;
        }
    }
    cout << -1;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	string s;
	cin>>n>>s;
	ll x,y,z,ans=0;
	char xx,yy,zz;
	ll arr[n+1],brr[n+1],crr[n+1];
	for(int a=0;a<=n;a++)
	{
		arr[a]=brr[a]=crr[a]=0;
	}
	for(int a=n-1;a>=0;a--)
	{
		if(s[a]=='R')
		arr[a]=arr[a+1]+1;
		else
		arr[a]=arr[a+1];
		if(s[a]=='G')
		brr[a]=brr[a+1]+1;
		else
		brr[a]=brr[a+1];
		if(s[a]=='B')
		crr[a]=crr[a+1]+1;
		else
		crr[a]=crr[a+1];
	}
	for(int a=0;a<n;a++)
	{
		for(int b=a+1;b<n-1;b++)
		{
			if(s[a]==s[b])
			continue;
			else 
			{
				xx=s[a];
				yy=s[b];
				if(xx=='R'&&yy=='G')
				zz='B';
				else if(xx=='G'&&yy=='R')
				zz='B';
				if(xx=='R'&&yy=='B')
				zz='G';
				else if(xx=='B'&&yy=='R')
				zz='G';
				if(xx=='B'&&yy=='G')
				zz='R';
				else if(xx=='G'&&yy=='B')
				zz='R';
				if(zz=='R')
				{
					ans+=arr[b+1];
					if(b+b-a<n)
					{
						if(s[b+b-a]=='R')
						ans--;
					}
				}
				if(zz=='G')
				{
					ans+=brr[b+1];
					if(b+b-a<n)
					{
						if(s[b+b-a]=='G')
						ans--;
					}
				}
				if(zz=='B')
				{
					ans+=crr[b+1];
					if(b+b-a<n)
					{
						if(s[b+b-a]=='B')
						ans--;
					}
				}
			}
		}
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pii pair<int, int>
#define vii vector<pii>
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vd vector<double>
#define vvi vector< vector<int> >
#define vvii vector< vector< pii > >
#define ld long double
#define mapii map<int, int>
#define mapsi map<string, int>
#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define INF  LLONG_MAX
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define pi  acos(-1)
#define mod(n,m) ((n % m + m) % m)
#define eps (1e-8)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'
#define output freopen("output.txt", "w", stdout)
#define mp(x, y, z) {x, {y, z}}

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

	int n;
	cin >> n;

	vector< pair<int, pii> > vec;
	vec.push_back(mp(0, 0, 0));
	rep(i, 0, n)
	{
		int a, b, c;
		cin >> a >> b >> c;
		vec.push_back(mp(a, b, c));
	}

	sort(all(vec));

	int xx = 0, yy = 0, t = 0;
	rep(i, 1, sz(vec))
	{
		int a = vec[i].first;
		int x = vec[i].second.first;
		int y = vec[i].second.second;

		ll hawsallak = abs(xx-x) + abs(yy-y);


		ll wa2t = a - t;

		ll rem = wa2t - hawsallak;

		if (wa2t < hawsallak)
			return cout << "No", 0;

		if (rem & 1)
			return cout << "No", 0;

		t = a, xx = x, yy = y;
	}

	cout << "Yes\n";

	return 0;
}


Measured memory_bytes: 1912
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  ll n = 4;
  vll a(n);
  rep(i, n){
    a[i] = s[i]-'0';
  }
  rep(i, 8){
    ll k = a[0];
    string ans;
    ans += s[0];
    rep(j, 3){
      if((i>>j)&1){
        k += a[j+1];
        ans += "+";
        ans += s[j+1];
      }else{
        k -= a[j+1];
        ans += "-";
        ans += s[j+1];
      }
    }
    ans += "=7";
    if(k == 7){
      print(ans);
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){  a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N=1e6+3;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,d;
      cin>>n>>d;
      vector<int> a[n];
      for(int i=0;i<n;i++)
      {
            for(int j=0;j<d;j++)
            {
                  int x;
                  cin>>x;
                  a[i].pb(x);
            }
      }
      int ans=0;
      for(int i=0;i<n;i++)
      {
            for(int j=i+1;j<n;j++)
            {
                  int s=0;
                  for(int k=0;k<d;k++)
                  {
                        s+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
                  }
                  int o=sqrt(s);
                  if(o*o==s) ans++;
            }
      }
      cout<<ans;
}     
// I never lose. I either win or I learn

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        cout << "Bad" << endl;
    else {
        cout << "Good" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
	char A[201],buf[201];
	int n,i,h;
	while(1){
		scanf("%s",A);
		if(strcmp(A,"-")==0) break;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d",&h);
			strcpy(buf,A+h);
			strncat(buf,A,h);
			strcpy(A,buf);
		}
		printf("%s\n",A);
	}
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            for (var i = 0; i < 100; ++i)
            {
                if (0 <= N - i * 4 && 0 == (N - i * 4) % 7)
                {
                    WriteLine("Yes");
                    return;
                }
            }
            WriteLine("No");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str s; cin >>s;
  if(s.size()==3) reverse(all(s));
  fin(s)
  return;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

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

    int prefix = s / 100;
    int suffix = s % 100;
  
    bool isp = false, iss = false;

    if (prefix > 0 && prefix < 13){
        isp =true;
    }
    if (suffix > 0 && suffix < 13){
        iss = true;
    }

    if (isp && iss){
        cout << "AMBIGUOUS" << endl;
    }
    else if (isp && ! iss){
        cout << "MMYY" << endl;
    }
    else if (!isp && iss){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    int sum = 0;
    rep(i, n)cin >> l[i], sum+=l[i];

    sort(ALL(l), greater<int>());
    if(l[0] < sum - l[0])cout << "Yes";
    else cout << "No";

}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

mia = sorted([i for i in a if i < 0], reverse=True)
pla = sorted([i for i in a if i >= 0])
ans, num = 1, []

if len(pla) == 0 and k % 2 == 1:
    for i in mia[:k]:
        ans = ans * i % mod
    print(ans)
    exit()

for _ in range(k):
    if len(mia) > 0 and len(pla) > 0:
        if abs(mia[-1]) <= pla[-1]:
            tmp = pla.pop()
        elif abs(mia[-1]) > pla[-1]:
            tmp = mia.pop()
    elif len(mia) == 0:
        tmp = pla.pop()
    elif len(pla) == 0:
        tmp = mia.pop()
    num.append(tmp)

cnt = sum(i < 0 for i in num)
for i in num:
    ans = ans * i % mod

if cnt % 2 == 1:
    if len(mia) > 0 and cnt != k:
        for i in num[::-1]:
            if i >= 0:
                p, q = i, mia[-1]
                break
        if len(pla) == 0:
            ans *= q * pow(p, mod - 2, mod)
    if len(pla) > 0:
        for i in num[::-1]:
            if i < 0:
                r, s = i, pla[-1]
                break
        if len(mia) == 0 or cnt == k:
            ans *= s * pow(r, mod - 2, mod)
    if len(mia) > 0 and len(pla) > 0 and cnt != k:
        if q * r >= p * s:
            ans *= q * pow(p, mod - 2, mod)
        if q * r < p * s:
            ans *= s * pow(r, mod - 2, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 33096
#include<bits/stdc++.h>
#define int long long
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define mod 1000000007
#define float long double
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define do int n; cin>>n; vector<int>v1(n); rep(i,0,n) cin>>v1[i];
#define print(v1) rep(i,0,v1.size()){cout<<v1[i]<<" ";} cout<<"\n";
using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int modulo(int n,int m=1000000007){
    if(n<0){
        return (m-abs(n)%m)%m;
    }
    if(n%m>=0)return n%m; return n%m+m;;
}
bool isPrime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0)
      return false;
  }
  return true;
}
int power(int a,int n){
    if(n==0) return 1;
    if(n==1) return a;
    if(n==2) return (a*a)%mod;
    if(n&1){
        n--;
        return (a*power(power(a,2),n/2))%mod;
    }
    else return (power(power(a,2),n/2))%mod;
}
int fact(int n){
  int total=1;
  rep(i,2,n+1){
    total=(total*i)%mod;
    // cout<<total+mod<<"\n";
  }
  return (total)%mod;
}
int find(int n){
  int x=n,sum=1;
  while(x>0){
    sum*=(x%10);
    x=x/10;
  }
  return sum;
}
void solve()
{
    int n;
    cin>>n;
    if(n<2)
    cout<<0;
  else{
    cout<<modulo(power(10,n)-2*power(9,n)+power(8,n));
  }
}
 
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   
   int t=1;
   //cin>>t;
   while(t--)
   {
      solve();
      cout<<"\n";
   }
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
  return 0;
 }

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

void bubbleSort(string *A, int N){
  bool flag=true;
  while(flag){
    flag=false;
    for(int i=N-1;i>0;i--){
      if(A[i-1][1]>A[i][1]){
        swap(A[i-1], A[i]);
        flag=true;
      }
    }
  }
}

void selectionSort(string *A, int N){
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(A[j][1]<A[minj][1]) minj=j;
    }
    if(i!=minj){
      swap(A[i], A[minj]);
    }
  }
}

int main(){

  int n;
  string c1[40], c2[40];

  cin>>n;
  for(int i=0;i<n;i++){
    string card;

    cin>>card;
    c1[i]=card;
    c2[i]=card;
  }

  bubbleSort(c1, n);
  selectionSort(c2, n);

  for(int i=0;i<n;i++){
    cout<<(i?" ":"");
    cout<<c1[i];
  }
  cout<<endl<<"Stable"<<endl;

  for(int i=0;i<n;i++){
    cout<<(i?" ":"");
    cout<<c2[i];
  }
  cout<<endl;

  bool flag=true;
  for(int i=0;i<n;i++){
    if(c1[i]!=c2[i]) flag=false;
  }
  if(flag) cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;

  return 0;
}



Measured memory_bytes: 3176
import numpy as np


H, W = map(int, input().split())
grid = np.array([list(input()) for _ in range(H)]) == "."

up = np.zeros((H, W), dtype = int)
down = np.zeros((H, W), dtype = int)
left = np.zeros((H, W), dtype = int)
right = np.zeros((H, W), dtype = int)

for i in range(H):
    down[i] = (down[i - 1] + 1) * grid[i]
    up[-i - 1] = (up[-i] + 1) * grid[-i - 1]

for i in range(W):
    right[:, i] = (right[:, i - 1] + 1) * grid[:, i]
    left[:, -i - 1] = (left[:, -i] + 1) * grid[:, -i - 1]

print(np.max(up + down + left + right) - 3)

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

#define rep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
using ll = long long;

ll aabs(ll x){
    if (x < 0){
        return -x;
    }else{
        return x;
    }
}

int main(){

    ll N,X,Y;
    cin >> N >> X >> Y;

    rep(k,1,N){

        ll ans = 0;

        rep(j,1,N+1){

            map<ll,ll> lis;
            lis[j-k]=1;
            
            lis[j+k] = 1;
            lis[Y+(k-aabs(j-X)-1)] = 1;
            lis[Y-(k-aabs(j-X)-1)] = 1;
            lis[X+(k-aabs(j-Y)-1)] = 1;
            lis[X-(k-aabs(j-Y)-1)] = 1;
        

            for( auto i = lis.begin(); i != lis.end() ; ++i ) {
                ll ii = i->first;

                if ((1<=ii) && (ii<=N) && (min(aabs(ii-X)+1+aabs(j-Y) , min(aabs(ii-Y)+1+aabs(j-X),aabs(ii-j)))==k)){
                 ans+=1;
                }
            }
        }

        cout << ans/2 << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

class node{
public:
	int id;
	vector<int> children;
	int parent;
	int sibling;
	int depth;
	int height;
};

bool operator<=(node a, node b) {
	return a.id <= b.id;
}
bool operator<(node a, node b) {
	return a.id < b.id;
}

int main() {
	int  n,tmp2,index_root;
	cin >> n;
	node* nod = new node[n];
	bool* root = new bool[n];
	for (int i = 0;i < n;i++) {
		cin >> nod[i].id;
		for (int j = 0;j < 2;j++) {
			cin >> tmp2;
			nod[i].children.push_back(tmp2);
		}
		root[i] = true;
	}
	sort(nod, nod + n);
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < nod[i].children.size();j++) {
			root[nod[i].children[j]] = false;
		}
	}
	for (int i = 0;i < n;i++) {
		if (root[i]) {
			index_root = i;
			break;
		}
	}
	nod[index_root].depth = 0;
	nod[index_root].parent = -1;
	nod[index_root].sibling = -1;
	queue<node*> q;
	q.push(&nod[index_root]);
	node* work_node;
	//深さ決定
	while (!q.empty()) {
		work_node = q.front();
		q.pop();
		for (int i = 0;i < work_node->children.size();i++) {
			nod[work_node->children[i]].parent = work_node->id;
			nod[work_node->children[i]].depth = work_node->depth + 1;
			q.push(nod + work_node->children[i]);
		}
	}
	//decide sibling
	for (int i = 0;i < n;i++) {
		if (nod[i].children[0] != -1) {
			nod[nod[i].children[0]].sibling = nod[i].children[1];
		}
		if (nod[i].children[1] != -1) {
			nod[nod[i].children[1]].sibling = nod[i].children[0];
		}
	}
	//decide height
	for (int i = 0;i < n;i++) {
		if (nod[i].children[0] == -1) {
			nod[i].height = 0;
			q.push(nod + i);
		}
	}
	while (!q.empty()) {
		work_node = q.front();
		q.pop();
		if (work_node->parent != -1) {
			nod[work_node->parent].height = work_node->height + 1;
			q.push(nod + work_node->parent);
		}
	}
	for (int i = 0;i < n;i++) {
		cout << "node " << i << ": parent = " << nod[i].parent << ", sibling = " << nod[i].sibling << ", degree = ";
		cout << (nod[i].children[0] != -1) + (nod[i].children[1] != -1);
		cout << ", depth = " << nod[i].depth << ", height = " << nod[i].height << ", ";
		if (nod[i].depth == 0) {
			cout << "root";
		}
		else if (nod[i].children[0] == -1&&nod[i].children[1]==-1) {
			cout << "leaf";
		}
		else {
			cout << "internal node";
		}
		cout << endl;
	}


}




Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

ll gcd(ll m, ll n) {
  while(n != 0) {
    ll r = m % n;
    m = n; n = r;
  }
  return m;
}

ll gcm(ll m, ll n) {
  return m / gcd(m, n) * n;
}

ll solve(const int N, const int M, const string& S, const string& T) {
  ll ans = -1LL;
  ll GCD = gcd(N, M);
  ll GCM = gcm(N, M);
  int s1 = GCM / (ll)M;
  int s2 = GCM / (ll)N;
  //  cout << s1 << " " << s2 << endl;
  int is = 0, it = 0;
  for(; is < N && it < M; is += s1, it += s2) {
    if(S[is] != T[it]) return ans;
  }
  return GCM;
}

int main() {
  int N, M; cin>>N>>M;
  string S, T; cin>>S>>T;
  if(N < M) {
    swap(M, N);
    swap(S, T);
  }
  ll ans = solve(N,M,S,T);
  //  cout << "Answer=";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
L = list(map(int,input().split()))
N = int(input())

A = min(4*L[0],2*L[1],L[2])
B = L[3]
if N % 2 == 0 :
    ans = min(A*N,B*N//2)
else :
    ans = min(A*(N-1),B*(N-1)//2) + A
print(ans)


Measured memory_bytes: 3060
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);

void main() {
    int p,q,r;
    readf("%d %d %d\n", &p,&q,&r);
    writeln(min(p+q, q+r, r+p));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	string S;
	int Q;
	cin>>S>>Q;
	string front,rear;
	rear=S;
	rep(i,0,Q){
		int T,F;
		char C;
		cin>>T;
		if(T==1){
			swap(front,rear);
		}
		else{
			cin>>F>>C;
			if(F==1){
				front.pb(C);
			}
			else{
				rear.pb(C);
			}
		}
	}
	reverse(all(front));
	S=front+rear;
	cout<<S<<endl;
	return 0;
}


Measured memory_bytes: 1260
# -*- coding: utf-8 -*-
# 文字列の入力
S = input()
# 出力
if S.isdecimal() == False:
    print("NA")
elif 1<=int(S[0:2]) and 12>=int(S[0:2]):
    if 1<=int(S[2:4]) and 12>=int(S[2:4]):
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1<=int(S[2:4]) and 12>=int(S[2:4]):
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[]
for i in range(n):
    c.append((a[i],b[i]))
c=sorted(c,key=lambda x:x[0]-x[1])
x=0
ans = 0
j = 0
for i in range(n):
    if c[i][0]-c[i][1] <0:
        ans += 1
        x += abs(c[i][0]-c[i][1])
    else:
        j=i
        break
for i in range(n-1,j-1,-1):
    if j == 0:
        break
    x-=c[i][0]-c[i][1]
    ans+= 1
    if x<=0:
        break
    
if x<=0:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 86704
n = int(input())
adjacency_list = []
for i in range(n):
    input_list = list(map(int, input().split()))
    adjacency_list.append(input_list[2:])
checked_set = set()
dfs_stack = []
v =[0 for i in range(n)]
f =[0 for i in range(n)]
time = 1
for i in range(n):
    if i not in checked_set:
        dfs_stack = []
        dfs_stack.append(i)
        while dfs_stack:
            current = dfs_stack.pop()
            if current not in checked_set:
                checked_set.add(current)
                v[current] = time
                dfs_stack.append(current)
                for ad in reversed(adjacency_list[current]):
                    if ad-1 not in checked_set:
                        dfs_stack.append(ad-1)
                time +=1
            elif f[current] == 0:
                f[current] = time
                time +=1
for i in range(n):
    print(f'{i+1} {v[i]} {f[i]}')


Measured memory_bytes: 5636
#include"bits/stdc++.h"
using namespace std;
int main(){

    int a=0,b=0;
    string s; cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+')a++;
        else b++;
    }
    if(a>b)cout<<abs(a-b);
    else cout<<a-b;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 200

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int count(int n) {
	return n % 2 ? 0 : count(n / 2) + 1;
}

int main() {
	int n, g;

	scanf("%d", &n);
	g = 0;
	while (n--) {
		int a;

		scanf("%d", &a);
		g = gcd(g, a);
	}
	printf("%d\n", count(g));
	return 0;
}


Measured memory_bytes: 128
n = int(input())
x = [int(x) for x in input().split()]
x.sort()
ans = 10**9+7
for i in range(1, x[-1]+1):
  key = 0
  for j in range(n):
    key += (x[j]-i)**2
  if key < ans:
    ans = key
print(ans)

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

class BinaryIndexedTree {
    using T = pair<ll, ll>;
    private:
        int N;
        std::vector<T> dat;
    public:
        BinaryIndexedTree(int n) : N(n), dat(n+1) {}
        // a is 1-indexed
        void add(int a, const T v) {
            while (a <= N) {
                dat[a].first += v.first;
                dat[a].second += v.second;
                a += (a & -a);
            }
        }
        // return sum of [1, a]
        // a is 1-indexed
        T sum(int a) const {
            T res = make_pair(0LL, 0LL);
            while (a > 0) {
                res.first += dat[a].first;
                res.second += dat[a].second;
                a -= (a & -a);
            }
            return res;
        }
        // return sum of [a. b)
        // a and b are 1-indexed
        T sum(int a, int b) const {
            T res = make_pair(0LL, 0LL);
            T tmpb = sum(b-1), tmpa = sum(a-1);
            res.first = tmpb.first - tmpa.first;
            res.second = tmpb.second - tmpa.second;
            return res;
        }
};

void solve() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; ++i) cin >> a[i];

    // compress
    vector<int> b = a;
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    int M = (int)b.size();

    BinaryIndexedTree bit(M);
    for (int i=1; i<N; ++i) bit.add(lower_bound(b.begin(), b.end(), a[i])-b.begin()+1, {1, a[i]});
    vector<ll> res(N);
    for (int i=0; i<N; ++i) res[0] += a[i];
    int l = 0;
    for (int r=1; r<N; ++r) {
        int cur = lower_bound(b.begin(), b.end(), a[r]) - b.begin() + 1;
        if (a[l] < a[r]) {
            auto p = bit.sum(lower_bound(b.begin(), b.end(), a[l])-b.begin()+2, M+1);
            ll num = p.first, sum = p.second;
            res[r] = sum - num * a[l];
            res[l] -= res[r];
            l = r;
        }
        bit.add(cur, {-1, -a[r]});
    }
    for (ll x : res) cout << x << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 4224
from collections import deque
K = int(input())

q = deque([1,2,3,4,5,6,7,8,9])

for _ in range(K):
    x = q.popleft()
    ichi_no_kurai = x%10
    if ichi_no_kurai == 0:
        q.append(10*x+ichi_no_kurai)
        q.append(10*x+ichi_no_kurai+1)
    elif x%10 == 9:
        q.append(10*x+ichi_no_kurai-1)
        q.append(10*x+ichi_no_kurai)
    else:
        q.append(10*x+ichi_no_kurai-1)
        q.append(10*x+ichi_no_kurai)
        q.append(10*x+ichi_no_kurai+1)
print(x)

Measured memory_bytes: 18804
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
      	int nam = 0;
      
      for(int i =0;i < n ;i++){
        int s = in.nextInt();
        int g = in.nextInt();
        nam +=  (g-s)+1;
      }
      System.out.print(nam);
	}
}

Measured memory_bytes: 26064
#include<stdio.h>
#include<stdlib.h>

int insertionSortCount(int*, int, int);
void shellSort(int*, int);

int main(void){
	int n, *a, i;
	
	scanf("%d\n", &n);
	a = (int*)malloc(sizeof(int)*n);
	for(i = 0; i < n; i++){
		scanf("%d\n", &a[i]);
	}
	shellSort(a, n);
	for(i = 0; i < n; i++){
		printf("%d\n", a[i]);
	}
	free(a);
	
	return 0;
}

int insertionSortCount(int* arr, int len, int h){
	int i, j, v, cnt = 0;
	for(i = h; i < len; i++){
		v = arr[i];
		j = i-h;
		while(j >= 0 && arr[j] > v){
			arr[j+h] = arr[j];
			j -= h;
			cnt++;
		}
		arr[j+h] = v;
	}
	return cnt;
}

void shellSort(int* arr, int len){
	int cnt = 0, m = 1, i = 0, j, g[100];
	while(len >= m){
		g[i] = m;
		m = m*3 + 1;
		i++;
	}
	printf("%d\n", i);
	for(j = i-1; j >= 0; j--){
		j == 0 ? printf("%d\n", g[j]) : printf("%d ", g[j]);
		cnt += insertionSortCount(arr, len, g[j]);
	}
	printf("%d\n", cnt);
}


Measured memory_bytes: 5496
#include<stdio.h>

#define MAX_N 100000

int binary_search(int n, int key, int *S)
{
  int left = 0;   // first index of search range
  int right = n;  // next index of search range
  int mid;        // middle index of search range

  while (left < right) {
    mid = (left + right)/2;
    if (S[mid] == key)
      return mid;
    else if (key < S[mid])
      right = mid;
    else
      left = mid + 1;
  }
  return -1;
}
int main(void)
{
  int n, q, key;
  int S[MAX_N];

  // 入力処理
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d ", &S[i]);
  }
  scanf("%d", &q);
  int cnt = 0;
  for (int i = 0; i < q; i++) {
     scanf("%d ", &key);
     if (binary_search(n, key, S) != -1)
       cnt++;
  }

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

}
  



Measured memory_bytes: 2116
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

h = [[False] * 3 for _ in range(3)]

for i in range(3):
  for j in range(3):
    if b.count(a[i][j]) >= 1:
      h[i][j] = True


def ok():
  print('Yes')
  exit()


for i in range(3):
  if all(h[i]):
    ok()
for j in range(3):
  for i in range(3):
    if not h[i][j]:
      break
  else:
    ok()
if all([h[k][k] for k in range(3)]):
  ok()
if all([h[3 - 1 - k][k] for k in range(3)]):
  ok()

print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
int n;
int count=0;
cin>>n;
vi h(n);
rep(i,n)
	cin>>h[i];

REP(i, 1 ,101){

	bool flag=false;
	rep(j,n){

		if(h[j]<i)
			flag=false;

		else{
			if(flag==false){
				count+=1;
			}
			
			flag=true;
		}	
	}
}
cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256