akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
 int a, b;
 cin >> a >> b;
 if(b%a  == 0)
     cout << a+b fin;
     else
         cout << b-a fin;

  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

class UnionFind {
public:
    vector<int> par;

    UnionFind(int n) : par(n, -1) {};

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    int size(int x) {
        return -par[root(x)];
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, 0, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    reverse(all(a));
    reverse(all(b));

    vector<ll> ans(m);

    ans[0] = 1LL * (n - 1) * n / 2;

    UnionFind uf(n);
    for (int i = 0; i <= m - 2; i++) {
        if (uf.same(a[i], b[i])) {
            ans[i + 1] = ans[i];
        } else {
            ans[i + 1] = ans[i] - 1LL * uf.size(a[i]) * uf.size(b[i]);
            uf.unite(a[i], b[i]);
        }
    }

    reverse(all(ans));
    rep(i, 0, m) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3328
# 各行の所属するグループを配列として持たせる実装。列ごと見ていってダメなら垂直線追加していく
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
ans = 10**9
for bit in range((1 << (H-1))):
    vidx = []
    gok = True
    g = 0
    gid = [0] * H
    for i in range(H-1):
        if (bit >> i) & 1:
            g += 1
        gid[i+1] = g
    g += 1
    gnum = [0]*g
    vertical = 0
    for w in range(W):
        ok = True
        one = [0]*g
        for h in range(H):
            one[gid[h]] += int(S[h][w])
            gnum[gid[h]] += int(S[h][w])
            if one[gid[h]] > K:
                gok = False
            if gnum[gid[h]] > K:
                ok = False
        if not ok:
            vertical += 1
            vidx.append(w)
            gnum = one

    # if bit == 2:
    #    print('aaaaa')
    #    print(gid)
    #    print(vidx)
    #    print(bin(bit), g-1, vertical)
    #    print('aaaaa')
    if gok:
        if ans > g-1 + vertical:
            ans = g-1 + vertical
            # print(bin(bit), g-1, vertical)
            # print(vidx)
            # print(ans)
        # ans = min(ans, g-1 + vertical)
if ans == 10**9:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 69996
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin.bytes().map(|c| c.expect("faild") as char).skip_while(|c| c.is_whitespace()).take_while(|c| !c.is_whitespace()).collect();
    token.parse().ok().expect("faild parse")
}
fn main(){
    loop{
        let a: i32 = read();
        let op: String = read();
        let b: i32 = read();
        if op == "?"{
            break;
        }
        let ans = match op.as_str(){
            "+" => a+b,
            "-" => a-b,
            "*" => a*b,
            "/" => a/b,
            _ => a,
        };
        println!("{}", ans)
    }
}


Measured memory_bytes: 1064
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, K;
  cin>>N>>K;

  Int n = N % K;

  Int ans = min(K - n, n);
  cout<<ans<<endl;

  return 0;
}


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_bacn
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

int main()
{
	fast;
	int h, n;
	cin >> h >> n;
	vi dp(h + 1, 1e8 + 1);
	dp[0] = 0;
	FOR(n)
	{
		int health, point;
		cin >> health >> point;
		for (int j = 1; j < h + 1; j++)
			dp[j] = min(dp[j], dp[max(0, j - health)] + point);
	}
	cout << dp[h];
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
long long int n,m,j,k,l,t,arr[200009],brr[200009],tree[600009],i,ans,d;
vector<pair<ll,ll> >v;
vector<ll>v1,v2;
void update(ll node, ll start, ll end, ll idx, ll val)
{
    if(start == end)
    {
        // Leaf node
        tree[node] += val;
    }
    else
    {
        int mid = (start + end) / 2;
        if(start <= idx and idx <= mid)
        {
            // If idx is in the left child, recurse on the left child
            update(2*node+1, start, mid, idx, val);
        }
        else
        {
            // if idx is in the right child, recurse on the right child
            update(2*node+2, mid+1, end, idx, val);
        }
        // Internal node will have the sum of both of its children
        tree[node] = tree[2*node+1] + tree[2*node+2];
    }
}
ll query(ll node, ll start, ll end, ll l, ll r)
{
    if(r < start or end < l)
    {
        // range represented by a node is completely outside the given range
        return 0;
    }
    if(l <= start and end <= r)
    {
        // range represented by a node is completely inside the given range
        return tree[node];
    }
    // range represented by a node is partially inside and partially outside the given range
    ll mid = (start + end) / 2;
    ll p1 = query(2*node+1, start, mid, l, r);
    ll p2 = query(2*node+2, mid+1, end, l, r);
    return (p1 + p2);
}
int main()
{
   scanf("%lld %lld %lld",&n,&m,&d);
   for(i=0;i<n;i++){
    scanf("%lld %lld",&arr[i],&brr[i]);
    v.push_back({arr[i],brr[i]});
   }
   sort(v.begin(),v.end());
   for(i=0;i<n;i++)
   {
       v1.push_back(v[i].first);
        v2.push_back(v[i].second);
   }
   for(i=0;i<n;i++)
   {
       j=v1[i]-(2*m);
       t=lower_bound(v1.begin(),v1.end(),j)-v1.begin();
       while(t<0)
        t=0;
       while(v1[t]<j)
        t++;
       l=query(0,0,n-1,t,i);
       v2[i]-=l;
       if(v2[i]<0)
        v2[i]=0;
       j=v2[i]/d;
       if(v2[i]%d)
        j++;
       j*=d;
       update(0,0,n-1,i,j);
       j/=d;
       ans+=j;
   }
   printf("%lld\n",ans);
}


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

using namespace std;


int main(){
    int n;
    string s;
    
    cin >> n >> s;
    if(n%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    
    string a = s.substr(0, n/2);
    string b = s.substr(n/2, n/2);
    
    //cout << a << " - " << b << endl;
    
    if(a == b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
(function() {
  var isInRange, isNum, reader;

  isNum = function(n) {
    return n.match(/(-|)\d{1,3}/);
  };

  isInRange = function(n) {
    return n >= 1 && n <= 10000;
  };

  reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
  });

  reader.on('line', function(line) {
    var a, b, c, sorted, sp;
    sp = line.split(/\s/);
    a = isNum(sp[0]) ? parseInt(sp[0], 10) : void 0;
    b = isNum(sp[1]) ? parseInt(sp[1], 10) : void 0;
    c = isNum(sp[2]) ? parseInt(sp[2], 10) : void 0;
    if (isInRange(a) && isInRange(b) && isInRange(c)) {
      sorted = [a, b, c].sort(function(a, b) {
        if (a > b) {
          return 1;
        } else if (a < b) {
          return -1;
        } else {
          return 0;
        }
      });
      return console.log(sorted.join(" "));
    }
  });

}).call(this);

Measured memory_bytes: 15876
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,n) for(int i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < 3; i ++){
    if(s.at(i) == t.at(i)){
      ans++;
    }
    
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long res1 = n % k;
		long res2 = k - n % k;
		if(res1 > res2){
			res1 = res2;
		}
		System.out.println(res1);
	}
}

Measured memory_bytes: 35676
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long int
int main(void)
{
  ll a, i, m = 1;
  scanf("%lld", &a);
  for (i = 2; i <= sqrt(a); i++)
  {
    if (a % i == 0)
      m = i;
  }
  printf("%lld\n", m + (a / m) - 2);
  return 0;
}

Measured memory_bytes: 128
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

typedef long long ll;


using namespace std;


int main(){
    int x,y,z,c;
    cin>>x>>y>>z;
    rp(i,x,y+1){
        if(z%i==0) c++;
    }
    cout<<c<<endl;

    return 0;
};

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define INF 1e9
// constexpr ll INF = 1LL << 60;

int main(){
  string X;
  cin >> X;
  int N = X.size();
  int d = 0, s = 0;
  for(auto x : X){
    if(x == 'S'){
      s++;
    }
    else{
      if(s){
        s--;
        d++;
      }
    }
  }
  cout << N - 2*d << endl;

  return 0;
}



Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] * (N+1)

ans = []
for i in range(N, 0, -1):
    sum = 0
    for j in range(2 * i, N+1, i):
        sum ^= B[j]
    B[i] = sum ^ A[i]
    if B[i]:
        ans.append(str(i))

print(len(ans))
if ans:
    print(' '.join(ans))


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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
const ll infll = 1e18 + 7;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int k, a, b; cin >> k >> a >> b;
    ForE(i, a, b) if (i % k == 0) Ptest("OK");
    cout << "NG";
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = (ll)1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N;
  string S;
  int A[26] = {0};
  cin >> N >> S;
  rep(i,N)
  {
    A[S[i] - 'a'] ++; 
  }
  int ans = 1;
  rep(i,26)
  {
    ans *= (A[i]+1);
    ans %= MOD;
  }
  ans --;
  cout << ans%MOD<< endl;

}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ps := make([]int, n)
	for i := range ps {
		sc.Scan()
		ps[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.IntSlice(ps))
	var sum int
	for i := 0; i < k; i++ {
		sum += ps[i]
	}
	fmt.Println(sum)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1848
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s <= "2019/04/30")
    {
        cout << "Heisei" << endl;
    }
    else
    {
        cout << "TBD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int d;

        while (true) {
            try {
                d = sc.nextInt();
            } catch (NoSuchElementException e) {
                break;
            }

            int area = 0; 
            
            for(int x = d; x < 600; x+=d) {
                area += x * x; 
            }

            System.out.println(area * d);

        }
        
    }
}

Measured memory_bytes: 12000
#include<iostream>
#include<map>
#include<queue>
#include<algorithm>
#include<string>
using namespace std;
int direc[4]={1,-1,4,-4};
map<string,int> dp;
void check()
{
	queue<string> sum;
	sum.push("01234567");
	dp["01234567"]=0;
	while(sum.size())
	{
		string str=sum.front();
		sum.pop();
		int p;
		for(int i=0;i<8;i++)
			if(str[i]=='0')
			{
				p=i;
				break;
			}
		for(int i=0;i<4;i++)
		{
			int n=p+direc[i];
		if(n>=0&&n<8&&!(p==3&&i==0)&&!(p==4&&i==1))
		{
			string new1=str;
			swap(new1[n],new1[p]);
			if(!dp.count(new1))
			{
				dp[new1]=dp[str]+1;
				sum.push(new1);
			}
		}
		}
	}
}
int main()
{
	check();
	string strs;
	while(getline(cin,strs))
	{
		strs.erase(remove(strs.begin(),strs.end(),' '),strs.end());
		cout<<dp[strs]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5412
s = [int(input()) for i in range(3)]
target = s[2]
if s[0] >= s[1]:
  long = s[0]
  short = s[1]
else:
  long = s[1]
  short = s[0]
 
for i in range(short):
  if long * (i+1) >= target:
    print(str(i+1))
    break

Measured memory_bytes: 3064
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n = ii()
    d, x = mi()
    a = []
    for i in range(n):
        tmp = ii()
        a.append(tmp)
    ans = 0
    for i in a:
        tmp = 1
        while tmp <= d:
            ans += 1
            tmp += i
    ans += x
    print(ans)


main()


Measured memory_bytes: 10020
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;

void solve() {
	int n; cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), i - 2 >= 0 ? dp[i - 2] + abs(h[i] - h[i - 2]) : INT_MAX);
	}

	cout << dp[n - 1] << endl;
}

int main() {
    FAST_INPUT;

    solve();

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int x;
    cin >> x;
    if (400 <= x && x <= 599) {
        cout << 8 << endl;
    } else if (x <= 799) {
        cout << 7 << endl;
    } else if (x <= 999) {
        cout << 6 << endl;
    } else if (x <= 1199) {
        cout << 5 << endl;
    } else if (x <= 1399) {
        cout << 4 << endl;
    } else if (x <= 1599) {
        cout << 3 << endl;
    } else if (x <= 1799) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <string> 
#include <math.h>
#include <set>
#include <vector>
#include <numeric>
#define rep(i,n) for(int i=0; i< (int)(n); ++i)
using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    cout << accumulate(s.begin(), s.end(), 0) - 3*'0' << "\n";
    
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		char[] s = in.next().toCharArray();
		for (int i = 0; i < s.length; i++) {
			if (s[i] + n >= 0 && s[i] + n < 26) {
				char tmp = s[i];
				tmp += n;
				System.out.print(tmp);
			} else {
				int num = (s[i] - 'A' + n) % 26;
				char tmp = 'A';
				tmp += num;
				System.out.print(tmp);
			}
		}
		System.out.println();
		in.close();
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    vector<int> T(N);
    for (int i=0; i<N; i++){
        cin >> S[i] >> T[i];
    }
    string X;
    cin >> X;
    int cur;
    for (int i=0; i<N; i++){
        if (S[i] == X){
            cur = i+1;
            break;
        }
    }
    int ans=0;
    for (int i=cur; i<N; i++){
        ans += T[i];
    }

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


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

int calc(int x)
{
    int ret = 0;
    while (x % 100 == 0)
    {
        x /= 100;
        ++ret;
    }
    return ret;
}

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

    int counter = 0, value = 0;
    while (counter < N)
    {
        value++;
        if (calc(value) == D)
            counter++;
    }
    cout << value << endl;
    return (0);
}

// int main(void)
// {
//     int D, N;
//     cin >> D >> N;

//     // vector<int> container(N, 0);
//     int ans;
//     if (D == 0)
//     {
//         ans = N;
//     }
//     else if (D == 1)
//     {
//         ans = N * 100;
//     }
//     else
//     {
//         ans = N * 100 * 100;
//     }
//     cout << ans << endl;
//     return (0);
// }

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 1000000007

#define inf 1000000000000000
#define MAX 200000

struct segtree {
    int N;
    // first: 手数
    // second: 今の場所
    // third: 次に出す目
    pair<pair<long long int, int>, int> dat[2*MAX];
    segtree() {}
    segtree(int n) {
        N = 1;
        while(N < n) N *= 2;
        for(int i = 0; i < 2*N-1; i++)
            dat[i] = make_pair(make_pair(inf, inf), inf);
    }
    // update k th element
    void update(int k, pair<pair<long long int, int>, int> a) {
        k += N-1; // leaf
        dat[k] = a;
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b) and its index
    pair<pair<long long int, int>, int> query(int a, int b) { return query(a, b, 0, 0, N); }
    pair<pair<long long int, int>, int> query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return make_pair(make_pair(inf, inf), -1);
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

int main()
{
	int n, m;
	string s;
	cin >> n >> m >> s;
	struct segtree st(n + 10);
	st.update(n, make_pair(make_pair(0, n), -1));
	for(int i = n - 1; i >= 0; i--){
		if(s[i] == '1') continue;
		pair<pair<long long int, int>, int> tmp = st.query(i + 1, i + m + 1);
		// first: 手数
		// second: 今の場所
		// third: 次に出す目
		long long int first = (tmp.first).first;
		long long int second = (tmp.first).second;
		long long int third = tmp.second;
		// cout << i << " " << first << " " << second << " " << third << endl;
		pair<pair<long long int, int >, int> res = make_pair(make_pair(first + 1, i), second - i);
		st.update(i, res);
	}
	int now = 0;
	pair<pair<long long int, int>, int> ans = st.query(0, 1);
	// cout << (ans.first).first << " "<< (ans.first).second << " " << ans.second << endl;
	if(ans.second < 0){
		cout << -1 << endl;
	}
	while(ans.second >= 0){
		cout << ans.second << endl;
		now += ans.second;
		ans = st.query(now, now + 1);
	}
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n, A, B, C, D; cin >> n >> A >> B >> C >> D;
  A--;
  B--;
  C--;
  D--;
  string s; cin >> s;
  auto can_go = [&](int x, int y) {
    bool ok = true;
    REPI (i, x, y) {
      dump(s[x], s[y]);
      assert(s[x] == '.' && s[y] == '.');
      if (s[i] == '#' && s[i + 1] == '#') ok = false;
    }
    return ok;
  };
  if (C < D) {
    if (can_go(A, C) && can_go(B, D)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    bool ok = false;
    REPI (i, B, D + 1) {
      if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') ok = true;
    }
    if (ok && can_go(A, C) && can_go(B, D)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 592
import java.io.*;

class Main{

	public static void main(String[] args)throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] div = str.split(" ");
		int a = Integer.parseInt(div[0]);
		int b = Integer.parseInt(div[1]);
		
		int area = a * b;
		int length = 2 * (a + b);
		
		System.out.println(area + " " +length);
		
	}
	
}

Measured memory_bytes: 17060
import java.util.Scanner;


public class Main{
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      int count = 0;
      for(int i = 0;i <= N;i++){
        if(i % 2 == 1){
          count++;
        }
      }

      if(count >= K){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }

}

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

int main() {
  int N;
  cin >> N;
  vector<PII> P(N);
  rep(i, N) {
    int a;
    cin >> a;
    P[i] = {a, i};
  }
  sort(P.begin(), P.end());
  int mx = 0;
  int cnt = 0;
  rep(i, N - 1) {
    if (P[i].second < P[i + 1].second) {
      cnt++;
      mx = max(mx, cnt);
    } else {
      cnt = 0;
    }
  }
  cout << N - mx - 1 << endl;
  return 0;
}


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

using namespace std;
#define PI 3.14159265358979

int main() {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double complex = cosl(((h * 60 - 11 * m) / 360) * PI);
  long double ans2 = (a * a) + (b * b) - 2 * (a * b) * complex;
  long double ans = sqrt(ans2);
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}


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

int main()
{
	while(true){
		int n[5];
		int c1=0,c2=0,c3=0;
		cin >> n[0];
		if(n[0]==0)
				break;
		for(int i=1; i<5; i++)
			cin >> n[i];
			
		for(int i=0; i<4; i++){
			if(n[i] != n[i+1])
				break;
			if(i==3){
				for(int i=0; i<5; i++)
					cout << '3' << endl;
				break;
			}
		}
		for(int i=0; i<5; i++){
			if(n[i] == 1)
				c1++;
			else if(n[i] == 2)
				c2++;
			else if(n[i] == 3)
				c3++;
		}
		if(c1 != 0 && c2 != 0 && c3 !=0)
			for(int i=0; i<5; i++)
				cout << '3' << endl;
		else{
			if(c1 > 0 && c2 > 0 && c3 == 0){
				for(int i=0; i<5; i++){
					if(n[i] == 1)
						cout << '1' << endl;
					else
						cout << '2' << endl;
				}
			}
			else if(c1 > 0 && c2 == 0 && c3 > 0){
				for(int i=0; i<5; i++){
					if(n[i] == 1)
						cout << '2' << endl;
					else
						cout << '1' << endl;
				}
			}
			else if(c1 == 0 && c2 > 0 && c3 > 0){
				for(int i=0; i<5; i++){
					if(n[i] == 3)
						cout << '2' << endl;
					else
						cout << '1' << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.*;
import java.lang.*;

public class Main {
    static final int INF = (1 << 31) - 1;             
    static final int MAXN = 11111;     
    static double a, b, c;
    static double a1, b1, c1;
    static double resX, resY;
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int x0, y0, x1, y1, x2, y2;
        int q;
        x0 = input.nextInt();
        y0 = input.nextInt();
        x1 = input.nextInt();
        y1 = input.nextInt();
        lineOf(x0, y0, y1 - y0, x0 - x1);
        q = input.nextInt();
        for (int i = 0; i < q; ++i) {
            x2 = input.nextInt();
            y2 = input.nextInt();
            line1Of(x2, y2, x0 - x1, y0 - y1);
            intersectionOf2Lines();
            System.out.printf("%.8f %.8f\n", resX, resY);
        }
    }
    
    static void lineOf(double x1, double y1, double vx, double vy) {
        a = vx;
        b = vy;
        c = - vx * x1 - vy * y1;
    }
    
    static void line1Of(double x1, double y1, double vx, double vy) {
        a1 = vx;
        b1 = vy;
        c1 = - vx * x1 - vy * y1;
    }
    
    static void intersectionOf2Lines() {
        double d = a * b1 - a1 * b;
        double dx = b * c1 - b1 * c;
        double dy = c * a1 - c1 * a;
        resX = dx / d;
        resY = dy / d;
    }
}

Measured memory_bytes: 33276
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,C = map(int, input().split())
    xv = [list(map(int, input().split())) for _ in range(n)]
    xv.sort()
    a, b = [], []
    kcal = 0
    for x, v in xv:
        kcal += v
        a.append(kcal - x)
        b.append(kcal-2*x)
    xv.sort(reverse=True)
    c, d = [], []
    kcal = 0
    for x, v in xv:
        kcal += v
        x = C - x
        c.append(kcal - x)
        d.append(kcal-2*x)
    
    for v in [a,b,c,d]:
        for i in range(1, n):
            if v[i] < v[i-1]:
                v[i] = v[i-1]
    
    res = 0
    for i in range(n):
        res = max(res, a[i], c[i])
        if i < n-1:
            res = max(res, b[i]+c[-(i+2)], d[i]+a[-(i+2)])
    print(res)

if __name__ == '__main__':
    main()

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

int main(){
  int n, t;
  cin >> n >> t;
  vector<int> a(MAX);
  rep(i,n) {
    int l, r;
    cin >> l >> r;
    a[l]++; a[r]--;
  }
  int ans = a[0];
  for(int i = 1; i < MAX; i++) {
    a[i] += a[i-1];
    ans = max(ans,a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
#define ri register int
#define il inline
#define mp make_pair
#define fi first
#define se second
#define solid const auto &
#define gm int mid((l+r)>>1)
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int,int> pii;
template<class T>il void in(T &x)
{
	x=0; char c=getchar(); bool f=0;
	while(!isdigit(c)) f|=(c=='-'),c=getchar();
	while(isdigit(c)) x=x*10+(c^'0'),c=getchar();
	f?x=-x:0;
}
template<class T>il void out(T x,const char c='\n')
{
	static short st[30]; short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar(c);
}
template<class T>il void err(const T &x,const char c='\n') {cerr<<x<<c;}
template<class T,class ...Args>il void err(const T &x,const Args &...args) {err(x,' '),err(args...);}
const int md=1e9+7;
il int qpow(int a,int b) {int r=1; for(;b;b>>=1,a=(LL)a*a%md) if(b&1) r=(LL)r*a%md; return r;}
il int fit(const int x) {return x>=md?x-md:x;}
il void inc(int &x,const int v) {(x+=v)>=md?x-=md:0;}
namespace i207M
{
const int N=3005;
int dp[N][N][2];
int n,m;
signed main()
{
#ifdef M207	
	freopen("in.in","r",stdin);
	//freopen("ot.out","w",stdout);
#endif
	in(n),in(m);
	dp[0][0][1]=1;
	for(ri i=1;i<=n;++i) dp[0][i][0]=1;
	for(ri i=0;i<m;++i)
		for(ri j=0;j<=n;++j)
		{
			if(j) 
			{
				// RR 
				inc(dp[i+1][j-1][1],dp[i][j][1]);
				if(j==1) inc(dp[i+1][j-1][1],dp[i][j][0]);
				else inc(dp[i+1][j-1][0],dp[i][j][0]);
				// RB
				inc(dp[i+1][j][1],dp[i][j][1]);
				if(j==1) inc(dp[i+1][j][1],dp[i][j][0]);
				else inc(dp[i+1][j][0],dp[i][j][0]);
			}
			if(j<n) 
			{
				// BR
				inc(dp[i+1][j][1],dp[i][j][1]);
				inc(dp[i+1][j][0],dp[i][j][0]);
				// BB
				inc(dp[i+1][j+1][1],dp[i][j][1]);
				inc(dp[i+1][j+1][0],dp[i][j][0]);
			}
		}
	int ans=0;
	for(ri i=0;i<=n;++i) inc(ans,dp[m][i][1]);
	out(ans);
	return 0;
}
}
signed main()
{
	i207M::main();
	return 0;
}

Measured memory_bytes: 70656
function MaxProfit(array) {
    var i = 0;
    var j = 1;
    var iMin = array[i];
    var maxProfit = Number.NEGATIVE_INFINITY;
    while (j < array.length) {
        if (array[i] < iMin) {
            iMin = array[i];
        }
        if (array[j] - iMin > maxProfit) {
            maxProfit = array[j] - iMin;
        }
        i++;
        j++;
    }
    console.log(maxProfit);
}
function main(input) {
    var array = input
        .trim()
        .split("\n")
        .map(Number);
    array.shift();
    MaxProfit(array);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));



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

#define F first
#define S second
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()
#define mod 1000000007
#define dbg(a) cout<<#a<<" = "<<a<<endl
#define dbg2(a,b) cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<endl
#define dbg3(a,b,c) cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<", "<<#c<<" = "<<c<<endl
#define dbg4(a,b,c,d) cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<", "<<#c<<" = "<<c<<", "<<#d<<" = "<<d<<endl
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>

const int nn = 1e5+5;
int par[nn];

int find(int u){
    if(par[u]==u) return u;
    par[u] = find(par[u]);
    return par[u];
}

void unify(int u,int v){
    u = find(u);
    v = find(v);
    if(u!=v) par[u]=v;
}

void solve()
{
    int n,q;ll m;cin>>n>>m>>q;
    int a[q],b[q],c[q];
    for(int i=0;i<n;i++){
        par[i]=i;
    }
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i];
        if(c[i]==0) unify(a[i], b[i]);
    }
    int cnt=0, tot=0;
    for(int i=0;i<q;i++){
        if(c[i]==0) continue;
        int u=find(a[i]), v=find(b[i]);
        if(u==v){
            cout<<"No\n";
            return;
        }
        cnt=1;
    }
    for(int i=0;i<n;i++){
        int u=i;
        if(par[u]!=u) m--;
        else tot++;
    }
    if(cnt) cnt=tot;
    else cnt=tot-1;
    // dbg3(cnt,m,tot);
    if(cnt<=m && m<= 1ll*tot*(tot-1)/2) cout<<"Yes\n";
    else cout<<"No\n";
}
 

int main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed << setprecision(13);
    clock_t beg=clock();
    int t = 1; 
    // cin>>t;
    // n = t;
    while(t--){
        // cout << "Case #" << n-t << ": ";
        solve();
    }
    //
    clock_t end=clock();
    fprintf(stderr, "%lf sec\n", (double)(end-beg)/(CLOCKS_PER_SEC));
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int a, b,check=0;
	cin >> a >> b;
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		if (i < a&&str[i] >= '0'&&str[i] <= '9') {
			check++;
		}
		else if (i == a&&str[i]=='-') {
			check++;
		}else if(i >a &&str[i] >= '0'&&str[i] <= '9'){
			check++;
		}
	}
	cout << (check == str.size() ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
#define pii pair<int,int>
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int MAXN = 1e5 + 10;
const int MAXM = 2e6 + 10;
const ll mod = 1e9 + 7;

int k;
ll a[MAXN];

int judge(ll x) {
    for(int i=0; i<k; i++)
        x = x / a[i] * a[i];
    if(x > 2) return 2;
    else if(x == 2) return 1;
    else return 0;
}

int main() {
#ifdef local
    freopen("data.txt","r",stdin);
//    freopen("data.txt","w",stdout);
#endif
    scanf("%d",&k);
    for(int i=0; i<k; i++)
        scanf("%lld",&a[i]);
    ll l = 0,r = 1e18;
    ll minn = 1e18, maxx = 0;
    while(l <= r) {
        ll mid = (l + r) / 2;
        if(judge(mid) == 2) r = mid - 1;
        else if(judge(mid) == 1) {
            minn = min(minn,mid);
            r = mid - 1;
        }
        else l = mid + 1;
    }
    l = 0,r = 1e18;
    while(l <= r) {
        ll mid = (l + r) / 2;
        if(judge(mid) == 2) r = mid - 1;
        else if(judge(mid) == 1) {
            maxx = max(maxx,mid);
            l = mid + 1;
        }
        else l = mid + 1;
    }
    if(maxx == 0 && minn == 1e18)
        puts("-1");
    else
        printf("%lld %lld\n",minn,maxx);
    return 0;
}


Measured memory_bytes: 1024
def bubbleSort(a, n)
  flag = true
  cnt = 0
  while flag
    flag = false
    (1..n-1).reverse_each do |j|
      if a[j] < a[j-1]
        tmp = a[j]
        a[j] = a[j-1]
        a[j-1] = tmp
        flag = true
        cnt += 1
      end
    end
  end
  puts a.join(' ')
  puts cnt
end

n = gets.to_i
a = gets.split.map(&:to_i)
bubbleSort(a, n)


Measured memory_bytes: 6944
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ull;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    int n,m,x;
    cin >> n >> m >> x;
    vector<vector<int> > data;
    REP(i, n)
    {
        int a;
        vector<int> v;
        REP(j,m+1){
            cin >> a;
            v.pb(a);
        }
        data.pb(v);
    }

    // REP(i,n){
    //     REP(j,m+1){
    //         cout << data[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    // return 0;
    vector<int> cost;
    vector<vector<int> > a;

    int l = (int)pow(2,n);
    REP(i,l){
        int p = i;
        int sum = 0;
        int j = 0;
        vector<int> adata;
        REP(k,m){
            adata.pb(0);
        }
        while(p>0){
            if(p%2){
                sum += data[j][0];
                REP(k,m){
                    adata[k] += data[j][k+1];
                }
            }
            p /= 2;
            j++;
        }
        a.pb(adata);
        cost.pb(sum);
    }
    int min = INF;
    REP(i,l){
        // cout << cost[i] << " ";
        // REP(k,m){
        //     cout << a[i][k] << " ";
        // }
        // cout << endl;
        // continue;
        int flag = 1;
        if(cost[i]<min){
            REP(j,m){
                if(a[i][j]<x){
                    flag = 0;
                    break;
                }
            }
            if(flag){
                min = cost[i];
            }
        }
    }
    if(min!=INF){
        cout << min << endl;
    }else{
        cout << -1 << endl;
    }
    
}


Measured memory_bytes: 4376
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String buf=sc.next();
		int[] a=new int[4];
		for(int i=0;i<4;i++){
			a[i]=Integer.parseInt(buf.substring(i, i+1));
		}
		
		for(int i=0;i<8;i++){
			int ans=a[0];
			String anss=Integer.toString(a[0]);
			for(int j=0;j<3;j++){
				if(((int)Math.pow(2, j)&i)!=0){
					ans+=a[j+1];
					anss+="+"+Integer.toString(a[j+1]);
				}else{
					ans-=a[j+1];
					anss+="-"+Integer.toString(a[j+1]);
				}
			}
			if(ans==7){
				System.out.println(anss+"=7");
				return;
			}
		}
		
	}
}

Measured memory_bytes: 24020
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;


/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
 int N;
 cin >> N;
 vector<int> H(N);
 REP(i,N){
     cin >> H[i];
     
 }
int ans = 0;
REP(i,N){
    bool high = true;
   for(int j = i-1; j>=0; j--){
        if(H[i]<H[j]) high = false;
    }
    if(high == true){
        ans++;
    }
}
cout << ans << endl;

}

Measured memory_bytes: 256