akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;


int main(){
    int k, s, cnt;
    cin >> k >> s;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(0<=s-i-j && s-i-j<=k){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

using namespace std;

int main()
{
    int n;
    int a[20];

    cin >> n;

    for(int i = 0;i < n;i++) cin >> a[i];

    sort(a,a+n);

    int sum = 0;
    for(int i = 0;i < n-1;i++){
        sum += a[i];
    }
    if(sum > a[n-1]){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

struct edge {
	int from, to;
	edge(int from, int to) : from(from), to(to) {}
};
using node = vector<edge>;
using graph = vector<node>;
void addedge(graph& g, int from, int to, bool bidirectional = false) {
	g[from].emplace_back(edge(from, to));
	if (bidirectional) g[to].emplace_back(edge(to, from));
}

class Solution {
public:
	const int inf = 0x7f7f7f7f;
	vector<int> a, ans;
	void dfs(graph& g, int u, vector<int>& lis, int len = 0, int p = -1) {
		int d = distance(lis.begin(), lower_bound(lis.begin(), lis.end(), a[u]));
		if (d > len) len = d;
		int tmp = a[u];
		ans[u] = len;
		swap(tmp, lis[d]);
		for (auto e : g[u]) {
			if (e.to == p) continue;
			dfs(g, e.to, lis, len, u);
		}
		swap(tmp, lis[d]);
		if (lis[d] == inf) len--;
	}

	void solve() {
		int n;
		cin >> n;
		a = vector<int>(n);
		ans = vector<int>(n);
		for (int i = 0; i < n; i++) cin >> a[i];
		graph g(n);
		for (int i = 0; i < n - 1; i++) {
			int u, v;
			cin >> u >> v;
			addedge(g, u - 1, v - 1, true);
		}
		vector<int> lis(n + 1, inf);
		lis[0] = 0;
		dfs(g, 0, lis);
		for (int i = 0; i < n; i++) cout << ans[i] << "\n";
		cout << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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


int main() {
	
	priority_queue <long long> pq_right; // default 大きい順
	priority_queue<long long, vector<long long>, greater<long long> > pq_left; // 小さい順
	long long N;
	cin >> N;
	vector<long long> arr;
	for (long long i = 0; i < 3*N; i++){
		long long tmp;
		cin >> tmp;
		arr.push_back(tmp);
	}
	//long long sikiri = N-1;	//leftはsikiriまで含む。
	long long left=0;
	long long right=0;
	for (long long i = 0; i < N; i++){
		left += arr[i];
		pq_left.push(arr[i]);
		right += arr[3*N - 1 - i];
		pq_right.push(arr[3*N - 1 - i]);
	}
	//leftを更新

	long long ans = numeric_limits<long long>::min();
	vector<long long> vleft, vright;
	vleft.push_back(left);
	vright.push_back(right);
	for (long long sikiri = N; sikiri < 2*N; sikiri++){
		left += arr[sikiri];
		pq_left.push(arr[sikiri]);
		left -= pq_left.top();
		pq_left.pop();
		vleft.push_back(left);

	}


	
	
	for (long long sikiri = 2 * N - 1; sikiri >= N; sikiri--){
		right += arr[sikiri];
		pq_right.push(arr[sikiri]);
		right -= pq_right.top();
		pq_right.pop();
		vright.push_back(right);

	}
	reverse(vright.begin(), vright.end());

	for (long long i = 0; i <= N; i++){
		if (ans < vleft[i] - vright[i]){
			ans = vleft[i] - vright[i];
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 8684
N = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))

a_list = [a-1 for a in a_list]

sat = 0
sat += sum(b_list)
# print(sat)
for i in range(len(a_list)-1):
    if a_list[i+1] - a_list[i] == 1:
#         print(i)
#         print(c_list[i])
        sat += c_list[a_list[i]]
        
print(sat)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (c <= a + b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  vll A(9);
  REP(i, 0, 9) {
    ll a;
    cin >> a;
    A[i] = a;
  }
  ll N;
  cin >> N;
  vll B(N);
  REP(i, 0, N) {
    ll b;
    cin >> b;
    B[i] = b;

    REP(j, 0, 9) {
      if (A[j] == b) {
        A[j] = 0;
      }
    }
  }

  if ((A[0] == 0 && A[1] == 0 && A[2] == 0) ||
      (A[3] == 0 && A[4] == 0 && A[5] == 0) ||
      (A[6] == 0 && A[7] == 0 && A[8] == 0) ||
      (A[0] == 0 && A[3] == 0 && A[6] == 0) ||
      (A[1] == 0 && A[4] == 0 && A[7] == 0) ||
      (A[2] == 0 && A[5] == 0 && A[8] == 0) ||
      (A[0] == 0 && A[4] == 0 && A[8] == 0) ||
      (A[2] == 0 && A[4] == 0 && A[6] == 0)
      ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from sys import exit
N = int(input())
A = list(map(int,input().split()))

for i in A:
  if i % 2 == 0 and (i % 3 == 0 or i % 5 ==0) or i % 2 == 1 : continue
  else: 
    print("DENIED") 
    exit()
print("APPROVED")   

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  sort(all(A));
  string ans = "YES";
  REP(i, N) {
    if(i == N - 1) continue;
    if(A[i] == A[i + 1]) ans = "NO";
  }
  cout << ans << endl;
}

Measured memory_bytes: 4820
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int n, m, d;

signed main() {
    cin >> n >> m >> d;
    long double a = 1.0 * (m - 1) * (n - d) / (n * n);
    if (d != 0)a *= 2;
    printf("%.20Lf\n", a);
    return 0;
}
//C


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

int main(){
    int X, Y;
    cin >> X >> Y;
    int a = 4 * X - Y;
    int b = Y - 2 * X;
    if(a >= 0 && b >= 0 && a % 2 == 0 && b % 2 == 0)
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
int main()
{
    double sum=0,ans=0;
    int n,x=1;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=(1/(arr[i]*1.0));
    }
    cout<<1/sum<<endl;
 
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
string X,Y; 
long long int lcs( long long int m,long long int n ) 
{ 
   long long int L[m+1][n+1]; 
   long long int i, j; 
   for (i=0; i<=m; i++) 
   { 
     for (j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
   
       else if (X[i-1] == Y[j-1]) 
        {
		  L[i][j] = L[i-1][j-1] + 1;
	}
   
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
   long long int index = L[m][n]; 
   long long int index1=index;
  
   // Create a character array to store the lcs string 
   char lcs1[index+1]; 
   	lcs1[index] = '\0';
    i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs1[index-1] = X[i-1]; 
          i--; j--; index--;      
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   if(index1==0)
   cout<<" ";
   else
   cout <<lcs1; 
   return L[m][n]; 
} 
int main()
{
ios_base::sync_with_stdio;
	cin.tie(NULL);
	cout.tie(NULL);
	long long int i,j,k,l,m,n,w;
	cin>>X>>Y;
	m=X.length();
	n=Y.length();
	k=lcs(m,n);
//	cout<<endl;
	//for(i=0;i<k;i++)
	//cout<<v[i];
	return 0;
}

Measured memory_bytes: 70656
class Integer
  def fac
    return 1 if self.zero?
    (1..self).reduce(&:*)
  end

  def combi r
    self.fac / (r.fac * (self - r).fac)
  end
end

def line_sum s_size, i, idx
  (0..idx).reduce(0) do |sum, k|
    sum + if k != 0
      i * (10 ** (idx - k)) * ((1 + 1) ** (s_size - 1 - 1 - (idx - k)))
    else
      i * (10 ** (idx - k)) * ((1 + 1) ** (s_size - 1 - 0 - (idx - k)))
    end
  end
end

s = gets.chomp.chars.map(&:to_i)
res = s.reverse.each_with_index.reduce(0) do |sum , (i, idx)|
  sum + line_sum(s.size, i, idx)
end
puts res

Measured memory_bytes: 14348
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  int N, K;
  cin >> N >> K;

  int now = 1;
  REP(i, N) {
    now = min(now * 2, now + K);
  }

  cout << now << endl;
  return 0;
}


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

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

int main() {
  string s = "";
  REP(i, 4) {
    string t;
    cin >> t;
    s += t;
  }
  sort(all(s));
  if (s == "1479") puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

int n,k,x,y;

int main(){
  ll ans=0LL;
  string s,t;cin>>s>>t;
  int slen=s.length();
  int tlen=t.length();

  //ま-1をチェック
 vi ss(26);
 vi tt(26);
 REP(i,slen){
   ss[s[i]-97]++;
 }
 REP(i,tlen){
   tt[t[i]-97]++;
 }
 REP(i,26){
   if (ss[i]==0){
     if (tt[i]!=0){
      cout<<-1<<endl;
      return 0;
     }
   }
 }

  //sの小文字26文字がそれぞれどの位置に配置されてるか +1
  vvi sindex(26, vi(slen));
  vi ri(26);
  REP(i,slen){
    int id=s[i]-97;
    sindex[id][ri[id]]=i+1;
    ri[id]++;
  }


  vvi data(slen, vi(26));  // slen * 26 の2次元配列
  
  REP(j,26){
    int id=0;
    if (ri[j]!=0){
      REP(i,slen){
        if (id==-1){
          data[i][j]=sindex[j][0]-1;
          continue;
        }

        if ((sindex[j][id]-1)<=i){
          id++;
          if (id==ri[j]){
            id=-1;
            data[i][j]=sindex[j][0]-1;
            continue;
          }
        }
        data[i][j]=sindex[j][id]-1;
      }
    }
  }

  //tを前から検索 
  int tmy=slen-1;
  //tmy=data[0][t[0]-97];
  //ans+=tmy;

  ll tmmpl;
  for(int i=0;i<tlen;i++){
    int tm=t[i]-97;
    int nexti=data[tmy][tm];
    //cout<<nexti<<endl;
    if (tmy>=nexti){
      tmmpl=(slen-tmy+nexti);
      
    }
    if (tmy<nexti){
      tmmpl=nexti-tmy;
    }
    ans=ans+tmmpl;
    //cout<<tmmpl<<endl;
    tmy=nexti;
  }



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

Measured memory_bytes: 23928
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

struct union_find {
	ll par[MAX_N];
	ll Size[MAX_N];
	union_find(ll n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			Size[i] = 1;
		}
	}
	ll root(ll x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	bool same(ll x, ll y) {
		return root(x) == root(y);
	}
	void unite(ll x, ll y) {
		if (same(x, y))return;
		Size[root(x)] += Size[root(y)];
		par[root(y)] = root(x);
	}
};

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]--;
    }
    int x,y;
    struct union_find U(n);
    for(int i=0;i<m;i++){
        cin>>x>>y;
        x--; y--;
        U.unite(x,y);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(U.same(i,p[i])) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<long long> A(N+1), B(N+1);
    map<int, int> C;
    long long cnt = 0;
    for (int i = 1; i <= N; i++) cin >> A[i];
    for (int i = 1; i <= N; i++) B[i] = B[i-1] + A[i];
    for (int i = 0; i <= N; i++) C[B[i] % M]++;
    for (auto it : C) cnt += (long long)it.second * (it.second-1) / 2;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4736
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

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 &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

Int Iabs(Int n){
	return (n>=0)?n:-n;
}

int main() {
	Int n;
	for(;cin>>n;){
		Int m,pow;
		int i,j;
		for(i=10;i>1;i--){
			pow=1;
			m=0;
			for(j=0;j<i-1;j++){
				m+=Iabs(n/pow%10+n/pow/10%10)%10*pow;
				pow*=10;
			}
			n=m;
		}
		cout<<n<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i=1;i<=9;i++) for(int j=1;j<=9;j++){
        if(i*j == n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

struct S { long long zero, one, inv; };
S op (S a, S b) { return S{a.zero + b.zero, a.one + b.one, a.inv + b.inv + a.one * b.zero}; }
S e () { return S{0ll, 0ll, 0ll}; }
using F = bool;
S mapping (F f, S a) {
    if (!f) return a;
    return S{a.one, a.zero, a.zero * a.one - a.inv};
}
F composition (F f, F g) { return (!f && g) || (f && !g); }
F id () { return false; }

int main(){
    int n, q;  cin >> n >> q;
    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        int aa; cin >> aa;
        if (aa == 0) a[i] = S{1ll, 0ll, 0ll};
        else a[i] = {0ll, 1ll, 0ll};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> data(a);

    while (q--) {
        int t, l,  r; cin >> t >> l >> r; l--;
        if (t == 1) data.apply(l, r, true);
        else cout << data.prod(l, r).inv << "\n";
    }
    return 0;
}

Measured memory_bytes: 20456
n,T=map(int,input().split())
c=[]
t=[]
ans=2e31-1
for i in range(n):
    c,t=map(int,input().strip().split(' '))
    if t<=T:
        ans=min([ans,c])
if  ans==2e31-1:
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D,X,C[110],ans;
  cin >>N>>D>>X;
  for(int k = 0;k < N;k++){
    cin >> C[k];
  }
  for(int p = 0;p < N;p++){
    ans += (((D-1)/C[p])+1);}
  cout << ans+X << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back

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

int main()
{
    int N;
    while (cin >> N, N) {
        int W, H;
        char pmap[101][101];
        fill_n((char *)pmap, 101*101, 0);
        cin >> W >> H;
        rep(i,N){
            int x, y;
            cin >> x >> y;
            pmap[y][x] = '*';
        }
        int S, T;
        cin >> S >> T;
        int max = 0;
        for(int j = 1; j + T <= H+1; j++){
            for(int i = 1; i + S <= W+1; i++){
                int count = 0;
                rep(y, T){
                    rep(x, S){
                        if (pmap[j+y][i+x]=='*')
                            count++;
                    }
                }
                if (count > max) max = count;
            }
        }
        cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
// Bismillahirrahmanirrahim
// by Batrrr Tolkynbayev
#include <bits/stdc++.h>
// skripi krasava
#define respa return 0
#define all(x) x.begin(), x.end()
#define sz size
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 2e5 + 17, M = N << 2, mod = 1e9 + 7; 

int tt = 1, n, m;
char a[10][10];
bool used[10][10];

void solve () {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			cin >> a[i][j];
		}
	}
	int i = 1, j = 1;
	while (i < n || j < m) {
		used[i][j] = true;
		if (i == n) {++j; continue;}
		if (j == m) {++i; continue;}
		if (a[i + 1][j] == '#') ++i;
		else ++j;
	}
	used[n][m] = true;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if ((a[i][j] == '#' && !used[i][j]) || (a[i][j] == '.' && used[i][j])) {
				cout << "Impossible"; return;
			}
		}
	}
	cout << "Possible";
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cin >> tt;
	while (tt--) solve();
	respa;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define xx first
#define yy second
using namespace std;
ll mem[2003][2003], n;
typedef pair<ll, int>pi;
pi p[2003];
ll dp(int l, int r)
{
    if(l>r)return 0;
    if(mem[l][r]!=-1)return mem[l][r];
    int pos= l+n-r-1;
    return mem[l][r]= max(p[pos].xx*abs(p[pos].yy-l)+dp(l+1, r), p[pos].xx*abs(p[pos].yy-r)+dp(l, r-1));
}
int main()
{
    scanf("%lld", &n);
    for(int i=0; i<n; i++)
    scanf("%lld", &p[i].xx), p[i].yy= i;
    sort(p, p+n, greater<pi>());
    memset(mem, -1, sizeof mem);
    printf("%lld\n", dp(0, n-1));
    return 0;
}


Measured memory_bytes: 35184
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

h = I()

n = int(math.log2(h))+1

print(2**n-1)

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

int main() {
    ll n, X;
    cin >> n >> X;
    vector<ll> x(n), sa(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
        sa[i] = abs(X - x[i]);
    }
    
    int r = accumulate(sa.begin(), sa.end(), 0, [](int m, int n) {
        return gcd(m, n);
    });

    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4772
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long base = 26L;
        long max = 26L;
        int d = 1;
        Map<Integer, Long> mmap = new HashMap<>();
        mmap.put(d, max);
        mmap.put(0, 0L);
        while(max < n){
            base *= 26L;
            max += base;
            d++;
            mmap.put(d, max);
        }
        String ans = "";
        for (int i = d-1; i >= 0; i--) {
            base /= 26L;
            int a = (int)((n - mmap.get(i) -1) / base);
            char c = (char)((int)'a' + a);
            ans += c;
            n -= base * (a+1);
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 39292
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int i,j,n,dmax,dmin;
  int *price;

  scanf("%d",&n);
  price = (int *)malloc(n * sizeof(int));

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

  dmax = price[1]-price[0];
  dmin = price[0];
  for(j=1; j<n; j++){
    dmax = (int)fmax((double)dmax,(double)(price[j] - dmin));
    dmin = (int)fmin((double)dmin,(double)price[j]);
  }

  printf("%d\n",dmax);

  free(price);

  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
using namespace std;
//#define local
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    char s[20],s1[20]="";
    cin>>s;
    int i,j=0;
    for(i=0; s[i]!='\0'; i++)
    {
        if(s[i]=='B')
        {
            if(j) s1[--j]='\0';
        }
        else s1[j++]=s[i];
    }
    cout<<s1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll A, B, C;
    cin >> A >> B >> C;
    if(A % 2 != 0 && B % 2 != 0 && C % 2 != 0){
        cout << min({A * B, B * C, C * A});
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            int s,w;
            cin >> s >> w;
            if(w >= s)
                cout << "unsafe" << endl;
            else 
                cout << "safe" << endl;





           return 0;
        }
          

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
typedef long long int ll;
#define FOR(i,a,n) for(int i=a;i<n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
#define pos std::pair<int,int>
const int INF = 1LL << 30;
const int INF_ = 0 - INF;
const ll LLINF = 1LL << 60;
int main() {
	int x, y, z;
	std::cin >> x >> y >> z;
	x -= z;
	std::cout << x / (y+z) << std::endl;
	return 0;

}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.BitSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int x = in.nextInt();
		int y = in.nextInt();
		final int os = 301;
		final int U = 603+os;
		final int F= 603+os;
		int[][] dp = new int[U][F];
		final int inf = -Integer.MAX_VALUE;
		int[][] newdp = new int[U][F];
		for(int j=0; j<U; j++)
			Arrays.fill(dp[j], inf);
		dp[x+os][y+os] = 0;
		for(int i=0; i<n; i++){
//			for(int j=0; j<U; j++)
//				Arrays.fill(newdp[j], inf);
			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();
			int d = in.nextInt();
			for(int j=0; j<U; j++){
				for(int k=0; k<F; k++){
					newdp[j][k] = dp[j][k];
				}
			}
			for(int j=-os; j<U-os; j++){
				for(int k=-os; k<F-os; k++){
					if(j+os>=U || k+os>=F || dp[j+os][k+os]==inf) continue;
					newdp[j-a+os][k+b+os] = Math.max(newdp[j-a+os][k+b+os], dp[j+os][k+os]);
					newdp[j+os][k-c+os] = Math.max(newdp[j+os][k-c+os], dp[j+os][k+os]+d);
				}
			}
			for(int j=0; j<U; j++){
				for(int k=0; k<F; k++){
					dp[j][k] = newdp[j][k];
				}
			}
//			for(int j=-10; j<=20; j++){
//				for(int k=-10; k<=20; k++){
//					System.out.printf("%18s",j+":"+k+":"+dp[j+os][k+os]+"\t");
//				}
//				System.out.println();
//			}
//			System.out.println();
		}
		int max = 0;
		for(int i=os; i<U; i++){
			for(int j=os; j<F; j++){
				max = Math.max(dp[i][j], max);
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 36588
n = gets.to_i
s = gets.chomp.split("")

ans = Marshal.load(Marshal.dump(s))

l, r = 0, 0
s.each do |p|
  case p
  when "("
    l += 1
  when ")"
    r += 1
    
    if r > l
      ans.unshift("(")
      l += 1
    end
  end
end
(r-l).times { ans.unshift("(") }
(l-r).times { ans.push(")") }

puts ans.join

Measured memory_bytes: 1788
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int res[15][15];

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	int cnt[65]={0};
	int ans=0;
	For(i,0,n-1){
		int t; cin>>t;
		For(j,0,59){
			if(t&(1ll<<j)) ans+=(1ll<<j)%MOD*(i-cnt[j]);
			else           ans+=(1ll<<j)%MOD*(cnt[j]);
			if(t&(1ll<<j)) cnt[j]++;
			ans%=MOD;
		}
	}
	cout<<ans<<"\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++)

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

  string x, y;
  cin >> x >> y;
  if (x < y) {
    cout << '<' << endl;
  } else if (x == y) {
    cout << "=" << endl;
  } else {
    cout << ">" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}
ll a[9999] = {0};
void prime_factorize(ll n){
    for(int i = 2;i * i <= n;i++){
        if(n % i != 0) continue;
            ll ex = 0;
            while(n % i == 0){
                ++ex;
                n /= i;
            }
        //cout << i << " " << ex << endl;
        a[i] += ex;
    }
    if(n != 1) a[n]++;//cout << n << " " << 1 << endl;
}


int main(){
    int n; cin >> n;
    for(int i = 1;i <= n;i++){
        prime_factorize(i);
    }
    ll ans = 1;
    for(int i = 2;i <= 9999;i++){
        if(a[i] != 0){
            ans *= a[i]+1;
            ans %= MOD;
        }
    }
    cout << ans;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using lb=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   vvin c(3,vin(3));
           rep(i,0,3)rep(j,0,3)cin>>c[i][j];
           rep(i,0,101)rep(j,0,101)rep(k,0,101){
             vin a(3);
             vin b(3);
             a[0]=i;a[1]=j;a[2]=k;
             b[0]=c[0][0]-a[0];b[1]=c[0][1]-a[0];b[2]=c[0][2]-a[0];
             bool ans=true;
             rep(p,0,3)rep(q,0,3)if(c[p][q]!=a[p]+b[q])ans=false;
             if(ans){
              cout<<"Yes"<<endl;
               return 0;
             }
           }
           cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i=0;4*i<=100;i++)for(int j=0;7*j<=100;j++)if(4*i+7*j==n){cout << "Yes" << endl; return 0;}
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, Q, a, b;
int main() {
	cin >> N >> Q;
	while(Q--) {
		cin >> a >> b; a--, b--;
		cout << min({a, b, N - a - 1, N - b - 1}) % 3 + 1 << endl;
	}
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int f1=0,f2=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C'){
			f1=1;
		}
		else if(s[i]=='F'&&f1==1){
			f2=1;
		}
	}
	if(f1==1&&f2==1){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>
#define e 1000000007
#define PI 3.141592653589793

typedef  long long ll;

int int_cmp(const void *a, const void *b){ 
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib; 
} 


ll int_cmp1(const void *a, const void *b){ 
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib; 
} 



ll max(ll a,ll b){
	if(a<b)
		a=b;
	return a;	
}

ll min(ll a,ll b){
	if(a>b)
		a=b;
	return a;	
}

int absolu(int n){
	if(n<0)
		n*=-1;
	
	return n;	
}


void solve(){ 
	ll a,b,c,d,ans;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	ll 	x=max(a*c,a*d);
	ll y=max(b*c,b*d);
	ans = max(x,y);
	printf("%lld\n",ans);
	
}

int main(){
 /* int t;
	scanf("%d",&t);
	
	while(t--)*/
		solve();
	
	return 0;
}	
	

Measured memory_bytes: 1732
#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>;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  for(int i = a;i <= b;++i){
    if(i%n == 0){
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  return 0;
}


Measured memory_bytes: 3620
n = int(input())
n -= 1

for i in range(1, 15):
    if n >= 26**i:
        n -= 26**i
        continue
    ans = ""
    for j in range(i):
        ans += chr(n%26 + ord("a"))
        n //= 26
    print(ans[::-1])
    break

Measured memory_bytes: 61752
#include<cstdio>
using namespace std;
int main () {
	char a[105];
	bool ok=0;
	scanf("%s",a);
	for(int i=0;a[i];i++){
		if(a[i]=='C')ok=1;
		else if(a[i]=='F'&&ok){
			printf("%s","Yes");
			return 0;
		}
	}
	printf("%s","No");
	return 0;
}

Measured memory_bytes: 128
import math
a, b, C = map(float, input().split())

S = a * b * math.sin(math.radians(C))/2
L = a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C)))
h = S * 2 / a

print("{0:04f}".format(S))
print("{0:04f}".format(L))
print("{0:04f}".format(h))

Measured memory_bytes: 7716
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

// elt.at(x) x の親 (Elternteil)
vector<int> elt;
// 木の深さ
vector<int> tiefe;

// ツリーの初期化
void init( int n ){
	elt.clear();
	tiefe.clear();
	for( int i = 0; i < n; ++i ){
		elt.push_back(i);
		tiefe.push_back(0);
	}
}

// wurz(x) x の根 (Wurzel)
int wurz( int x ){
	if( elt.at(x) == x ){
		return x;
	} else {
		// wurz(elt.at(x)) で親の根を順番に再帰的にたどっていく
		// return wurz(elt.at(x)) でも動作はするが，高速化のために経路の圧縮を行う
		// 再帰的にたどって一番上の根にたどり着いたら，elt.at(x) に根を代入することでノードをその根に付け替える
		// こうすることによって深さが 1 になり，木が大きくなることを防ぐことができる
		return elt.at(x) = wurz(elt.at(x));
	}
}

// kopp(x, y) x と y の木をつなげる (koppeln)
void kopp( int x, int y ){
	// 根に根をつなげるので，まず根を探しに行く
	x = wurz(x);
	y = wurz(y);
	if( x == y ) return;
	// 深さの小さい木に深さの大きい木をくっつければ，深さが大きくなる
	// 深さの大きい木に深さの小さい木をくっつければ，深さが変わらない　←このほうが有利
	if( tiefe.at(x) < tiefe.at(y) ){
		elt.at(x) = y;
	} else {
		elt.at(y) = x;
		// 深さ N と 深さ N ならくっつけてできる木の深さは N+1 になる
		// 深さ 0 と 0 のときは 1 になる
		if( tiefe.at(x) == tiefe.at(y) ){
			++tiefe.at(x);
		}
	}
}

// x と y が同じ木に属しているか
bool gleich( int x, int y ){
	return wurz(x) == wurz(y);
}

int main(){
	int n, m;
	cin >> n >> m;
	int ans = 0;
	vector<pair<int, int>> v;
	for( int i = 0; i < m; ++i ){
		int x, y;
		cin >> x >> y;
		--x; --y;
		v.emplace_back(x, y);
	}
	for( int i = 0; i < m; ++i ){
		init(n);
		for( int j = 0; j < m; ++j ){
			if( j != i ){
				kopp(v.at(j).first, v.at(j).second);
			}
		}
		for( int j = 0; j < n; ++j ){
			if( gleich( j, (j+1) % n ) == false ){
				++ans;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(void)
{
	string str;
	int alpha_count[26] = {0};
	
	//文字列入力
	while(getline(cin, str))
	{

		//文字数のカウント
		for(int i = 0; i < str.length(); i++)
		{
			if( (str[i] >= 'a') && (str[i] <= 'z') )
			{
				int idx = str[i] - 'a';
				alpha_count[idx]++;
			}
			else if( (str[i] >= 'A') && (str[i] <= 'Z') )
			{
				int idx = str[i] - 'A';
				alpha_count[idx]++;
			}
		}
	}

	//文字数の出力
	for(int i = 0; i < sizeof(alpha_count)/sizeof(int); i++)
	{
		cout << char(i + 'a') << " : " << alpha_count[i] << endl;
	}

	return 0;
}




Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    string s;bool flag = true;
    cin>>s;
    int c[27]={};
    rep(i,s.size()){
        int k=s[i]-'a';
        c[k]++;
    }
    rep(i,27){
        if(c[i]%2){
            flag=false;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 1e5+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1,Sahaand=2018;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/
#define int ll
main(){
    fast();per(0);
    //get_fact();
    int n;cin>>n;
    bool ok=1;
    pii p={0,0};
    int t=0;
    for(int i=1;i<=n;i++){
        int tt,x,y;cin>>tt>>x>>y;
        int dis=(abs(p.F-x)+abs(p.S-y));
        if(dis>(tt-t))
            return cout<<"No",0;
        if((tt-t)%2!=(abs(p.F-x)+abs(p.S-y))%2)
            return cout<<"No",0;
        t=tt;
        p={x,y};
    }
    cout<<"Yes";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[110][110], b[1000], c[1000];
int main(){
	int m, n;

	cin >> n >> m;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			a[i][j] = 0;

		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> a[i][j];

		}
	}
	for (int j = 0; j < m; j++){
		b[j] = 0;
	}
	for (int j = 0; j < m; j++){
		cin >> b[j];
	}
	for (int i = 0; i < n; i++){
		c[i] = 0;
	for (int j = 0; j < m; j++){
		c[i] += a[i][j] * b[j];
	}}
	for (int i = 0; i < n; i++){
		cout << c[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
  int N;

  cin >> N;
  vector<pair<int,int>> v;

  for(int i = 0;i < N;i++){
    int X,Y;
    cin >> X;
    cin >> Y;
    v.push_back(make_pair(X,Y));
  }

  double sum = 0;

  for(int i = 0;i < N;i++){
    for(int j = i + 1;j < N;j++){
      
      sum += sqrt((v[i].first - v[j].first)*(v[i].first - v[j].first) + (v[i].second - v[j].second)*(v[i].second - v[j].second));
    }    
  }


  std::cout << std::setprecision(10) << std::fixed << (2*sum/N) << std::endl;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

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

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

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


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


  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;

  if (A1 + A2 + A3 >= 22){
    cout << "bust" << endl;
  } 
  else cout << "win" << endl; 

  return 0;
}



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

int main(){
  string S;
  cin >> S;
  int A=S.size();
  for(int i=0;i<A-1;i++){
    if(S.at(i)==S.at(i+1)){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }
  for(int i=0;i<A-2;i++){
    if(S.at(i)==S.at(i+1) || S.at(i+1)==S.at(i+2) || S.at(i+2)==S.at(i)){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
}
  
  

Measured memory_bytes: 3732
from math import ceil
N = int(input())
t,a = map(int,input().split())
#print(t,a)
for _ in range(1,N):
    T,A = map(int,input().split())
    d = max(-(-t//T),-(-a//A))
    t,a = T*d,A*d
    #print(t,a,d)
print(t+a)

Measured memory_bytes: 73040
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int h = in.nextInt();
        int w = in.nextInt();
        char[][] a = new char[h+1][w+1];
        for(int i = 1; i <= h;i++){
            a[i] = in.next().toCharArray();
        }
        for(int i = 1 ; i <= 2*h ; i++){
            for(int j = 0 ; j < w;j++){
                System.out.print(a[(i+1)/2][j]);
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 29456
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>  
#include <stdlib.h> 
#include <string.h> 
#include <math.h>   


int main(void)
{
    double n;
    scanf("%lf", &n);

    double a, b, c;
    a = n / 3;
    b = n / 3;
    c = n - a - b;

    double ans;
    ans = a * b * c;

    printf("%lf\n", ans);

   

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	string s; cin >> s;
	for (int i = s.size() - 3; i >= 0; i -= 2) {
		bool flg = true;
		for (int j = 0; j <= (i / 2); ++j) {
			if (s[j] != s[j + (i / 2) + 1]) {
				flg = false;
			}
		}
		if (flg) {
			cout << i + 1 << endl;
			return;
		}
	}
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;
use std::io::BufReader;

fn main() {
    let lines = BufReader::new(io::stdin())
        .lines()
        .skip(1)
        .next()
        .unwrap()
        .unwrap()
        .split(' ')
        .step_by(2)
        .filter(|x| x.bytes().last().unwrap() & 1 == 1)
        .count();
    println!("{}", lines);
}


Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
using namespace std;
using ll = long long;

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

	string tmp;
	int res = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (i == 0)
		{
			res++;
			tmp = s.at(i);
			continue;
		}
		if (tmp.at(0) != s.at(i)) res++;
		tmp = s.at(i);
	}

	cout << res << endl;
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    int a, b, c,cont=0;

    cin >> a >> b >> c;

    int aux = b/a;
    int ans = (aux>c) ? c : aux;
    
    cout<< ans <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include<unordered_map>
#include<unordered_set>

using namespace std;
#define IO                 \
	ios::sync_with_stdio(0); \
cin.tie(0);              \
cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define getcurrtime() \
	cerr << "Time = " << ((double)clock() / CLOCKS_PER_SEC) << endl

#define watch(x) cerr << (#x) << " is " << (x) << endl;

#ifndef LOCAL
#define cerr if(false)cerr
#endif
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll P=1e9+7;
double PI=3.141592653589793;
const int arrn = 2e5 + 1;


void solve(){
	int n;
	cin >> n;
	vector<int> in(n);
	forn(i,n) cin >> in[i];
	map<int,int> proc;
	proc[in[0]]=1;
	ll ans=0;
	forse(i,1,n){
		ans+=proc[i-in[i]];
		proc[i+in[i]]++;
	}
	cout << ans ;
}

int main() {
	IO;
	int T=1;
//	cin >> T;
	forn(c,T){
		solve();
	}
}



Measured memory_bytes: 21088