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

#define ARRAY_LENGTH (100010)

// Infinity value
const long long INF = 1LL << 60;

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

int main(void)
{
  int N;
  long long H[ARRAY_LENGTH];
  long long dp[ARRAY_LENGTH];

  std::cin >> N;

  // Input costs
  for(int i = 0;i < N;i++){
    std::cin >> H[i];
  }

  // Initialize DP
  for(int i = 0;i < ARRAY_LENGTH;i++){
    dp[i] = INF;
  }

  // Initial condition
  dp[0] = 0;

  // Loop
  for(int i = 1;i < N;i++){
    chmin(dp[i], dp[i-1] + abs(H[i] - H[i-1]));
    if(i > 1){
      chmin(dp[i], dp[i-2] + abs(H[i] - H[i-2]));
    }
  }

  std::cout << dp[N-1] << std::endl;

  return 0;
}


Measured memory_bytes: 1792
program sample
    implicit none
  
    integer(8) :: i,j,m,n,k
    real(8)::a,b
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    n=n+1
    a=log10(real(n))
    m=int(a) !桁数-1
    k=m*9+n/10**m-1
    write(*,*) k
  
    stop
end program sample
  



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>

using ll = long long;

int main() {
    int N;
    std::cin >> N;
    std::string s, t;
    std::cin >> s >> t;

    int ans = 2 * N;

    for (int i = N; i >= 1; i--) {
        std::string subS = s.substr(N - i, i);
        std::string subT = t.substr(0, i);
        if (subS == subT) {
            ans -= i;
            break;
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		hs[i] = scanInt(sc)
	}

	costs := make([]int, n)
	costs[0] = 0
	costs[1] = abs(hs[1] - hs[0])

	for i := 2; i < n; i++ {
		c1 := costs[i-1] + abs(hs[i]-hs[i-1])
		c2 := costs[i-2] + abs(hs[i]-hs[i-2])
		costs[i] = min(c1, c2)
	}

	fmt.Println(costs[n-1])
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
        using namespace std;
        int main()
        {
          int n,ne;
          cin>>n;
          int arr[n];
          ne=0;
          bool flag=true;
          for(int i=0;i<n;i++)
          {
        		cin>>arr[i];
            if(arr[i]%2==0)
            {
              if(arr[i]%3!=0 &&  arr[i]%5!=0)
              {
                flag=false;
              }
            }
          }
          if(flag)
          {
            cout<<"APPROVED";
          }
          else
          {
            cout<<"DENIED";
          }
          return 0;
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll mod = 1000000007;//998244353;
// auto mod int
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, m; cin >> n >> m;
   int k; cin >> k;
   combination C =combination(200000);
   mint ans = 0;
   for (int d = 1; d < n; d++){
      ans += mint(d) * mint(n-d) * C(n*m-2, k-2) * mint(m) * mint(m);
   }
   for (int d = 1; d < m; d++){
      ans += mint(d) * mint(m-d) * C(n*m-2, k-2) * mint(n) * mint(n);
   }
   cout << ans << endl;
}

Measured memory_bytes: 6352
#include <iostream>
#include <string>
#include <algorithm>    
#include <cmath>
#include <map>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <set>
#include <functional>
#define int long long
#define mod(int)(1000000007)
using namespace std;
const int INF = 1000000000000;
int cnt[345678];
signed main() {
	int n, ans = 0; cin >> n;
	vector<vector<int>>aa(n, vector<int>(2));
	vector<vector<int>>bb(n, vector<int>(2));
	for (int h = 0; h < n; h++) {
		cin >> aa[h][1] >> aa[h][0];
	}
	sort(aa.begin(), aa.end());
	for (int h = 0; h < n; h++) {
		cin >> bb[h][0] >> bb[h][1];
	}
	sort(bb.begin(), bb.end());
	for (int h = 0; h < n; h++) {
		int a = -1;
		for (int i = n - 1; i >= 0; i--) {
			if (cnt[i] != 1 && aa[i][1] <= bb[h][0] && aa[i][0] <= bb[h][1]) {
				a = i; break;
			}
		}
		if (a != -1) { cnt[a] = 1; ans++; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int N, temp, flg = 1, i = 0, cou = 0;
    scanf("%d", &N);
    int A[N];
    for (int x=0; x<N; x++) {
        scanf("%d", &A[x]);
    }
    
    while (flg) {
        flg = 0;
        for (int j=N-1; j>i; j--) {
            if (A[j] < A[j-1]) {
                temp = A[j];
                A[j] = A[j-1];
                A[j-1] = temp;
                cou++;
            }
            flg = 1;
        }
        i++;
    }
    
    for (int y=0; y<N; y++) {
        printf("%d", A[y]);
        if (y == N - 1) {
            putchar('\n');
        } else {
            putchar(' ');
        }
    }
    printf("%d\n", cou);
    return 0;
}



Measured memory_bytes: 2132
// C
 #ifndef _GLIBCXX_NO_ASSERT
 #include <cassert>
 #endif
 #include <cctype>
 #include <cerrno>
 #include <cfloat>
 #include <ciso646>
 #include <climits>
 #include <clocale>
 #include <cmath>
 #include <csetjmp>
 #include <csignal>
 #include <cstdarg>
 #include <cstddef>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <ctime> 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #include <ccomplex>
 #include <cfenv>
 #include <cinttypes>
 #include <cstdbool>
 #include <cstdint>
 #include <ctgmath>
 #include <cwchar>
 #include <cwctype>
 #endif
 
 // C++
 #include <algorithm>
 #include <bitset>
 #include <complex>
 #include <deque>
 #include <exception>
 #include <fstream>
 #include <functional>
 #include <iomanip>
 #include <ios>
 #include <iosfwd>
 #include <iostream>
 #include <istream>
 #include <iterator>
 #include <limits>
 #include <list>
 #include <locale>
 #include <map>
 #include <memory>
 #include <new>
 #include <numeric>
 #include <ostream>
 #include <queue>
 #include <set>
 #include <sstream>
 #include <stack>
 #include <stdexcept>
 #include <streambuf>
 #include <string>
 #include <typeinfo>
 #include <utility>
 #include <valarray>
 #include <vector> 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #include <array>
 #include <atomic>
 #include <chrono>
 #include <condition_variable>
 #include <forward_list>
 #include <future>
 #include <initializer_list>
 #include <mutex>
 #include <random>
 #include <ratio>
 #include <regex>
 #include <system_error>
 #include <thread>
 #include <tuple>
 #include <typeindex>
 #include <type_traits>
 #include <unordered_map>
 #include <unordered_set>
 #endif 
using namespace std;
using Graph = vector< vector<int> >;
bool seen[110];
int d[110];
int f[110];

void dfs(Graph &G,int v,int &time){
    seen[v] = true;
    d[v] = time++;
    for(auto nv : G[v]){
        if(seen[nv]) continue;
        dfs(G,nv,time);
    }
    f[v] = time++;
}

int main(){
    int n; cin >> n;
    Graph G(n);
    for(int i=0;i<n;++i){
        int u,k; cin >> u >> k;
        --u;
        if(k==0) continue;
        for(int j=0;j<k;++j){
            int v;
            cin >> v;
            --v;
            G[u].push_back(v);
        }
    }
    int time = 1;
    for(int v=0;v<n;++v){
        if(seen[v]) continue;
        dfs(G,v,time);
    }
    
   
    for(int v=0;v<n;++v){
        cout << v+1 << ' ' << d[v] << ' ' << f[v] << endl;
    }
    return 0;
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.ST << ", " << p.ND << ")";
}

template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto &e : x)
        	out << e << (&e == &*--x.end() ? "" : ", ");
	return out << '}';
}

template<class... Args> void dump(Args&&... args) {
	((cerr << args << ";  "), ...);
}
 
#ifdef DEBUG
#  define debug(x...) cerr << "[" #x "]: ", dump(x), cerr << "\n"
#else
#  define debug(...) false
#endif
 
template<class T> int size(T && a) { return (int) a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n;
	cin >> n;
	vector<int> v(n + 1), w(n + 1);
	FOR(i, 1, n) cin >> v[i] >> w[i];

	int pre = min(n, 512), cap = 1e5;
	vector<vector<int>> dp(pre + 1, vector<int>(cap + 1));
	FOR(i, 1, pre) {
		if(i != 0) dp[i] = dp[i / 2];
		for(int j = cap; j >= w[i]; j--)
			dp[i][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
	}

	int q;
	cin >> q;
	REP(i, q) {
		int x, l;
		cin >> x >> l;

		vector<int> f;
		while(x > pre) {
			f.emplace_back(x);
			x /= 2;
		}

		int r = size(f), opt = 0;
		REP(mask, 1 << r) {
			int gain = 0, cost = 0;
			REP(j, r) if(mask & (1 << j)) {
				gain += v[f[j]], cost += w[f[j]];
			}

			if(cost <= l) {
				opt = max(opt, dp[x][l - cost] + gain);	
			}
		}

		cout << opt << "\n";
	}
	
}


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

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return is_prime
a = primes(100000)
resemble = []
for i in range(len(a)):
    if a[i]:
        if a[(i+1)//2]:
            resemble.append(i)
n = int(input())
ans = [0]*100000
q =[]
for i in range(1,100001):
    if i in resemble:
        ans[i-1] = ans[i-2] + 1
    elif i>1:
        ans[i-1] = ans[i-2]
#print(ans[:30])
for i in range(n):
    l,r = map(int,input().split())
    if l>1:
        q.append(ans[r-1]-ans[l-2])
    elif r>1:
        q.append(ans[r-1])
    else:
        q.append(0)
for i in range(n):
    print(q[i])

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll a;
lli ans = 0;

int main(){
  cin >> n;
  a = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  lli x = 0;
  lli prev = 0;
  for(lli i = 0;i < n;i++){
    if(a[i] == prev){
      x++;
    }else{
      ans += x/2;
      x = 1;
    }
    prev = a[i];
  }
  ans += x/2;
  cout << ans << endl;
}


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

Measured memory_bytes: 3620
def gcd(n, m):
    while n!=0:
        tmp = n
        n = m % n
        m = tmp
    return m

while 1:
    try:
        n, m = map(int, input().split())
        x = gcd(n, m)
        print(x, int(n*m/x))
    except EOFError:
        break

Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
#define makefast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define int long long

const int N = 5e3 + 7;

int dp[N][N];
int n, a, b;
int p[N], pnt[N];

int32_t main() {
	makefast;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++)
		cin >> p[i], pnt[p[i]] = i;
	set <int> s;
	s.insert(0);
	for (int i = n; i >= 1; i--) {
		s.insert(p[i]);
		auto it = s.rbegin();
		int lst = *it;
		int mn = pnt[lst];
		int x = lst;
		int cnt = 0;
		it++;
		while (it != s.rend()) {
			//	cout << endl << endl << i << " LST : " << lst << " X : " << x << " " << cnt << endl;
			for (int j = lst; j > *it; j--) {
				dp[i][j] = min(dp[mn + 1][lst] + a, dp[mn + 1][x + 1] + b * cnt);
				//		cout << i << " " << j << " > " << dp[i][j] << " " << dp[mn + 1][1] + a << " & " << dp[mn + 1][x + 1] + b * cnt << endl;
			}
			lst = *it;
			if (lst == 0)
				break;
			if (pnt[lst] < mn) {
				mn = pnt[lst];
				x = lst;
				cnt = 0;
			}
			else	
				cnt++;
			it++;
		}
	}
	cout << dp[1][1];

	return 0;
}



Measured memory_bytes: 196224
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	// tmp = input[1].split(" ");
	// var value = parseInt(input);
  	var value = input[1];
	var flag = false;
  	if (value.length % 2 !== 0) {
		console.log('No');
        return;
    }
    var first = value.slice(0, value.length / 2);
	var second = value.slice(value.length / 2 * -1);

  	if (first === second) {
      flag = true;
    }
  	//出力
  	var output = flag ? 'Yes' : 'No';
	console.log(output);
    return;
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
 printf("%d %d %f\n",a/b,a%b,(double)a/b);
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	while(cin>>n,n){
		int wh,hi;
		cin>>wh>>hi;
		bool place[100][100]={};
		for(int i=0,x,y;i<n;i++){
			cin>>x>>y;
			place[y][x]=1;
		}
		int w,h,ans=0;
		cin>>w>>h;
		for(int i=1;i<=hi-h+1;i++){
			for(int j=1;j<=wh-w+1;j++){
				int co=0;
				for(int k=i;k<i+h;k++)for(int l=j;l<j+w;l++)if(place[k][l]==1)co++;
				ans=max(co,ans);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1176
S = list(input())
ansarr = []
ans = 0
ansarr.append(ans)
for i in S:
    if ans == 0:
        if i == 'A' or i == 'C' or i == 'G' or i == 'T':
            ans += 1
    else:
        if i == 'A' or i == 'C' or i == 'G' or i == 'T':
            ans += 1
        elif i != 'A' or i != 'C' or i != 'G' or i != 'T':
            ansarr.append(ans)
            ans = 0
else:
    ansarr.append(ans)


print(max(ansarr))


Measured memory_bytes: 3060
def resolve():
    S = input()
    total = int(S)
    for bits in range(1<<(len(S)-1)):
        _total = 0
        prev = 0
        for odr in range(len(S)-1):
            if (bits & (1<<odr)):
                _total += int(S[prev:odr+1])
                prev = odr+1
        if bin(bits).count("1") > 0 and len(S[prev:]) > 0:
            _total += int(S[prev:])
        total += _total
    print(total)


if '__main__' == __name__:
    resolve()



Measured memory_bytes: 3064
#include <stdio.h>

int main() {

  int H , W ,i,j;

  while(1){
    scanf("%d %d",&H, &W);
    if(H == 0 && W == 0) {
      break;
    }


    for(j=1; j<=H; j++) {
      for(i=1; i<=W; i++) {
	if((i+j)%2 == 0 ) {
	  printf("#");
	} else  { 
	  printf(".");
	} 
      }
      printf("\n");  
    }
    printf("\n");
  }
  return 0;
}

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

int main(){
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC127 {
	class Program {
		static void Main (string[] args) {
			// 入力(答えが10^7をオーバーする可能性があるので注意)
			Int64 r, D, x2000;
			Int64[] array = Array.ConvertAll (Console.ReadLine ().Split (' '), Int64.Parse);
			r = array[0];
			D = array[1];
			x2000 = array[2];
			// 処理・出力
			Int64 outPal = x2000;
			for (int i = 0; i < 10; i++) {
				outPal = r * outPal - D;
				Console.WriteLine (outPal);
			}
		}
	}
}

Measured memory_bytes: 11220
r, c = map(int, input().split())

matrix = []
column_sum = [0]*(c+1)

for _ in range(r):
    matrix.append(list(map(int, input().split())))

for row in matrix:
    row_sum = 0
    for i in range(len(row)):
        row_sum += row[i]
        column_sum[i] += row[i]
    row.append(row_sum)
    column_sum[c] += row_sum
matrix.append(column_sum)

for row in matrix:
    print(' '.join(list(map(str, row))))


Measured memory_bytes: 5700
n, k = map(int, input().split())
towns = [int(s) for s in input().split()]
pos = []
pos_set = set()
cur = towns[0]
i = 0
end = False
while not cur in pos_set:
    i += 1
    if k == i:
        print(cur)
        end = True
        break
    pos.append(cur)
    pos_set.add(cur)
    cur = towns[cur-1]

if not end:
    j = pos.index(cur)
    print(pos[(k-j-1)%(len(pos)-j) + j])


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


int main() {
    string S;
    cin >> S;
    
    if (S == "ABC") puts("ARC");
    else puts("ABC");
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>

#define MOD 1000000007
#define INTMAX 0x7fffffff
#define INTMIN 0x80000000
#define LLMAX 0x7fffffffffffffffLL
#define LLMIN 0x8000000000000000LL

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

using namespace std;
using ll = long long;

struct QUERY {
	int x1;
	int y1;
	int x2;
	int y2;
};

int main(){
	int N,M,Q;
	cin >> N >> M >> Q;

	vector<vector<int>> S(N,vector<int>(M,0));
	vector<vector<int>> Ssum(N,vector<int>(M,0));
	vector<vector<int>> Shrz(N,vector<int>(M,0));
	vector<vector<int>> Svrt(N,vector<int>(M,0));

	// input map
	for (int i=0;i<N;++i) {
		string seq;
		cin >> seq;
		for (int j=0;j<M;++j) {
			S[i][j] = seq[j] - '0';
		}
	}

	// calculate cumlative sum of verticles
	Ssum[0][0] = S[0][0];
	REP(i, 1, N) {
		Ssum[i][0] = Ssum[i-1][0] + S[i][0];
	}
	REP(j, 1, M) {
		Ssum[0][j] = Ssum[0][j-1] + S[0][j];
	}
	REP(i, 1, N) REP(j, 1, M) {
		Ssum[i][j] = Ssum[i-1][j] + Ssum[i][j-1] - Ssum[i-1][j-1] + S[i][j];
	}
	
	// calculate cumlative sum of horizontal edges
	rep(i, N) {
		Shrz[i][0] = 0;
		REP(j, 1, M) {
			int above = i == 0 ? 0 : Shrz[i-1][j];
			int left = Shrz[i][j-1];
			int above_left = i == 0 ? 0 : Shrz[i-1][j-1];
			Shrz[i][j] = above + left - above_left + (S[i][j-1] * S[i][j] == 1 ? 1 : 0);
		}
	}

	// calculate cumlative sum of vertical edges
	rep(j, M) {
		Svrt[0][j] = 0;
		REP(i, 1, N) {
			int above = Svrt[i-1][j];
			int left = j == 0 ? 0 : Svrt[i][j-1];
			int above_left = j == 0 ? 0 : Svrt[i-1][j-1];
			Svrt[i][j] = above + left - above_left + (S[i-1][j] * S[i][j] == 1 ? 1 : 0);
		}
	}

	// input queries
	vector<QUERY> queries(Q,{0,0,0,0});
	rep(i, Q) {
		cin >> queries[i].x1 >> queries[i].y1 >> queries[i].x2 >> queries[i].y2;
	}

	// answer queries
	rep(i, Q) {
		QUERY q = queries[i];

		// count verticles in a query area
		int above = q.x1-2 < 0 ? 0 : Ssum[q.x1-2][q.y2-1];
		int left = q.y1-2 < 0 ? 0 : Ssum[q.x2-1][q.y1-2];
		int above_left = q.x1-2 < 0 || q.x1-2 < 0 ? 0 : Ssum[q.x1-2][q.y1-2];
		int verticles = Ssum[q.x2-1][q.y2-1] - above - left + above_left;

		// count edges in a query area
		above = q.x1-2 < 0 ? 0 : Shrz[q.x1-2][q.y2-1] + Svrt[q.x1-1][q.y2-1];
		left = q.y1-2 < 0 ? 0 : Shrz[q.x2-1][q.y1-1] + Svrt[q.x2-1][q.y1-2];
		above_left = q.x1-2 < 0 || q.x1-2 < 0 ? 0 : Shrz[q.x1-2][q.y1-1] + Svrt[q.x1-1][q.y1-2];
		int sequences = Shrz[q.x2-1][q.y2-1] + Svrt[q.x2-1][q.y2-1] - above - left + above_left;

		// print number of trees (= verticles - sequences)
		cout << verticles - sequences << endl;
	}

}

Measured memory_bytes: 67712
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    s=STR()
    r=s.count('R')
    g=s.count('G')
    b=s.count('B')
    ans=r*g*b
    #print(ans)
    for i in range(n+1):
        for j in range(1,n//2+2):
            k=i+2*j
            if k<=n-1:
                #print(ch)
                if (s[i]!=s[i+j] and s[k]!=s[i+j] and s[i]!=s[k]):
                    ans-=1
                    
    print(ans)

                
if __name__ == '__main__':
    do()

Measured memory_bytes: 9244
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

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

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

const ll MOD = 1000000007;
const ll INF = 10000000;


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

    int v[3] = { abs(b - a) + abs(c - a), abs(a - b) + abs(c - b), abs(a - c) + abs(b - c) };

    int ans = INF;
    for (int i = 0; i < 3; i++) ans = min(ans, v[i]);

    cout << ans << endl;
    

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, min = LLONG_MAX;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        ll temp = 0;
        while (a[i] / 2 != 0 && a[i] % 2 == 0)
        {
            a[i] /= 2;
            temp++;
        }
        if (min > temp)
            min = temp;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
signed main()
{
    crap;
    int sum=0;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='+')
        sum+=1;
        else
        sum-=1;
    }cout<<sum<<endl;
}

Measured memory_bytes: 256
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    N, M, D = map(int, input().split())

    if not D:
        prob = 1 / N
    else:
        prob = 2 * (N - D) / (N * N)

    ans = prob * (M - 1)
    print(ans)

main()


Measured memory_bytes: 2940
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    inl(x);

    ll tmp = x / 11;
    ll tmp2 = x - 11 * tmp;
    if (tmp2 == 0)
        out(tmp * 2);
    else if (tmp2 <= 6)
        out(tmp * 2 + 1);
    else
        out(tmp * 2 + 2);
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main()
{
	long long n,x,t;
	cin>>n>>x>>t;
	if(n%x==0)
	{
		cout<<(n/x)*t<<endl;
	}
	else
	{
		cout<<(n/x+1)*t<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint n, m, s, t1, t2;
vector<edge> G[105], revG[105];
llint distS[105], distT1[105], distT2[105];

void dijkstra(vector<edge> G[], llint S, llint dist[])
{
	for(int i = 1; i <= n; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue<P, vector<P>, greater<P> > Q;
	Q.push(P(0, S));
	
	llint v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size();i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push(P(dist[G[v][i].to] , G[v][i].to));
			}
		}
	}
}

int main(void)
{
	while(1){
		cin >> n >> m >> s >> t1 >> t2;
		if(n == 0 || m == 0) break;
		
		for(int i = 1; i <= n; i++) G[i].clear(), revG[i].clear();
		
		llint u, v, w;
		for(int i = 0; i < m; i++){
			cin >> u >> v >> w;
			G[u].push_back(edge(v, w));
			revG[v].push_back(edge(u, w));
		}
		
		dijkstra(G, s, distS);
		dijkstra(revG, t1, distT1);
		dijkstra(revG, t2, distT2);
		
		llint ans = inf;
		for(int i = 1; i <= n; i++) ans = min(ans, distS[i]+distT1[i]+distT2[i]);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string s;
    cin >> s;

    cout << s.substr(0, 3) << "\n";

    return 0;
}



Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define id(x) x-'a'
using namespace std;

const int N = 1e3+1;
const int inf = 0x7fffffff;

char s[N];
int f[N][N];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n-1;++i)
	if(s[i]!=s[i+1])goto ddd;
	cout<<0;return 0;
	
	ddd:;
	
	
	
	
	
	for(int i=1;i<=n;++i)f[1][i]=1<<id(s[i]);
	int i;
	for(i=2;i<=n;++i)
	{
		for(int t=1;t<=n-i+1;++t)
		{
			f[i][t]=f[i-1][t]|f[i-1][t+1];
		}
		for(int j=1;j<=24;++j)
		{
			bool flag=1;
			for(int t=1;t<=n-i+1;++t)
			if((f[i][t]&(1<<(j-1)))==0){flag=0;break;}
			if(flag)goto a11;
		}
	}
	a11:;
	cout<<i-1;
	return 0;
}

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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int calc(vector<int> & a,vector<int>& b, int m)
{
  vector<int> dp(m+1,0);
  for (int i = 0; i < a.size(); i++)
  {
    //v + a[i]個をv個 + b[i]個に換金する。
    //max: ax + by + cz
    //s.t. px + qy + rz <= Nが解ける。すごい。
    for (int v = 0; v + a[i] <= m; v++)
    {
      chmax(dp[v + a[i]],dp[v] + b[i]);
    }

  }
  int res = m;
  for (int i = 0; i < m+1; i++)
  {
    chmax(res,dp[i] + m - i);
  }
  return res;
  
}

void solve(void)
{ 
  vector<int> a(3,0);
  vector<int> b(3,0);
  int n;cin>>n;
  for (size_t i = 0; i < a.size(); i++)
  {
    cin>>a[i];
  }
  
for (size_t i = 0; i < b.size(); i++)
  {
    cin>>b[i];
  }
  n = calc(a,b,n);
  n = calc(b,a,n);
  cout<<n<<endl;


  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n, r; cin >> n >> r;
    if (n == 0) break;
    vi32 a(n);
    iota(all(a), 1);
    reverse(all(a));
    rep(_, r) {
      vi32 b = a;
      int p, c; cin >> p >> c;
      rep(i, c) b[i] = a[i + p - 1];
      rep(i, p - 1) b[i + c] = a[i];
      a = b;
    }
    cout << a[0] << '\n';
  }
}



Measured memory_bytes: 3184
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007LL
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

ll productmod(ll x, ll y){
  if(x*y >= MOD) return (x*y) % MOD;
  else return x*y;
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    scanf("%d", &n);
    vector<Pii> a(2*n);
    rep(n){
        scanf("%d", &a[i].first);
        a[i].second = 1;
    }
    rep(n){
        scanf("%d", &a[n+i].first);
        a[n+i].second = 0;
    }
    sort(all(a));
    ll ans = 1LL;
    ll cnt[2] = {0, 0};
    rep(2*n){
        if(cnt[1-a[i].second] == 0){
            cnt[a[i].second]++;
        }else{
            ans = productmod(ans, cnt[1-a[i].second]);
            cnt[1-a[i].second]--;
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1792
import sys
def main():
    N,K=tuple(map(int,sys.stdin.readline().split()))
    a=tuple(map(int,sys.stdin.readline().split()))
    dp=[False for _ in range(K+1)]
    for i in range(K+1):
        for x in a:
            if i-x>=0:dp[i]=dp[i] or (not dp[i-x])
    print('First') if dp[K] is True else print('Second')
if __name__=='__main__':main()

Measured memory_bytes: 9808
def main():
    input()
    array = sorted(int(x) for x in input().split())
    maximum = array[-1] + 1
    counter = [0] * maximum

    for x in array:
        if counter[x] != 0:
            counter[x] = 2
            continue
        else:
            for multiple in range(x, maximum, x):
                counter[multiple] += 1
    ans = sum(counter[x] == 1 for x in array)
    print(ans)


main()


Measured memory_bytes: 32384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    sc.close();
    int ans = 0;
    char b = s[0];
    for (char i:s){
      if (b != i){
        ans++;
        b = i;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 26324
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;


int main() {
	int n,c;
	cin >> n;
  	int a[n];
	rep(i,n){ a[i] = 0; }
    rep(i,n-1){
     	cin >> c;
      	a[c-1]++;
    }
  	rep(i,n){
		cout << a[i] << '\n';
    }
	//cout << n;   
	return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
int len(int n){
    if(n==0)return 1;
    int i=0;
    while(n!=0){
        n/=10;
        i++;
    }
    return i;
}
int func(int i,int j,vvi &dp,vector<vector<char>>&v){
    if(i==-1 || j==-1)return 0;
    if(i==0 && j==0)return 1;
    if(dp[i][j]!=-1)return dp[i][j]%mod;
    int x=0;
    if(i>0 && v[i-1][j]!='#'){
        x+=func(i-1,j,dp,v)%mod;
    }
    if(j>0 && v[i][j-1]!='#'){
        x+=func(i,j-1,dp,v)%mod;
    }
    dp[i][j]=x%mod;
    return dp[i][j]%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t =1;
    while(t--){
        int h,w,i,j;
        cin>>h>>w;
        vector<vector<char>>v(h,vector<char>(w));
        for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>v[i][j];
        vvi dp(h,vi(w,-1));
        cout<<func(h-1,w-1,dp,v)<<endl;
    }
    return 0;
}

Measured memory_bytes: 9216
import sys
N = int(input())
D = [[int(x) for x in input().split()] for _ in range(N)]
cnt = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        print('Yes')
        sys.exit(0)

print('No')

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> m.at(i);
    sum += m.at(i);
  }
  sort(m.begin(), m.end());
  cout << N + (X - sum) / m.at(0) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
mod = 1000000007

n, m  = map(int, input().split())
dp = [0 for _ in range(n+1)]
broken = [False for _ in range(n+1)]
for _ in range(m):
    a = int(input())
    broken[a] = True

dp[0] = 1
dp[1] = 0 if broken[1] else 1
for i in range(2, n+1):
    if broken[i]:
        continue
    if not broken[i-2]:
        dp[i] += dp[i-2]
        dp[i] %= mod
    if not broken[i-1]:
        dp[i] += dp[i-1]
        dp[i] %= mod

print(dp[n])


Measured memory_bytes: 7800
S  = ""
while True:
    try:
        S = S + input().lower()
    except: break



def count(arg1):
    count = S.count(arg1)+S.count(arg1.upper())
    print(arg1+" : ", end="")
    print(count)

count("a")
count("b")
count("c")
count("d")
count("e")
count("f")
count("g")
count("h")
count("i")
count("j")
count("k")
count("l")
count("m")
count("n")
count("o")
count("p")
count("q")
count("r")
count("s")
count("t")
count("u")
count("v")
count("w")
count("x")
count("y")
count("z")



Measured memory_bytes: 5556
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int K,N;
    cin>>N>>K;
    vector<int> p(N);
    rep(i,N) cin>>p[i];
    sort(p.begin(),p.end());
    long int ans=0;
    rep(i,K) ans+=p[i];
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3560
L,R = map(int, raw_input().split())

if 2019 <= R - L:
    print(0)
else:
    l_mod = L % 2019
    r_mod = R % 2019
    if r_mod < l_mod:
        print(0)
    else:
        min = 2018
        for i in range(l_mod, r_mod):
            for j in range(i + 1, r_mod + 1):
                x = i * j % 2019
                if x < min:
                    min = x
        print(min)

Measured memory_bytes: 2692
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int W,H,x,y,r;
W=sc.nextInt();
H=sc.nextInt();
x=sc.nextInt();
y=sc.nextInt();
r=sc.nextInt();
if((x+r)<=W && (y+r)<=H && (x-r)>=0 && (y-r)>=0)
{System.out.println("Yes");}
else {System.out.println("No");}}}

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

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 1000000007;

using P = pair<int, int>;

signed main() {
	string s; cin >> s;
	if (s.back() != 's')s += 's';
	else s += "es";
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T &a, T b){if(a > b){ a = b; return true;} return false;}

int main(){
    int n; cin >> n;
    int dp[n+2], h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 0; i < n; i++){
        dp[i] = 1001001001;
    }
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        chmin(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
        if(i > 1) chmin(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using static System.Math;
using Number = System.Int32;

namespace Program {
	public class Solver {
		Random rnd = new Random(0);
		public void Solve() {
			var n = ri;
			var m = ri;
			Console.WriteLine(n * (n - 1) / 2 + m * (m - 1) / 2);
		}

		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < a.Length; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = true });
		var solver = new Program.Solver();
		//* 
		var t = new System.Threading.Thread(solver.Solve, 50000000);
		//t.Start();
		//t.Join();
		//*/
		solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

	public class Printer : StreamWriter {
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	}

	public class StreamScanner {
		public StreamScanner(Stream stream) { str = stream; }

		public readonly Stream str;
		private readonly byte[] buf = new byte[1024];
		private int len, ptr;
		public bool isEof = false;
		public bool IsEndOfStream { get { return isEof; } }

		private byte read() {
			if (isEof) return 0;
			if (ptr >= len) {
				ptr = 0;
				if ((len = str.Read(buf, 0, 1024)) <= 0) {
					isEof = true;
					return 0;
				}
			}
			return buf[ptr++];
		}

		public char Char() {
			byte b = 0;
			do b = read(); while ((b < 33 || 126 < b) && !isEof);
			return (char)b;
		}
		public string Scan() {
			var sb = new StringBuilder();
			for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
			return sb.ToString();
		}
		public string ScanLine() {
			var sb = new StringBuilder();
			for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
			return sb.ToString();
		}
		public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
		public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
		public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
	}
}

#endregion


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
struct lpl{int a, b;}lin;
int H, W, N;
long long ans[10];
int a[] = {0, -2, -1, 0}, b[] = {0, -2, -1, 0};
set<lpl> s;
map<lpl, int> mp;

inline bool operator < (lpl A, lpl B){return (A.a == B.a) ? (A.b < B.b) : (A.a < B.a);}

inline bool check(int a, int b){return (1 <= a && a <= (H - 2) && 1 <= b && b <= (W - 2));}

int main()
{
	//freopen("lpl.in", "r", stdin);
    scanf("%d%d%d", &H, &W, &N); lpl qwe;
    ans[0] = (long long)(H - 2) * (long long)(W - 2);
    for(int i = 1; i <= N; ++i){
        scanf("%d%d", &lin.a, &lin.b); qwe = lin;
        if(s.count(lin) == 1) continue; s.insert(lin);
        for(int t = 1; t <= 3; ++t)
            for(int r = 1; r <= 3; ++r){
                qwe.a = lin.a + a[t]; qwe.b = lin.b + b[r];
                if(!check(qwe.a, qwe.b)) continue;
                //printf("a = %d b = %d  %d\n", qwe.a, qwe.b, mp[qwe]);
                ans[mp[qwe]]--; ans[mp[qwe] + 1]++; mp[qwe]++;
                //printf("a = %d b = %d  %d\n", qwe.a, qwe.b, mp[qwe]);
            }
    }
    for(int i = 0; i <= 9; ++i) printf("%lld\n", ans[i]);
    return 0;
}

Measured memory_bytes: 61184
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    ll k;
    cin >> s >> k;
    int n = SZ(s);
    for(int i = 0; i < n; i++){
        if(s[i] == '1'){
            k -= 1;
            if(k == 0){
                cout << s[i];
                return 0;
            }
        }else{
            cout << s[i];
            return 0;
        }
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
using namespace std;
int main(){
    int N;
    string S;
    cin>>N>>S;
    if(N%2==1)cout<<"No"<<endl;
    else if(S.substr(0,N/2)==S.substr(N/2,N/2))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3120