akhauriyash/Code-Regression huggingface dataset:
/*"You can do anything you set your mind to,man" - Eminem*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define l_b(a,val) min((int)a.size()-1, (int)(lower_bound(a.begin(),a.end(),val)-a.begin()))
#define f first
#define up(a,b) max(a,b)
#define s second
#define INF 9223372036854775807
const  int mod = 1000000007;
template <typename T> T add(T& a, T b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
template <typename T> T mul(T& a, T b){a*=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
template <typename T> T up_self(T& a, T b){a = up(a,b);}
template <typename T> T min_self(T& a, T b){a = min(a,b);}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int msb(ll n){int ans;for(int i = 0 ; i < 64;  i++)if(n&(1LL<<i))ans = i+1;return ans;}
int main()
{
	int n; cin>>n;
	vector<double> p_head(n+1);
	for(int i = 0 ; i < n; i++)	
		cin>>p_head[i+1];
	vector<double> dp(n+1);// dp[i] = probability of having i number of heads
	dp[0] = 1;
	for(int i = 1; i <=n; i++){
		for(int j = i; j>=0; j--){
			dp[j] = ((j==0)?0:dp[j-1])*p_head[i]+ dp[j]*(1-p_head[i]);
			//at the ith iteration
				//visit all the previous positions(in reverse order to prevent double couting)
					//at pos j the value represents the probability of getting j number of heads 
					//out of i-1 tosses. so, now we need to store the probability of getting i heads 
					//in i tosses. this is done in parts i.e. multiplying the probability of the latest tail with the 
					//total probability of j heads in i-1 tosses(therefore making it j heads in i tosses) and multiplying the probability of latest head with the
					//total probability of j-1 heads in i-1 tosses(thus also making it j heads in i tosses).
		}
	}
	double ans =0 ;
	for(int i = 0; i<=n ; i++ ){
		int tail = n-i;
		if(tail<=i)
			ans+=dp[i];
	}
	cout<<fixed<<setprecision(9)<<ans<<endl;
  	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        var sorted = new int[N];
        Array.Copy(A, sorted, N);
        Array.Sort(sorted);
        A = A.Select(a => Array.BinarySearch(sorted, a)).ToArray();
        int ans = A.Select((a, i) => a % 2 == 0 ? i % 2 : 0).Sum();
        Console.WriteLine(ans);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 9288
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

void main() {
    long x, y;
    scan(x, y);

    if (x < y || x % y) {
        writeln(x);
    }
    else {
        writeln(-1);
    }
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

typedef bitset<10001> bt;

void solve() {
	int n, k; cin >> n >> k;
	vector<string> s(n);
	rep(i, n) {
		cin >> s[i];
	}
	vector<bt> b(n + 1);
	b[n] = 0; b[n][0] = 1;
	per(i, n) {
		b[i] = b[i + 1] | (b[i + 1] << s[i].size());
	}
	string ans;
	vector<int> u(k + 1, mod);
	rep(i, n) {
		if (k >= s[i].size() && b[i + 1][k - s[i].size()]) {
			if (u[s[i].size()] == mod) {
				u[s[i].size()] = i;
			}
			else {
				int id = u[s[i].size()];
				if (s[id] > s[i]) {
					u[s[i].size()] = i;
				}
			}
		}
	}
	rep(i, k) {
		int mi = 25;
		rep1(j, k) {
			if (u[j] == mod)continue;
			int id = u[j];
			mi = min(mi, s[id][s[id].size() - j] - 'a');
		}
		char ch = 'a' + mi;
		vector<int> nex;
		//cout << i << " " << u[1] << endl;
		if (u[1] < mod&&s[u[1]][s[u[1]].size() - 1] == ch) {
			Rep(j, u[1] + 1, n) {
				if (k - i - 1 >= s[j].size() && b[j + 1][k - i - 1 - (int)s[j].size()]) {
					nex.push_back(j);
				}
			}
		}
		ans.push_back(ch);
		u[1] = mod;
		Rep1(j, 2, k) {
			if (u[j] == mod)continue;
			if (s[u[j]][s[u[j]].size() - j] == ch) {
				u[j - 1] = u[j];
			}
			u[j] = mod;
		}
		rep(j, nex.size()) {
			int id = nex[j];
			//cout << i << " " << id << endl;
			int len = s[id].size();
			if (u[len] == mod) {
				u[len] = id;
			}
			else {
				int to = u[len];
				if (to < id) {
					if (s[to].substr(s[to].size() - len, len) > s[id]) {
						u[len] = id;
					}
				}
				else {
					if (s[to].substr(s[to].size() - len, len) >= s[id]) {
						u[len] = id;
					}
				}
				
			}
		}
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(50);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 3968
import sys
from copy import deepcopy
input=sys.stdin.readline
n,m=map(int,input().split())
XYZ=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(8):
    a=1 if i&1 else -1
    b=1 if (i>>1)&1 else -1
    c=1 if (i>>2)&1 else -1
    xyz=deepcopy(XYZ)
    l=[]
    for j in range(n):
        l.append(xyz[j][0]*a+xyz[j][1]*b+xyz[j][2]*c)
    l.sort(reverse=True)
    ans=max(ans,sum(l[:m]))
print(ans)


Measured memory_bytes: 46424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vll A(N), B(N);

    ll dif = 0, ans = 0, sum = 0, Max = 0;
    rep(i, N)
    {
        cin >> A[i];
        Max += A[i];
    }

    rep(i, N)
    {
        cin >> B[i];
        sum += B[i];
    }

    if (sum > Max)
    {
        cout << -1 << endl;
        return 0;
    }
    vector<pair<ll, ll>> AB(N);
    for (int i = 0; i < N; i++)
    {
        AB[i] = {A[i], B[i]};
    }
    sort(all(AB), [](pair<ll, ll> a, pair<ll, ll> b) {
        return a.first - a.second < b.first - b.second;
    });
    for (int i = 0; i < N; i++)
    {
        ll a = AB[i].first, b = AB[i].second;
        if (b - a > 0)
        {
        }
        else if (b == a)
        {
            ans++;
        }
        else
        {

            sum += (a - b);
            if (sum <= Max)
            {
                ans++;
            }
        }
    }

    cout << N - ans;
    return 0;
}

Measured memory_bytes: 3328
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	for i := 10.0; i <= 1000.0 ; i++ {
		if int(i * 0.08) == a && int(i * 0.1) == b {
			fmt.Println(i)
			return
		}
	}

	fmt.Println(-1)
}

Measured memory_bytes: 512
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}

struct qu{
  ll t, a;
  qu(){}
  qu(ll t, ll a): t(t), a(a){};
};

ll a[100002], b[100002], w[100002];

int main(int argc, char const* argv[])
{
  ll X;
  cin >> X;
  int k;
  cin >> k;
  vector<ll> r(k);
  rep(i, k)cin >> r[i];
  int q;
  cin >> q;
  vector<qu> vec(q);
  rep(i, q)cin >> vec[i].t >> vec[i].a;
  a[0] = 0, b[0] = X, w[0] = 0;
  for(int i = 0; i < k; i++){
    ll dt = r[i] - (i > 0 ? r[i-1]: 0);
    if(i % 2 == 0){
      if(b[i] + w[i] - dt <= 0){
        a[i+1] = 0, b[i+1] = 0, w[i+1] = 0;
      }else if(a[i] + w[i] - dt <= 0){
        a[i+1] = dt - w[i], b[i+1] = b[i], w[i+1] = w[i] - dt;
      }else{
        a[i+1] = a[i], b[i+1] = b[i], w[i+1] = w[i] - dt;
      }
    }else{
      if(X - a[i] - w[i] - dt <= 0){
        a[i+1] = 0, b[i+1] = 0, w[i+1] = X;
      }else if(X - b[i] - w[i] - dt <= 0){
        a[i+1] = a[i], b[i+1] = X - w[i] - dt, w[i+1] = w[i] + dt;
      }else{
        a[i+1] = a[i], b[i+1] = b[i], w[i+1] = w[i] + dt;
      }
    }
    //cout << a[i+1] << " " << b[i+1] << " " << w[i+1] << endl;
  }
  rep(i, q){
    int index = upper_bound(all(r), vec[i].t) - r.begin();
    ll res = w[index];
    if(vec[i].a <= a[index])res += a[index];
    else if(vec[i].a <= b[index])res += vec[i].a;
    else res += b[index];
    if(index % 2 == 1)res += vec[i].t - (index > 0 ? r[index-1]: 0);
    else res -= vec[i].t - (index > 0 ? r[index-1]: 0);
    if(res < 0)res = 0;
    if(res > X)res = X;
    cout << res << endl;
  }
	return 0;
}


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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e16;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int x, y, z;
    ll K;
    cin >> x >> y >> z >> K;
    vector<ll> a, b, c;
    for (int i = 0; i < x; ++i) {
        ll t;
        cin >> t;
        a.push_back(t);
    }
    for (int i = 0; i < y; ++i) {
        ll t;
        cin >> t;
        b.push_back(t);
    }
    for (int i = 0; i < z; ++i) {
        ll t;
        cin >> t;
        c.push_back(t);
    }

    vector<ll> ab;
    for (auto s : a) {
        for (auto t : b) {
            ab.push_back(s + t);
        }
    }
    sort(begin(ab), end(ab), greater<ll>());

    vector<ll> abc;
    for (int i = 0; i < min((ll)ab.size(), K); ++i) {
        for (auto u : c) {
            abc.push_back(ab[i] + u);
        }
    }
    sort(begin(abc), end(abc), greater<ll>());
    
    for (int i = 0; i < K; ++i) {
        cout << abc[i] << endl;
    }

    return 0;
}


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

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

using namespace std;

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

  int result=1000;
  rep(i,s.size()-2){
    int c = stoi(s.substr(i,3));
    result = min(result, abs(753-c));
  }

  cout<<result;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using vl = vector<ll>;
vector<vl> g;
vl c, ans;ll in = 0;
void dfs(ll i, ll p) {
  for(auto v : g[i])
    if(v != p) dfs(v, i);
  ans[i] = c[in];
  in++;
}
int main() {
  ll n;cin >> n;g.resize(n);
  rep(i, n - 1) {
    ll a, b; cin >> a >> b;a--;b--;
    g[a].push_back(b);g[b].push_back(a);
  }
  c.resize(n);
  rep(i, n) cin >> c[i];
  sort(all(c));ans.resize(n);dfs(0, -1);
  cout << accumulate(c.begin(), c.end() - 1, 0LL) << endl;
  rep(i, n) cout << ans[i] << ' ';
  cout << endl;
}

Measured memory_bytes: 4472
from sys import stdin
N = int(stdin.readline().rstrip())
input = stdin.readline().split()
d = [int(input[i]) for i in range(N)]
d_sorted = sorted(d)
# print(d)
# print(d_sorted)
# print(d_sorted[int(N/2)])
# print(d_sorted[int(N/2)-1])
print(d_sorted[int(N/2)] - d_sorted[int(N/2)-1])

Measured memory_bytes: 15068
#!/usr/bin/env ruby

word = []
numbers = []
sharp = "#"
i = 0

loop do 
    word = gets.split.map(&:to_i)
    if word[0] == 0 and word[1] == 0 then; break; end
    word.each do |key|
        numbers << key
    end
end

((numbers.count + 1) / 2).times do
    numbers[i].times do  
        puts sharp * numbers[i + 1]
    end
    puts ""
    i += 2 
end


Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    string s;
    cin >> s;
    if(s[s.size() - 1] == 's') s += "es";
    else s += "s";
    cout << s << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = (ll)(1e9 + 7);

const int MAX_N = 1123456;
ll dp[MAX_N];
ll S[MAX_N];

int main2() {
  ll N = nextInt();
  ll M = N;

  dp[0] = 0;
  dp[1] = M;
  dp[2] = M * M % MOD;

  S[0] = 0;
  S[1] = dp[1];
  S[2] = (S[1] + dp[2]) % MOD;

  for (int n = 3; n <= N; n++) {
    ll val = 0;
    val += dp[n-1];
    val += (M-1)*(M-1) % MOD;

    if (n == 3) {
      val += M-1;
    } else {
      val += S[n-3];
      val += max(0LL, -n+M+2);
    }

    val %= MOD;
    dp[n] = val;
    S[n] = (S[n-1] + dp[n]) % MOD;
  }
  ll ans = dp[N];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string s1 = "0", s2= "1";
    for(int i = 1; i < n; i++){
        if(s1[i-1] == '1'){
        s1 += "0";
        s2 += "1";
        }
        else{
            s1 += "1";
            s2 += "0";
        }
    }
    int c1 = 0, c2 = 0;
    for(int i = 0; i < n; i++){
        if(s[i] != s1[i])
        c1++;
        if(s[i] != s2[i])
        c2++;
    }
    cout << min(c1, c2);
    return 0;
}

Measured memory_bytes: 768
#include <cstdio>

char ch[100002];

int i,ans,x,y;

int main(){
	scanf("%s",ch);
	for(i=0;ch[i];++i)
	{
		if(x==y){
			++x;
			if(ch[i]=='p')--ans;
		}
		else if(x>y){
			++y;
			if(ch[i]=='g')++ans;
		}
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	M += N * 3;
	cout << M / 2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int  main(void)
{
	char T[100];
	int count=0,max;
	
	scanf("%s",T);
	
	for(int i=0;T[i]!='\0';i++){
		count=0;
		for(int j=i;T[j]=='A'||T[j]=='G'||T[j]=='C'||T[j]=='T';j++){
			count++;
		}
		if(max<=count){
			max=count;
		}
	}
	
	printf("%d\n",max);
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int t[100005], x[100005], y[100005], n;
//	int xx = 0, yy = 0;

	cin >> n;

	t[0] = 0;
	x[0] = 0;
	y[0] = 0;

	for (i = 1; i <= n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}


	for (i = 1; i <= n; i++) {
		int num = abs(x[i - 1] - x[i]) + abs(y[i - 1] - y[i]);
		if ((t[i] - t[i - 1]) % 2 == 0) {
			if (num % 2 == 0 && num <= t[i] - t[i-1]) {

			}
			else {
				cout << "No" << endl;
				getchar();
				getchar();
				return 0;
			}
		}
		else {
			if (num % 2 == 1 && num <= t[i] - t[i - 1]) {

			}
			else {
				cout << "No" << endl;
				getchar();
				getchar();
				return 0;
			}

		}
	}


	cout << "Yes" << endl;












	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 1408
using System;

namespace Small__Large__or_Equal
{
    class SmallLargeorEqual
    {
        static void Main()
        {
            string input = Console.ReadLine();
            string[] ab = input.Split(' ');
            if (ab[0] == ab[1])
            {
                Console.WriteLine("a == b");
            }
            else if(int.Parse(ab[0]) > int.Parse(ab[1]))
            {
                Console.WriteLine("a > b");
            }
            else if(int.Parse(ab[0]) < int.Parse(ab[1]))
            {
                Console.WriteLine("a < b");
            }
        }
    }
}



Measured memory_bytes: 15940
while 1:
    n,m=map(int,input().split())
    if n==m==0:break
    s=set()
    c=0
    for d,v in sorted([list(map(int,input().split()))for i in range(n)],key=lambda x:-x[1]):
        if d in s:continue
        c+=v
        s.add(d)
        if len(s)>=m:
            break
    print(c)


Measured memory_bytes: 5620
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	
	int x=sc.nextInt(), y, z;
	y = Math.min(sc.nextInt(), sc.nextInt());
	z = Math.min(sc.nextInt(), sc.nextInt());
	System.out.println(Math.min(x,y)+z-50);
    }
}

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

int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pair<int,int>> vp;
    int idx=0;
    while(idx < n){
        int cnt = 0;
        char c = s.at(idx);
        while(idx < n && s.at(idx) == c){
            cnt++;
            idx++;
        }
        vp.push_back({c-'0',cnt});
    }
    // for(auto p:vp){
    //     cout << p.first << " " << p.second << endl;
    // }
    vector<int> v(vp.size()+10);
    int ofs = (vp.at(0).first+1) % 2; // "1" start
    rep(i,vp.size()){
        v.at(i+ofs) = vp.at(i).second;
    }

    int ln = k*2+1;
    int res = 0;
    int tot = 0;
    for(int i=0;i<min(ln,(int)v.size());i++){
        tot += v.at(i);
    }
    res = tot;
    for(int i=2;i+ln-1<v.size()-1;i+=2){
        tot -= v.at(i-1)+v.at(i-2);
        tot += v.at(i+ln-1)+v.at(i+ln-2);
        res = max(res,tot);
    }
    // rep(i,v.size()){
    //     cout << v.at(i) << " ";
    // }
    // cout << endl;
    cout << res << endl;
    return 0;
}

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

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
     
using namespace std;

main {
  loop(i, 1, 10) loop(j, 1, 10) cout<<i<<'x'<<j<<'='<<i*j<<endl;
  bye;
}

Measured memory_bytes: 2996
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int digit[] = {0,2,5,5,4,5,6,3,7,6};
 
int main() { _
  int n, m; cin >> n >> m;
  vector<pair<int, int>> dp(n+1, make_pair(-1, -1));
  dp[0] = make_pair(0, 0);
  vector<int> v(m);
  for (int i = 0; i < m; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  for (int i = 1; i <= n; i++) {
    for (int j : v) {
      if (i - digit[j] < 0 || dp[i - digit[j]].first < 0) continue;
      if (dp[i - digit[j]].first + 1 >= dp[i].first) 
        dp[i].first = dp[i-digit[j]].first+1, dp[i].second = j;
    }
  }
  string s = "";
  for (int i = n; i != 0; i -= digit[dp[i].second])
    s.push_back('0' + dp[i].second);
  sort(s.begin(), s.end(), greater<char>());
  cout << s << endl;
  return 0;
}

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

int main() {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x1 - x2;
    int dy = y2 - y1;
    int x3, y3, x4, y4;
    x3 = x2 - dy;
    y3 = y2 - dx;
    x4 = x1 - dy;
    y4 = y1 -dx;
    printf("%d %d %d %d", x3, y3, x4, y4);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){fastio
    string s;cin>>s;
    ll n=s.size();
    ll dp[n+1][13];memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    rep(i,0,n-1){
        if(s[i]=='?'){
            rep(j,0,12){
                rep(k,0,9){
                    Add(dp[i+1][(10*j+k)%13],dp[i][j]);
                }
            }
        }else{
            ll k=s[i]-'0';
            rep(j,0,12){
                Add(dp[i+1][(10*j+k)%13],dp[i][j]);
            }
        }
    }
    /*rep(i,0,n){
        rep(j,0,12){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }cout<<endl;*/
    
    cout<<mod(dp[n][5])<<endl;
    
    return 0;
}



Measured memory_bytes: 10704
#include<stdio.h>
#include<algorithm>
#include<string>
using namespace std;
pair<int,string>p[30];
string name[30];
char in[20];
int t[50];
int c[30][50];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<50;i++)t[i]=a+1;
		for(int i=0;i<30;i++)for(int j=0;j<50;j++)
			c[i][j]=0;
		for(int i=0;i<a;i++){
			int b;scanf("%s%d",in,&b);
			name[i]=in;
			for(int j=0;j<b;j++){
				int d;scanf("%d",&d);
				t[d]--;
			//	if(t[d]==0)t[d]=1;
				c[i][d]=1;
			}
		}
		for(int i=0;i<a;i++){
			int tmp=0;
			for(int j=0;j<30;j++){
				if(c[i][j])tmp+=t[j];
			}
			p[i]=make_pair(tmp,name[i]);
		}
		std::sort(p,p+a);
		printf("%d %s\n",p[0].first,p[0].second.c_str());
	}
}

Measured memory_bytes: 1084
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long unsigned llu;
typedef pair<ll, ll> P;//change when necessary
typedef long double ld;
#define mp make_pair
#define N ll(3e5 + 5)//change it
#define M ll(0)
const ll OO = 1e18;
const ll md = 1e9 + 7;
ll X[] = { 0,0,1,-1 }, Y[] = { 1,-1,0,0 };
void fast()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

ll n, p[N][2], res, t;
string s;
ll sm(ll x, ll y,ll z)
{
	if (y < x)
		return 0;
	return p[y][z] - p[x - 1][z];
}
int main()
{
	fast();
	cin >> n >> s;
	for (int i = 1; i <= s.size(); i++)
		p[i][0] = p[i - 1][0] + (s[i - 1] == 'E'),
		p[i][1] = p[i - 1][1] + (s[i - 1] == 'W');

	res = OO;
	for (int i = 1; i <= n; i++)
	{
		if (s[i] == 'E')
			t = sm(1, i - 1, 1) + sm(i + 1, n, 0);
		else
			t = sm(1, i - 1, 1) + sm(i + 1, n, 0);
		res = min(res, t);
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 5396
#include <bits/stdc++.h>
using namespace std;
#define All(A) A.begin(), A.end()
typedef pair<long long, long long> P;
int main(){
    long long N, D, A;
    cin >> N >> D >> A;
    vector<P> X(N);
    vector<long long> x(N);
    for(int i = 0; i < N; i++) {
        long long s, t;
        cin >> s >> t;
        X[i] = P(s, t);
        x[i] = s;
    }
    sort(X.begin(), X.end());
    sort(All(x));
    vector<long long> count(N + 1, 0);
    long long ans = 0;
    for(int i = 0; i < N; i++){
        if(i >= 1) count[i] += count[i - 1];
        if(X[i].second <= count[i]*A) continue;
        else X[i].second -= count[i]*A;
        int t = upper_bound(All(x), x[i] + 2 * D) - x.begin();
        long long s = (X[i].second + A - 1) / A;
        ans += s;
        count[i] += s;
        count[t] -= s;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<ll> ans(N+1);
    map<ll,pair<ll,ll>> mp;
    rep(i,N){
        ll a;
        cin >> a;
        if(!mp.count(a))mp[a].first = i;
        mp[a].second++;
    }

    ll total = 0; // 出現回数的な？
    ll minv = N; // 一番左のindex

    for(auto itr = mp.rbegin();itr != mp.rend();itr++){
        // 一番大きい山から見ていく感じ

        auto v = *itr;
        // v.second = pair<ll,ll> で v.second.first = index
        // v.second.second は出現回数
        auto it2 = itr;
        it2++;
        // 次に小さい山を調べる
        ll prev;
        if(it2 == mp.rend()) prev = 0;
        // もしもitrが一番小さい山だったら 次に小さい山のサイズは0にする
        else prev = it2->first;
        // そうじゃない場合は次に小さい山の大きさをprevにセットする

        total += v.second.second;
        // 個数をv.second.second個足す
        minv = min(minv,v.second.first);
        // 現時点で一番index番号が小さい場所を探す
        ans[minv] += total * (v.first - prev);
        // 現時点で一番index番号が小さい場所を基準として
        // 次に小さい山と同じサイズになるまで山をカットする
    }
    for(int i=0;i<N;i++)cout << ans[i] << endl;
}

Measured memory_bytes: 8192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Arrays;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
          String s = sc.next();

          int answer = 0;
          int loop = s.length() - 1;
          for (int i = 0; i < loop; i++) {
            if (s.charAt(i) != s.charAt(i + 1)) {
              answer++;
            }
          }

          System.out.println(answer);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 11348
def main():
	S = list(input())
	T = []
	reverse = False
	n_q = int(input())
	for i in range(n_q):
		q = input().split(" ")
		if q[0] == "1":
			reverse = not reverse
		elif q[0] == "2":
			f = q[1]
			c = q[2]
			if (f == "1" and not reverse) or (f == "2" and reverse):
				T.append(c)
			elif (f == "1" and reverse) or (f == "2" and not reverse):
				S.append(c)
	if reverse:
		S.reverse()
		ans = S + T
	elif not reverse:
		T.reverse()
		ans = T + S
	print("".join(ans))

main()

Measured memory_bytes: 14260
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

int n,m,a,b,c,x,y,aa[100010],ba[100010],ms[1000010];
bool r=true;
string s;
char ca,cb;


int main(){
    b=0;
    cin>>n;
    a=n;
    while(!ms[a]){
        b++;
        ms[a]=1;
        
        if(a%2==1)a=3*a+1;
        else a=a/2;
    }
    cout<<b+1<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,n;
	cin>>a;
	cin>>b;
	cin>>c;
	n=a+b+c;
	if(n>=22)
	cout<<"bust";
	else
	cout<<"win";
	return 0;
}


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

namespace _0319
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(x); Array.Reverse(x);
            int ret;
            for (ret = 0; n > ret && x[ret] > ret; ret++) ;
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 9748
#include<bits/stdc++.h>
using namespace std;
int aa[100009],ww[100009];

int main(){
  int n,m;
  int a=0,w=0;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int p;
    string s;
    cin>>p>>s;
    if(s=="AC"&&aa[p]==0){
      aa[p]++;
      a++;
      w+=ww[p];
    }
    else{
      ww[p]++;
    }
  }
  cout<<a<<" "<<w<<endl;
  return(0);
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 500010

int dp[SIZE][3];
int vec[SIZE/2];

int calc(char *s, int start, int end){
  if(start >= end) return 0;
  
  int cc = 0;
  int min_d = 0;

  int t = 0;
  
  for(int i=start;i<end;i++){
    if(s[i] == '1'){
      cc++;
    }else{
      if(cc > 0){
        vec[t++] = cc;
        min_d = min(min_d, cc);
      }
      cc = 0;
    }
  }

  if(cc > 0){
    vec[t++] = cc;
    min_d = min(min_d, cc);
    cc = 0;
  }

  if(min_d == INF) return 0;

  int m = t;
  
  for(int i=0;i<=m;i++){
    dp[i][0] = dp[i][1] = dp[i][2] = -INF;
  }

  dp[0][0] = 0;

  for(int i=0;i<m;i++){
    //0
    dp[i+1][0] = max(dp[i+1][0], dp[i][0]);
    dp[i+1][0] = max(dp[i+1][0], dp[i][2]);
    dp[i+1][0] = max(dp[i+1][0], dp[i][1] + vec[i]);
    
    //1
    dp[i+1][1] = max(dp[i+1][1], dp[i][0]);
    dp[i+1][1] = max(dp[i+1][1], dp[i][1]);

    if(vec[i] >= 2){
      dp[i+1][1] = max(dp[i+1][1], dp[i][1] + vec[i]-1);
      dp[i+1][1] = max(dp[i+1][1], dp[i][2]);
    }

    //2
    if(i+1 < m){
      dp[i+1][2] = max(dp[i+1][2], dp[i][0] + vec[i]);
      dp[i+1][2] = max(dp[i+1][2], dp[i][1] + vec[i]);
      dp[i+1][2] = max(dp[i+1][2], dp[i][2] + (vec[i]-1));
    }
  }

  return max(dp[m][0], dp[m][1]);  
}

int main(){
  char s[SIZE];
  int n;

  scanf("%d%s",&n,s);
  
  s[n] = s[n+1] = s[n+2] = s[n+3] = s[n+4] = '0';
  s[n+5] = '\0';
  
  int ans = 0;

  int l = 0;
  
  for(int i=0;i<n+1;i++){
    if(s[i] == '0' && s[i+1] == '0'){
      int res = calc(s, l, i);
      ans += res;
      l = i+2;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	int n,m;
	cin>>n>>m;
	vector<pair<ll,ll>> s;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		s.push_back({x,1LL});
	}
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		s.push_back({b,a});
	}
	sort(s.rbegin(),s.rend());
	int cur=0;
	long long int ans=0;
	for(auto x:s){
		ll z=x.second;
	//	cout<<x.first<<'\n';
		if(z+cur>n){
			ans+=(n-cur)*x.first;
			break;
		}
		else{
			ans+=x.first*x.second;
		}
		cur+=z;
	}
	cout<<ans;
}

Measured memory_bytes: 6512
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

char s[105][105]= {'\0'};
int n, m;

int movx[4]= {-1,0,1,0};
int movy[4]= {0,1,0,-1};

void dfs(int x,int y,char c)
{
    for(int i=0; i<4; i++)
    {
        if(s[x+movx[i]][y+movy[i]]==c)
        {
            s[x+movx[i]][y+movy[i]]='.';
            dfs(x+movx[i],y+movy[i],c);
        }
    }
}

int main()
{
    //freopen("in.in","r",stdin);
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        char c=getchar();
        int ans=0;
        if(n==0&&m==0)break;
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=m; j++)
                scanf("%c",&s[i][j]);
            c=getchar();
        }
        for(int i=1; i<=n; i++)
            for(int j=1; j<=m; j++)
                if(s[i][j]=='@')
                {
                    ans++;
                    s[i][j]='.';
                    dfs(i,j,'@');
                }
        for(int i=1; i<=n; i++)
            for(int j=1; j<=m; j++)
                if(s[i][j]=='#')
                {
                    ans++;
                    s[i][j]='.';
                    dfs(i,j,'#');
                }
        for(int i=1; i<=n; i++)
            for(int j=1; j<=m; j++)
                if(s[i][j]=='*')
                {
                    ans++;
                    s[i][j]='.';
                    dfs(i,j,'*');
                }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3580
n = int(input())
h = list(map(int, input().split()))
nm = len(h)
ans = 0
for _ in range(nm):
    cnt = 0
    while True:
        if len(h) == 1:
            break
        if h[0] >= h[1]:
            cnt += 1
            h.pop(0)
        else:
            h.pop(0)
            break
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 20516
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];

            WriteLine(0);
            var even = ReadLine();
            var left = 0L;
            var right = N;
            var q = (left + right) / 2;
            for (var i = 1; i < 20; ++i)
            {
                WriteLine(q);
                var s = ReadLine();
                if (s == "Vacant")
                    return;
                if (
                    (q % 2 == 0 && even == s) ||
                    (q % 2 == 1 && even != s)
                    )
                    left = q;
                else
                    right = q;
                q = (left + right) / 2;
            }
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13768
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for(int i=L;i<R;i++)
#define FE(i,L,R) for(int i=L;i<=R;i++)
#define RF(i,l,r) for(int i=r;i>l;i--)
#define RFE(i,l,r) for(int i=r;i>=l;i--)
#define getI(i) scanf("%d",&i)
#define getII(i,j) scanf("%d%d",&i,&j)
#define getIII(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define VgetI(i) int (i);scanf("%d",&(i));
#define VgetII(i,j) int (i),(j);scanf("%d%d",&(i),&(j));
#define VgetIII(i,j,k) int (i),(j),(k);scanf("%d",&(i),&(j),&(k));
#define EoF(n) int(n);while(~getI(n))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(n) (n>0?n:(-n))
#define INF 2147483647
#define nINF -2147483648
int main(){
	int n;
	while(~getI(n)){
		int arr[n],cnt[105]={0},ans=0;
		F(i,0,n) getI(arr[i]);
		F(i,0,n) cnt[arr[i]]++;
		F(i,0,105) if(cnt[i]) ans++;
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 256
#include <cstdio>

const int MAXN=3011, MAXX=MAXN<<1;
const int MOD=998244353;

inline int sum(const int &a, const int &b){
	return (a+b>=MOD)?(a+b-MOD):(a+b);
}

inline int mul(const int &a, const int &b){
	return (int)((1LL*a*b)%(long long)(MOD));
}

inline void add(int &a, const int &v){
	a+=v;if(a>=MOD)	a-=MOD;
}

int N, X;

int Ans=0;

int F[MAXN][MAXX];

int C[MAXN][MAXN];

inline int D(const int &a){
	return C[N][a];
}

int main(){
	
	scanf("%d%d", &N, &X);
	
	for(int i=0;i<=N;++i){
		C[i][i]=C[i][0]=1;
		for(int j=1;j<i;++j)
			C[i][j]=sum(C[i-1][j-1], C[i-1][j]);
	}
	
	F[0][0]=1;
	for(int i=0;i<N;++i){
		for(int j=0;j<X;++j){
			add(F[i+1][j+1], F[i][j]);
			add(F[i+1][j+2], F[i][j]);
		}
	}
	
	for(int i=0;i<=N;++i)
		for(int j=0;j<X;++j)
			add(Ans, mul(F[i][j], D(i)));
	
	for(int k=1;(k<<1)<X;++k){
		for(int i=0;i<N;++i){
			if(i+(k<<1)<=N){
				add(Ans, mul(F[i][X-(k<<1)-1], D(i+(k<<1))));
			}
		}
	}
	
	if(X&1){
		for(int k=X;k<=N;++k){
			//printf("%d %d\n", k, D(k));
			add(Ans, D(k));
		}
	}
	
	printf("%d\n", Ans);
	
	return 0;
}

Measured memory_bytes: 104832
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n,l;
    string s[110];
    while(cin>>n>>l)
    {
        for(int i=0;i<n;i++)
        {
            cin>>s[i];
        }
        sort(s,s+n);
        for(int i=0;i<n;i++)
        {
            cout<<s[i];
        }
        cout<<"\n";
    }
    return 0;
}


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

static const int N=1000;

int lcs(string X, string Y) {
   // lcs置き場
   int c[N+1][N+1];

   int m = X.size();
   int n = Y.size();
   int maxl = 0;
   X = ' ' + X;
   Y = ' ' + Y;
   for(int i = 0; i <=m; i++) c[i][0] = 0;
   for(int i = 1; i <=n; i++) c[0][i] = 0;

   for(int i = 1; i <= m; i ++) {
      for(int j = 1; j <= n; j++) {
         if(X[i] == Y[j]) c[i][j] = c[i-1][j-1] + 1;
         else c[i][j] = max(c[i-1][j], c[i][j-1]);
         maxl = max(maxl, c[i][j]);
      }
   }
   return maxl;
}

int main(){
   int n;cin>>n;
   rep(i, n) {
      string X, Y; cin>>X>>Y;
      cout << lcs(X, Y) << endl;
   }
   return 0;
}



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

using namespace std;

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int i,a1=0,a2=0;
  for(i=0;i<n;++i)
    if(s[i]=='>') break;
  a1=i;
  for(i=n-1;i>=0;--i)
    if(s[i]=='<') break;
  a2=n-i-1;
  cout << n-min(a1,a2) << endl;
  
  return 0;
}


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

using namespace std;

constexpr int INF = 1e9 + 7;

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

int n, m;
vector<bool> canUse;
map<int, int> dp;

int dfs(int now)
{
	if (now == n) return 1;
	if (dp.count(now)) return dp[now];
	long long res = 0;
	if (canUse[now + 1]) res += dfs(now + 1);
	res %= INF;
	if (now + 2 <= n && canUse[now + 2]) res += dfs(now + 2);
	res %= INF;
	return dp[now] = res;
}

void solve()
{
	cin >> n >> m;
	canUse.resize(n + 1, true);
	while(m--)
	{
		int a;
		cin >> a;
		canUse[a] = false;
	}
	cout << dfs(0) << "\n";
}

int main()
{
	solve();
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, i;
    cin >> n >> i;

    cout << n - i + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
map<int,int>mp[N];
int main(){
	int n,m,w,v;
	cin>>n>>m;
	mp[0][0]=0;
	for(int i=0;i<n;i++){
		scanf("%d%d",&w,&v);
		for(auto p:mp[i]){
			mp[i+1][p.fi]=max(mp[i+1][p.fi],mp[i][p.fi]);
			if(p.fi+w<=m){
				mp[i+1][p.fi+w]=max(mp[i+1][p.fi+w],mp[i][p.fi]+v);
			}
		}
	}
	int ans=0;
	for(auto p:mp[n]){
		ans=max(ans,p.se);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8428
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    int n,q;
    cin>>n>>q;
    if(!n&&!q){
      return 0;
    }
    vector<int> a(101,0);
    for(int i=0;i<n;i++){
      int m;
      cin>>m;
      for(int j=0;j<m;j++){
        int b;
        cin>>b;
        a[b]++;
      }
    }
    int ansid=-1;
    int ansr=-1;
    for(int i=1;i<=100;i++){
      if(ansr<a[i]){
        ansr=a[i];
        ansid=i;
      }
    }
    if(ansr>=q)cout<<ansid<<endl;
    else cout<<0<<endl;
  }
}



Measured memory_bytes: 3068
#include<stdio.h>
int main()
{
    int a,b,c,d,e=0,f=0,i;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    for(i=0;;i++)
    {
        e++;
        c=c-b;
        if(c<=0)
        {
            break;
        }
    }
     for(i=0;;i++)
    {
        f++;
        a=a-d;
        if(a<=0)
        {
            break;
        }
    }
    if(f>=e)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}


Measured memory_bytes: 1676
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N = int(stdin.readline().rstrip())

for i in range(1, 10):
    tmp = N // i

    if i * tmp == N and tmp < 10:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 66284