akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 100000 + 5;

int n , m , u , v , Ans , A[N] , dep[N];

struct Edge
{
    int to ; Edge *nxt;
} E[N << 1] , *pre[N];

void addedge(int u , int v)
{
    static int tot = 0;
    E[++tot] = (Edge){v , pre[u]} , pre[u] = &E[tot];
    E[++tot] = (Edge){u , pre[v]} , pre[v] = &E[tot];
}

void dfs(int u , int fa)
{
    dep[u] = 1;
    for(Edge *i = pre[u] ; i ; i = i->nxt)
    {
        int v = i->to;
        if(v == fa) continue ;
        dfs(v , u); //  , u);
        chkmax(dep[u] , dep[v] + 1);
    }
    if(dep[u] >= m && A[u] != 1)
    {
        Ans++ , dep[u] = 0;
    }
}

int main()
{
    read(n) , read(m);
    rep(i , 1 , n)
    {
        read(v) , u = i ;
        A[i] = v;
        if(i != 1) addedge(v , u);
    }
    if(A[1] != 1) Ans++ , A[1] = 1;
    dfs(1 , 0);
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 9600
n, m = map(int, input().split())
bulbs = []
ans = 0
for i in range(m):
    c = tuple(map(int, input().split()))
    bulbs.append(c[1:])
p = list(map(int, input().split()))
for i in range(2 ** n):
    cnt = 0
    for j, bulbs_sub in enumerate(bulbs):
        switch_on = 0
        for l in bulbs_sub:
            if i >> (l-1) & 1:
                switch_on += 1
        if switch_on % 2 == p[j]:
                cnt += 1
    if cnt == m:
        ans += 1
print(ans)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m, w, h; scanf("%d%d%d%d", &n, &m, &w, &h);
	for (int i = 1; i <= n; i++, puts(""))
		for (int j = 1; j <= m; j++) {
			int t1 = i <= h, t2 = j <= w;
			if (t1 ^ t2) putchar('0');
			else putchar('1');
		}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#define ff              first
#define ss              second
#define ll              int64_t
#define ld              long double
#define nl              cout<<"\n"
#define all(v)          v.begin(),v.end()
#define mset(a,v)       memset((a),(v),sizeof(a))
#define forn(i,a,b)     for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b)     for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

#define mod         1000000007
#define mod2        998244353 
#define inf         1000000000000007
#define pi          3.14159265358979323846

template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)        {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                 {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                   {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)         {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

void dbg_out() {cerr<<"]\n";}
template<typename Head,typename... Tail> 
void dbg_out(Head H,Tail... T) {cerr<<H;if(sizeof...(Tail))cerr<<", ";dbg_out(T...);}
#ifdef LOCAL
	#define dbg(...) cerr<<"["<<#__VA_ARGS__<<"] = [",dbg_out(__VA_ARGS__)
#else
	#define dbg(...)
#endif

ll count_digits(ll n)     {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p)   {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
ll mod_inv(ll a,ll m)     {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}
/* const ll MAXN=1000007;ll spf[MAXN+5];vector<ll> prime; */
/* void sieve(ll n)        {forn(i,2,MAXN+1)spf[i]=i;for(ll i=2;i*i<=n;i++)if(spf[i]==i)for(ll j=i*i;j<=n;j+=i)if(spf[j]==j)spf[j]=i;forn(i,2,MAXN+1)if(spf[i]==i)prime.push_back(i);} */

//-------------------------------L_I_Erq34-------------------------------

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	cin>>n;
	vector<ll> dp(n+1);
	dp[0]=1;
	forn(i,0,n)
		forn(j,3,n+1)
			if(i+j<=n)
				dp[i+j]=(dp[i+j]+dp[i])%mod;
	cout<<dp[n]<<"\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


Measured memory_bytes: 3684
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import deque

n, u, v = map(int, readline().split())
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)


def dfs(v):
    dist = [-1] * (n + 1)
    stack = deque([v])
    dist[v] = 0
    while stack:
        v = stack.popleft()
        memo = dist[v] + 1
        for w in graph[v]:
            if dist[w] >= 0:
                continue
            dist[w] = memo
            stack.append(w)
    return dist


U, V = dfs(u), dfs(v)
ans = 0
for x, y in zip(U[1:], V[1:]):
    if x < y:
        ans = max(ans, y - 1)
print(ans)


Measured memory_bytes: 30324
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    int h, w;
    while(true){
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++){
            if(i % 2 == 0){
                for(int j = 0; j < w / 2; j++){
                    printf("#.");
                }
                if(w % 2 == 1){
                    printf("#\n");
                } else {
                    printf("\n");
                }
            } else {
                for(int j = 0; j < w / 2; j++){
                    printf(".#");
                }
                if(w % 2 == 1){
                    printf(".\n");
                } else {
                    printf("\n");
                }
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3192
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = int(input())
	a = list(map(int,input().split()))
	ans = 0
	for i in a:
		ans += frac(1,i)
	print(1/float(ans))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n],b[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin>>b[i];
	}
	long long s=0LL;
	for (int i = 0; i < n; ++i)
	{
		s+=b[i]-a[i];
	}
	long long cnt1=0LL,cnt2=0LL;
	for (int i = 0; i < n; ++i)
	{
		if (a[i]>b[i])
		{
			cnt2+=a[i]-b[i];
		}
		else if (a[i]<b[i])
		{
			cnt1+=(b[i]-a[i]+1LL)/2LL;
			if ((b[i]-a[i])%2LL!=0LL)
			{
				++cnt2;
			}
		}
	}
	if (cnt1<=s&&cnt2<=s)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int edge[25];
int n;
int dp[1<<22];
#define MOD 1e9+7
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int x;
			cin>>x;
			edge[i]<<=1;
			edge[i]+=x;
		}
	}
	dp[0]=1;
	for(register int i=1;i<1<<n;i++){
		int cnt=n;
		for(register int j=0;j<n;j++){
			if(i&(1<<j)) --cnt;
		}
		for(register int j=0;j<n;j++){
			if(edge[cnt]&i&(1<<j)){
				dp[i]+=dp[i^(1<<j)];
				if(dp[i]>=MOD) dp[i]-=MOD;
			}
		}
	}
	cout<<dp[(1<<n)-1];
	return 0;
}

Measured memory_bytes: 10496
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x, y;
	cin >> x >> y;
	cout << (abs(x-y) <= 1LL ? "Brown" : "Alice") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<bitset>
#define _GLIBCXX_DEBUG

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	int sum = 0;
	sum += N * (N - 1) / 2 + M*(M-1)/2;
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f;

int n,a[100010];

int main()
{
    n=read();
    for(int i=1;i<=n;i++)a[i]=read();
    int A=0,B=0,Anum=0,Bnum=0;
    A=a[1];
    for(int i=2;i<=n;i++)
    {
    	if(a[i]!=A)
    	{
    		if(a[i]==A+1)
    		{
    			B=A;
    			A++;
    		}else
    		if(a[i]==A-1)
    		{
    			B=A-1;
    		}
    		else
    		{
    			printf("No");
    			return 0;
    		}
    	}
    }
    for(int i=1;i<=n;i++)
    {
    	if(a[i]==A)Anum++;
    	if(a[i]==B)Bnum++;
    }
//   printf("A=%d B=%d Anum=%d Bnum=%d\n",A,B,Anum,Bnum);
    if(B==0&&A==n-1)printf("Yes");else{
    if(A-Bnum>Anum/2||(A-Bnum<=0)||Anum==1)printf("No");else printf("Yes");}
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

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

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

int main(void) {
  int n;
  cin>>n;
  vector<int> v;
  vector<int> ans(n);
  for(int i=0; i<n; i++) {
    int x;
    cin>>x;
    v.push_back(x);
  }
  for(int i=0; i<n; i++) {
    ans[v[i]-1] = i+1;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 1784
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
var obj={};
Arr.forEach(function(v){
var arr=v.split(" ");
if(arr[0]=="insert")obj[arr[1]]=true;
if(arr[0]=="find")console.log(obj.hasOwnProperty(arr[1]) ? "yes":"no");
});

Measured memory_bytes: 184252
def main():
    N, A, B = map(int, input().split())
    X = [x for x in map(int, input().split())]
    ans = 0
    for i in range(1, N):
        dist = X[i] - X[i-1]
        if dist*A < B:
            ans += dist*A
        else:
            ans += B
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62832
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a*b > c*d){
		cout << a*b << endl;
	}else{
		cout << c*d << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long>a(3*n);
  int i;
  for(i=0;i<3*n;i++){
    cin >> a[i];
  }
  long ans = 0;
  sort(a.begin(),a.end(),greater<long>());
  for(i=1;i<2*n;i+=2){
    ans += a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
const double PI=3.14159265358979323846;
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
int main(void){
    int n,m;cin>>n>>m;
    vector<pair<int,char>>v(m);
    rep(i, m){
        int s;char c;cin>>s>>c;
        v[i]=make_pair(s,c);
    }
    int ans = -1;
    for(int i= (n!=1)?pow(10, n-1):0;i<pow(10,n);++i){
        string num = to_string(i);
        bool can = true;
        for(auto itr=v.begin();itr!=v.end();++itr){
            if(num[itr->first-1]!=itr->second){can=false;break;}
        }
        if(can){ans = i;break;}
    }
    co(ans);
}



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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error_old(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
#ifdef DEBUG
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {it++;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); }
#else
#define error(args...)
#endif
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

pair<int, string> lcs(string &s, string &t){
    int n = sz(s), m = sz(t);
    vector<vi> dp(n, vi(m, 0));
    vector<vi> jump(n, vi(m, -1));

    rep(i, n){
        rep(j, m){
            if(s[i] == t[j]){
                dp[i][j] = 1;
                if(i > 0 && j > 0){
                    dp[i][j] += dp[i - 1][j - 1];
                }
                jump[i][j] = 0;
            }else{
                if(j > 0){
                    if(dp[i][j] < dp[i][j - 1]){
                        dp[i][j] = dp[i][j - 1];
                        jump[i][j] = 1;
                    }
                }
                if(i > 0){
                    if(dp[i][j] < dp[i - 1][j]){
                        dp[i][j] = dp[i - 1][j];
                        jump[i][j] = 2;
                    }
                }
            }
        }
    }
    string lcsStr;
    int l = n - 1, r = m - 1;
    while(l >= 0 && r >= 0 && jump[l][r] != -1){
       if(jump[l][r] == 1){
           r--;
       }else if(jump[l][r] == 2){
           l--;
       }else if(jump[l][r] == 0){
           error(l, jump[l][r]);
           lcsStr.pb(s[l]);
           l--; r--;
       }
    }
    reverse(all(lcsStr));
    return {dp[n - 1][m - 1], lcsStr};
}

void solve(){
    string s, t;
    cin >> s >> t;
    cout << lcs(s, t).second << endl;
    // cout << lcs(s, t).first << endl;

}

signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    solve();

    return 0;
}


Measured memory_bytes: 141184
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    long N = sc.nextLong();
    long M = sc.nextLong();

    sc.close();

    if (M <= N * 2) {
      System.out.println(M / 2);
    } else {
      System.out.println(N + (M - N * 2) / 4);
    }

  }

}

Measured memory_bytes: 20948
#整数の入力
N = int(input())

#スペース区切りの整数の入力リスト
A_list = list(map(int, input().split()))

A_list = list(reversed(sorted(A_list)))
#print(A_list)



ans  = 0
for i in range(1,2*N,2):
  ans = ans + A_list[i]
print(ans)

Measured memory_bytes: 37084
import java.util.*;
 
public class Main{
	static Scanner in = new Scanner(System.in);
		// int n = in.nextInt();
		// int[] a = new int[n];
		// for(int i = 0; i<n; i++){
		// 	a[i] = in.nextInt();
		// }

		// int min = Integer.MAX_VALUE;
  		// int max = Integer.MIN_VALUE;
 	
	public static void main(String[] args) {
		//zhan
		//dos
		//md
		int test = 1;
		while(test>0){
			solve();
			test--;
		}
	}

	public static void solve(){
		String str = in.next();
		for(char c: str.toCharArray()){
			if(c == 'A') continue;
			if(c == 'C') continue;

			if(Character.isUpperCase(c)){
				System.out.println("WA");
				return;
			}
		}
		if(str.charAt(0) != 'A'){
			System.out.println("WA");
		}else if(str.indexOf("C") == str.lastIndexOf("C") && (str.indexOf("C")>=2 && str.indexOf("C")<=str.length()-2)){
			System.out.println("AC");
		}else{
			System.out.println("WA");
		}
	}
}

Measured memory_bytes: 35580
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

const int MOD = 1e9+7;

ll n, ans;
int main(){
    cin >> n;

    //10^n+8^n-2*9^n
    ll a = 1, b = 1, c = 1;
    rep(_, 0, n) { a *= 10; a %= MOD; }
    rep(_, 0, n) { b *= 8; b %= MOD; }
    rep(_, 0, n) { c *= 9; c %= MOD; }

    ll ans = (a+b-(2*c))%MOD;
    ans = (ans+MOD)%MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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 add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, S;
    cin >> K >> S;
    int ans = 0;
    REP(i, K+1) REP(j,K+1){
        int k = S - (i + j);
        if(k < 0) continue;
        if(k > K) continue;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int A,B,C;
    cin>>A>>B>>C;

    if((A<C&&C<B)||(A>C&&C>B))cout << "Yes" <<endl;
    else cout<<"No" << endl;

    



}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <iterator>
#include <list>
#include <unordered_map>
#include <string>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
	int n, m, sum = 0;
	cin >> n;
	vector<int> t(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	int p, x;
	string ans = "";
	for (int i = 0; i < m; i++) {
		cin >> p >> x;
		cout << sum - t[p-1] + x <<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
# C - 二人のアルピニスト / Two Alpinists
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
T = np.array(lr()).astype('int64')
A = np.array(lr()).astype('int64')
MOD = 10 ** 9 + 7

T_low = T.copy()
T_low[1:][T[1:] <= T[:-1]] = 1
A_low = A.copy()
A_low[:-1][A[:-1] <= A[1:]] = 1

lower = np.maximum(T_low, A_low)
upper = np.minimum(T, A)
domain = np.maximum(0, upper - lower + 1) #変域が0の時は記録が間違い
L = len(domain); LSQ = int(L**.5 + 1) # least squares method 最小二乗推定?
domain = np.resize(domain, LSQ**2) #行列の形に無理やりする下準備（1次元）
domain[L:] = 1 #後半は全部1
domain = domain.reshape((LSQ, LSQ))
for n in range(1, LSQ):
    domain[:, n] *= domain[:, n-1]; domain[:, n] %= MOD
for n in range(1, LSQ):
    domain[n, -1] *= domain[n-1, -1]; domain[n] %= MOD
answer = domain[-1, -1]
print(answer)


Measured memory_bytes: 25076
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [float('inf')]*N
dp[0] = 0
for i in range(N-1):
    for j in range(1,min(K+1,N-i)):
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
print(dp[-1])

Measured memory_bytes: 55008
import sys
from collections import defaultdict
import bisect
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
T = sr()
len_S = len(S)
indexes_S = defaultdict(list)
for i, s in enumerate(S):
    indexes_S[s].append(i)

x = -1 # 今いるところ、次はx+1から探索
for t in T:
    if len(indexes_S[t]) == 0:
        print(-1); exit()
    arr = indexes_S[t]
    y = (x+1) % len_S
    next_i = bisect.bisect_left(arr, y) # tの同じ文字がある次のindex
    if next_i < len(arr):
        x = (x+1) + arr[next_i] - y
    else:
        x = (x+1) + arr[0] + len_S - y # 1周して次のarr

print(x+1)


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

int main() {
  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  
  bool ok = true, over = false, three = false;
  if((a < b && c > d) || (a > b && c < d)) over = true;
  int l = s.size();
  if(a > b) swap(a, b);
  if(c > d) swap(c, d);
  for(int i = a; i < d-1; i++){
    if(s.at(i) == '#' && s.at(i+1) == '#') ok = false;
    if(i >= b-2 && i < c-1){
      if(s.at(i) == '.' && s.at(i+1) == '.' && s.at(i+2) == '.') three = true;
    }
  }
  
  if(over){
    if(!three) ok = false;
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e12;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int N, a[20][20];
int memo[(1 << 16)];
bool check[1 << 16];

int f(itn x) {
    if (check[x])
        return memo[x];
    check[x] = 1;

    int ret = 0;
    FOR(i, 0, N) {
        FOR(j, i + 1, N) {
            if (bit(x, i) && bit(x, j)) {
                ret += a[i][j];
            }
        }
    }
    for (int T = x & (x - 1); T > 0; T = (T - 1) & x) {
        chmax(ret, f(T) + f(x & (~T)));
    }
    return memo[x] = ret;
}

void solve() {
    cout << f((1ll << N) - 1) << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(N)
    FOR(j, N)
    cin >> a[i][j];


    solve();
    return 0;
}


Measured memory_bytes: 896
using System;

class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    if (N == 1)
    {
      Console.WriteLine("Hello World");
    }
    else
    {
      int A = int.Parse(Console.ReadLine());
      int B = int.Parse(Console.ReadLine());
      Console.WriteLine(A + B);
    }
  }
}

Measured memory_bytes: 11092
from heapq import*
L,R=[],[]
n=int(input())
B=0
cnt=0
l,r=0,0
for i in range(n):
    I=input()
    if I[0]=="1":
        a,b,c=map(int,I.split())
        B+=c
        cnt+=1
        
        if cnt%2:
            x=heappushpop(R,b)
            r+=b-x
            heappush(L,-x)
            l+=-x
        else:
            x=heappushpop(L,-b)
            l+=-b-x
            heappush(R,-x)
            r+=-x
        #print(L,R,l,r)
        #print(b,x)
    else:
        med=-L[0]
#        print(L,R)
#        print(l,r)
        print(med,cnt%2*med+B+l+r)

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

int countDivisor(int n) {
	int count = 1;
	int sqr = 0;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			count++;
			if (i * i == n) sqr = 1;
		}
	}
	return 2 * count - sqr;
}

int main()
{
	int n, answer = 0;
	cin >> n;
	for (int i = 1; i <= n; i+=2) {
		int count = countDivisor(i);
		if (count == 8) {
			answer++;
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n;
  cin>>n;
  ll mod = 1e9+7;
  
  ll ans = 1;
  vector<int> v(1001,0); 
  for(int m = 2; m <= n; m++){
    for(int i = 2; i <= m; i++){
      int tmp = m;
      ll cnt=0;
      while(tmp%i==0){
        tmp/=i;
        cnt++;
      }
      cnt%=mod;
      v[i]+=cnt;
      v[i]%=mod;
     
    }
  }
  
  for(int i = 1; i <= n; i++){
    bool flag = true;
    for(int j = 2;j < i; j++){
      if(i%j==0) flag = false;
    }
    if(flag){
    ans*=(v[i]+1);
    ans%=mod;}
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(4);
  for(int i=0;i<4;i++){
    vec.at(i) = n%10;
    n = n/10;
  }
  
  if(vec.at(0) == vec.at(2) && vec.at(1) == vec.at(0)){
    cout << "Yes" << endl;
  }
  else if(vec.at(3) == vec.at(2) && vec.at(1) == vec.at(2)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
use strict;
use warnings;
package SuffixArray;
sub sa_is(\@$);
sub sa_is(\@$){
	my@s=@{$_[0]};
	my$upper=$_[1];
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	$ls[$_]?$sum_l[$s[$_]+1]++:$sum_s[$s[$_]]++for 0..$n-1;
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa=(-1)x$n;
		my@buf=@sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(@sa){
			$sa[$buf[$s[$_-1]]++]=$_-1if$_>=1&&!$ls[$_-1];
		}
		@buf=@sum_l;
		for(reverse@sa){
			$sa[--$buf[$s[$_-1]+1]]=$_-1if$_>=1&&$ls[$_-1];
		}
		return@sa;
	};
	my@lms=grep!$ls[$_-1]&&$ls[$_],1..$n-1;
	my@lms_map=(-1)x($n+1);
	my$m=@lms;
	for(0..$m-1){
		$lms_map[$lms[$_]]=$_;
	}
	@sa=$induce->(@lms);
	if($m){
		my@sorted_lms=grep$lms_map[$_]!=-1,@sa;
		my@rec_s;
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms_map[$l]+1<$m?$lms[$lms_map[$l]+1]:$n;
			my$end_r=$lms_map[$r]+1<$m?$lms[$lms_map[$r]+1]:$n;
			my$same=1;
			if($end_l-$l!=$end_r-$r){
				$same=0;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$same=0if$l==$n||$s[$l]!=$s[$r];
			}
			$rec_upper++if!$same;
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper;
		}
		my@rec_sa=sa_is(@rec_s,$rec_upper);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->(@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(@s,255);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


Measured memory_bytes: 251964
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 1000 + 10, MOD = 1e9 + 7;
int h, w, dp[MAX_N][MAX_N];
char a[MAX_N][MAX_N];

void read_input() {
	cin >> h >> w;
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			cin >> a[i][j];
}

void solve() {
	dp[0][1] = 1;
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			if (a[i][j] == '.')
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
}

void print_output() {
	cout << dp[h][w];
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


Measured memory_bytes: 5248
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <string.h>
#include <unordered_map>
#include <set>
#include <vector>
#include <algorithm>
#define N 10010
using namespace std;
typedef long long ll;

int n,t;
int a[110];

void solve()
{
    int ans = n;
    int sum = 0, mx = 0;
    for(int i = 0; i < t; ++ i){
        if(a[i] > mx){
            mx = a[i];
        }
        sum += a[i];
    }
    if(mx <= sum - mx + 1){
        ans = 0;
    }else{
        ans = 2 * mx - sum - 1;
    }
    cout << ans << endl;
}

int main()
{
    while(cin >> n >> t){
        for(int i=0; i<t; ++i){
            cin >> a[i];
        }
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);


int N, K;
int BK[31];
int BA[100000][31];
ll V[100000];
int F[100000];

int main() {

	// input
	cin >> N >> K;
	for(int d = 0; d <= 30; d++){
		BK[30 - d] = K & 1;
		K = (K >> 1);
	}

	rep(i, N){
		ll a, v; cin >> a >> v;
		V[i] = v;
		for(int d = 0; d <= 30; d++){
			BA[i][30 - d] = a & 1;
			a = (a >> 1);
		}
	}

	// run
	ll ret = 0;
	rep(i, N) F[i] = 1;

	for(int d = 0; d <= 30; d++){
		if(BK[d] == 0){
			rep(i, N) if(BA[i][d] == 1) F[i] = 0;
		}
		else{
			// not use
			ll r = 0;
			rep(i, N) if(BA[i][d] == 0 && F[i] == 1) r += V[i];
			ret = max(r, ret);
		}
	}

	{
		// all use
        ll r = 0;
		rep(i, N) if(F[i] == 1) r += V[i];
		ret = max(r, ret);
	}

	cout << ret << endl;
}

Measured memory_bytes: 13568
#include <stdio.h>

int main(void) {

    int M1 = 0;
    int M2 = 0;
    int D1 = 0;
    int D2 = 0;

    scanf("%d %d", &M1, &D1);
    scanf("%d %d", &M2, &D2);

    if (M1 != M2 && D2 == 1) {
        printf("1\n");
    } else {
        printf("0\n");
    }

    return 0;
}

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

int main(){
	int n,q;
	cin>>n>>q;
	vector<char> s(n+2);
	s[0]='n';
	s[n+1]='n';
	for(int i=1;i<=n;++i) cin>>s[i];
	
	vector<char> t(q),d(q);
	REP(i,q){
		cin>>t[i]>>d[i];
	}
	
	int left=0,right=n+1;
	for(int i=q-1;i>=0;--i){
		if(d[i]=='L'){
			if(t[i]==s[left+1]) left++;//point.
			if(t[i]==s[right]) right++;
		}else{
			if(t[i]==s[right-1]) right--;//point.
			if(t[i]==s[left]) left--;
		}
	}
	
	cout<<max(0,right-left-1)<<endl;
	return 0;
}//解答解説参考.

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    unordered_map<int, int> c;
    rep(i, n) c[a[i]] = 0;
    rep(i, n) c[a[i]]++;

    ll sum = 0;
    for (auto kv: c) {
        int ai = kv.first;
        int ci = kv.second;
        if (ai <= ci) sum += ci - ai;
        else sum += ci;
    }

    put(sum);

    return 0;
}

Measured memory_bytes: 8088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    string s;
    cin >> s;
    int ans = 700;
    if(s.substr(0,1) =="o"){
        ans+=100;
    }
     if(s.substr(1,1)=="o"){
        ans+=100;
    }
     if(s.substr(2,1)=="o"){
        ans+=100;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
a, b, ab, x, y = map(int, input().split())

mn = min(x, y)

ans = 0

ans += min(a * mn + b * mn, 2 * mn * ab)

x -= mn
y -= mn

ans += min(x * a, 2 * x * ab)
ans += min(y * b, 2 * y * ab)

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n;
    ll k;
    ll arr[100010]={};
    cin >> n >> k;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        arr[a]+=b;
    }
    ll now = 0;
    int i=0;
    while(now<k){
        i++;
        now += arr[i];
    }
    cout << i << endl;
    return 0;
}

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

map<int, int> compress(vector<int> v) {
  map<int, int> zip;
  for (int i = 0; i < v.size(); i++) zip[v[i]] = -1;
  int idx = 0;
  for (auto& p : zip) p.second = idx++;
  return zip;
}

int main() {
  int n, w, h;
  cin >> n >> w >> h;
  vector<int> x(n), y(n), d(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> d[i];
  }

  vector<int> xt(2 * n + 2);
  auto fx = [&](int x) { return max(0, min(w, x)); };
  for (int i = 0; i < n; i++) {
    xt[2 * i] = fx(x[i] - d[i]);
    xt[2 * i + 1] = fx(x[i] + d[i]);
  }
  xt[2 * n] = 0;
  xt[2 * n + 1] = w;
  auto mpx = compress(xt);

  vector<int> yt(2 * n + 2);
  auto fy = [&](int y) { return max(0, min(h, y)); };
  for (int i = 0; i < n; i++) {
    yt[2 * i] = fy(y[i] - d[i]);
    yt[2 * i + 1] = fy(y[i] + d[i]);
  }
  yt[2 * n] = 0;
  yt[2 * n + 1] = h;
  auto mpy = compress(yt);

  int sw = mpx.size();
  int sh = mpy.size();
  vector<int> imosx(sw, 0), imosy(sh, 0);
  for (int i = 0; i < n; i++) {
    int sx = fx(x[i] - d[i]);
    int tx = fx(x[i] + d[i]);
    int sy = fy(y[i] - d[i]);
    int ty = fy(y[i] + d[i]);
    imosx[mpx[sx]]++;
    imosx[mpx[tx]]--;
    imosy[mpy[sy]]++;
    imosy[mpy[ty]]--;
  }

  for (int i = 0; i < sw - 1; i++) {
    imosx[i + 1] += imosx[i];
  }
  for (int i = 0; i < sh - 1; i++) {
    imosy[i + 1] += imosy[i];
  }

  bool ans1 = true;
  for (int i = 0; i < sw - 1; i++) ans1 &= (imosx[i] > 0);
  bool ans2 = true;
  for (int i = 0; i < sh - 1; i++) ans2 &= (imosy[i] > 0);
  cout << ((ans1 || ans2) ? "Yes" : "No") << endl;
}



Measured memory_bytes: 14544
using System;

namespace abc119_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split('/');
            int year = int.Parse(array[0]);
            int month = int.Parse(array[1]);
            int day = int.Parse(array[2]);

            if (year < 2019)
            {
                Console.WriteLine("Heisei");
            }
            else if(year == 2019)
            {
                if(month < 5)
                {
                    Console.WriteLine("Heisei");
                }
                else if (month == 0)
                {
                    Console.WriteLine("error");
                }
                else
                {
                    Console.WriteLine("TBD");
                }
            }
            else
            {
                Console.WriteLine("TBD");
            }
        }
    }
}


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

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class CWelcomeToAtCoder {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, M, ac = 0, wa = 0;
        in>>N>>M;
        vc<bool> A(N, false);
        vc<int> W(N, 0);
        while(M--){
            int p;
            string s;
            in>>p>>s;
            p--;
            if(s=="AC"){
                if(not A[p]){
                    ac++;
                    wa += W[p];
                    A[p] = true;
                }
            }else{
                W[p]++;
            }
        }
        out<<ac<<' '<<wa<<'\n';
    }
};


int main() {
	CWelcomeToAtCoder solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3692
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            print(i, j, n - i - j)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, T, dp[3009][6009];
pair<long long, long long> V[1 << 18];

int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) cin >> V[i].first >> V[i].second;
	sort(V, V + N);

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= 6000; j++) dp[i][j] = -(1LL << 60);
	}

	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 6000; j++) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		for (int j = 0; j < T; j++) dp[i + 1][j + V[i].first] = max(dp[i + 1][j + V[i].first], dp[i][j] + V[i].second);
	}

	long long ans = 0;
	for (int i = 0; i <= 6000; i++) ans = max(ans, dp[N][i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, k;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> k;
	ll h[n+1];
	h[0] = 0;
	rep(i, 1, n){cin >> h[i];}

	ll dp[n+1][n+1][k+1];
	rep(i, 0, n){
		rep(j, 0, n){
			rep(ki, 0, k){
				dp[i][j][ki] = INF;			
			}
		}	
	}
	dp[0][0][k] = 0;
	
	rep(i, 1, n){
		rep(j, 0, i){
			rep(ki, max(k-i, 0LL), k){
				if(dp[i-1][j][ki] != INF){
					dp[i][i][ki] = min(dp[i-1][j][ki]+max(h[i]-h[j], 0LL), dp[i][i][ki]);
				}
				if(ki < k && dp[i-1][j][ki+1] != INF){
					dp[i][j][ki] = min(dp[i-1][j][ki+1], dp[i][j][ki]);
				}
			}
		}
	}
	
	//rep(i, 1, n){rep(j, 0, i){rep(ki, 0, k){cout << i << " " << j << " " << ki << " " << dp[i][j][ki] << endl;}}}
	
	ll ans = INF;
	rep(j, 0, n){
		ans = min(dp[n][j][0], ans);
	}
	print(ans)
	return 0;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()
#define pb(a) push_back(a)
#define Yes(a) cout << (a ? "Yes" : "No") << endl
#define yes(a) cout << (a ? "yes" : "no") << endl
#define YES(a) cout << (a ? "YES" : "NO") << endl

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;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;
constexpr int MAX = 200020;

void solve()
{
    int k;
    in(k);
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    out(a[k - 1]);
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      cout<<"OK";
      return 0;
    }
  }
  cout<<"NG";
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double area = r * r * Math.PI;
		double circumference = 2 * r * Math.PI;
		String output = String.format("%6f %6f", area, circumference);
		System.out.println(output);
	}

}

Measured memory_bytes: 28296
#%%
import numpy as np

h, w = map(int, input().split())
s = [[] for _ in range(h)]
for i in range(h):
    s[i] = list(input())
s_0 = np.array(s)
s_90 = np.rot90(s_0)
s_180 = np.rot90(s_90)
s_270 = np.rot90(s_180)

c_0 = np.zeros(h*w).reshape(h,-1)
c_0[s_0 == '.'] = 1
c_90 = np.zeros(h*w).reshape(w,-1)
c_90[s_90 == '.'] = 1
c_180 = np.zeros(h*w).reshape(h,-1)
c_180[s_180 == '.'] = 1
c_270 = np.zeros(h*w).reshape(w,-1)
c_270[s_270 == '.'] = 1


for j in range(1, w):
    c_0[:, j] += c_0[:, j-1] * c_0[:, j]
#print(c_0)

for j in range(1, h):
    c_90[:, j] += c_90[:, j-1] * c_90[:, j]
c_90 = np.rot90(np.rot90(np.rot90(c_90)))
#print(c_90)

for j in range(1, w):
    c_180[:, j] += c_180[:, j-1] * c_180[:, j]
c_180 = np.rot90(np.rot90(c_180))
#print(c_180)

for j in range(1, h):
    c_270[:, j] += c_270[:, j-1] * c_270[:, j]
c_270 = np.rot90(c_270)
#print(c_270)

c = c_0 + c_90 + c_180 + c_270 - 3
print(int(c.max()))


Measured memory_bytes: 254744