akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

int dp[200100];
const int inf = 1e8;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    fill(dp, dp+N, inf);
    rep(i, N) {
        *lower_bound(dp, dp+N, a[i]) = a[i];
    }

    int len = lower_bound(dp, dp+N, inf) - dp;
    //cout << N - len << endl;

    int ans = 0, cur = 1;
    rep(i, len) {
        if (dp[i] == cur) {
            ans++;
            cur++;
        }
        else {
            break;
        }
    }

    if (ans == 0) {
        cout << -1 << endl;
    }
    else {
        cout << N - ans << endl;
    }
}


Measured memory_bytes: 1792
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

ab = sorted(ab, key = lambda x: x[0])
answer = 0 
current_amount = 0

for aabb in ab:
  if aabb[1] >= m - current_amount:
    answer += aabb[0]*(m-current_amount)
    print(answer)
    break
  else:
    answer += aabb[0]*aabb[1]
    current_amount += aabb[1]

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

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
inline ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
  ll N, X;
  cin >> N >> X;
  cout << 3 * (N - gcd(N, X)) << endl;
}


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

int main(void){
	int t, n;
	for(int i = 0; i < 4; i++){
		cin >> t >> n;
		if(t == 1) cout << n*6000 << endl;
		else if(t == 2) cout << n*4000 << endl;
		else if(t == 3) cout << n* 3000 << endl;
		else cout << n*2000 << endl;
	}
	return 0;
}


Measured memory_bytes: 3136
l, r = gets.split.map(&:to_i)

min = 2018
l.upto(r) do |i|
  if i % 2019 == 0
    puts 0
    exit
  end
  (i + 1).upto(r) do |j|
    if j % 2019 == 0
      puts 0
      exit
    end
    min = (i * j) % 2019 < min ? (i * j) % 2019 : min
  end
end

puts min


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<ll> x(n),cp(n);
  rep(i,n)cin>>x[i];
  rep(i,n)cp[i]=x[i];
  sort(all(cp));
  ll l=cp[n/2-1],r=cp[n/2];
  rep(i,n){
      if(x[i]<=l)cout<<r<<endl;
      else cout<<l<<endl;
  }
  return 0;
  }


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE
void solve(void)
{
  int N,L;
  cin>>N>>L;
  int SUM = 0;
  int X = INF;
  int index = 0;
  for (int i = 0; i < N; i++)
  {
    SUM += L + i;
    if(chmin(X,abs(0 - L-i)))
    {
      index = i;
    }
  }
  cout<<SUM - (L+index)<<endl;
  return;
}


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

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

 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define ft first
#define sd second
#define snd sd.ft
#define td sd.sd
#define all(a) a.begin(),a.end()
#define bitcnt(x) __builtin_popcountll(x)
#define inp(x) scanf("%lld",&x)
#define out(x) printf("%lld\n",x)
#define nl printf("\n")
#define tc int t;scanf("%d",&t);while (t-->0)
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 10000000019
#define MAXN 500005
#define ninf -1000000000
#define pinf 1000000000
//typedef unsigned long long int uint64;
typedef long long ll;
typedef vector<pair<ll,ll> > vecpair;
typedef vector<pair<ll, pair<ll,ll> > > vecpair3;

ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
ll invmod(ll x) {return power(x,MOD-2);}


int main()
{
	ll n,i;
	
	char a,b;
	
	cin>>a>>b;
	
	if(a=='H')
	{
		cout<<b;
		return 0;
	}
	else
	{
		if(b=='D')
		cout<<'H';
		else
		cout<<'D';
	}
	
	return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

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

typedef long long int int64;




int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    
    for (int r = 0; r <= n; r++)
        for (int c = 0; c <= m; c++)
        {
            int x = r * (m - c) + c * (n - r);
            if (x == k)
            {
                printf("Yes\n");
                return 0;
            }
        }
    printf("No\n");




	return 0;
}



Measured memory_bytes: 256
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n ,m = I2()
    if n == 2 or m == 2:
        print(0)
    else:
        print(max(1, n - 2)*max(1, m - 2))

Measured memory_bytes: 9092
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Allocation

????????????????????? wi(i=0,1,...n???1) ??? n ??????????????????
????????????????????¢????????????????????????????????????
????????????????????? k ??°?????????????????????????????????
???????????????????????£?¶??????? 0 ?????\??????????????????????????¨?????§???????????????
???????????????????????????????????????????????§????????? P ????¶????????????????????????????
?????§????????? P ?????????????????????????????§??±?????§??????

n???k???wi ???????????????????????§????????????????????????????????????????????????
?????§????????? P ???????°????????±???????????????°????????????????????????????????????

"""
import sys

# ??????????????\????????????
def kenzan(P, w, n, k):
#    print("P:{} kosu:{} track:{}".format(P,n,k))
    t = 1 # ????????????
    s = 0 # ?????????
    st = 0
    for i in range(n):
        x = s + w[i]
#        print("max:{} nimotu[{}]:{} + sekisai:{} = {} track:{}".format(P,i,w[i],s,x,t))
        if x > P: # ????????????
            t += 1
            st += s
            s = w[i]
#            print("next track:{} sekisai:{}".format(t,s))
            if t > k: # ??°??°????????????
#                print("\ttrack:{}/{} P:{} sekisai:{}".format(t,k,P,st))
                return st
        else:
            s = x

#    print("\ttrack:{}/{} P:{} sekisai:{}".format(t,k,P,st))
    return 0

def main():
    """ ????????? """
    n,k = list(map(int,input().split()))
    istr = sys.stdin.read()
    wi = list(map(int,istr.splitlines()))

    # ?????§?????¨???????????¨????°????????±???????
    P = 0
    total = 0
    min = 100000
    for w in wi:
        if P < w:
            P = w
        if min > w:
            min = w
        total += w
    na = int(total / n) # ?????????????????????
    if total % n > 0:
        na += 1
    ka = int(total / k) # ???????????????????????????
    if total % k > 0:
        ka += 1
    # ?????? P (??????????????§??????????????????????????????????±?????????????
#    print("kosu:{} MAX:{} MIN:{} na:{} ka:{} total:{}".format(n, P, min, na, ka, total))
    if P < na:
        P = na
    if P < ka:
        P = ka
    z = 0
    while P <= total:
        st = kenzan(P, wi, n, k)
#        print("??????????????°:{} ??????????????°??°:{} ?????????????????§??????:{} ????????????????????????:{} ??????????????????:{} ??????:{}".format(n, k, P, total, st,z))
        if st == 0:
            a = P - z
            b = P
            break
        z = int((total-st)/k)
        if z < 1:
            z = 1
        P += z
    
    while b - a > 0:
        x = int((b - a) / 2)
        if x < 1:
            a = b
        P = x + a
        st = kenzan(P, wi, n, k)
#        print("P:{} MAX:{} MIN:{} sekisai:{}".format(P, b, a, st))
        if st == 0:
            b = P
        else:
            a = P

    print(P)


if __name__ == '__main__':
    main()

Measured memory_bytes: 18860
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=1;i<n;i++)
    {
        bool left[26];
        bool right[26];
        memset(left,false,sizeof left);
        memset(right,false,sizeof right);
        for(int j=0;j<i;j++) left[s[j]-'a']=true;
        for(int j=i;j<n;j++) right[s[j]-'a']=true;
        int c=0;
        for(int j=0;j<26;j++)
        {
            if(left[j]and right[j]) 
                c++;
        }
        ans=max(ans,c);
    }
    cout<<ans;
    return 0;
    
}

Measured memory_bytes: 3612
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

from collections import defaultdict
d = defaultdict(list)
for i in range(len(ab)):
    a = ab[i][0] - 1
    b = ab[i][1] - 1
    d[a].append(b)
    d[b].append(a)

for i in range(n):
    print(len(d[i]))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
	long long a,b,c,k,i,j,x;
	cin>>a>>b>>c;
	cin>>k;
	j=0;
	while (b<=a)
	{
		b=b*2;
		j++;
	}
	//cout<<j<<endl; 
	x=0;
	while (c<=b)
	{
		c=c*2;
		x++;
	}
	//cout<<x<<endl;
	if ((x+j)<=k)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

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

using namespace std;

int main()
{
	int64_t  N, num, fnum;
	cin >> N ;
	fnum = N;
	num = 0;
	while (fnum > 0)
	{
		int t = fnum % 10;
		fnum = fnum / 10;
		num += t;
	}

	if (N % num == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
 	return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int h1, m1, h2, m2, k;

    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int x = h1 * 60 + m1;
    int y = h2 * 60 + m2;

    cout << (y - x) - k << endl;

    return 0;
}

Measured memory_bytes: 3636
n, m = list(map(int, input().split()))
p = [input().split() for i in range(m)]

s = {i + 1 for i in range(n)}

ac = 0
wa = {i + 1:[0, False] for i in range(n)}


for i in range(m):
  if int(p[i][0]) in s:
    if p[i][1] == 'WA':
      wa[int(p[i][0])][0] += 1
    else:
      ac += 1
      s.discard(int(p[i][0]))
      wa[int(p[i][0])][1] = True
      
wa_wa = 0
for i in range(1, n + 1):
  if wa[i][1]:
    wa_wa += wa[i][0]
print(ac, wa_wa)


Measured memory_bytes: 90196
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root
#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;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int a[10005];

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

	rep(x, 1, 101) rep(y, 1, 101) rep(z, 1, 101)
		if (x * x + y * y + z * z + x * y + y * z + z * x <= 10000)
			a[x * x + y * y + z * z + x * y + y * z + z * x]++;

	int n; read(n);
	rep(i, 1, n + 1) write(a[i]);
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main() {
    int K, A, B;
    cin >> K >> A >> B;

    bool isOK = false;
    for (int i = A; i <= B; ++i) {
        if (i % K == 0) {
            isOK = true;
            break;
        }
    }

    if (isOK) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}


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

int main()
{
ll n,k;
set<ll>s;
cin>>n>>k;
ll i;
for(i=0;i<k;i++)
{
ll c,d;
cin>>c;
for(ll j=0;j<c;j++)
cin>>d,s.insert(d);
}
cout<<n-s.size()<<endl;
return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int dp[1100][1100] = {0};
char x[1100], y[1100];

int count(char a[]){
  int i, sum;
  sum = 0;
  for (i = 0; a[i] != 0; i++) {
    sum++;
  }
  return sum;
}

int max(int x, int y){
  int max;
  if (x > y) {
    max = x;
  }
  else {
    max = y;
  }
  return max;
}

int lcs(char a[], char b[], int a_len, int b_len){
  int i, j;
  for (i = 0; i <= a_len; i++) {
    for (j = 0; j <= b_len; j++) {
      if (a[i] == b[j]) {
        dp[i+1][j+1] = dp[i][j] + 1;
      }
      else {
        dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
      }
    }
  }
  return dp[i-1][j-1];
}

int main(void){
  int i, q, x_len, y_len;

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%s", x);
    scanf("%s", y);
    x_len = count(x);
    y_len = count(y);
    printf("%d\n", lcs(x, y, x_len, y_len));
  }

  return 0;
}



Measured memory_bytes: 6116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
void init();
ll c(ll n, ll m);
ll qpow(ll t, ll p);
ll pre[200005];
ll inv[200005];
ll qpow(ll t, ll p) {
    ll ans = 1;
    while (p) {
        if (p & 1) ans = (ans * t) % mod;
        t = (t * t) % mod;
        p >>= 1;
    }
    return ans;
}
void init() {
    pre[0] = inv[0] = 1;
    for (int i = 1; i < 200005; i++) {
        pre[i] = (pre[i - 1] * i) % mod;
        inv[i] = qpow(pre[i], mod - 2);
    }
}
ll c(ll n, ll m) { return ((pre[n] * inv[n - m]) % mod * inv[m]) % mod; }
int main() {
    ll n, k, ans = 0;
    cin >> n >> k;
    init();
    if (n == 2) {
        if (k & 1)
            cout << 2;
        else
            cout << 1;
        return 0;
    }
    for (int i = 0; i <= min(n - 1, k); i++) {
        if (k == 1 && i == 0) continue;
        ans = (ans + c(n, i) * c(n - 1, n - i - 1)) % mod;
    }
    cout << ans;
}

Measured memory_bytes: 3328
N,M,C=map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    tmp = list(map(int, input().split()))
    tmp2 = 0
    for j in range(M):
        tmp2 += tmp[j] * B[j]
    tmp2 += C
    if tmp2 > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
use std::io::Read;
use std::rc::Rc;
use std::cell::RefCell;

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

    let answer = solve(&buf);

    print!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let m: usize = iterator.next().unwrap().parse().unwrap();

    let mut tree = BTS::new();
    let mut result = String::new();
    for _ in 0..m {
        let command = iterator.next().unwrap();
        if command == "insert" {
            let key: i64 = iterator.next().unwrap().parse().unwrap();
            tree.insert(key);
        } else {
            tree.print_in_order(&mut result);
            result.push('\n');
            tree.print_pre_order(&mut result);
            result.push('\n');
        }
    }

    return result;
}

enum BTS {
    Node {
        parent: Rc<RefCell<BTS>>,
        value: i64,
        left: Rc<RefCell<BTS>>,
        right: Rc<RefCell<BTS>>,
    },
    Nil
}

impl BTS {
    fn new() -> Self {
        BTS::Nil
    }

    fn insert(&mut self, new_value: i64) {
        match *self {
            BTS::Nil => {
                *self = BTS::Node {
                    parent: Rc::new(RefCell::new(BTS::Nil)),
                    value: new_value,
                    left: Rc::new(RefCell::new(BTS::Nil)),
                    right: Rc::new(RefCell::new(BTS::Nil)),
                }
            },
            BTS::Node {
                ref mut parent,
                ref mut value,
                ref mut left,
                ref mut right,
            } => {
                if new_value < *value {
                    left.borrow_mut().insert(new_value);
                } else {
                    right.borrow_mut().insert(new_value);
                }
            },
        }
    }

    fn print_in_order(&self, buf: &mut String) {
        match *self {
            BTS::Nil => {},
            BTS::Node {
                ref parent,
                ref value,
                ref left,
                ref right
            } => {
                left.borrow().print_in_order(buf);
                buf.push_str(&format!(" {}", value));
                right.borrow().print_in_order(buf);
            }
        }
    }

    fn print_pre_order(&self, buf: &mut String) {
        match *self {
            BTS::Nil => {},
            BTS::Node {
                ref parent,
                ref value,
                ref left,
                ref right
            } => {
                buf.push_str(&format!(" {}", value));
                left.borrow().print_pre_order(buf);
                right.borrow().print_pre_order(buf);
            }
        }
    }
}



Measured memory_bytes: 123776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lim 100000
#define mod 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sd(n) scanf("%lld",&n)
#define INF 10000000000
int main()
{
  ll n,a,b;
  cin>>n>>a>>b;
  int ans=abs(b-a);
  if(ans&1)
    cout<<"Borys";
  else cout<<"Alice";
}

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

int main(){
    map<int,int> space;
    int a_size;

    while(cin >> a_size, a_size != 0){
        bool flug = false;
        space.clear();
        for(int i=1; i<=a_size; i++){
            int n;
            cin >> n;
            if(flug == false){
                space[n]++;
                if(space[n] > a_size / 2){
                    cout << n << endl;
                    flug = true;
                }
            }
        }
        if(flug == false){
            cout << "NO COLOR" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, N: int, A: "List[int]"):
    sum_a = sum(A)
    if sum_a < H:
        print(NO)
    else:
        print(YES)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(H, N, A)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14068
#include<stdio.h>
int main()
{
  int m,f,r;
  while(1)
    {
      scanf("%d%d%d",&m,&f,&r);
      if((m==-1)&&(f==-1)&&(r==-1)) break;
      if((m==-1)||(f==-1)) printf("F\n");
      else if(m+f>=80) printf("A\n");
      else if(m+f>=65) printf("B\n");
      else if((m+f>=50)||((m+f>=30)&&(r>=50))) printf("C\n");
      else if(m+f>=30) printf("D\n");
      else printf("F\n");
    }
  return 0;
}

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

#define ll long long 
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

int main()
{
      string s,t;
      cin>>s>>t;
      t+=s;
      cout<<t;
      return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int N, P;
	cin >> N >> P;
	int even = 0, odd = 0;
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		if (x % 2 == 0) ++even;
		else ++odd;
	}
	if (odd == 0) cout << (P == 0 ? (1LL << N) : 0) << endl;
	else cout << (1LL << (N - 1)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define se second
#define sz(x) (int)(x.size())
#define ll long long
#define rep(i,x,y) for(int i = x; i <= y; ++i)
#define repr(i,x,y) for(int i = x; i >= y; --i)
#define pb push_back
#define mp make_pair
#define fi first
#define ull unsigned ll
 
#define pi 3.14159265358979
 
 
using namespace std;
 
const int N = (int)(1e6) + 322;
const ll INF = 2e18 + 17;
const int inf = 2e9;
const int mod = 1000000007;
const double eps = 1e-9;
 
int gcd(int a, int b) { return b ? gcd (b, a % b) : a; }
 
int nbr_bits(int a){
	return log2(a)+1;
}
 
 
int binpow(int a, int n, int mod) {
    int res = 1;
    while (n) {
        if (n & 1) {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
        n >>= 1;
    }
    return res;
}

int fastpow(int a, int n, int mod) {
    if(n==0)
    	return 1;
    if(n%2==0){
    	int res = fastpow(a,n/2,mod);
    	res*=res;
    	res%=mod;
    	return res;
	}
	int res = (fastpow(a,n-1,mod)*a)%mod;
	return res;
    
}
 
// ----------------------------------------------------
 
char mat[10][10];
int t;
int ref[26] ; 
 
signed main()
{
   
   string s ;
   cin >> s ;
   
	if(s[s.size()-1] == 's'){
	  s += "es";
	}
   else{
     s += "s";
	}
   
   cout << s << endl;
   
	return 0;
}
	

Measured memory_bytes: 3604
import java.util.Scanner;
import java.text.DecimalFormat;

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

        double men = r * r * 3.141592653589;

        double tyo = r + r;

        double syu = tyo * 3.141592653589;

        DecimalFormat df1 = new DecimalFormat(".000000");

        System.out.println(df1.format(men) + " " + df1.format(syu));
    }
}


Measured memory_bytes: 27908
#define _crt_secure_no_warnings

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main()
{
	string str,y="yuiophjklnm";
	set<char>data;
	for (auto x : y)
	{
		data.insert(x);
	}
	while (1)
	{
		int count = -1;
		int f = 2;
		cin >> str;
		if (str == "#")break;
		for (auto x : str)
		{
			if (data.find(x) != data.end())
			{
				if (f != 1)
				{
					f = 1;
					count++;
				}
			} else
			{
				if (f != 0)
				{
					f = 0;
					count++;
				}
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1196
from collections import Counter as counter

ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########

n,k = mi()
res = 0
a = []
for i in range(k):
    d = input()
    a.extend(mi())
c = counter(a)
for i in range(1,n+1):
    if c[i] == 0: res+=1
print(res)

Measured memory_bytes: 9480
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int A, B, C;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B >> C;

	int coin = 0;
	rep(day, 1, C + 1) {
		coin += A;
		if (day % 7 == 0) coin += B;
		if (C <= coin) {
			cout << day << endl;
			return;
		}
	}
}



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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

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


void solve()
{
  ll n, k; cin >> n >> k;
  vector<ll> a(n); REP(i, n) cin >> a[i];
  ll ans = 0;
  ll i2 = modinv(2, MOD);
  ll kk2 = ((k - 1) * (( k * i2) % MOD)) % MOD;

  cerr << i2 << endl;
  REP(i, n) {
    ll c1 = 0, c2 = 0;
    REP(j, n) {
      if(a[i] > a[j]) {
	if(j < i) {
	  c1 ++;
	} else {
	  c2 ++;
	}
      }
    }
    
    ans += (c2 * k) % MOD;
    ans +=  ((c1 + c2) * kk2) % MOD ;
    ans %= MOD;
  }
  
  cout << ans % MOD << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  outl((n - 2) * 180);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
	ll C[n + 1][k + 1]; 
	ll i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = (C[i - 1][j - 1] + 
										C[i - 1][j])%MOD; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const string &a , const string&b){
	
}
 
void solve()
{
	int  n ;
	cin>>n ;
	string s ; 
	cin>>s ;
	int wc = 0 ;
	rep(i , n){
		if(s[i]=='W'){
			wc++;
		}
	}
	int st =  n-1 , i = n-1 ;
	int op = 0 ;
	while(i>-1){
		if(wc>0 && s[i]=='R'){
			op++;
			wc--;
		}
		else if(wc>0 && s[i]=='W'){
			wc--;
		}
		i--;
	}
	cout<<op<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    sort(all(v));
    int sum=0;
    for(auto i:v)
        sum+=i;
    bool f=0;
    int val;
    for(auto i:v)
        if(i%10)
        {
            f=1;
            val=i;
            break;
        }
    if(sum%10==0&&!f)
        cout<<"0\n";
    else if(sum%10==0)
        cout<<sum-val<<endl;
    else
        cout<<sum<<endl;

    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;
typedef double db;
typedef long double ldb;


typedef unsigned long long bvec;
const int BITS = sizeof(bvec)*8;
struct basis{
	int rk; bvec dat[BITS];
	void init(){ rk = 0;	for (int i = 0; i < BITS; ++i)	dat[i] = 0; }
	void insert(bvec x){
		for (int k = 0; x && k < BITS; ++k)      if((x&dat[k])>>k)
			x ^= dat[k];
		if(x == 0)	return;
		int p = BITS-1-__builtin_clzll(x);
		dat[p] = x;
		for (int k = p+1; k < BITS; ++k)    if(dat[k]>>p&1)
			dat[k] ^= x;
		++rk;
		assert(rk <= BITS);
	}
	bvec greatest(){
		bvec ret = 0;
		for (int i = 0; i < BITS; ++i)	ret ^= dat[i];
		return ret;
	}
};

const int MAX_N = 200;
int64 A[MAX_N];
basis crt, backup;
bool same(const basis& A, const basis &B){
	FOR(i,BITS)
		if(A.dat[i] != B.dat[i])
			return false;
	return true;
}

char turns[MAX_N+1];
int main(){
	int T;	cin >> T;
	while(T--){
		int N;	cin >> N;
		FOR(i,N)	cin >> A[i];
		cin >> turns;
        crt.init();
        backup.init();
		int ans = 0;
		for (int i = N-1; i >= 0; --i){
			crt.insert(A[i]);
			if(turns[i] == '1' && !same(crt, backup))	ans = 1;
			backup = crt;
		}
		cout << ans << endl;
	}
}




Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll N,K,R,S,P;
    string T;
    cin >>N>>K>>R>>S>>P>>T;
    ll ans = 0;
    map<ll,char> out;
        rep(i,N){
            if(T[i] == 's' && out[i-K] !='r'){
                ans+=R;
                out[i] = 'r';
            }
        }
        rep(i,N){
            if(T[i] == 'p' && out[i-K] !='s'){
                ans+=S;
                out[i] = 's';
            }
        }

        rep(i,N){
            if(T[i] == 'r' && out[i-K] !='p'){
                ans+=P;
                out[i] = 'p';
            }
        }
    
    cout << ans << endl;


    return 0;
    

}

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

typedef long long ll;

const int N = 1e5 + 5;

int vis[N][3];
vector<int> edge[N];
queue<tuple<int, int, int> > Q;

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++ i) {
    int u, v;
    scanf("%d%d", &u, &v);
    edge[u].emplace_back(v);
  }
  int s, t;
  scanf("%d%d", &s, &t);
  Q.push(make_tuple(s, 0, 0));
  int fd = -1;
  while (!Q.empty()) {
    tuple<int, int, int> q = Q.front(); Q.pop();
    int u = get<0>(q);
    int k = get<1>(q);
    int stp = get<2>(q);
    if (k == 0 && u == t) {
      fd = stp; break;
    }
    int nk = (k + 1) % 3;
    for (auto &v : edge[u]) {
      if (vis[v][nk]) {
        continue;
      }
      vis[v][nk] = 1;
      Q.push(make_tuple(v, nk, stp + (0 == nk)));
    }
  }
  printf("%d\n", fd);
  return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define PI 3.14159265359

int main() {
    int A,B,H,M;
    cin >> A >> B >> H >> M;
    double MA = 6*M;
    if(MA == 0)MA = 360;
    if(H>=12)H -= 12;
    double HA = 30*H;
    HA += (double)(0.5*M);
    double angle = abs(max(HA,MA)-min(MA,HA));
    double ans = sqrt((double)(A*A+B*B-2*A*B*cos(angle*PI/180)));
    printf("%.20f\n",ans);

    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int n; std::cin >> n;
    int ct = 0, cx = 0, cy = 0;
    bool ok = true;
    rep(i, n) {
        int t, x, y; std::cin >> t >> x >> y;
        int dt = t - ct, dx = abs(x-cx), dy = abs(y-cy);
        if (dt < dx+dy || dt-(dx+dy)&1) ok = false;
        ct = t, cx = x, cy = y;
    }
    std::cout << (ok ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, T;
  cin >> N >> T;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  ll diff = 0;
  ll mi = A[0];
  for (int i = 0; i < N; i++)
  {
    ll now = A[i];
    if (now > mi)
      diff = max(now - mi, diff);
    mi = min(mi, now);
  }
  map<ll, int> mp;
  ll ans = 0;
  for (int i = 0; i < N; i++)
  {
    ll now = A[i];
    if (mp.find(A[i] - diff) != mp.end())
      ans++;
    mp[now]++;
  }
  cout << ans << endl;
  return 0;
}

// まずO(N)で利益の最大値を求める．そしてx = A[i] - A[j]すなわちA[i] - x == A[j]となるようなjの数を求める．


Measured memory_bytes: 7296
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    ll n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import fractions

def solve(A: int, B: int, C: int, D: int):
    E = C * D // fractions.gcd(C, D)
    count_c = B // C - (A-1) // C
    count_d = B // D - (A-1) // D
    count_e = B // E - (A-1) // E
    print(B-A+1 - count_c - count_d + count_e)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,y;
    cin>>n>>y;
    y/=1000;

    FOR(i,0,n+1){
        FOR(j,0,n+1-i){
            int k = n-i-j;
            if(i + j*5 + k*10 == y){
                printf("%d %d %d", k,j,i);
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 3784