akhauriyash/Code-Regression huggingface dataset:
str = gets().split(" ")
x = str[0].to_i
a = str[1].to_i
b = str[2].to_i

if b - a <= 0
	puts("delicious")
elsif b - a > 0 && b - a <= x
	puts("safe")
elsif b - a > 0 && b - a > x
	puts("dangerous")
end

Measured memory_bytes: 1788
#include<stdio.h>
#define N 100000

bool binSearch(int S[],int n,int key)
{
    int left = 0, right = n;
    int mid;
    while(left < right) {
        mid = (left + right) / 2;
        if(S[mid] == key)
            return true;
        else if(S[mid] < key)
            left = mid + 1;
        else
            right = mid;
    }
    return false;
}

int main()
{
    int S[N];
    int n;

    scanf("%d",&n);
    for(int i = 0;i < n;i++)
        scanf("%d",&S[i]);

    int q, sum = 0;
    int key;
    scanf("%d",&q);
    for(int i = 0;i < q;i++) {
        scanf("%d",&key);
        if(binSearch(S,n,key))
            sum++;
    }
    printf("%d\n",sum);
}



Measured memory_bytes: 2972
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        mut h: [i64; n],
    }
    let mut possible = HashSet::new();
    possible.insert(h[0]);

    for i in 0..n {
        let next = vec![h[i], h[i] - 1];
        let mut next_possible = HashSet::new();
        for &n in &next {
            for &p in &possible {
                if n - p >= 0 {
                    next_possible.insert(n);
                }
            }
        }
        possible = next_possible;
        if possible.is_empty() {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll a,b,c;
    cin >> a >> b >> c;
    for(ll i=a;i<=a*b;i+=a){
        if(i%b==c){
            cout << "YES" << "\n";
            return 0;
        }
    }
    cout << "NO" << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC044
{
    class Program
    {
        static void Main(string[] args)
        {
            //new A();
            new B();
        }
    }

    class A
    {
        public A()
        {
            int N, K, X, Y;
            N = int.Parse(Console.ReadLine());
            K = int.Parse(Console.ReadLine());
            X = int.Parse(Console.ReadLine());
            Y = int.Parse(Console.ReadLine());

            int ans;
            ans = X * K + Y * (N - K);
            Console.WriteLine(ans);
        }
    }

    class B
    {
        public B()
        {
            string str = Console.ReadLine();
            char[] cstr = str.ToCharArray();
            int[] ary = new int[26];

            foreach (var e in cstr)
                ary[e-'a']++;

            string ans = "Yes";
            foreach (var e in ary)
                if (e%2 != 0)
                {
                    ans = "No";
                    break;
                }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 2648
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int d = sc.nextInt();
        int hw = h * w;
        int[] x = new int[hw + 1];
        int[] y = new int[hw + 1];
        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                int a = sc.nextInt();
                x[a] = i;
                y[a] = j;
            }
        }
        int[] pos = new int[hw + 1];
        for(int i=d+1; i<=hw; i++) {
            pos[i] = pos[i-d] + Math.abs(x[i-d] - x[i]) + Math.abs(y[i-d] - y[i]);
        }


        int q = sc.nextInt();
        for(int i=0; i<q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(pos[r] - pos[l]);
        }

    }

}


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

vector<vector<int>> v(100010);
int cnt[100010];
int used[100010];
int ans[100010];
queue<int> q;

void bfs(int p){
    for(auto i:v[p]){
        used[i]++;
        if(used[i] == cnt[i]){
            q.push(i);
            ans[i] = p+1;
        }
    }
    if(!q.empty()){
        int next = q.front();
        q.pop();
        bfs(next);
    }
}

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

    int n,m;
    cin>>n>>m;
    int s[n+m-1],t[n+m-1];
    for(int i=0;i<n+m-1;i++){
        int a,b; cin>>a>>b;
        a--,b--;
        s[i] = a, t[i] = b;
        cnt[b]++;
        v[a].push_back(b);
    }
    int root;
    for(int i=0;i<n;i++){
        if(cnt[i] == 0){
            root = i;
            break;
        }
    }
    bfs(root);

    for(int i=0;i<n;i++){
        cout << ans[i] << "\n";
    }
    
    
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
int dp[1100][5000];//dp[iこまで鍵をつかう][状態]とできるか
int main()
{
    int n,m;
    cin >> n >> m;
    vector<P> keys(m);
    rep(i,m){ 
        int a,b;
        int res = 0;
        cin >> a >> b;
        rep(j,b){
            int c;
            cin >> c;
            res |= 1<<(c-1);
        }
        keys[i] = P(a,res);//こすと、あける箱の集合

    }
    
    rep(i,m+1)rep(j,1<<(n+1))dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,m)rep(j,1<<n){
        int ni = i+1;
        int nj = j | keys[i].second;
        dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
        dp[ni][nj] = min(dp[ni][nj],dp[i][j]+keys[i].first);
    }
    int ans = INF;
    ans = dp[m][(1<<n)-1];
    if(ans == INF)ans = -1;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 20736
#include <stdio.h>
int main(void){
	int h, n, a;
	int sum = 0;
	scanf("%d%d", &h, &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		sum += a;
	}
	if (sum >= h)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
<?php
  $s = trim(fgets(STDIN));

  $len = strlen($s);
  $halfLen = floor($len/2);

  $count = 0;
  for($i=0; $i<$halfLen; $i++){
    //echo $s[$i]."--".$s[$len-1-$i]."\n";
    
    if($s[$i]!=$s[$len-1-$i]){
      $count++;
    }
  }

  echo $count."\n";


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	long long mi = 1e18;
	long long ans = 0;
	for(int i = 0; i < n; i++)
	{
		long long a,b;
		scanf("%lld %lld",&a, &b);
		if(a > b)
			mi = min(b,mi);
		ans += a;
	}
	if(mi >= (long long)1e18)
	{
		puts("0");
	}
	else
		printf("%lld\n",ans-mi);
	
	return 0;
}

Measured memory_bytes: 256
let st = Scanf.sscanf (read_line ()) "%s %s" (fun s t -> [s;t])
let ab = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> [a;b])
let u = read_line ()
let _ = 
  match u with
  | u when u = (List.hd st) -> Printf.printf "%d %d\n" ((List.hd ab) - 1) (List.nth ab 1)
  | _ -> Printf.printf "%d %d\n" (List.hd ab) ((List.nth ab 1) - 1)




Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int atA = 0;
		int atZ = 0;

		for (int i = 0; i < S.length(); i++) {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		}
		System.out.println(atZ - atA + 1);
	}
}


Measured memory_bytes: 38396
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here
vector<int> dp;
void M(int& a){ if(a>998244353) a-=998244353; }
signed main(){
    string s;
    cin >> s;
    int n = s.size(), curb=0;
    dp.resize(2*n+1);
    dp[0] = 1;
    for(int i = 0, curr = 0; i < 2*n; i++){
        if(i<n)curb += s[i]-'0', curr+='2'-s[i];
        for(int j = 2*n; j >= 0; j--){
            int cur = dp[j];
            if(!(curr>i-j)) dp[j]=0;
            if(curb>j) M(dp[j+1]+=cur);
        }
    }
    cout << dp[curb] << endl;
}


Measured memory_bytes: 256
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("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    if b % a == 0 {
        println!("{}", a + b);
    } else {
        println!("{}", b - a);
    }

}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    double ans=0;
    for(int i=0;i<n;i++){
        ans+=(double)(1.0/a[i]);
    }
    printf("%.10f\n",1.0/ans );
}

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

int main(){
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int ans = 0, res = x;
  for(int i=0; i<N-1; i++){
    if(res >= a.at(i)){
      ans++;
      res -= a.at(i);
    }else{
      break;
    }
  }
  if(res == a.back()){
    ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>

int main(void){
  int a = 0,i = 0;
  char S[4];
  
  scanf("%s",S);
  
  while(S[i]){
    if(S[i] == '+')
      a++;
    else if(S[i] == '-')
      a--;
    i++;
  }
  
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef unordered_map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

vi adj[200001];

struct DSU
{
	int S;
	
	struct node
	{
		int p;
		unordered_map<int,int> ma;
	};
	vector<node> dsu;
	
	DSU(int n)
	{
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i;
			dsu.pb(tmp);
		}
	}
	
	void reset(int n, vi &vec)
	{
		dsu.clear();
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i;
			tmp.ma[vec[i]]++;
			dsu.pb(tmp);
		}
	}
	
	int rt(int u)
	{
		if(dsu[u].p == u) return u;
		dsu[u].p = rt(dsu[u].p);
		return dsu[u].p;
	}
	
	void merge(int u, int v)
	{
		u = rt(u); v = rt(v);
		if(u == v) return ;
		if(dsu[v].ma.size()>dsu[u].ma.size()) swap(u,v);
		dsu[v].p = u;
		while(!dsu[v].ma.empty())
		{
			mit it = dsu[v].ma.begin();
			dsu[u].ma[it->fi]+=it->se;
			dsu[v].ma.erase(it);
		}
	}
	
	bool sameset(int u, int v)
	{
		if(rt(u) == rt(v)) return true;
		return false;
	}

};
//DSU end

vi cc;
int cn = 0;
bool vis[200001];
void dfs(int u)
{
	vis[u]=1;
	cc[u]=cn;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		if(vis[v]) continue;
		dfs(v);
	}
}

DSU dsu(1);

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	srand(77);
	int n, k, l;
	cin>>n>>k>>l;
	for(int i = 0; i < k; i++)
	{
		int u, v; cin>>u>>v;
		u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	cc.resize(n);
	for(int i = 0; i < n; i++)
	{
		if(!vis[i])
		{
			dfs(i);
			cn++;
		}
	}
	dsu.reset(n,cc);
	for(int i = 0; i < l; i++)
	{
		int u, v; cin>>u>>v;
		u--; v--;
		dsu.merge(u,v);
	}
	for(int i = 0; i < n; i++)
	{
		cout<<dsu.dsu[dsu.rt(i)].ma[cc[i]];
		if(i<n-1) cout<<' ';
	}
}


Measured memory_bytes: 36836
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct Point {
    db x,y;
    Point(db _x = 0,db _y = 0) {x = _x;y = _y;}
    friend Point operator + (const Point &a,const Point &b) {
	return Point(a.x + b.x,a.y + b.y);
    }
    friend Point operator - (const Point &a,const Point &b) {
	return Point(a.x - b.x,a.y - b.y);
    }
    friend Point operator * (const Point &a,const db &d) {
	return Point(a.x * d,a.y * d);
    }
    friend db operator * (const Point &a,const Point &b) {
	return a.x * b.y - a.y * b.x;
    }
    friend db dot(const Point &a,const Point &b) {
	return a.x * b.x + a.y * b.y;
    }
    db norm() {
	return sqrt(x * x + y * y);
    }
}P[4];
db Calctan(Point a,Point b) {
    return (a.norm() * b.norm() + dot(a,b)) / fabs(a * b);
}
db Getans(int a,int b,int c) {
    db t1 = Calctan(P[c] - P[a],P[b] - P[a]);
    db t2 = Calctan(P[c] - P[b],P[a] - P[b]);
    return (P[a] - P[b]).norm() / (2 + t1 + t2);
}
void Solve() {
    for(int i = 1 ; i <= 3 ; ++i) {
	scanf("%lf%lf",&P[i].x,&P[i].y);
    }
    db res = 0;
    res = max(Getans(1,2,3),res);
    res = max(Getans(1,3,2),res);
    res = max(Getans(2,3,1),res);
    printf("%.10lf\n",res);
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n);SCIN(s);V a(n);REP(i,n)a[i]=(s[i]=='o');
  REP(j,4){
    V v(n);
    if(j==0){v[0]=0;v[1]=0;}
    if(j==1){v[0]=0;v[1]=1;}
    if(j==2){v[0]=1;v[1]=0;}
    if(j==3){v[0]=1;v[1]=1;}

    FOR(i,1,n-1){//v[i]==羊 a[i]==同じ
      if((v[i]==1) == (a[i]==1))v[i+1]=v[i-1];
      else v[i+1]= !v[i-1];
    }
    if( (a[n-1]==v[n-1]) != (v[0]==v[n-2]))continue;
    if( (a[0]==v[0]) != (v[1]==v[n-1]) )continue;

    REP(i,n)cout<<(v[i]?'S':'W');
    ENDL;return 0;
  }
  COUT(-1);
  
  return 0;
}



Measured memory_bytes: 1408
#include<iostream>
#include<cstring>
typedef long long ll;
using namespace std;
ll n,sum=0;
int sym[1000000]={0};
string a;
ll cal(){
    ll su=0,temp=0;
    for(int i=0;i<n;i++){
        temp*=10;
        temp+=a[i]-'0';
        if(sym[i]==1||i==n-1){
            su+=temp;
            temp=0;
        }
    }
    return su;
}
void dfs(int deep){
    if(deep>=n-1){
        sum+=cal();
        return;
    }
    for(int i=0;i<=1;i++){
        sym[deep]=i;
        dfs(deep+1);
    }
}
int main(){
    cin>>a;
    n=a.length();
    dfs(0); 
    cout<<sum;
}

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

//?????????????????\???????????§?????§??§19???????¶???????????????§???????????????
static const int INFTY = 2000000000;

void WarshallFloyd(int weight[][100], int verNum) {

	//k????¢??????????????????????????????°????¢??????????????????????????±???????
	//???????????????????¨???????
	for (int k = 0; k < verNum; k++)
		for (int i = 0; i < verNum; i++) {
			//?????????????????£?????????????????§??´??°???????????????????????????
			if (weight[i][k] == INFTY) continue;
			for (int j = 0; j < verNum; j++) {
				if (weight[k][j] == INFTY) continue;
				weight[i][j] = min(weight[i][j], weight[i][k] + weight[k][j]);
			}
		}
}

int main() {

	int weight[100][100];
	int verNum;
	int edgeNum;
	cin >> verNum >> edgeNum;

	//Initialize
	for (int i = 0; i < verNum; i++)
		for (int j = 0; j < verNum; j++)
			weight[i][j] = (i == j) ? 0 : INFTY;

	for (int i = 0; i < edgeNum; i++) {
		int first_ver, second_ver, wei;
		cin >> first_ver >> second_ver >> wei;
		weight[first_ver][second_ver] = wei;
	}

	WarshallFloyd(weight, verNum);

	//?????¨???
	bool negative = false;
	for (int i = 0; i < verNum; i++)
		if (weight[i][i] < 0) negative = true;

	if (negative)
		cout << "NEGATIVE CYCLE" << endl;
	else {
		for (int i = 0; i < verNum; i++) {
			for (int j = 0; j < verNum; j++) {
				if (j) cout << " ";

				string verVal;
				if (weight[i][j] == INFTY) verVal = "INF";
				else                                  verVal = to_string(weight[i][j]);

				cout << verVal;
			}
			cout << endl;
		}
	}

	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
  int K;
  string S;
  cin >> K >> S;

  if (S.size() <= K) {
    cout << S << endl;
  } else {
    cout << S.substr(0, K);
    cout << "...";
    cout << endl;
  }
}


Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BCountBalls {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, A, B;
        cin >> N >> A >> B;
        int num = N / (A + B);
        cout << num * A + min(N - num * (A + B), A) << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BCountBalls solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
from itertools import product
h, w, k = map(int, input().split())
s = list()
best_so_far = float('inf')
for _ in range(h):
  line = input()
  s.append(list(map(int, list(line))))
# loop over possible horizontal lines, 2**9=512 possibilities
horizontal_line_choices = product([False, True], repeat=h-1)
for chosen_indices in horizontal_line_choices:
  hyperrow_values = [s[0].copy()]
  for i in range(h-1):
    if chosen_indices[i]:
      hyperrow_values.append(s[i+1].copy())
    else:
      for dw in range(w):
        hyperrow_values[-1][dw] += s[i+1][dw]
  if any(value>k for row in hyperrow_values for value in row):
    continue
  # now got hyperrow_values, do a greedy search on vertical lines
  num_hyperrows = len(hyperrow_values)
  count_cuts = sum(chosen_indices)
  hyperrow_cumulative = [hyperrow_values[r][0] for r in range(num_hyperrows)]
  for j in range(1, w):
    if all(hyperrow_cumulative[r]+hyperrow_values[r][j]<=k for r in range(num_hyperrows)):
      for r in range(num_hyperrows):
        hyperrow_cumulative[r] += hyperrow_values[r][j]
    else:
      count_cuts += 1
      for r in range(num_hyperrows):
        hyperrow_cumulative[r] = hyperrow_values[r][j]
  best_so_far = min(best_so_far, count_cuts)
print(best_so_far)

Measured memory_bytes: 72716
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

using ll = long long;
const int mod = 1e9 + 7;
const ll INF = 1e18L + 5;
int n, m, k, q;

int main()
{
	fast();
	int n;
	cin >> n;
	map<string, int> a;
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		a[s] ++;
	}
	cout << a.size();
}			

Measured memory_bytes: 19212
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        // input
        String input = scan.next();
        int a = Integer.parseInt(input.substring(0, 1));
        int b = Integer.parseInt(input.substring(1, 2));
        int c = Integer.parseInt(input.substring(2, 3));
        int d = Integer.parseInt(input.substring(3));

        // search
        loop: for(int i = 0; i < 2; i++){
            for(int j = 0; j < 2; j ++){
                for(int k = 0; k < 2; k++){
                    int result = a;
                    char op1 = 0;
                    char op2 = 0;
                    char op3 = 0;
                    switch(i){
                        case 0:
                            result += b;
                            op1 = '+';
                            break;
                        case 1:
                            result -= b;
                            op1 = '-';
                    }
                    switch(j){
                        case 0:
                            result += c;
                            op2 = '+';
                            break;
                        case 1:
                            result -= c;
                            op2 = '-';
                    }
                    switch(k){
                        case 0:
                            result += d;
                            op3 = '+';
                            break;
                        case 1:
                            result -= d;
                            op3 = '-';
                    }
                    if(result == 7){
                        System.out.println(a + "" + op1+ "" + b + "" + op2 + "" + c + "" + op3 + "" + d + "=7");
                        break loop;
                    }
                }
            }
        }
    }
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int a[n] = {0};
    for(int i=0; i<2*m; ++i){
        int tmp; cin >> tmp;
        ++a[tmp-1];
    }
    for(int i=0; i<n; ++i){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//注释版
#include<bits/stdc++.h>
using namespace std;
int getint()
{
	char c;
	int ans=0,k=1;
	while(c=getchar(),c>'9' || c<'0') if(c=='-') k=-1;
	while(ans=ans*10+c-'0',c=getchar(),c>='0' && c<='9');
	return ans*k;
}
const int N=2e6+5;
int n;
int a[N];

//如果有两个相邻的数字都小于或大于二分的顶层数字，
//那么这个数字有可能一直被带到顶峰，成立
//于是可以利用单调性二分

inline bool check(int k){//从中间往两边查看有没有两个相同性质的数字（同大或同小）
    for(int i=0;i<n-1;i++){
        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))//查看相邻两个数是否一起比k大或同小
            return 1;
        if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))
            return 0;
    }
    return a[1]<=k;
}
int main()
{
	scanf("%d",&n);
	int left=0,right=(n<<1)-1;      // =n*2-1
	for(int i=1;i<=right;i++) a[i]=getint();
	int mid;
	while(left<=right){
		mid=left+right>>1;
		if(check(mid)) right=mid-1;
		else left=mid+1;
	}
	printf("%d\n",left);
	
}

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

MOD = 10**9 + 7

N = int(input())
ball = (tuple(int(x) for x in row.split()) for row in sys.stdin.readlines())

# x座標を1,2,...,N
# y座標をN+1,N+2,...,N+N

graph = [set() for _ in range(N+N+1)]
for x,y in ball:
    graph[x].add(y+N)
    graph[y+N].add(x)

visited = [False] * (N+N+1)
components = []
for x in range(1,N+N+1):
    if visited[x]:
        continue
    V = set([x])
    E = []
    q = [x]
    visited[x] = True
    while q:
        y = q.pop()
        for z in graph[y]:
            if y < z:
                E.append((y,z))
            if visited[z]:
                continue
            V.add(z)
            visited[z] = True
            q.append(z)
    components.append((V,E))

def make_get_pattern(V):
    deg1 = [x for x in V if len(graph[x]) == 1]
    get = {}
    while deg1:
        x = deg1.pop()
        if not graph[x]:
            continue
        y = graph[x].pop()
        se = graph[y]; se.remove(x)
        if len(se) == 1: deg1.append(y)
        if x < y:
            get[(x,y)] = 0
        else:
            get[(y,x)] = 1
    for x in V:
        if graph[x]:
            y = graph[x].pop()
            break
    # 残りはサイクル
    graph[y].remove(x)
    if x > y: x,y = y,x
    get[(x,y)] = 2
    while graph[x]:
        y = graph[x].pop()
        graph[y].remove(x)
        if x < y:
            get[(x,y)] = 3
        else:
            get[(y,x)] = 2
        x = y
    return get

def F(V,E):
    # V is connected
    if len(E) != len(V):
        return 0
    ret = 0
    E.sort()
    get = make_get_pattern(V)
    den1,den2 = 1,1
    dp1 = {x:0 for x in V}
    dp2 = {x:0 for x in V}
    for x,y in E:
        if get[(x,y)] == 0:
            k1 = dp1[x] + 1; k2 = dp2[x] + 1
        elif get[(x,y)] == 1:
            k1 = dp1[y] + 1; k2 = dp2[y] + 1
        elif get[(x,y)] == 2:
            k1 = dp1[x] + 1; k2 = dp2[y] + 1
        else:
            k1 = dp1[y] + 1; k2 = dp2[x] + 1
        dp1[x] += k1; dp1[y] += k1
        dp2[x] += k2; dp2[y] += k2
        den1 *= k1; den2 *= k2
        den1 %= MOD; den2 %= MOD
    return sum(pow(x,MOD-2,MOD) for x in (den1,den2))

prob = 1
for c in components:
    prob *= F(*c)
    prob %= MOD

answer = prob
for n in range(1,N+N+1):
    answer *= n
    answer %= MOD
print(answer)

Measured memory_bytes: 162980
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
const int MOD=1e9+7;
int n;
const int mxN=2e6+5;
ll fact[mxN];

ll mul(ll a,ll b) {
    return (a*b)%MOD;
}

void precompute() {
    fact[0]=1;
    FOR(i,1,mxN)
        fact[i]=mul(fact[i-1],i);
}

ll modpow(ll a,ll b) {
    if(b==0)
        return 1;
    ll res=modpow(a,b/2);
    if(b%2)
        return mul(a,mul(res,res));
    return mul(res,res);
}

ll nCr(ll a,ll b) {
    if(b>a)
        return 0;
    ll num=fact[a];
    ll den=mul(fact[b],fact[a-b]);
    return mul(num,modpow(den,MOD-2));
}

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    precompute();
    int k;
    cin >> k;
    string s;
    cin >> s;
    n=sz(s)+k;
    ll tot=0;
    F0R(i,n) {
        ll cur=modpow(26,i);
        cur=mul(cur,mul(nCr(n-i-1,sz(s)-1),modpow(25,n-i-sz(s))));
        tot=(tot+cur)%MOD;
    }
    cout << tot;

    return 0;
}


Measured memory_bytes: 19884
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 35
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
struct P{ int x,y,d; };
bool operator < (P a,P b) { return a.d > b.d; }
P mt(int x,int y,int d)
{
	P re;
	re.x = x;
	re.y = y;
	re.d = d;
	return re;
}
//
int n,m;
int dx[4]={0,0,1,-1}, dy[4]={1,-1,0,0};
int dis[M][M];
char mp[M][M];
bool ins(int x,int y)
{
	return x>=1 && x<=n && y>=1 && y<=m && mp[x][y]!='#';
}
int main()
{
	int x,y,d;
	int nx,ny,nd;
	priority_queue<P> q;
	MSET(dis, -1);

	RI(n,m);
	REP(i,1,n) scanf("%s", mp[i]+1);
	REP(i,1,n)REP(j,1,m) if(mp[i][j]=='S')
	{
		q.push( mt(i,j,0) );
		break;
	}

	while(!q.empty())
	{
		x = q.top().x;
		y = q.top().y;
		d = q.top().d;
		q.pop();
		if(dis[x][y] != -1) continue;
		dis[x][y] = d;
		///////
		
		REP(i,0,3)
		{
			nx = x + dx[i];
			ny = y + dy[i];
			if( !ins(nx, ny) ) continue;
			if( dis[nx][ny] != -1 ) continue;
			if( mp[nx][ny]=='x' ) continue;

			nd = mp[nx][ny]=='o' ? 1:2;
			q.push( mt(nx, ny, d+nd) );
		}

		REP(i,0,3)
		{
			nx = x;
			ny = y;
			REP(j,1,3)
			{
				nx = nx+dx[i];
				ny = ny+dy[i];
				if( !ins(nx, ny) ) break;
				if( dis[nx][ny] != -1 ) continue;
				
				nd = 2+j;
				q.push( mt(nx, ny, d+nd) );
			}
		}
	}

	int ans=0;
	REP(i,1,n) REP(j,1,m) if(mp[i][j]=='G') ans = dis[i][j];
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1212
N, M, Q=list(map(int,input().split()))
LR=[list(map(int,input().split()))+[0] for _ in range(M)]
pq=[list(map(int,input().split()))+[1]+[_] for _ in range(Q)]

# print(LR)
# print(pq)

a=LR+pq
# print(a)
a.sort(key=lambda x:x[1])
# print(a)
b=[0]*(N+1)
ans=[]
for i in a:
    if i[2]==0:
        b[i[0]]+=1
    else:
        ans.append([sum(b[i[0]:i[1]+1]), i[3]])
    # print("b", b)
# print(ans)
ans.sort(key=lambda x:x[1])
# print(ans)
for i in ans:
    print(i[0])


Measured memory_bytes: 69312
import collections
import itertools
import math
import statistics
import datetime
from bisect import bisect_left
import heapq

__author__ = 'sudoplox // Sudhanshu'
__contact__ = "sudoplox[at]gmail.com"


def BinarySearch(a, x):
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    else:
        return -1


def fibonacci(n):
    a = 0
    b = 1
    if n < 0:
        print("Incorrect input")
    elif n == 0:
        return a
    elif n == 1:
        return b
    else:
        for i in range(2, n):
            c = a + b
            a = b
            b = c
        return b


def ngreatestelem(lis, n):
    return heapq.nlargest(n, lis)


def nsmallestelem(lis, n):
    return heapq.nsmallest(n, lis)


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def sieve():
    # Complexity: O(n * log2(log2(n)))
    primes[1] = 1
    primes[2] = 2
    j = 4
    while j < 1000000:
        primes[j] = 2
        j += 2
    j = 3
    while j < 1000000:
        if primes[j] == 0:
            primes[j] = j
            i = j * j
            k = j << 1
            while i < 1000000:
                primes[i] = j
                i += k
        j += 2


def possiblepermutations(lis):
    return itertools.permutations(lis)


sieve = False
if sieve:
    primes = [0] * 1000000

# for _ in range(int(input())):
#     n = int(input())
#     s = input()
#     arr = list(map(int, input().split(" ")))

def solve(n,k):
    for i in range(0, n + 1):
        if i * 2 + 4 * (n - i) == k:
            return("Yes")
    return ("No")

n,k=map(int, input().split(" "))
print(solve(n,k))


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

int main(){
  int a,b,c;
  cin >> a >> b;
  if(a==b){
    c = a+b;
  }else if(a>=(b+1)){
    c = 2*a-1;
  }else if(b>=(a+1)){
    c = 2*b-1;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
using System;

namespace tes
{
    class Program
    {
        public static void Main()
        {
            String str = Console.ReadLine();
            String[] num = str.Split(' ');
            Console.WriteLine((int.Parse(num[0]) * int.Parse(num[1])) +" "+ (2 *(int.Parse(num[0]) + int.Parse(num[1]))));
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 5596
#include<stdio.h>
#define MIN(a,b,c) (a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c)
#define MID(a,b,c) ((a)-(b))*((a)-(c))<=0?(a):((b)-(a))*((b)-(c))<=0?(b):(c)
#define MAX(a,b,c) (a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c)

int main(void){
  int a,b,c;

  scanf("%d%d%d",&a,&b,&c);
  printf("%d %d %d\n",MIN(a,b,c),MID(a,b,c),MAX(a,b,c));
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void){
    int a;
    int b;
    int x;
    scanf("%d %d %d", &a, &b, &x);

        if(x > (a+b)){
            printf("NO\n");
        }else if( x<a){
            printf("NO\n");
        }else{
            printf("YES\n");
        }
    return 0;
}    


Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int S,h,m,s, r;
  scanf("%d",&S);
   
  h=S/3600;
  r=S%3600;
  m=r/60;
  s=r%60;
 
printf("%d:%d:%d\n",h,m,s);
 
return 0;
}


Measured memory_bytes: 2096
use strict;
use utf8;
use warnings;

chomp(my @lines = <STDIN>);
my ($odd, $even) = @lines;
my @ans_list = ();
my @o_list = split(//, $odd);
my @e_list = split(//, $even);
foreach (1..$#e_list+1){
    push @ans_list, $o_list[$_-1];
    push @ans_list, $e_list[$_-1];
}
if ($#o_list != $#e_list){push @ans_list, $o_list[-1]}
my $ans = join("", @ans_list);
print "$ans\n";

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  sort(rng(A));
  uni(A);
  if(sz(A) == N) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

const int m = 2019;
string s;
int ma[m];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	int g = 1;
	int b = 0;
	++ma[b];
	int fp = 0;
	for(int i = (int)s.size() - 1; i >= 0; --i) {
		int a = (g * (int)(s[i] - '0')) % m;
		b += a;
		b %= m;
		fp += ma[b];
		++ma[b];
		g *= 10;
		g %= m;
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 3696
N = int(input())
txy = [[0, 0, 0]]
for i in range(N):
    txy.append(list(map(int, input().split())))


def solve():
    for i in range(1, len(txy)):
        if (
            txy[i][0] - txy[i - 1][0]
            < (abs(txy[i][1] - txy[i - 1][1]) + abs(txy[i][2] - txy[i - 1][2]))
        ) or (
            (txy[i][0] - txy[i - 1][0]) % 2
            != (abs(txy[i][1] - txy[i - 1][1]) + abs(txy[i][2] - txy[i - 1][2])) % 2
        ):
            print("No")
            return 0
    print("Yes")
    return 0


solve()


Measured memory_bytes: 27380
#include <cstdio>
#include <iostream>
#include <string>
#define INF (1<<21)
using namespace std;

int main(){
  int i,j,k,kk,aa,bb,n,m,a,b,d,dd,c[101][101],t[101][101],f;
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    for(i=1;i<=m;i++){
      for(j=1;j<=m;j++){
	if(i == j){
	  c[i][j] = 0;
	  t[i][j] = 0;
	}
	else{
	  c[i][j] = INF;
	  t[i][j] = INF;
	}
      }
    }

    for(i=0;i<n;i++){
      cin >> a >> b >> d >> dd;
      c[a][b] = c[b][a] = d;
      t[a][b] = t[b][a] = dd;
    }

    for(k=1;k<=m;k++){
      for(i=1;i<=m;i++){
	for(j=1;j<=m;j++){
if(t[i][k] >= INF || t[k][j] >= INF || c[i][k] >= INF || c[k][j] >= INF) continue; 
	  if(t[i][k] + t[k][j] > INF || c[i][k] + c[k][j] > INF) continue;
	  t[i][j] = min(t[i][j],t[i][k] + t[k][j]);
	  c[i][j] = min(c[i][j],c[i][k] + c[k][j]);
	}
      }
    }

    cin >> kk;
    for(i=0;i<kk;i++){
      cin >> aa >> bb >> f;
      if(f) cout << t[aa][bb] << endl;
      else cout << c[aa][bb] << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 944
N = int(input())
lx, ly, lh = [], [], []
for i in range(N):
    x, y, h = map(int, input().split())
    lx.append(x)
    ly.append(y)
    lh.append(h)
# すべての座標(i, j)について全探索
for i in range(101):
    for j in range(101):
        k = 0
        while lh[k] == 0:
            k += 1
        H = int(abs(lx[k]-i)) + int(abs(ly[k]-j)) + lh[k]
        b = True
        for k in range(len(lh)):
            if lh[k] != max(H - int(abs(lx[k]-i)) - int(abs(ly[k]-j)), 0):
                b = False
                break
        if b:
            print(i, j, H)


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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(){

    int n, a[200005];
    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }

    sort(a, a + n, greater<int>());

    ll ans = 0;
    for(int i = 1; i < n; ++i){
        ans += a[i / 2];
    }

    cout << ans << "\n";

    return 0;
}


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

string s, t;
int dp[3003][3003];
pair<int, int> p[3003][3003];

int main() {
    getline(cin, s);
    getline(cin, t);
    s = "*" + s;
    t = "*" + t;
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i < s.size(); i++) {
        for (int j = 1; j < t.size(); j++) {
            if (s[i] == t[j]) {
                dp[i][j] = dp[i-1][j-1]+1;
                p[i][j] = {i-1, j-1}; 
            } else {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                if (dp[i-1][j] >= dp[i][j-1]) {
                    p[i][j] = {i-1, j}; 
                } else {
                    p[i][j] = {i, j-1}; 
                }
            }
        }
    }
    int y = s.size()-1;
    int x = t.size()-1;
    pair<int, int> pp;
    string res;
    while (y != 0 && x != 0) {
        pp = p[y][x];
        if (y - pp.first + x - pp.second == 2) {
            res = s[y] + res;
        }
        y = pp.first;
        x = pp.second;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 105984
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int N;
LL A[100000];
LL wa1[100000] = {};
LL wa2[100000] = {};
int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i+1];
	
	for(int i=0; i<N; i++){
		if(i%2 == 0){
			wa1[i+1] = wa1[i] + A[i+1];
			wa2[i+1] = wa2[i] - A[i+1];
		}
		else{
			wa1[i+1] = wa1[i] - A[i+1];
			wa2[i+1] = wa2[i] + A[i+1];
		}
	}
	
	for(int i=0; i<N; i++){
		if(i != 0) cout << " ";
		if(i%2 == 0){
			LL tmp = wa1[N] - wa1[i];
			tmp += wa2[i];
			cout << tmp;
		}
		else{
			LL tmp = wa2[N] - wa2[i];
			tmp += wa1[i];
			cout << tmp;
		}
	}
	cout << endl;
	
	
}
//a1=b1+b2 +
//a2=b2+b3 -
//a3=b3+b4 +
//:
//an=bn+b1 +
//n is an odd number


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

int main(){
	int p,q,r;
	cin >> p >> q >> r;
	
	if(p <= q){
		cout << p + min(q,r) << endl;
		return 0;
	}
	if(q <= r){
		cout << q + min(r,p) << endl;
		return 0;
	}
	if(r <= p){
		cout << r + min(p,q) << endl;
		return 0;
	}
}

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

using namespace std;


int main() {
    int n,k;
    cin >> n >> k;
    int c = n / 2;
    if(n % 2 == 1) {
        c++;
    }
    if(c >= k) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,i,N,flag = 0;
    scanf("%d %d", &a, &b);
    scanf("%d", &N);
    int s[N];
    int f[N];

    for(i=0;i<N;++i)
      scanf("%d %d", &s[i], &f[i]);

    for(i=0;i<N;++i) {
        if((a<=s[i] && b>s[i]) || (a<f[i] && b>=f[i])){
            flag = 1;
            break;
        }else if(a>=s[i] && b<=f[i]) {
            flag = 1;
            break;
        }
    }
    printf("%d\n", flag);

    return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
// #define DEBUG 10
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const int oo = 1e9 + 7;
const ll mod = 1e9 + 7, maxn = 155, maxm = 15;
const double PI = acos(-1);
 

int main (){
    ios_base::sync_with_stdio(false);
    int n, k, c, last = -oo;
    string s;
    cin >> n >> k >> c >> s;

    vector<int> l(n), r(n);

    for (int i=0; i<n-1; i++){
        l[i+1] = l[i];
        if (s[i] == 'o' and last + c < i){
            last = i;
            l[i+1]++;
        }
    }
    last = oo;
    for (int i=n-1; i>0; i--){
        r[i-1] = r[i];
        if (s[i] == 'o' and last - c > i){
            last = i;
            r[i-1]++;
        }
    }

    for (int i=0; i<n; i++){
        if (l[i] + r[i] < k){
            cout << i+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5124
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    bool isDaikei = true;
    unsigned long  side1, side2;
    unsigned long n, x;
    unsigned long length = 0;

    scanf("%lu", &n);
    scanf("%lu", &x);

    if (x >= n-x) {
        side1 = x;
        side2 = n-x;
    } else {
        side1 = n-x;
        side2 = x;
    }
    length = n;
    //printf("%d + ", length);

    unsigned long div, r;
    r = 1;
    
    while (r != 0) {
        div = side1 / side2;
        r = side1 % side2;    
        if (r != 0) {
            length += div * 2 * side2;
        } else {
            length += (2* div -1) * side2;
        }
        side1 = side2;
        side2 = r;
    }
    printf("%lu\n", length);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

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

int main(){
  int n; cin >> n;
  vector<int> p;
  for(int i = 2; i<=200000; i++){
    bool isPrime = true;
    int j = 0;
    while(j < p.size() && p[j]*p[j] <= i){
      if(i % p[j] == 0) isPrime = false;
      j++;
    }
    if( isPrime ) p.push_back(i);
  }
  rep(i,p.size()){
    if(p[i] >= n){
      cout << p[i] <<  "\n";
      break;
    }
  }
}

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

using namespace std;

int main()
{
    int n;

    while (cin >> n) {
        if (!n)
            break;

        vector< pair<long long, int> > team;

        for (int i = 0; i < n; i++) {
            int id;
            long long time;
            int m, s;

            time = 0;
            cin >> id;
            for (int j = 0; j < 4; j++) {
                cin >> m >> s;
                time += m * 60 + s;
            }
            team.push_back(pair<long long, int>(time, id));
        }
        sort(team.begin(), team.end());

        cout << team[0].second << endl;
        cout << team[1].second << endl;
        cout << team[n - 2].second << endl;
    }

    return 0;
}

Measured memory_bytes: 1328