akhauriyash/Code-Regression huggingface dataset:
A,B,C,D=map(int,input().split())

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

def lcm(a,b):
    return a*b//gcd(a,b)

cnt_C=B//C-(A-1)//C
cnt_D=B//D-(A-1)//D

lcm_CD=lcm(C,D)
cnt_CD=B//lcm_CD-(A-1)//lcm_CD

ans=(B-A+1)-cnt_C-cnt_D+cnt_CD
print(ans)

Measured memory_bytes: 9116
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;

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

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

	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main() {
    char c;
    cin >> c;
    string vowel = "aeiou";
    for(auto &a: vowel){
        if(a == c){
            cout << "vowel" << "\n";
            return 0;
        }
    }
    cout << "consonant" << "\n";
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int N;
long long int h[100100];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  long long int ans = h[N-1];
  for (int i = N-1; i >= 0; i--) {
    if (h[i] -1 > ans) {
      cout << "No" << endl;
      return 0;
    }
    ans = std::min(h[i], ans);
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    const ll mod=2019;
    ll L,R;
    cin>>L>>R;
    if(R-L>mod){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1e12;
    rep(L,i,R+1){
        rep(i+1,j,R+1){
            ans=min(ans,(i*j)%mod);
            if(ans==0)break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from sys import stdin
from queue import Queue
from math import ceil
inp = lambda : stdin.readline().strip()

X = [0,1,0,-1]
Y = [-1,0,1,0]
def isValid(x,y):
    if x >= 0 and y >= 0 and x < h  and y < w:
        return True
    return False


def dfs_iter(x,y):
    stack = [(x,y)]
    while stack:
        x,y = stack.pop()
        if isValid(x,y) and visited[x][y] == -1 and  maze[x][y] != '#':
            visited[x][y] = curr
            for i,j in zip(X,Y):
                if isValid(x+i,y+j) and visited[x+i][y+j] == -1  and maze[x+i][y+j] != '#':
                    stack.append((x+i,y+j))
def bfs(n):
    stack = Queue()
    stack.put(n)
    depths = Queue()
    depths.put(0)
    ans = 10**9 + 7
    while not stack.empty():
        node = stack.get()
        depth = depths.get()
        if not visited2[node]:
            visited2[node] = True
            if node == visited[dh-1][dw-1]:
                ans = min(ans,depth)
            for child in adj[node]:
                if not visited2[child]:
                    stack.put(child)
                    depths.put(depth+1)
    if ans == 10**9 + 7:
        return -1
    return ans


h, w = [int(x) for x in inp().split()]
ch,cw = [int(x) for x in inp().split()]
dh, dw = [int(x) for x in inp().split()]
visited  = [[-1]*w for x in range(h)]

maze = []
adj = [set() for i in range(ceil(h*w/2))]
visited2 = [False]*(ceil(h*w/2))
for i in range(h):
    maze.append(list(inp()))

curr = 0
ans = []
for i in range(h):
    for j in range(w):
        if visited[i][j] == -1 and maze[i][j] != '#':
            dfs_iter(i,j)
            curr += 1
for i in range(h):
    for j in range(w):
        if maze[i][j] != '#':
            for k in range(-2,3):
                for l in range(-2,3):
                    if not (k==l and l == 0):
                        if isValid(i+k,j + l) and visited[i][j] != visited[i+k][j+l] and maze[i+k][j+l] != '#':
                            adj[visited[i][j]].add(visited[i+k][j+l])

print(bfs(visited[ch-1][cw-1]))

Measured memory_bytes: 192144
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 1000
//<<fixed << setprecision(9)
 
int main()
{
    int n,i,j,t,a;
    boost;
    int b;
    cin>>a>>b;

    if(a<=5) b=0;
    else if(a>12) 
    {
        ;
    }
    else b/=2;
    cout<<b;
    return 0;
}



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

class D
{
	static void Main()
	{
		Func<long[]> read = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
		long[] h = read(), a = read(), b = read(), c = read();
		Console.WriteLine(string.Join("\n", comb(comb(a, b, (int)h[3]), c, (int)h[3])));
	}

	static long[] comb(long[] p, long[] q, int count)
	{
		var r = new long[p.Length * q.Length];
		for (int i = 0, k = 0; i < p.Length; i++)
			for (int j = 0; j < q.Length; j++, k++)
				r[k] = p[i] + q[j];
		Array.Sort(r);
		Array.Reverse(r);
		Array.Resize(ref r, count);
		return r;
	}
}


Measured memory_bytes: 44896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,seki;
  cin >> a >> b;
  seki = a * b;
  if (seki % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())
n = 'No'
if c21-c11 == c22-c12 == c23-c13:
  if c31-c11 == c32-c12 == c33-c13:
    if c12-c11 == c22-c21 == c32-c31:
      if c13-c11 == c23-c21 == c33-c31:
        print('Yes')
      else:
        print(n)
    else:
      print(n)
  else:
    print(n)
else:
  print(n)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#define MAX 1000
void compare(char s1[],char s2[]);
int max(int a,int b);
int c[MAX+1][MAX+1];

int main(void){
	char s1[MAX];
	char s2[MAX];
	int i,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
	scanf("%s%s",s1+1,s2+1);
		s1[0]=s2[0]=' '; //空白を代入する
		compare(s1,s2);
	}
}

int max(int a,int b){
	if(a>b){
		return a;
	}
	return b;
}

void compare(char s1[],char s2[]){
	int i,j;
	int m1,m2;
	m1=strlen(s1)-1;
	m2=strlen(s2)-1;
	
	int maximum=0;
	
	for(i=0;i<m1;i++){
		c[i][0]=0;
	}
	for(j=0;j<m2;j++){
		c[0][j]=0;
	}
	for(int i=1;i<=m1;i++){
		for(int j=1;j<=m2;j++){
			if(s1[i]==s2[j]){
				c[i][j]=c[i-1][j-1]+1;
			}
			else {
				c[i][j]=max(c[i-1][j],c[i][j-1]);
			}
			maximum=max(maximum,c[i][j]);
		}
	}
	
	printf("%d\n",maximum);
}




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


// modint
// 1000000007 で割ったあまりに関する四則演算を直感的に行える
template<int MODULO> struct Fp {
    long long val;

    constexpr Fp(long long v = 0) noexcept : val(v % MODULO) {
        if (val < 0) v += MODULO;
    }
    constexpr Fp operator - () const noexcept {
        return val ? MODULO - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MODULO) val -= MODULO;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MODULO;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MODULO;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MODULO, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MODULO;
        if (val < 0) val += MODULO;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
};

template<int MODULO> constexpr ostream& operator <<
(ostream &os, const Fp<MODULO>& x) noexcept {
    return os << x.val;
}
template<int MODULO> constexpr istream& operator >>
(istream &is, Fp<MODULO>& x) noexcept {
    return is >> x.val;
}

template<int MODULO> constexpr Fp<MODULO> modpow
(const Fp<MODULO> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
}


// 二項係数ライブラリ
template<int MODULO> struct BiCoef {
    vector<Fp<MODULO> > fac, inv, finv;
    constexpr BiCoef(int n) noexcept : fac(n, 1), inv(n, 1), finv(n, 1) {
        for(int i = 2; i < n; i++){
            fac[i] = fac[i-1] * i;
            inv[i] = -inv[MODULO%i] * (MODULO/i);
            finv[i] = finv[i-1] * inv[i];
        }
    }
    constexpr Fp<MODULO> com(int n, int k) const noexcept {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * finv[k] * finv[n-k];
    }
};



// ここから解答
const int MAX = 201010;
const int MOD = 1000000007;
using mint = Fp<MOD>; // mod 計算を直感的に

int main() {
    BiCoef<MOD> bc(MAX); // 二項係数計算の前処理

    long long N, K;
    cin >> N >> K;

    if (K >= N) cout << 1 << endl;
    else cout << 0 << endl;
}



Measured memory_bytes: 7416
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}

int N,M,W,T;
string ss[10];
int vs[10];
int ps[10];
int ls[10];
int xs[10];
int ys[10];
vector<pii> sels[10];
int minDists[1<<7];
// 各町の組み合わせごとに，何がいくらで買えるかをリストアップ
vector<pii> wb[1<<7];
// 今のmaskにおいて，まだWの余裕があるときに獲得できる利益の最大数
int dp1[1<<7][10][10001];
// 現在の時間からえられる最大の利益
ll dp2[10001];

const int INF=1<<30;
int main(){
  while(cin>>N>>M>>W>>T&&(N|M|W|T)){
    map<string,int> dict;
    for(int i=0;i<10;i++)sels[i].clear();
    for(int i=0;i<M;i++){
      cin>>ss[i]>>vs[i]>>ps[i];
      int idx=dict.size();
      if(dict.count(ss[i])==0)dict[ss[i]]=idx;
    }
    for(int i=0;i<N;i++){
      cin>>ls[i]>>xs[i]>>ys[i];
      for(int j=0;j<ls[i];j++){
	int r,q;
	string s;
	cin>>s>>q;
	r=dict[s];
	sels[i].push_back(pii(r,q));
      }
    }
    // 各訪れる町の組み合わせごとの最短コストを求める
    for(int mask=0;mask<(1<<N);mask++){
      vector<int> v;
      for(int j=0;j<N;j++)if((mask>>j)&1)v.push_back(j);
      minDists[mask]=INF;
      do{
	pii cur=pii(0,0);
	int sum=0;
	for(int j=0;j<(int)v.size();j++){
	  sum+=abs(cur.second-xs[v[j]])+abs(cur.first-ys[v[j]]);
	  cur=pii(ys[v[j]],xs[v[j]]);
	}
	sum+=abs(cur.first)+abs(cur.second);
	minDists[mask]=min(minDists[mask],sum);
      }while(next_permutation(v.begin(),v.end()));
    }
    // 各訪れる町ごとに，かえる商品のリストを作成し，DP
    for(int mask=0;mask<(1<<N);mask++){
      map<int,int> m;
      for(int j=0;j<N;j++){
	if((mask>>j)&1){
	  for(int k=0;k<(int)sels[j].size();k++){
	    int idx=sels[j][k].first;
	    int val=sels[j][k].second;
	    if(val<ps[idx]){
	      if(m.count(idx)==0)
		m[idx]=ps[idx]-val;
	      else
		m[idx]=max(m[idx],ps[idx]-val);
	    }
	  }
	}
      }
      for(map<int,int>::iterator it=m.begin();it!=m.end();it++)
	wb[mask].push_back(pii(it->first,it->second));
    }
    // 各訪れる町の組み合わせごとに，ある重みWにおいて，買うことのできる最大の利益を求めておく
    for(int mask=0;mask<(1<<N);mask++){
      for(int i=wb[mask].size();i>=0;i--){
	for(int j=0;j<=W;j++){
	  int res=0;
	  if(i!=(int)wb[mask].size()){
	    res=max(res,dp1[mask][i+1][j]);
	    if(j-vs[wb[mask][i].first]>=0)
	      res=max(res,dp1[mask][i][j-vs[wb[mask][i].first]]+wb[mask][i].second);
	  }
	  dp1[mask][i][j]=res;
	}
      }
    }
    // for(int i=0;i<(1<<N);i++){
    //   cout<<dp1[i][0][W]<<endl;
    // }
    // for(int mask=0;mask<(1<<N);mask++){
    //   cout<<minDists[mask]<<endl;
    // }
    //cout<<T<<endl;
    // 時間Tにおいて，どのmaskを選べば最大の利益を選べるかを行うDP
    for(int i=0;i<=T;i++){
      ll res=0;
      for(int mask=0;mask<(1<<N);mask++)
	if(i-minDists[mask]>=0)res=max(res,dp2[i-minDists[mask]]+dp1[mask][0][W]);
      dp2[i]=res;
    }
    cout<<dp2[T]<<endl;
  }
  return 0;
}

Measured memory_bytes: 40000
n, m = map(int, input().split())
path = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    path[a].append(b)
    path[b].append(a)

q = [1]
visited = [-1] * (n + 1)

visited[1] = 0
while q:
    node = q.pop(0)
    for i in path[node]:
        if visited[i] == -1:
            q.append(i)
            visited[i] = node

if any([True for v in visited[2:] if v == -1]):
    print("No")
else:
    print("Yes")
    for v in visited[2:]:
        print(v)


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

using namespace std;
const int Max = 1e4 + 5;
int n, x, y, a[Max];

int main() {
    cin>>n>>x>>y;
    for (int i = 1; i <= n - 1; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dis = j - i;
            dis = min(dis, abs(i - x) + abs(j - y) + 1);
            a[dis]++;
        }
    }
    for (int i = 1; i <= n - 1; i++)
       cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

s = [0]*(n+1)
for i in range(len(a)):
    s[i+1]=s[i]+a[i]

case1 = 0
now = 0
for i in range(n):
    now += a[i]
    if i%2 == 0:
        if now < 0:
            continue
        else:
            case1 += abs(now)+1
            now = -1

    else:
        if now > 0:
            continue
        else:
            case1 += abs(now)+1
            now = 1

case2 = 0
now = 0
for i in range(n):
    now += a[i]
    if i % 2 == 1:
        if now < 0:
            continue
        else:
            case2 += abs(now) + 1
            now = -1

    else:
        if now > 0:
            continue
        else:
            case2 += abs(now) + 1
            now = 1

print(min(case1,case2))

Measured memory_bytes: 14468
import java.util.Scanner;
public class Main {
 public static void main(String[] a) {
   Scanner in = new Scanner(System.in);
   char[] s = in.next().toCharArray();
   if (s[2] == s[3] && s[4] == s[5]) {
     System.out.println("Yes");
   }
   else {
     System.out.println("No");
   }
 }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
	string s;
	cin >> s;
    if(s.size()>=4){
	    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
	     cout << "Yes"<<endl;
    	}else{
	     cout << "No" <<endl;
    	}
    }else{
        cout << "No" <<endl;
    }
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		for (char s : sc.next().toCharArray()) {
			if (s == '+') {
				ans++;
			} else {
				ans--;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int a;
    string s;

    cin >> a;
    cin >> s;

    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 888
n=int(input())
a=map(int,raw_input().split(' '))
n=len(a)
ans=0
while 1 :
    k=0
    for i in xrange(1,n) :
        if a[i]>a[k] :
            k=i
    if a[k]<n :
        break
    t=a[k]/n
    ans+=t
    for i in xrange(n) :
        a[i]+=t
    a[k]-=t*(n+1)

print ans


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

using namespace std;

const int md=1000000007;

int fac[8009],inv[8009];
int f[4005][4005];
int a[200005];
int b[200005];
int ans,n;

inline long long qpow(long long a,int b)
{
    long long ret=1;
    while(b)
    {
        if(b&1)
            ret=ret*a%md;
        a=a*a%md;
        b>>=1;
    }
    return ret;
}

inline int c(int n,int m)
{
    return 1ll*fac[n]*inv[m]%md*inv[n-m]%md;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",a+i,b+i);
        f[2001-a[i]][2001-b[i]]++;
    }

    for(int i=1;i<4002;i++)
        for(int j=1;j<4002;j++)
            f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%md;   

    fac[0]=1;
    for(int i=1;i<=8002;i++)
        fac[i]=1ll*fac[i-1]*i%md;
    inv[8002]=qpow(fac[8002],md-2);
    for(int i=8001;i>=0;i--)
        inv[i]=1ll*inv[i+1]*(i+1)%md;

    for(int i=0;i<n;i++)
        ans=(ans+f[2001+a[i]][2001+b[i]])%md;
    for(int i=0;i<n;i++)
        ans=((ans-c((a[i]+b[i])<<1,b[i]<<1))%md+md)%md;

    ans=(500000004ll*ans)%md;
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 64512
#include<iostream>

using namespace std;

int a[100], n;
long long int dp[100][21];

int main()
{
	cin >> n;

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

	dp[0][a[0]] = 1;

	for (int i = 1; i < n - 1; i++)
	{
		for (int j = 0; j < 21; j++)
		{
			if (0 <= j + a[i] && j + a[i] <= 20)
			{
				dp[i][j + a[i]] += dp[i - 1][j];
			}
			if (0 <= j - a[i] && j - a[i] <= 20)
			{
				dp[i][j - a[i]] += dp[i - 1][j];
			}
		}
	}

	cout << dp[n - 2][a[n - 1]] << endl;
	return 0;
}

Measured memory_bytes: 1172
n = list(input())
ans = 0
for i in range(2**(len(n)-1)):
    plus = [""]*(len(n))
    fomula = ""
    for j in range(len(n)-1):
        if(i>>j & 1):
            plus[j] = "+"
    for i in range(len(n)):
        fomula += n[i] + plus[i]
    ans += eval(fomula)
print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define l long long
#define c continue
using namespace std;
int main(){l m=1e9+7,x,y,z,w,o,p,q,v[93],t[91][91][2],a,b;v[0]=1,v[1]=1;for(l i=2;i<93;i++)v[i]=v[i-1]+v[i-2];for(l i=2;i<91;i++){for(l j=1;j<i;j++){a=v[i],b=v[i+1];if(j<2){t[i][0][0]=a,t[i][0][1]=b,t[i][j][0]=b,t[i][j][1]=2*b-a;c;}t[i][j][0]=t[i-1][j-1][1],t[i][j][1]=t[i-1][j-1][1]+t[i-1][j-1][0];}}cin>>q;while(q--){cin>>x>>y;if(x>y)swap(x,y);if(y<2){cout<<"1 1\n";c;}for(l i=0;i<93;i++){if(v[i]>x||v[i+1]>y){z=i-1;break;}}cout<<z<<" ";if(z<2){cout<<x*y%m<<" ";c;}w=0;for(l j=0;j<z;j++){o=t[z][j][0],p=t[z][j][1];if(o>x||p>y)c;w+=(y-p)/o+1;if(x>=p)w+=(x-p)/o+1;}cout<<w%m<<" ";}}

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main(void){
    int n,a[100001]={0};
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int b=1,c=-1;
    for(int i=0;i<n;i++){
        b=a[b];
        if(b==2){
            c=i+1;
            i=n;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define loop(I, N) for(int I = 1; I <= N; I++)
#define pool(I, N) for(int I = N; I >= 1; I--)
#define rep(I, N) for(int I = 0; I < N; I++)
#define per(I, N) for(int I = N - 1; I >= 0; I--)
#define FOR(I, L, R) for(int I = L; I <= R; I++)
#define FOD(I, R, L) for(int I = R; I >= L; I--)
#define SET(P, VAL) memset(P, VAL, sizeof(P));

int n, x[100005], y[100005], t[100005], cx = 0, cy = 0;
int main() {
	scanf("%d", &n);
	loop(i, n) scanf("%d%d%d", &t[i], &x[i], &y[i]);
	x[0] = y[0] = t[0] = 0;
	loop(i, n) {
		int dst = x[i] - x[i - 1] + y[i] - y[i - 1];
		if(dst <= t[i] - t[i - 1] && (t[i] - t[i - 1] - dst) % 2 == 0) continue;
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int i,a;
	int array[10000];

	

	for ( i = 0; ( i < 10000); i++){
		scanf("%d", &array[i]);
		if (array[i] == 0) {
			break;
		}
	}
	for (i = 0; (i < 10000); i++) {
		if (array[i] == 0) {
			break;
		}
		printf("Case %d: %d\n", i+1, array[i]);
	}
	return 0;
}


Measured memory_bytes: 1992
n = gets.to_i
a = gets.split.map(&:to_i).sort!

max_v = a.max

check = Array.new(max_v + 1, true)

a.each_with_index do |x, i|
  t = 2
  if i > 0 && a[i] == a[i - 1]
    t = 1
  end

  while x * t <= max_v do
    check[x * t] = false
    t += 1
  end
end

ans = 0
a.each do |x|
  ans += 1 if check[x]
end

puts ans

Measured memory_bytes: 36992
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int[] cost = new int[sc.nextInt()];
			int m = sc.nextInt();

			for(int i = 0; i < cost.length; i++) {
				cost[i] = sc.nextInt();
			}
			int[] vote = new int[cost.length];
			for(int j = 0; j < m; j++) {
				int base = sc.nextInt();
				for(int i = 0; i < cost.length; i++) {
					if(cost[i] <= base) {
						vote[i]++;
						break;
					}
				}
			}
			int max = 0;
			int max_index = 0;
			for(int i = 0; i < vote.length; i++) {
				if(max < vote[i]) {
					max = vote[i];
					max_index = i;
				}
			}
			System.out.println(max_index + 1);
		}
	}
}


Measured memory_bytes: 33908
#include <iostream>
#include <string>
#include <list>
#include <cstring>

#define USE_SET

int main(void) {
  int K;

  std::string str;

  std::string s_;
  std::cin >> s_;
  const char* s = s_.c_str();

  std::cin >> str;
  K = std::stoi(str);

  size_t lsize = 0;
  size_t len = s_.length();

#if defined(USE_SET)
  typedef struct s_set {
    int pos;
    int len;

    s_set(int i, int j) : pos(i), len(j) {
    }
  } set;
#endif

#if defined(USE_SET)
  std::list<set> wlist;
  wlist.push_back(set(0, 1));
#else
  std::list<std::string> wlist;
  wlist.push_back(s_.substr(0, 1));
#endif

  for (int a = 'a'; a <= 'z' && lsize < K; ++a) {        /* a to z   */
    for (int b = 'a'; b <= 'z' && lsize < K; ++b) {      /* a to z   */
    for (int c = 'a'; c <= 'z' && lsize < K; ++c) {      /* a to z   */
      for (int i = 0; i < len; ++i) {                    /* 0 to len */
        if (s[i] == a && (i+1 >= len || (s[i+1] == b && (i+2 >= len || s[i+2] == c)))) {
          for (int j = 1; j <= len - i && j <= K; ++j) {           /* length 1 to len - i */
            for (auto itr = wlist.begin(); itr != wlist.end(); ++itr) {
#if defined(USE_SET)
              int cmp = s_.compare(i, j, s_, itr->pos, itr->len);
#else
              int cmp = s_.compare(i, j, *itr);
#endif
              if (cmp == 0) {
                break;
              }
              if (cmp < 0) {
#if defined(USE_SET)
                wlist.insert(itr, set(i, j));
#else
                wlist.insert(itr, s_.substr(i, j));
#endif
                lsize++;
                break;
              }
#if defined(USE_SET)
              if (cmp > 0 && (itr->pos == wlist.rbegin()->pos && itr->len == wlist.rbegin()->len)) {
                wlist.push_back(set(i, j));
#else
              if (cmp > 0 && itr->c_str() == wlist.rbegin()->c_str()) {
                wlist.push_back(s_.substr(i, j));
#endif
                lsize++;
                break;
              }
            }
          }
        }
      }
    }
    }
  }

  size_t idx = 0;
  for (auto &str : wlist) {
    idx++;
    if (idx == K) {
#if defined(USE_SET)
      //std::cout << str.pos << "," << str.len << std::endl;
      std::cout << s_.substr(str.pos, str.len) << std::endl;
#else
      std::cout << str << std::endl;
#endif
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string tap;
  cin>>tap;
  int i,even_flag=1,odd_flag=1;
  for(i=0;i<tap.length();i++){
    if(tap[i]!='L'){
    }
    else{
      even_flag=0;
    }
    i++;
    if(tap[i]!='R'){
    }
    else{
      odd_flag=0;
    }
  }
  if(odd_flag && even_flag){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
using namespace std;

void call(int n)
{
  for(int i=1;i<=n;i++){
    int x=i;
    if(x%3 == 0)
      cout << " " << i;
    else
      while(x){
	if(x%10 == 3){
	  cout << " " << i;
	  break;
	}else
	  x/=10;
      } 
  }
  cout<<endl;
}



int main()
{
  int n;
  cin>>n;
  call(n);
  return 0;
}



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

//整数を各桁の数値に分解したベクトルを返す（桁数の若い順に出力)
vector<int> getOrders(long long value) {
	vector<int> v;
	long long x = value;
	while (x > 0) {
		v.push_back(x % 10);
		x /= 10;
	}
	return v;
}


int main() {
	int N, K;
	set<int> D;
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		int x;  cin >> x; D.insert(x);
	}

	int pay = N;
	while (true) {
		
		vector<int> v= getOrders(pay);
		bool existDislike = false;
		for (int i : v) {
			if (D.count(i) > 0) {
				existDislike = true;
				break;
			}
		}

		if (!existDislike) break;
		pay++;
	}

	cout << pay << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N, M; cin >> N >> M;
  vector<ll> k(M);
  vector<vector<ll> > s( M , vector<ll>(N) ) ;
  rep(i,M){
    cin >> k[i];
    rep(j,k[i]){
      cin >> s[i][j];
      s[i][j] --;
    }
  }
  vector<ll> p(M);
  rep(i,M) cin >> p[i];
  ll ans = 0;

  rep(i, (1 << N) ){
    // switchの状態
    vector<ll> swi(N);
    rep(j , N){
      if( (i >> j) % 2) swi[j] = 1;
    }
    // それぞれの計算
    vector<ll> score(M);
    rep(j , M){
      rep(l, k[j]){
        score[j] += swi[ s[j][l] ];
      }
    }
    // cout << i << " " << score[0] << " " << score[1] << " " << swi[0] << endl;
    bool check = true;
    rep(j, M){
      if(score[j] %2 != p[j]) check = false;
    }
    if(check){
      // cout << i << " " << score[0] << " " << score[1] << " " << endl;
      ans ++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;

const int mx=200010;
const ll mod=1e9+7;

int n,a,b;

int main(){
  cin >> n >> a >> b;

  cout << min(a,b) << " " << max(a+b-n,0) << endl;
  return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll a, b; cin >> a >> b;
  if (b % a == 0) {
    cout << a + b << endl;
  }else {
    cout << b - a << endl;
  }

  return 0;
}



Measured memory_bytes: 3540
import java.util.Scanner;

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

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long k = sc.nextLong();

		long ans = 0;

		if (k <= a) {
			ans = k;
		} else if (k <= a + b) {
			ans = a;
		} else if (k <= a + b + c) {
			ans = 2 * a - k + b;
		} else {
			ans = a - c;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 27076
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on





auto Main() {
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	auto c = abs(b-a);

	auto x=v*t;
	auto y=c+w*t;
	if(x>=y) cout<<"YES";
	else cout<<"NO";
	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 3648
fun main(args: Array<String>) {
    val MOD = 1000000007L
    val dp = linkedMapOf<Pair<Long, Long>, Long>()
    fun f(S: Long, X: Long): Long {
        val d = dp[S to X]
        if (d != null) return d!!
        if ((S == 0L && X == 0L) || (S == 1L && X == 0L) || (S == 0L && X == 1L)) return 1
        var ans = f(S / 2, X / 2) % MOD
        if (S >= 1 && X >= 1) ans = (ans + f((S - 1) / 2, (X - 1) / 2)) % MOD
        if (S >= 2) ans = (ans + f((S - 2) / 2, X / 2)) % MOD
        dp[S to X] = ans
        return ans
    }
    val N = nextLong()
    val ans = f(N, N)
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()


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

#define F first
#define FF first.first
#define FS first.second
#define S second
#define SF second.first
#define SS second.second
#define ii pair<int,int>
#define iii pair<ii, int>
#define iiii pair<ii, ii>
#define viiii vector< iiii >
#define viii vector< iii >
#define vii vector< ii >
#define vi vector< int >
#define vvi vector<vector< int > >
#define int long long

#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define pb push_back
#define FOR(v, i, l) for(int v = i; v < (int)l; ++v)
#define REP(v, l) FOR(v, 0, l)

#define EPS 1e-6
#define oo (1LL<<60)
#define MAX 1000000000000000000LL
#define MOD 1000000007LL
#define debug(x) cout << #x << " is " << x << "\n";

const int dx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int dy[8] = {2, -2, 2, -2, 1, -1, 1, -2};

int PAsum(int in, int fi, int s){
   if(fi<in)return 0;
   return ((in+fi)*(1+(fi-in)/s))/2LL;
}

int modPow(int x, int y, int mod = MOD){
   int ans = 1;
   while( y ){
      if(y%2){
         ans = (ans*x)%mod;
      }
      x = (x*x)%mod;
      y /= 2;
   }
   return ans;
}

int countBit(int x){
   int ans  = 0;
   while(x){
      ans += (x%1);
      x /= 2;
   }
   return ans;
}

int N, M, K, L, R, J, P, CASES;
int A,B,C,D;

main(){
   cin >> N >> M;

   set<int> S;
   for(int i = 0; i < M; i++){
      int x;
      cin >> x;
      S.insert(x);
   }
   int ans = 0;
   for(int i = 0; i <= 100; i++){
      if( !S.count(N-i) ){
         ans = N-i;
         break;
      }
      if( !S.count(N+i) ){
         ans = N+i;
         break;
      }
   }
   printf("%lld\n", ans);
}

/*

*/


Measured memory_bytes: 3724
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

n = int(input())
D = [list(map(int,readline().split())) for i in range(n)]

cnt = 0

for (a,b) in D:
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if (cnt == 3):
        print("Yes")
        exit()
print("No")



Measured memory_bytes: 9440
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	cout <<  s<< endl;
}

Measured memory_bytes: 1176
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

#define PB push_back
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef vector<int> Vi;

void init();
void bfs(int org, vector<int>& d);

int n;
Vi opt, dp;

int main()
{
	init();

	bfs(0, dp);

	cout << dp[n] << endl;
}

void init()
{
	cin >> n;

	dp.resize(n + 1, -1);

	opt.PB(1);
	for (int x = 6; x <= n; x *= 6)
		opt.PB(x);
	for (int x = 9; x <= n; x *= 9)
		opt.PB(x);

	sort(ALL(opt), greater<>());
}


void bfs(int org, vector<int>& d)
{
	d[org] = 0;
	queue<int> que;
	que.push(org);

	while (!que.empty())
	{
		int v = que.front();
		que.pop();

		for (int x : opt)
			if (v + x <= n)
				if (dp[v + x] == -1)
				{
					dp[v + x] = dp[v] + 1;
					que.push(v + x);
				}
	}
}

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

int main() {
  int n; cin >> n;
  vector<int> ans(n);
  rep(i, n-1) {
    int a; cin >> a; a--;
    ans[a]++;
  }
  rep(i, n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 4052
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  string s;
  cin >> s;
  vector<char> o(s.length(), 'x');
  cout << string(o.begin(), o.end()) << endl;
}


Measured memory_bytes: 3124
#include <stdio.h>

int main(void)
{
    int N, M, C, i;
    scanf("%d%d%d", &N, &M, &C);

    int b[M], a[N][M];

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

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

    int ans = 0;
    for ( i = 0; i < N; i++)
    {
        int sum = 0;
        for (int j = 0; j < M; j++)
        {
            sum += a[i][j] * b[j];
        }
        if(sum + C > 0)
            ans++;
        }

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

        return 0;
}

Measured memory_bytes: 128
begin
  input_line = []
  while line = $stdin.gets.chomp
    break if line == ""
    input_line.push(line.split(" "))
  end
rescue
end

input_line = input_line.first.map{|i| i.to_i }

if (input_line[2] < 0) || (input_line[3] < 0)
  puts "No"
elsif (((input_line[2] + input_line[4]) <= input_line[0]) && ((input_line[3] + input_line[4]) <= input_line[1])
    ) && ((input_line[2] - input_line[4]) >= 0) && ((input_line[3] - input_line[4]) >= 0)
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8684
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<cmath>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;
 
int main()
{
int n,i; cin >> n;
	for ( i = 1;; i *= 2)
	{
		if (i * 2 > n)
			break;
	}
	cout << i;
return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

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

Measured memory_bytes: 572
import sys
sys.setrecursionlimit(10 ** 7)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def SI(): return input()


def main():
    N, X = LI()
    L = LI()
    now = 0
    count = 1
    for l in L:
        now += l
        if now > X:
            break
        count += 1
    print(count)


main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 112345;
int dp[MAXN], h[MAXN];
int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 1; i<=n; ++i) {
        scanf("%d", h+i);
        dp[i] = INF;
    }
    dp[1] = 0;
    for (int i = 1; i<=n; ++i) {
        for (int j = 1; j<=k && i+j<=n; ++j) {
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    printf("%d\n", dp[n]);
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		int A[] = new int[N];
		int sum = 0;

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}

		if (sum < H) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 49992
import java.util.*;

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

        S = S.replace("eraser",  "");
        S = S.replace("erase",   "");
        S = S.replace("dreamer", "");
        S = S.replace("dream",   "");
        if (S.length() == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 28756
def main():
    n,d = map(int,input().split())
    counter = 0
    for i in range(n):
        x,y = map(int,input().split())
        if x ** 2 + y ** 2 <= d**2:
            counter += 1

    print(counter)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 12 01:49:19 2020

@author: Kanaru Sato
"""

n = int(input())
s = input()

if n%2 != 0:
    print("No")
else:
    firsthalf = s[0:n//2]
    secondhalf = s[n//2:n]
    if firsthalf == secondhalf:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 2940
S = input()

b_cumsum = [0] * len(S)
now = 0
for i in range(len(S)):
    if S[i] == "B":
        b_cumsum[i] = now + 1
        now += 1
    else:
        b_cumsum[i] = now

S = S[::-1]
b_cumsum = b_cumsum[::-1]
ans = 0
for i, s in enumerate(S):
    if s == "W":
        ans += b_cumsum[i]

print(ans)


Measured memory_bytes: 12580
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define llong long long
#define ldouble long double
#define uint unsigned int
#define ullong unsigned long long
#define udouble unsigned double
#define uldouble unsigned long double
#define modinc(x) {if(x>=P) x-=P;}
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define piiii pair<pair<int,int>,pair<int,int> >
#define pli pair<llong,int>
#define pll pair<llong,llong>
#define Memset(a,x) {memset(a,x,sizeof(a));}
using namespace std;

const int N = 1e6;
char a[N+3];
int que[N+3];
int n,q;

int main()
{
	scanf("%d",&n);
	scanf("%s",a+1);
	scanf("%d",&q);
	for(int cas=1; cas<=q; cas++)
	{
		int m; scanf("%d",&m);
		llong ans = 0ll; int head = 1,tail = 0; llong cur = 0ll,numd = 0ll,numm = 0ll;
		for(int i=1; i<=n; i++)
		{
			while(head<=tail && i-que[head]>=m)
			{
				if(a[que[head]]=='D')
				{
					cur -= numm;
					numd--;
				}
				else if(a[que[head]]=='M')
				{
					numm--;
				}
				head++;
			}
			if(a[i]=='D')
			{
				numd++;
				tail++; que[tail] = i;
			}
			else if(a[i]=='M')
			{
				numm++; cur += numd;
				tail++; que[tail] = i;
			}
			else if(a[i]=='C')
			{
				ans += cur;
				tail++; que[tail] = i;
			}
//			printf("head=%d tail=%d\n",head,tail);
		}
		printf("%lld\n",ans);
		for(int i=tail; i>=0; i--) que[i] = 0;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		ans^=a;
	}
	if(!ans)cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main(void) {
    char s[100];
    int n,i,wa=0;
    scanf("%s",s);
    n=strlen(s);
    for(i=0;i<n/2;i++){
        if(s[i]!=s[n-1-i]){
            wa++;
        }
    }
    for(i=0;i<n/4;i++){
        if(s[i]!=s[n/2-1-i]){
            wa++;
        }
    }
    for(i=0;i<n/4;i++){
        if(s[n/2+1+i]!=s[n-1-i]){
            wa++;
        }
    }
    if(wa==0){
        printf("Yes");
    }
    else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long long int n;
    cin>>n;
    vector<long long int>a(n),b(n),c(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long long int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(long long int i=0;i<n;i++)
    {
        cin>>c[i];
    }
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    vector<long long int>countb(n,0);
    for(long long int i=0;i<b.size();i++)
    {
        auto it=upper_bound(c.begin(),c.end(),b[i]);
        countb[i]=c.end()-it;
    }
    long long int  prev=0;
    for(long long int i=n-1;i>=0;i--)
    {
        countb[i]+=prev;
        prev=countb[i];
    }
    long long int finalsum=0;
    for(long long int i=0;i<a.size();i++)
    {
        auto it=upper_bound(b.begin(),b.end(),a[i]);
        long long int index=it-b.begin();
        if(index<countb.size())
        {
            finalsum+=countb[index];
        }
    }   
    cout<<finalsum;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int q,i,j,k,l1,l2,m,n;
    string X,Y;
    cin>>q;
    for(i=0; i<q; i++)
    {
        cin>>X>>Y;
        l1=X.length()+1;
        l2=Y.length()+1;
        int arr[l2][l1];
        for(k=0; k<l1; k++)
        {
            arr[0][k]=0;
        }
        for(k=0; k<l2; k++)
        {
            arr[k][0]=0;
        }
        for(k=1; k<l2; k++)
        {
            for(j=1; j<l1; j++)
            {
                if(Y[k-1]==X[j-1])
                {
                    arr[k][j]=1+arr[k-1][j-1];
                }
                else
                {
                    m=arr[k-1][j];
                    n=arr[k][j-1];
                    arr[k][j]=max(m,n);
                }
            }
        }
        cout<<arr[l2-1][l1-1]<<endl;
    }
}



Measured memory_bytes: 7072
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(auto& v:a){
        cin >> v;
    }
    ll ans = 0;
    for(int i=1; i<n; i++){
        if(a[i-1] % 2 == 1 && a[i] > 0){
            a[i-1]--;
            a[i]--;
            ans++;
        }
    }
    for(int i=0; i<n; i++){
        ans += a[i] / 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	ll n;
	cin >> n;
	string sol = "";
	while(n){
		n--;
		char cur = (n % 26) + 'a';
		sol = cur + sol;
		n /= 26;
	}
	cout << sol << '\n';
}


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

int main() {
    int n; cin >> n;
    
    for (int i=0; i<n; i++) {
        int xi, yi, bi, pi; cin >> xi >> yi >> bi >> pi;
        cout << min(bi*xi+pi*yi, 4*(max(5, bi)*xi+max(2, pi)*yi)/5) << endl;
    }
}


Measured memory_bytes: 3112
n = int(input())
cl = [i for i in range(1,n+1)]
pl = [int(i) for i in input().split()]
for i in range(1,n+1):
    if not i == pl[i-1]:
        tmp=pl[i-1]
        pl[i-1]=pl[tmp-1]
        pl[tmp-1]=tmp
        break
if cl==pl:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<string, int> P;

const double PI = 3.14159265358979323846;


int main(int argc, char *args[]) {
	int n; cin >> n;
	int r; cin >> r;
	if (n >= 10)cout << r << endl;
	else cout << r + 100 * (10 - n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d",&n);
	int room[4][3][10] = {};
	for(int i = 0; i < n; i++){
		int a,b,c,d;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		room[a-1][b-1][c-1] += d;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				printf(" %d",room[i][j][k]);
			}
			printf("\n");
		}
		if(i > 2)break;
		printf("####################\n");
	}
}


Measured memory_bytes: 2040
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct cake{
	int num,sum;
}a[105];
int now,n,k,t,ans,last;
bool cmp(cake a,cake b){return a.sum>b.sum;}
int main()
{
	cin>>k>>t;
	for(int i=1;i<=t;i++){a[i].num=i;cin>>a[i].sum;}
	sort(a+1,a+1+t,cmp);
	while(k--)
	{
		now=-1;
		for(int i=1;i<=t;i++)if(a[i].sum&&last!=a[i].num){a[i].sum--;now=a[i].num;break;}
		if(now==-1)
		{
		ans++;
		for(int i=1;i<=t;i++)if(a[i].sum){a[i].sum--;now=a[i].num;break;}
		}
		last=now;
		sort(a+1,a+1+t,cmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
 
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    max_val = max(A)
    AA = A[:]
    AA.remove(max_val)
    second_max_val = max(AA)
    for a in A:
        if a != max_val:
            print(max_val)
        else:
            print(second_max_val)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 14076