akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF (1e10+5)
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define FRL(i,a,n) for(i=a;i<n;i++)
#define FR(i,n) FRL(i,0,n)
#define RFRL(i,n) for(i=n;i>=0;i--)
#define MOD 998244353
#define fill(a) memset(dp,a,sizeof(dp));
#define all(c) c.begin(),c.end() 
#define rall(c) c.rbegin(),c.rend() 
using namespace std;
//using namespace __gnu_pbds;
//using in = long long int;
//----SHREEJEEB---//
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int  ll;

typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector< pair<ll,ll> > vpi;
typedef set<ll> st;
typedef map<ll,ll> mp;
typedef unordered_map<ll,ll> ump;

template< class T>
T minn(T a,T b)
{
	return (a>b)?b:a;
}
template< class T>
T maxx(T a,T b)
{
	return (a>b)?a:b;
}


void FILE_OP()
{
	#ifndef ONLINE_JUDGE
        freopen("inputf.txt", "r", stdin);
        freopen("outpuf3.txt", "w", stdout);
    #endif
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}




void SOLVE()
{


	int tt,i,j,n,m,k,a,b,c,d;
	ll N,P,K,l;
	
	//cin>>tt;
	tt=1;
	
	
	while(tt--)
	{

		cin>>n;
		int mn=1e9+5;
		int cnt=0;
		while(n--)
		{
			cin>>a;
			mn=minn(mn,a);
			if(a==mn)
				cnt++;
		}
		cout<<cnt<<"\n";

		
	}

}

int main()
{
	FAST_IO
//	FILE_OP();
	SOLVE();

	return 0;
}


Measured memory_bytes: 256
"""AtCoder Beginner Contest 178.

E
"""

import sys


def input() -> str:  # noqa: A001
    """Input."""
    return sys.stdin.readline()[:-1]


def calc(p1: list, p2: list) -> int:
    """Calc Manhattan Distance."""
    return abs(p2[1] - p1[1]) + abs(p2[0] - p1[0])


def main():
    """Run."""
    n = int(input())

    patterns = {
        'lt': (1, 1),
        'rt': (-1, 1),
        'lb': (-1, -1),
        'rb': (1, -1),
    }

    points: dict = {k: None for k in patterns.keys()}

    for _ in range(n):
        p = list(map(int, input().split(' ')))

        for k, (x, y) in patterns.items():
            max_p = points[k]

            if max_p:
                max_p_pos = (max_p[0] * x) + (max_p[1] * y)
                p_pos = (p[0] * x) + (p[1] * y)
                if max_p_pos < p_pos:
                    points[k] = p
            else:
                points[k] = p

    ans = 0
    for i, p1 in enumerate(points.values()):
        for p2 in list(points.values())[i + 1:]:
            ans = max(ans, calc(p1, p2))

    print(ans)


main()


Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N,M;
const int MAX_V=100000;
vector <int> G[MAX_V];
int color[MAX_V];
//頂点を１と−１で塗る
bool dfs(int v,int c){
    color[v] = c;
    bool t=true;
    rep(i, 0, G[v].size()){
        //隣接している頂点が同じ色ならfalse
        if (color[G[v][i]] == c) t=false;
        //隣接している頂点がまだ塗られていないなら-cで塗る
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) t=false;
    }
    //すべて塗れたらtrue
    return t;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M;
    rep(i,0,M){
        int u,v;
        cin>>u>>v;
        u--;
        v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    ll s=0,t=0,k=0;
    rep(i,0,N){
        if(color[i]==0){
            if(sz(G[i])==0) k++;
            else{
                if(dfs(i,1)){
                        s++;
                        t++;
                }
                else{
                    t++;
                }
            }
        }
    }
    cout <<N*N-(N-k)*(N-k)+t*t+s*s<<"\n";
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)


#define needF 101010
ll f[needF+1];//f[x]=x!
void initF() {
    f[0] = 1;
    repd(i,1,needF+1) f[i]=( f[i-1]*i ) % mod;
}

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    ll N,M;
    cin >>N>>M;
    initF();
    ll ans=1;
    if(N==M){
        //ans=N!*M!*2
        ans=f[N];
        ans*=f[M];
        ans%=mod;
        ans*=2;
        ans%=mod;
    }else if(N-1==M || M-1==N){
        //ans=N!*M!
        ans=f[N];
        ans*=f[M];
        ans%=mod;
    }else{
        ans=0;
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int N, ans, res;
    cin >> N;
    res = ans = 0;
    for (int i = N; i >= 1; i--) {
        if (i % 2 != 0) {
            for (int j = 1; j <= N; j++) {
                if (i % j == 0) {
                    ans++;
                }   
            }
        }
        if (ans == 8) {
            res++;
        }
        ans = 0;
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var inputRow, inputCol, inputCorrect int
	fmt.Scanf("%d", &inputRow)
	fmt.Scanf("%d", &inputCol)
	fmt.Scanf("%d", &inputCorrect)

	ret := 0
	row := inputRow
	col := inputCol
	sum := 0
	rowCount := 0
	colCount := 0
	for i := 0; i < 10000; i++ {
		plus, rCount, cCount := selectCount(row - colCount, col - rowCount)
		sum += plus
		rowCount += rCount
		colCount += cCount

		ret++
		if inputCorrect <= sum {
			break
		}
	}
	fmt.Printf("%d\n", ret)
}

func selectCount(row, col int) (add , retRow , retCol int) {
	if row <= 0 && col <= 0 {
		return 0, 0, 0
	}

	if row > col {
		return row, 1, 0
	}
	if col > row {
		return col, 0, 1
	}
	return row, 1, 0
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

int main(){
  int sum=0;
  for(int i=0; i<4; i++){
    int s;
    cin>>s;
    sum+=s;
  }
  int x=sum/60; sum%=60;
  int y=sum;
  cout<<x<<endl<<y<<en
}



Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>

char mas[8][8];

void init() {
  int i, j;
  for(i = 0; i < 8; i++)
    for(j = 0; j < 8; j++)
      mas[i][j] = '.';
}

void out() {
  int i, j;
  for(i = 0; i < 8; i++) {
    for(j = 0; j < 8; j++) putchar(mas[i][j]);
    puts("");
  }
}

int used_r[8];
int used_c[8];
int used_d[2][16];
void dfs(int r, int n) {
  int c;
  if(n == 0) {
    out();
    exit(0);
  }
  if(r == 8) return;

  if(used_r[r]) {
    dfs(r+1, n);
    return;
  }
  for(c = 0; c < 8; c++) {
    if(used_c[c] || used_d[0][r-c+8] || used_d[1][r+c]) continue;
    used_r[r] = used_c[c] = used_d[0][r-c+8] = used_d[1][r+c] = 1;
    mas[r][c] = 'Q';
    dfs(r+1, n-1);
    mas[r][c] = '.';
    used_r[r] = used_c[c] = used_d[0][r-c+8] = used_d[1][r+c] = 0;
  }
}

int main() {
  int n, r, c, i;

  init();  
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d %d", &r, &c);
    mas[r][c] = 'Q';
    used_r[r] = 1;
    used_c[c] = 1;
    used_d[0][r-c+8] = used_d[1][r+c] = 1;
  }
  dfs(0, 8-n);

  return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 100005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007




int main()
{
	FAST;
	ll n;
	cin >> n;
	ll x[n+6], y[n+7];
	ll t[n+6];
	ll h1 = 0;
	ll op = 0;
	bool ans = true;
	for(ll i = 0; i < n; i++){
		cin >> t[i] >> x[i] >> y[i];
		ll h = abs(x[i] + y[i] - op);;
		ll t1 = t[i] - h1;
		if((t1 - h) % 2 != 0 || (t1 - h) < 0){
			ans = false;
		}
		h1 = t[i];
		op = x[i] + y[i];
	}
	if(ans){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

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

using namespace std;

#define watch(x) cout << (#x) << " is " << (x) << endl
#define watchArray(v) for(auto i : v) cout << i << " "; cout << endl;
#define all(v) (v).begin(), (v).end()

#define endl '\n'
#define MAX 100000
#define MOD 100000007
#define INF numeric_limits<int>::max()
#define INFLL numeric_limits<long long int>::max()

typedef long long int lli;
typedef long double ld;

int n;
vector<double> v, dp(3001);

int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  v.resize(n);
  for(auto &i : v) cin >> i;
  dp[0] = 1;

  for(int i = 0; i < n; i++) {
    for(int j = i+1; j >= 0; j--) {
      dp[j] = (j == 0 ? 0 : dp[j-1] * v[i]) + (dp[j] * (1 - v[i]));
    }  
  }

  double ans = 0;
  for(int i = n; i > n/2; i--) {
    ans += dp[i];
  }

  cout << fixed << setprecision(10);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import Data.List
import qualified Data.Set as Set

substrings :: Int -> String -> [String]
substrings k = concatMap (take k . tail . inits) . init . tails

solve :: Int -> String -> String
solve k = (!! (k-1)) . Set.toList . Set.fromList . substrings k

main :: IO ()
main = do
  s <- getLine
  k <- read <$> getLine
  putStrLn $ solve k s


Measured memory_bytes: 4348
import java.util.Scanner;

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

    int n = sc.nextInt();
    switch (n % 10) {
      case 3 :
      System.out.println("bon");
      break;

      case 0 :
      case 1 :
      case 6 :
      case 8 :
      System.out.println("pon");
      break;

      default :
      System.out.println("hon");
      break;
      

    }

  }
}


Measured memory_bytes: 27092
#include<stdio.h>

int bubbleSort(int A[], int N) {
  int cnt = 0;
  for ( int i = 0; i < N; i++ ) {
    for ( int j = N - 1; j > i; j-- ) {
      if ( A[j] < A[j - 1]) {
        int t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
        cnt++;
      }
    }
  }
  return cnt;
}



int main() {
  int N, cnt = 0;
  int A[100];

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

  cnt = bubbleSort(A, N);

  for ( int i = 0; i < N; i++ ) {
    if ( i ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");

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

  return 0;
}



Measured memory_bytes: 2732
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題157

            int[,] a = new int[3, 3];

            for (int i = 0; i < 3; i++)
            {
                string[] line = Console.ReadLine().Split(' ');

                for (int j = 0; j < 3; j++)
                {
                    a[i, j] = int.Parse(line[j]);
                }
            }

            int n = int.Parse(Console.ReadLine());

            int[] b = new int[n];
            for (int i = 0; i < n; i++)
            {
                b[i] = int.Parse(Console.ReadLine());
            }

            int[,] ana = new int[3, 3];

            for (int k = 0; k < n; k++)
            {
                for (int i = 0; i < 3; i++)
                {

                    for (int j = 0; j < 3; j++)
                    {
                        if (a[i, j] == b[k])
                        {
                            ana[i, j] = 1;
                        }
                    }
                }
            }

            //チェック
            //横
            for (int i = 0; i < 3; i++)
            {
                if (ana[i, 0] + ana[i, 1] + ana[i, 2] == 3)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            //縦
            for (int i = 0; i < 3; i++)
            {
                if (ana[0, i] + ana[1, i] + ana[2, i] == 3)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            //斜め
            if (ana[0,0] + ana[1,1] + ana[2,2] == 3)
            {
                Console.WriteLine("Yes");
                return;
            }

            if (ana[2,0] + ana[1,1] + ana[0,2] == 3)
            {
                Console.WriteLine("Yes");
                return;
            }


            Console.WriteLine("No");


        }

    }





    
}


Measured memory_bytes: 27464
#include <stdio.h>
#define N 25
#define EMPTY -1

typedef struct {
  int parent;
  int left;
  int right;
} Node;

int depth[N];
int height[N];
Node node[N];

void depthcount(int x, int d){
  if(x == EMPTY) return;
  depth[x] = d;
  depthcount(node[x].right,d+1);
  depthcount(node[x].left,d+1);
}

int heightcount(int x){
  int h1=0, h2=0;
  if(node[x].right != EMPTY) h1 = heightcount(node[x].right)+1;
  if(node[x].left != EMPTY) h2 = heightcount(node[x].left)+1;
  if(h1 >= h2) return height[x] = h1;
  else return height[x] = h2;
}  

int siblingcount(int x){
  if(node[x].parent == EMPTY) return EMPTY;
  else if(node[node[x].parent].left != EMPTY && node[node[x].parent].left != x) return node[node[x].parent].left;
  else if(node[node[x].parent].right != EMPTY && node[node[x].parent].right != x) return node[node[x].parent].right;
  return EMPTY;
}

int degcount(int x){
  int count=0;
  if(node[x].right != EMPTY) count++;
  if(node[x].left != EMPTY) count++;
  return count;
} 

int main(){
  int i,j,n,l,r,child,root=0,id;

  scanf("%d",&n);
  for(i=0; i<n; i++) {
    node[i].left = EMPTY;
    node[i].right = EMPTY;
    node[i].parent = EMPTY;
  }


  for(i=0; i<n; i++){
    scanf("%d%d%d",&id,&l,&r);
    node[id].left = l;
    node[id].right = r;
    if(l != EMPTY) node[l].parent = id;
    if(r != EMPTY) node[r].parent = id;
  }


  for(i=0; i<n; i++) if(node[i].parent == EMPTY) root = i;
  depthcount(root,0);  //根と深さの数がはいる
  heightcount(root);

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,node[i].parent,siblingcount(i),degcount(i),depth[i],height[i]);
    if(node[i].parent == EMPTY) printf("root\n");
    else if(node[i].left == EMPTY && node[i].right == EMPTY) printf("leaf\n");
    else printf("internal node\n");
  }

  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <stack>
#include <deque>
using namespace std;

struct p {int f; int s;};

int main()
{
	char c;
	int A = 0;
	deque<p> L;
	stack<int> s;

	for (int i = 0; cin >> c; i++)
		if (c == '\\')
			s.push(i);
		else if (c == '/' && !s.empty()) {
			int j = s.top(), a = i - j;
			s.pop();
			A += a;
			while (!L.empty() && L.back().f > j) {
				a += L.back().s;
				L.pop_back();
			}	
			L.push_back({j, a});
		}
	
	cout << A << endl << L.size();
	for (p x: L)
		cout << " " << x.s;
	cout << endl;
}


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

int main() {

  int N;
  int TK;
  int x;
  TK = 0;
  cin >> N;
  x = N;

  while(x > 0){
    TK += x % 10;
    x /= 10;
  }
  if(N % TK == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x)
#define debug(x)
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    int N, K;
    cin >> N >> K;
    vll H(N);
    rep(i, N) cin >> H[i];

    if (K == N) {
        cout << 0 << endl;
        return;
    }
    
    vvll dp;
    initvv(dp, N, N+1, INFL);

    rep(i, N) {
        dp[i][1] = H[i];
    }

    rep(i, N) {
        rep(j, i) {
            rep(k, 1, N+1) {
                mins(dp[i][k+1], dp[j][k] + max(0LL, H[i] - H[j]));
            }
        }
    }

    ll ans = INFL;

    rep(i, N) {
        rep(j, N-K, N+1) {
            mins(ans, dp[i][j]);
        }
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	string s;
	getline(cin,s);
	for(int i=0;i<s.size();i++){
		if(s[i]>=97&&s[i]<=122){
			s[i]-=32;
		}
	}
	cout<<s<<endl;
	return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

constexpr auto M = 1000000007L;

int64_t powm(int64_t x, int64_t y) {
    if (y == 0) {
        return 1;
    }

    if (y == 1) {
        return x;
    }

    int64_t t = powm(x, y / 2);

    return t * t % M * powm(x, y % 2) % M;
}

int main() {
    int64_t n, k;
    cin >> n >> k;

    int64_t ans = 0;
    vector<int64_t> nums(k + 1);
    for (auto g : irange(1L, k + 1) | reversed) {
        nums[g] += powm(k / g, n);
        for (auto gg = 2 * g; gg <= k; gg += g) {
            nums[g] += M - nums[gg];
            nums[g] %= M;
        }
        ans += g * nums[g] % M;
        ans %= M;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4052
n = int(input())
txy = [list(map(int,input().split())) for _ in range(n)]
flag = 0
for i in range(n):
  if txy[i][0]<txy[i][1]+txy[i][2] or (txy[i][1]+txy[i][2])%2 != txy[i][0]%2:
    flag = 1
    print("No")
    break
if flag == 0:
  print("Yes")

Measured memory_bytes: 60504
import std;

long calc(long a, long b, long n) {
    long x = min(b-1, n);
    return a * x / b;
}

void main() {
    long a, b, n; scan(a, b, n);
    writeln(calc(a, b, n));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys
import heapq
import copy
import itertools

inf = float('inf')

def path(u, v):
    return frozenset((u, v))


class Graph_dijkstra(object):
    def __init__(self, V: "List[int]", E: "Set[FrozenSet[int, int]]", L: "Dict[FrozenSet[int, int], int]"):
        self.V = V
        self.E = E
        self.L = L
        self.E_shortest = copy.deepcopy(E)
        self.adjacent = self.init_adjacent() # type: Dict[int: List[int]]
        self.shortest_path = self.init_shortest_path() # type: Dict[FrozenSet[int, int], int]
    
    def init_adjacent(self):
        ret = {v: [] for v in self.V}
        for e in self.E:
            el = list(e)
            ret[el[0]].append(el[1])
            ret[el[1]].append(el[0])
        return ret
    
    def init_shortest_path(self):
        ret = {path(s, g): inf for s, g in itertools.permutations(self.V, 2)}
        for v in self.V:
            ret[path(v, v)] = 0
        return ret
    
    def dijkstra(self, s: int, g: int):
        d = self.shortest_path[path(s, g)]
        if d < inf:
            return d

        D = {v: inf for v in self.V}
        D[s] = 0
        prev = {v: None for v in self.V}
        Q = [(0, s)]

        while len(Q) > 0:
            du, u = heapq.heappop(Q)
            for v in self.adjacent[u]:
                e = path(u, v)
                alt = du + self.L[e]
                if alt < D[v]:
                    D[v] = alt
                    prev[v] = u
                    heapq.heappush(Q, (D[v], v))

        for v in self.V:
            self.shortest_path[path(s, v)] = D[v]

        return self.shortest_path[path(s, g)]


def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    V = list(range(N))
    E = set()
    L = dict()
    
    for i in range(M):
        e = path(a[i], b[i])
        E.add(e)
        L[e] = c[i]

    G = Graph_dijkstra(V, E, L)
    count = 0
    for e in E:
        el = list(e)
        path_len = G.dijkstra(el[0], el[1])
        if path_len < L[e]:
            count += 1
    print(count)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    c = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))-1
        b[i] = int(next(tokens))-1
        c[i] = int(next(tokens))
    solve(N, M, a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5928
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)

n=int(data())
H=list(mdata())
d=[0]*n
d[1]=abs(H[0]-H[1])
for i in range(2,n):
    d[i]=min(d[i-1]+abs(H[i]-H[i-1]),d[i-2]+abs(H[i]-H[i-2]))
print(d[-1])


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

int main(){
	int k, s, z, ans = 0;
	cin >> k >> s;
	rep(i, k+1){
		rep(j, k+1){
			int temp = s - i - j;
			if(temp <= k && temp >= 0){
				ans++;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc129/tasks/abc129_b
#include <bits/stdc++.h>
#define debugi(x) cerr << "x -> " << x << endl;
#define For(i, n) for (__typeof(i) i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define _                             \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

#define ONLINE_JUDGE

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

void solve()
{
    ll i, j, n;
    cin >> n;
    vector<int> arr(n, 0);
    For(i, n)
    {
        cin >> arr[i];
    }
    i = 0;
    j = arr.size() - 1;
    ll sum_1 = 0LL, sum_2 = 0LL;
    while (i <= j)
    {
        if (sum_1 <= sum_2)
        {
            sum_1 += arr[i++];
        }
        else
        {
            sum_2 += arr[j--];
        }
    }
    // debugi(sum_1);
    // debugi(sum_2);
    cout << abs(sum_1 - sum_2) << endl;
}
int main()
{
    _;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ull testcases = 1LL;
    // cin >> testcases;
    while (testcases--)
        solve();
    return 0;
}

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

using namespace std;

int N, K;
string S;
vector<pair<int, int>> v;

int main() {
    cin >> N >> K >> S;
    S += '0';
    bool f = false;
    int a, b;
    v.push_back(make_pair(-1, -1));
    for (int i = 0; i <= N; i++) {
        if (S[i] == '1') {
            if (!f) {
                f = true;
                a = i;
            }
        } else if (S[i] == '0') {
            if (f) {
                f = false;
                b = i - 1;
                v.push_back(make_pair(a, b));
            }
        }
    }
    v.push_back(make_pair(N, N));
    int l = v.size();
    if (l - 1 <= K) {
        cout << N << endl;
        return 0;
    }
    int ans = 0;
    for (int i = 0, j = K; j < l; i++, j++) {
        int a = v[j].second - v[i].first + 1;
        if (i == 0) {
            a--;
        }
        if (j == l - 1) {
            a--;
        }
        ans = max(ans, a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
pair<int,int> p[100010];
priority_queue<int> q;
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++) cin>>p[i].first>>p[i].second;
	sort(p,p+n);
	int i=0;
	for (int j=m-1;j>=0;j--){
		while (i<n&&p[i].first+j<=m) q.push(p[i++].second);
		if (!q.empty()) ans+=q.top(),q.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int n, l;
    cin >> n >> l;

    int ans = 0;
    int bite = 10000;
    FOR(i, 1, n + 1){
        ans += l + i - 1;
        if( abs(bite) > abs(l+i-1)){
            bite = l + i - 1;
        }
    }
    cout << ans - bite << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    
    int W,H,x,y,r;
    int t = 0;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    if(x+r > W || y+r > H){
        t = 1;
    }
    if(x-r < 0 || y-r < 0){
        t = 1;
    }
    if(t==0){
        puts("Yes");
    }else{
        puts("No");
    }
    return(0);
}


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


Measured memory_bytes: 2740
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    string s;
    ll k;
    cin >> k >> s;

    rep(i,0,min((ll)s.size(),k)){
        cout << s[i];
    }

    if(s.size() > k) cout << "...";
    cout << endl;
    return 0;
}

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

// main
int main(){
    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
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from sys import exit

import sys
sys.setrecursionlimit(1000000000)
mod = 998244353

#############
# Main Code #
#############

N, K = getNM()
que = [getList() for i in range(K)]

dp = [0] * (N + 1)
dp[1] = 1
dp[2] = -1

for i in range(1, N + 1):
    dp[i] += dp[i - 1]
    dp[i] %= mod
    for l, r in que:
        if i + l <= N:
            dp[i + l] += dp[i]
        if i + r + 1 <= N:
            dp[i + r + 1] -= dp[i]
print(dp[N] % mod)

Measured memory_bytes: 69792
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

vector<ll> TopologicalSort(ConnectNodeInfo& connect){
	int N=connect.size();
	stack<ll> vertex;
	vector<ll> input(N),sorted;
	REP(i,N){
		for(auto& x:connect[i]) input[x.first]++;
	}
	REP(i,N){
		if(input[i]==0) vertex.push(i);
	}
	while(!vertex.empty()){
		auto v=vertex.top();vertex.pop();
		sorted.push_back(v);
		for(auto& x:connect[v]){
			input[x.first]--;
			if(!input[x.first]) vertex.push(x.first);
		}
	}
	return sorted;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int V=in(),E=in();
	ConnectNodeInfo connect(V);
	REP(i,E){
		int u=in(),v=in();
		connect.AddDirectionalConnection(u,v,1);
	}
	
	auto P=TopologicalSort(connect);

	for(auto& x:P){
		out(x);
	}
	return 0;
}



Measured memory_bytes: 4468
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
using namespace std;
 
int main(){
  while(true){
 	int n;cin>>n;
    if(n==0) return 0;
    int msum=0;
    double mave=0.0,ans=0.0;
 	vector<int> s(n);
  		for(int i=0;i<n;i++){
  			cin>>s.at(i);
          	msum+=s.at(i);
  		}
    	mave=1.0*msum/n;
    	
    	for(int i=0;i<n;i++){
  			ans+=(s.at(i)-mave)*(s.at(i)-mave);
  		}
    		ans=sqrt(ans/n*1.0);
    	printf("%lf\n",ans);    
  }
}



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

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

    int H, W;
    cin >> H >> W;
    vector<string> map(H);
    for (int i = 0; i < H; i++)
    {
        string M;
        cin >> M;
        map.at(i) = M;
    }

    queue<ti> moves;
    //全マスを起点で全探索
    int answer = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(map.at(i).at(j) == '#'){
                continue;
            }
                vector<vector<bool>> alreadyMoved(H, vector<bool>(W, false));
                moves.push(make_tuple(i, j, 0));
                alreadyMoved.at(i).at(j) = true;
                while(moves.size()){
                    ti move = moves.front();
                    moves.pop();
                    int curH, curW, count;
                    tie(curH, curW, count) = move;
                    answer = max(answer, count);
                    int nextH, nextW;
                    //上
                    nextH = curH - 1;
                    nextW = curW;
                    if(0 <= nextH && map.at(nextH).at(nextW) == '.' && !alreadyMoved.at(nextH).at(nextW)){
                        moves.push(make_tuple(nextH, nextW, count + 1));
                        alreadyMoved.at(nextH).at(nextW) = true;
                    }
                    //下
                    nextH = curH + 1;
                    nextW = curW;
                    if(nextH < H && map.at(nextH).at(nextW) == '.' && !alreadyMoved.at(nextH).at(nextW)){
                        moves.push(make_tuple(nextH, nextW, count + 1));
                        alreadyMoved.at(nextH).at(nextW) = true;
                    }
                    //左
                    nextH = curH;
                    nextW = curW - 1;
                    if(0 <= nextW && map.at(nextH).at(nextW) == '.' && !alreadyMoved.at(nextH).at(nextW)){
                        moves.push(make_tuple(nextH, nextW, count + 1));
                        alreadyMoved.at(nextH).at(nextW) = true;
                    }
                    //右                    
                    nextH = curH;
                    nextW = curW + 1;
                    if(nextW < W && map.at(nextH).at(nextW) == '.' && !alreadyMoved.at(nextH).at(nextW)){
                        moves.push(make_tuple(nextH, nextW, count + 1));
                        alreadyMoved.at(nextH).at(nextW) = true;
                    }
                }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

ll dp[100050];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V<ll> w;
    w.push_back(1LL);
    for(ll i=2;i<=n;i++)dp[i]=INF;
    ll cur=6;
    while(cur<=n){
        dp[cur]=1;
        w.push_back(cur);
        cur*=6LL;
    }
    cur=9;
    while(cur<=n){
        dp[cur]=1;
        w.push_back(cur);
        cur*=9LL;
    }
    
    dp[1]=1;
    for(ll i=1;i<n;i++){
        for(ll id:w){
            if(i+id<=n){
                chmin(dp[i+id],dp[i]+1);
            }
        }
    }
    cout<<dp[n]<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 4352
/* ABC168_A
    Stuartyg */

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>


int main(void){
    int n;
    scanf("%d",&n);
    n%=10; /*10で割った余りがnの1の位*/
    switch(n){
        case 3:
            printf("bon\n");
            break;
        case 0:
            printf("pon\n");
            break;
        case 1:
            printf("pon\n");
            break;
        case 6:
            printf("pon\n");
            break;
        case 8:
            printf("pon\n");
            break;
        default:
            printf("hon\n");
            break;
    }
    return 0;
}


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

int main(){
    vector<int> a(5);
    int sum = 0;
    rep(i,5) cin >> a[i];
    vector<int> b(5);
    rep(i,5) b[i] = a[i]%10;
    int cnt;
    for(int i = 1;i < 10;i++){
        for(int j = 0;j < 5;j++){
            if(10-b[j] == i){
                cnt = j;
                break;
            }
        }
    }
    for(int i =0;i < 5;i++){
        if(cnt == i) sum += a[i];
        else{
            sum += a[i];
            if(b[i] != 0) sum += 10-b[i];
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s = to_string(n);
  if(s[0] == '9' || s[1] == '9') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

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


int main() {

	ll a, b, ans = LINF;
	cin >> a >> b;

	for (ll i = a; i <= b; i++) {
		for (ll j = a; j <= b; j++) {
			if (i != j) {
				if ((i * j) % 2019 == 0) {
					cout << 0 << endl;
					return 0;
				}
				ans = min((i * j) % 2019, ans);
			}
		}
	}
	cout << ans << endl;
	return 0;

}

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

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

using namespace std;

int main(void) {
	int N, M; cin >> N >> M;
	bool flag = false;
	vector<int> ans(N, -1);
	rep(i, M) {
		int a, b; cin >> a >> b;
		a--;
		if (ans[a] != -1 && ans[a] != b)flag = true;
		else ans[a] = b;
	}

	if (ans[0] == 0 && N >= 2)flag = true;
	else if (ans[0] == -1) ans[0] = (N >= 2?1:0);

	if (flag)cout << -1 << endl;
	else {
		rep(i, N) cout << (ans[i] != -1 ? ans[i] : 0);
	}
	cout << endl;

	return 0;
}

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

using namespace std;

int CoordinatesOfSprinkler[10][2];
int N;


bool hasWaterInSprinklerRange(int px, int py, int node) {
	int dx[] = { 0,-1,0,1,-1,1,-1,0,1 };
	int dy[] = { 0,-1,-1,-1,0,0,1,1,1 };

	int currentX, currentY;
	for (int i = 0; i < 9; i++) {
		currentX = CoordinatesOfSprinkler[node][0] + dx[i];
		currentY = CoordinatesOfSprinkler[node][1] + dy[i];

		if (currentX < 0 || currentX > 9 || currentY < 0 || currentY > 9) {
			continue;
		}

		if (currentX == px && currentY == py) {
			return true;
		}
	}

	return false;
}

bool surviveMapDataByFrog(int x, int y,int node) {
	//cout << "px:" << x << "  py:" << y << endl;
	//cout << "node:" << node << endl;
	if (node == N) {
		return true;
	}

	int dx[] = { -2,-2,-2,-1,0,1,2,2,2,-1,0,1 };
	int dy[] = { -1,0,1,-2,-2,-2,-1,0,1,2,2,2 };
	int currentPX, currentPY;
	bool hasWater;

	for (int i = 0; i < 12; i++) {
		currentPX = x + dx[i];
		currentPY = y + dy[i];

		if (currentPX < 0 || currentPX > 9 || currentPY < 0 || currentPY > 9) {
			continue;
		}

		hasWater = false;
		if (hasWaterInSprinklerRange(currentPX, currentPY, node)) {
			hasWater = true;
		}
		if (hasWater) {
			if (surviveMapDataByFrog(currentPX, currentPY, node + 1)) {
				return true;
			}
		}
	}
	return false;
}

int main() {
	int px, py;
	bool result;

	while (cin >> px >> py, (px | py)) {
		memset(CoordinatesOfSprinkler, 0, sizeof(CoordinatesOfSprinkler));
		cin >> N;
		for (int i = 0; i < N; i++) {
			cin >> CoordinatesOfSprinkler[i][0]>> CoordinatesOfSprinkler[i][1];
		}
		
		result = surviveMapDataByFrog(px, py, 0);
		if (result) {
			cout << "OK" << endl;
		}
		else {
			cout << "NA" << endl;
		}

	}

	return 0;
}


Measured memory_bytes: 3036
#include <iostream>

using namespace std;

int main(){
  int N, C[20], V[20], D[20], i, TV=0;
  cin >> N;
  
  for(i=0; i<N; i++){
  	cin >> V[i];
  }
  
  for(i=0; i<N; i++){
  	cin >> C[i];
  }
  
  for(i=0; i<N; i++){
  	D[i]=V[i]-C[i];
  }
  
  for(i=0; i<N; i++){
    if(D[i]>0){
      TV+=D[i];
    }
  }

  cout << TV << endl;

  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, y;
  cin >> x >> y;
  vector<int> a = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
  
  if (a[x-1] == a[y-1]) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}

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

using namespace std;

int main(){

	int a , b, c; cin >> a >> b >> c;
	if(a==b && a !=c) cout << "Yes" << endl;
	else if(b==c && a !=c) cout << "Yes" << endl;
	else if(a==c && b!=c) cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

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


def solve(S: str):
    if (S[2] == S[3]) and (S[4] == S[5]):
        print(YES)
    else:
        print(NO)
    return


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

if __name__ == '__main__':
    main()


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, X, a, b, c, xa, xb;
    int count = 0;
    cin >> A >> B >> C >> X;
    a = min(A, X / 500);
    for(int i=a; i>=0; i--){
        xa = X - 500 * i;
        b = min(B, xa / 100);
        for(int j=b; j>=0; j--){
            xb = xa - 100 * j;
            c = min(C, xb / 50);
            for(int k=c; k>=0; k--){
                if((xb - 50 * k) == 0)count++;
            }
        }
    }
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 62;
constexpr double eps = (1e-9);

// [l, r)
int calc(vector<int>& h, const int& l, const int& r) {
  ll ans = 0;
  int mi = INF;
  for (int i = l; i < r; i++) {
    chmin(mi, h[i]);
  }
  for (int i = l; i < r; i++) {
    h[i] -= mi;
  }
  ans += mi;
  for (int i = l; i < r; i++) {
    if (h[i] == 0) continue;
    int j;
    for (j = i; j < r; j++) if (h[j] <= 0) break;
    ans += calc(h, i, j);
    i = j;
  }
  return ans;
}

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

  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int ans = calc(h, 0, n);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
using namespace std;


int main(){

  int n, x;
  cin >> n >> x;

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

  vector<long long int> b(n+2, 0);
  b[0] = a[0];
  for(int i=1; i<n+1; i++){
    b[i] = a[i-1] + a[i];
  }

  long long int ans = 0;
  for(int i=0; i<n; i++){
    if( b[i] > x ){
      long long int tmp = b[i] - x;
      b[i] -= tmp;
      b[i+1] -= tmp;
      ans += tmp;
    }
  }


  cout << ans << endl;


  return 0;
}














// EOF


Measured memory_bytes: 1408
import sys 
from bisect import insort
 
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    jobs = [[] for _ in range(M)]
    
    for _ in range(N):
        A,B = map(int,input().split())
        if A<=M:
            jobs[M-A].append(B)
            
    job_candidate = []
    reward = 0
    
    for i in range(M-1,-1,-1):
        for x in jobs[i]:
            insort(job_candidate,x)
        if job_candidate:
            reward += job_candidate.pop(-1)
            
    print(reward)
            
    
    
if __name__ == "__main__":
    main()


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

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int s1, t1, x, y;
	string s, t, g;
	cin >> s >> t;
	s1 = s.size(); t1 = t.size();
	vector<vector<int>> v(s1+1, vector<int>(t1+1,0));
	for (int i = 1; i <= s1; i++)
		for (int j = 1; j <= t1; j++)
		{
			if (s[i-1] == t[j-1])
				v[i][j] = max(v[i][j],v[i - 1][j - 1] + 1);
			else
				v[i][j] = max(v[i - 1][j], v[i][j - 1]);
		}
	x = s1; y = t1;
	while (v[x][y] != 0)
	{
		if (v[x][y] == v[x][y - 1])
			y--;
		else if (v[x][y] == v[x - 1][y])
			x--;
		else
		{
			g = g + s[x - 1];
			x--; y--;
		}
	}
	if (g.size() == 0)
		cout << "";
	else
		for (int i = g.size() - 1; i >= 0; i--)
		cout << g[i];
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if ( ( a + b ) % 2 > 0 ) {
  cout << ( a + b ) / 2 + 1 << endl;
  }
  else {
  cout << ( a + b ) / 2 << endl;
  }
}

Measured memory_bytes: 256