akhauriyash/Code-Regression huggingface dataset:
// OURL: https://atcoder.jp/contests/abc165/tasks/abc165_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v);  }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", ";  } first = false; res += to_string(x);  } res += "}"; return res;  }

string to_string(string s) { return '"' + s + '"';  }
string to_string(const char* s) { return to_string((string) s);  }
string to_string(bool b) { return (b ? "true" : "false");  }
string to_string(vector<bool>::reference b) { return to_string(bool(b));  }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";  }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res; }

void debug_out() { cerr << endl;  }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...);  }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

struct X {
  int a;
  int b;
  int c;
  int d;
};

int n,m,q;
vector<X> as;
int ans = 0;

int point(vector<int> &vs) {
  int p = 0;
  for (int i = 0; i < q; ++i) {
    X &x = as[i]; 
    if (vs[x.b] - vs[x.a] == x.c) {
      p += x.d;
    }
  }
  return p;
}

void rec(int idx, int s, vector<int> &vs) {
  for (int i = s; i <= m; ++i) {
    vs[idx] = i;
    if (idx == n-1) ans = max(ans, point(vs));
    else rec(idx+1, i, vs);
  }
}

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

  cin >> n >> m >> q;
  as = make_v<X>(q);

  for (int i = 0; i < q; ++i) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    as[i] = X{a -1, b-1, c, d};
  }

  auto vs = make_v<int>(n);
  rec(0, 1, vs);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 27 20:42:18 2019

@author: Owner
"""


import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*M
Y = [0]*M
for m in range(M):
    P[m], Y[m] = map(int, input().split())
    
all(nstr.count(c) for c in '753')
"""

N, A, B = map(int, input().split())

result = []

result.append(min(A, B))
if (A+B) < N:
    result.append(0)
else:
    result.append(A+B - N)
print(result[0],result[1])

Measured memory_bytes: 24108
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	a := make([]int, 3)
	con.Scan(&a[0], &a[1], &a[2])
	sort.Ints(a)
	con.Println(a[0] + a[1])
	return nil
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

const LLI mod = 1e9+7;

LLI dp[30][1<<21];

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

  int N; cin >> N;
  vector<vector<int>> a(N, vector<int>(N)); cin >> a;

  dp[0][0] = 1;
  
  REP(i,N){
    REP(j,1<<N){
      if(__builtin_popcount(j) != i+1) continue;
      dp[i+1][j] = dp[i][j];

      REP(k,N){
	if(a[i][k] == 1 && (j & (1<<k))){
	  (dp[i+1][j] += dp[i][j ^ (1<<k)]) %= mod;
	}
      }
    }
  }

  cout << dp[N][(1<<N)-1] << endl;

  return 0;
}


Measured memory_bytes: 311552
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, k;
  cin >> k >> n;
  vector<int> a(n);
  rep(i,n)
  {
    cin >> a[i];
  }
  int ans = 0;
  sort(a.begin(), a.end());
  rep(i,n-1)
  {
    ans = max(ans, abs(a[i + 1] - a[i]));
  }
  ans = max(ans, (k - a[n - 1]) + a[0]);
  cout << k - ans;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define REP(i, a) for (ll i(0), _##i(a); i < _##i; ++i)
#define FOR(i, a, b) for (ll i(a), _##i(b); i <= _##i; ++i)

#ifdef LOCAL
#define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define _FE_1(_CALL, x) _CALL(x)
#define _FE_2(_CALL, x, ...) _CALL(x) _FE_1(_CALL, __VA_ARGS__)
#define _FE_3(_CALL, x, ...) _CALL(x) _FE_2(_CALL, __VA_ARGS__)
#define _FE_4(_CALL, x, ...) _CALL(x) _FE_3(_CALL, __VA_ARGS__)
#define _FE_5(_CALL, x, ...) _CALL(x) _FE_4(_CALL, __VA_ARGS__)
#define _FE_6(_CALL, x, ...) _CALL(x) _FE_5(_CALL, __VA_ARGS__)
#define FOR_EACH_MACRO(MACRO, ...)                                             \
  _NTH_ARG(__VA_ARGS__, _FE_6, _FE_5, _FE_4, _FE_3, _FE_2, _FE_1)              \
  (MACRO, __VA_ARGS__)
#define watch(x) cerr << "\033[1;32m" #x " = \033[1;34m" << (x) << "\033[0m; ";
#define debug(...)                                                             \
  cerr << "\033[2;31mLine " << __LINE__ << ": \033[0m";                        \
  FOR_EACH_MACRO(watch, __VA_ARGS__)                                           \
  cerr << endl
#else
#define debug(...)
#endif

using namespace std;

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << '{' << p.first << ", " << p.second << '}';
}

template <class T, class = decltype(begin(declval<T>())),
          class = enable_if_t<!is_same<T, string>::value>>
ostream &operator<<(ostream &os, const T &c) {
  os << '[';
  for (auto it = begin(c); it != end(c); ++it)
    os << (it == begin(c) ? "" : ", ") << *it;
  return os << ']';
}
using ll = long long;

void solve() {
  string s, t;
  cin >> s >> t;
  const int n = (int)s.size();
  const int m = (int)t.size();
  s = ' ' + s;
  t = ' ' + t;
  vector<vector<int>> dp(n + 1, vector<int>(m + 1));

  FOR(i, 1, n) {
    FOR(j, 1, m) {
      dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      if (s[i] == t[j]) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
      }
    }
  }

  string ans;
  int i = n;
  int j = m;
  while (i >= 1 && j >= 1) {
    if (s[i] == t[j]) {
      ans += s[i];
      --i;
      --j;
    } else {
      if (dp[i - 1][j] > dp[i][j - 1]) {
        --i;
      } else {
        --j;
      }
    }
  }
  reverse(ALL(ans));
  cout << ans << "\n";
}

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

  int T = 1;
  // cin >> T;
  while (T--) {
    solve();
  }
}


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

int main() {
  vector<int> a = {2, 4, 5, 7, 9}, b = {0, 1, 6, 8};
  int n; cin >> n;
  rep(i, a.size()) {
    if (n % 10 == a[i])
      cout << "hon";
  }
  rep(i, b.size()) {
    if (n % 10 == b[i])
      cout << "pon";
  }
  if (n % 10 == 3)
    cout << "bon";
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define N 3001
using namespace std;

string s, t, ans;
int ss, tt, dp[N][N];

int main() {
	cin>>s>>t;
	ss=s.size(),tt=t.size();
	for (int i=1; i<=ss; i++) {
		for (int j=1; j<=tt; j++) {
			dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
			if (s[i-1]==t[j-1]) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
		}
	}
	for (int i=ss,j=tt; i>0 && j>0;) {
		if (s[i-1]==t[j-1]) ans+=s[i-1],i--,j--;
		else if (dp[i][j-1]>dp[i-1][j]) j--;
		else i--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

vector<LL> AB,ABC;
int main(){
    int X,Y,Z;
    cin>>X>>Y>>Z;
    int K;
    cin>>K;
    LL A[1010],B[1010],C[1010];
    for(int i=0;i<X;i++){
        cin>>A[i];
    }
    for(int i=0;i<Y;i++){
        cin>>B[i];
    }
    for(int i=0;i<Z;i++){
        cin>>C[i];
    }
    
    for(int i=0;i<X;i++){
        for(int j=0;j<Y;j++){
            AB.push_back(A[i]+B[j]);
        }
    }
    sort(AB.begin(),AB.end(),greater<LL>());
    for(int i=0;i<min(K,X*Y);i++){
        for(int j=0;j<Z;j++){
            ABC.push_back(AB[i]+C[j]);
        }
    }
    sort(ABC.begin(),ABC.end(),greater<LL>());
    for(int i=0;i<K;i++){
        cout<<ABC[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 43364
import sys
sys.setrecursionlimit(10**6)
g=[]

def  jdream(l,i):
    if len(l)>=i+5:

        if l[i:i+5]=="dream":
            i=i+5
            if i==len(l):
                g.append("Y")
                return
     
            else:
                jer(l,i)
                jdream(l,i)
                return
        else:
            
            return
    else:
        
        return

def jerase(l,i):
    if len(l)>=i+5:

        if l[i:i+5]=="erase":
            i=i+5
            if i==len(l):
                g.append("Y")
                return
            else:
                jr(l,i)
                jerase(l,i)
                jdream(l,i)
                return
        else:
            
            return
    else:
        
        return

def jer(l,i):
    if len(l)>=i+2:

        if l[i:i+2]=="er":
            i=i+2
            if i==len(l):
                g.append("Y")
                return
            else:
                jase(l,i)
                jerase(l,i)
                jdream(l,i)
                return
        else:
            
            return
    else:
        
        return

def jase(l,i):
    if len(l)>=i+3:

        if l[i:i+3]=="ase":
            i=i+3
            if i==len(l):
                g.append("Y")
                return
            else:
                jdream(l,i)
                jerase(l,i)
                jr(l,i)
                return
        else:
            
            return
    else:
        
        return

def jr(l,i):
    if len(l)>=i+1:

        if l[i:i+1]=="r":
            i=i+1
            if i==len(l):
                g.append("Y")
                return
            else:
                jdream(l,i)
                jerase(l,i)
                return
        else:
            
            return

    else:
        
        return

s=input()
n=0
jerase(s,n)
n=0
jdream(s,n)


if 'Y' in g:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 65516
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int h[100100];
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  int maxx = 0;
  int cnt = 0;
  for(int i=0; i<n; i++){
    if(i == n-1) continue;
    if(h[i]>=h[i+1]) cnt++;
    else cnt = 0;
    maxx = max(maxx, cnt);
  }
  cout << maxx << endl;
}

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



// last submission

typedef long long  int ll;
#define s(n) scanf("%lld",&n)
#define s2(n,m) scanf("%lld%lld",&n,&m)
ll n,a[100005];
bool cm(ll x,ll y)
{
    return x>=y;
}
ll mx()
{

    ll sum = 0;
    ll lv,rv;
    lv = rv = a[0];
    ll i =1,j=n-1;
    ll on,tw,tr,fr,mxx;
    while(i<=j)
    {
        on = abs(lv-a[i]);
        tw  = abs(lv-a[j]);
        tr = abs(rv-a[i]);
        fr = abs(rv-a[j]);

        mxx = max(on,max(tw,max(tr,fr)));

       // cout<<lv<<" "<<rv<<" "<<i<<" "<<j<<" "<<mx<<endl;

        if(mxx==on)
            lv = a[i++];

        else if(mxx==tw) lv = a[j--];
        else if(mxx==tr) rv=a[i++];
        else
            rv = a[j--];
        sum+=mxx;

    }
    return sum;
}

int main()
{

    s(n);
    for(ll i=0; i<n; i++) s(a[i]);
    sort(a,a+n);
    ll ans = mx();


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





}


Measured memory_bytes: 1024
def median_of_medians(N: int, A: list)->int:
    def search(c):
        bar = N
        r = 0
        res_nega = 0
        dp_arr = [0]*(2*N+1)
        for i in range(N):
            dp_arr[bar] += 1
            if A[i] < c:
                r += dp_arr[bar]
                bar += 1
            else:
                r -= (dp_arr[bar-1])
                bar -= 1
            res_nega += r
        return res_nega

    # binary search
    a_sorted = sorted(A)
    left = 0
    right = N
    mid = N // 2
    C = N*(N+1) // 2
    while True:
        if search(a_sorted[mid]) <= C // 2:
            if mid == N-1:
                break
            elif search(a_sorted[mid+1]) > C // 2:
                break
            else:
                left = mid
                mid = (mid + right) // 2
        else:
            right = mid + 1
            mid = (mid + left) // 2

    return a_sorted[mid]


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = median_of_medians(N, A)
    print(ans)


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

int main(void) {
	char s[4];
	int l;
	scanf("%s", s);

	l = strlen(s);

	if (l == 2) {
		printf("%s", s);
	}
	else {
		printf("%c%c%c", s[2], s[1], s[0]);
	}
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;


int main(){
	LL n;
	cin >> n;
	n *= 3;
	LL a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	LL ans = 0;
	for(int i = 0; i < n/3; i++){
		ans += a[n-2-2*i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>

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

void insertionSort(int arr[], int N) {
    int j, i ,k;
    for (i=1; i<N; i++) {
        k=arr[i];
        j=i-1;
        while (j>=0 && arr[j]>k) {
            arr[j+1]=arr[j];
            j--;
        }
        arr[j+1]=k;
        trace(arr, N);
    }
}

int main() {
    int i, j, N;
    int arr[100];
    
    scanf("%d", &N);
    for (i=0; i<N; i++) scanf("%d", &arr[i]);
    
    trace(arr, N);
    insertionSort(arr, N);
    
    return 0;
}


Measured memory_bytes: 2756
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());

            var result = 1;
            for(var b = 2; b<=(int)Math.Sqrt(X); b++)
            {
                for (var p = 1; (int)Math.Pow(b, p) <= X; p++)
                {
                    var y = (int)Math.Pow(b, p);
                    if (y > result)
                    {
                        result = y;
                    }
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11220
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, L = LI()
    per = 0
    for i in range(N):
        per += i + L
    
    cur_min = inf
    ans = inf
    for i in range(N):
        c = i + L
        if abs(c) < cur_min:
            ans = c
            cur_min = abs(c)
    print(per - ans)
main()



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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

string str;
int k;
int dp[300][301][301];

int main() {
    cin >> str;
    cin >> k;
    int n = str.size();
    int ans = 1;
    rep(i,n) dp[i][1][0] = 1;
    for (int j = 2; j <= n; j++) {
        rep(i,n-j+1) {
            for (int u = 0; u <= k; u++) {
                if (str[i] == str[i+j-1]) {
                    dp[i][j][u] = dp[i+1][j-2][u]+2;
                } else {
                    dp[i][j][u] = max(dp[i][j-1][u], dp[i+1][j-1][u]);
                }
                if (u >= 1) dp[i][j][u] = max(dp[i][j][u], dp[i+1][j-2][u-1]+2);
                ans = max(ans, dp[i][j][u]);
            }
        }
    }
    cout << ans << endl;
}
































Measured memory_bytes: 104704
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define all(x) x.begin(),x.end()
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    string s;
    cin>>s;
    cout<<(s[2]==s[3] and s[4]==s[5]?"Yes":"No");
}

int main(){ 
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            String t = in.next();
            int ans = 0;
            for (int i = 0, l = s.length(); i < l; i++)
                if (s.charAt(i) == t.charAt(i))
                    ans++;
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 22868
INF = float('inf')
MAX_N = 10**5

N = int(input())
a,b,c = [0]*N, [0]*N, [0]*N
for i in range(N):
    a[i],b[i],c[i] = map(int, input().split())

# dp table
# dp[i][j] := 状態jにおけるi日目に得る幸福度の総和の最大値
dp = [[0]*3 for _ in range(N)]

dp[0][0],dp[0][1],dp[0][2] = a[0],b[0],c[0]

for i in range(1,N):
    for j in range(3):
        if j==0:
            dp[i][j] = max(dp[i-1][j+1]+a[i],dp[i-1][j+2]+a[i])
        if j==1:
            dp[i][j] = max(dp[i-1][j-1]+b[i],dp[i-1][j+1]+b[i])
        if j==2:
            dp[i][j] = max(dp[i-1][j-2]+c[i],dp[i-1][j-1]+c[i])
print(max(dp[N-1]))

Measured memory_bytes: 61400
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N, x;
  cin >> N >> x;
  vll a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  ll ans = 0;
  if(a.at(0) > x){
    ans += a.at(0) - x;
    a.at(0) = x;
  }
  for(int i = 1; i < N; i++){
    if(a.at(i) + a.at(i-1) > x){
      ans += a.at(i) + a.at(i-1) - x;
      a.at(i) -= a.at(i) + a.at(i-1) - x;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

int main(){
	int N,A,B,C,X;
	while(~scanf("%d %d %d %d %d",&N,&A,&B,&C,&X)){
		//x' = (A × x + B) mod C
		if(N==0) break;
		int count = 0;
		vector<int> Y;
		for(int i=0;i<N;i++){
			int y;
			scanf("%d",&y);
			Y.push_back(y);
		}

		if(Y[0]==X && Y.size() == 1){
			goto last;
		}
		
		for(int i=0;i<Y.size();i++){
			for(int j=0;j<=100000;j++){	
				if(i==0 && Y[i]==X){
					continue;
				}
				count++;
				X = (A*X + B) % C;
				if(Y[i]==X){
					break;
				}
				if(count > 10000) goto last;						
			}
		}

last:;
		printf("%d\n",count > 10000 ? -1 : count);
	}
}

Measured memory_bytes: 1208
#include <stack>
#include <vector>
#include <iostream>
struct State {
	int size, index;
	void set(const int &i) {
		size = size * i + i;
	}
	State(int s = 0, int i = 0) :size(s), index(i) {};
};

int maximum(std::vector<int> &state) {
	std::stack<State> stack;
	stack.push(State());
	int max = 0;
	for (auto i = 0; i < state.size(); ++i) {
		if (state.at(i) > stack.top().size) {
			stack.push(State(state.at(i), i));
		}
		else {
			auto temp = stack.top();
			while (stack.top().size > state.at(i)) {
				temp = stack.top();
				if (max < (i - stack.top().index) * stack.top().size) {
					max = (i - stack.top().index) * stack.top().size;
				}
				stack.pop();
			}
			temp.size = state.at(i);
			stack.push(temp);
		}
	}
	return max;
}
struct Container {
	std::vector<int> *now, *prev;
	Container(const int &n = 0) :now{ new std::vector<int>(n, 0) }, prev{ new std::vector<int>(n, 0) } { };
	int &at(const int &i) { return now->at(i); }
	int &at2(const int &i) { return prev->at(i); }
	std::vector<int> &get_now() { return *now; }
	void swit() { auto temp = now; now = prev; prev = temp; }

};
int main() {
	int h, w;
	std::cin >> h >> w;
	Container vector(w + 1);
	int max = 0;
	for (auto i = 0; i < h; ++i) {
		for (auto j = 0; j < w; ++j) {
			int c;
			std::cin >> c;
			vector.at(j) = (vector.at2(j) + 1) * (1 - c);
		}
		auto temp = maximum(vector.get_now());
		if (temp > max) {
			max = temp;
		}
		vector.swit();
	}
	std::cout << max << std::endl;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n) {
        if(a[i] == i+1) {
            if(i < n-1) swap(a[i], a[i+1]);
            else swap(a[i], a[i-1]);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

ll gcd(ll a, ll b){
	if (a == 0) return b;
	return gcd(b  %a, a);
}

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

ll n,m,visited[100008],dp[100008];
vector <ll> g[100008];

void dfs(ll v)
{
	visited[v] = 1;
	ll ed = g[v].size();

	for(ll i=0;i<ed;i++)
	{
		if(!visited[g[v][i]])
			dfs(g[v][i]);
		
		dp[v] = max(dp[v] , dp[g[v][i]] + 1);
	}

}

ll longest_path()
{
	memset(visited,0,sizeof(visited));
	memset(dp,0,sizeof(dp));

	for(ll i=1;i<=n;i++)
	{
		if(!visited[i])
			dfs(i);
	}

	ll ans =0;

	for(ll i=1;i<=n;i++)
		ans = max(ans,dp[i]);

	return ans;
}

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

	cin >> n >> m;
	ll i;

	for(i=0;i<m;i++)
	{
		ll x,y;
		cin >> x >> y;
		g[x].push_back(y);
	}

	cout << longest_path() << endl;
}

Measured memory_bytes: 9344
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    while(1){
        i64 a,sum;
        scanf("%lli",&sum);
        if(sum==0LL) break;
        i64 other=0LL;
        for(i64 i=0LL;i<9LL;++i){
            scanf("%lli",&a);
            other+=a;
        }
        printf("%lli\n",sum-other);
    }
    return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	vector<ar<ll,3> >v;
	for(ll i=0,j,k,c; i<m; i++)
	{
		cin>>j>>k>>c, --j,--k;
		c = -c;
		v.push_back({j,k,c});
	}
	ll dist[n];
	fill(dist,dist+n,(ll)(1e18));
	dist[0]=0;
	for(int i = 0; i<n-1; i++)
	{
		for(auto it:v)
		{
			if(dist[it[0]]==(ll)1e18)
				continue;
			dist[it[1]] = min(dist[it[1]],dist[it[0]]+ it[2]);
		}
	}

	bool vis[n] = {0};
	for(auto it:v)
	{
		if(dist[it[0]]== (ll)1e18)
			continue;
		if(dist[it[0]]+it[2]<dist[it[1]])
		{
			dist[it[1]]= it[2]+dist[it[0]];
			vis[it[1]] = 1;
		}
		if(vis[it[0]])
			vis[it[1]]=1;
	}
	if(vis[n-1])
		cout<<"inf"<<endl;
	else
		cout<<(-dist[n-1])<<endl;
	return 0;
}

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

def main():
    N, M = map(int, input().split())
    a_b = sorted([list(map(int, input().split())) for _ in range(M)])
    used = [0] * M
    ans = 0
    for i in range(M):
        k = M - i - 1
        if used[k]:
            continue
        used[k], c = 1, a_b[k][0]
        for j in range(k):
            if a_b[j][0] <= c < a_b[j][1]:
                used[j] = 1
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
    char *e={"QWERTYUIOPASDFGHJKLZXCVBNM"};
    //char o[26]={q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m};
    char t;
    int x=0;
    int i;
    scanf("%s",&t);
    for(i=0;i<27;i++){
        if(strncmp(&t,&e[i],1)==0){
        x=1;
        break;
        }
    }
    if(x==1){
        printf("A\n");
    }else{
        printf("a\n");
    }

    return 0;

}

Measured memory_bytes: 1660
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
P = LIST()
Q = LIST()
 
def hoge(A, m):
  c = -1
  for j in range(m):
    if A[j] == 1  :
      c += 1   
  return c
 
def Numth(R, N):
  ORDER = [1]*N
  c = 0
  for i in range(N-1):
    c += hoge(ORDER, R[i]) *factorial(N-i-1)
    ORDER[R[i]-1] = 0 
  return c+1
 
print(abs(Numth(P, N)-Numth(Q, N)))

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

int main(){
  map<char,int> S;
  for(int i=0;i<4;i++){
    char c;
    cin>>c;
    S[c]++;
  }
  for(pair<char,int> i:S)
    if(i.second!=2){
      cout<<"No"<<endl;
      return 0;
    }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	string s, t;
	cin >> s >> t;
	map<int, char> mp;
	vector<int> cnt[26] = {};
	for (int i = 0; i < s.size(); i++) {
		cnt[s[i] - 'a'].push_back(i);
	}
	vector<int> cnt2[26] = {};
	for (int i = 0; i < t.size(); i++) {
		cnt2[t[i] - 'a'].push_back(i);
	}
	sort(cnt, cnt + 26);
	sort(cnt2, cnt2 + 26);
	for (int i = 0; i < 26; i++) {
		if (cnt[i].size() != cnt2[i].size()) {
			cout << "No\n";
			return 0;
		}
		for (int j = 0; j < cnt[i].size(); j++) {
			if (cnt[i][j] != cnt2[i][j]) {
				cout << "No\n";
				return 0;
			}
		}
	}
	// for (int i = 0; i < 26; i++) {
	// 	cout << "i:" << char('a' + i) << endl;
	// 	if (cnt[i].size()) {
	// 		for (int j = 0; j < cnt[i].size(); j++) {
	// 			cout << cnt[i][j] << " ";
	// 		}
	// 	}
	// 	cout << endl;
	// }
	// for (int i = 0; i < 26; i++) {
	// 	if (cnt[i].size() >= 2) {
	// 		for (int j = 1; j < cnt[i].size(); j++) {
	// 			if (t[cnt[i][j]] != t[cnt[i][j - 1]]) {
	// 				cout << "No\n";
	// 				return 0;
	// 			}
	// 		}
	// 	}
	// }
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 5108
N = int(input())
dic = {}
for _ in range(N):
    IN = input()
    A = "".join(sorted(list(IN)))
    if A not in dic:
        dic[A] = 1
    else:
        dic[A] += 1
answer = 0
for k,v in dic.items():
    answer += v*(v-1)//2
print(answer)


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

// template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
// template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

ll dp[3010][3010];
ll a[3010];

ll rec(int l, int r, int player){// player? taro : jiro
    if(dp[l][r]!=-1) return dp[l][r];
    if(r==l+1){
        if(player) return dp[l][r] = a[l];
        else return dp[l][r] = -a[l];
    }
    ll res = 0;
    if(player){
        res = max( rec(l,r-1,!player) + a[r-1] , rec(l+1,r,!player) + a[l] );
    }
    else{
        res = min( rec(l,r-1,!player) - a[r-1] , rec(l+1,r,!player) - a[l] );
    }
    return dp[l][r] = res;
}

int main(){
    int N; cin>>N;
    rep(i,N)cin>>a[i];
    rep(i,3010)rep(j,3010) dp[i][j] = -1;
    cout<<rec(0,N,1)<<endl;
}

Measured memory_bytes: 74580
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(long long i=0; i<n; i++)

int main(){
  long long N, M, K;
  cin >> N >> M >> K;
  long long tmp;
  long long A[N], B[M];
  rep(i, N)
    cin >> A[i];
  rep(i, M)
    cin >> B[i];
  // 入力終了

  // A[]とB[]の累積和
  long long cua[N+1]; cua[0] = 0;
  long long cub[M+1]; cub[0] = 0;
  rep(i, N)
    cua[i+1] = cua[i] + A[i];
  rep(i, M)
    cub[i+1] = cub[i] + B[i];

  long long ans = 0;

  // B[]をなめるindexと，その中で最適なbn
  int bn, bestbn = M;
  
  rep(an, N+1){
    // 累積和の性質上，bestbnから左に見ていけばOK
    bn = bestbn;

    // Kを下回るまでbnを減らしていく
    while(cua[an] + cub[bn] > K && bn>0)
      bn--;

    // bestの更新
    bestbn = bn;

    if(cua[an] + cub[bn] <= K){
      // 最大値の更新
      if(an + bn > ans)
	ans = an + bn;
    }
  }

  // 解答
  cout << ans << endl;
  
  return 0;
}


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

using namespace std;
int main(){
    double a,b,h,m;cin>>a>>b>>h>>m;
    double radmr = m / 60 * 2 * M_PI;
    double radhr = (h*60 + m) / 720 * 2 * M_PI;
    //cout << radmr << endl;
    //cout << radhr << endl;
    double hx=0, mx=0, hy=a, my=b;
    double mthet=2*M_PI - radmr;
    double hthet=2*M_PI - radhr;

    double nhx=cos(hthet) * hx - sin(hthet) * hy;
    double nhy=sin(hthet) * hx + cos(hthet) * hy;

    double nmx=cos(mthet) * mx - sin(mthet) * my;
    double nmy=sin(mthet) * mx + cos(mthet) * my;

    //cout << hthet << " "<< nhx << " " << nhy << endl;
    //cout << nmx << " " << nmy << endl;

    double dist = sqrt( pow(nhx-nmx,2) + pow(nhy-nmy,2) );
    cout << setprecision(12) << dist << endl;                                                                        
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const int INF = 1000000007;

int N, A[100005];
multiset<int> st;

int main(void) {
  cin >> N;
  st.insert(INF);
  for(int i=0; i<N; i++) {
    int a; scanf("%d", &a);
    a *= -1;
    auto itr = st.upper_bound(a);
    if (*itr == INF) st.insert(a);
    else {st.erase(itr); st.insert(a);}
  }
  cout << st.size()-1 << endl;
  
  
    
    return 0;
}



Measured memory_bytes: 4992
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()

is_pices_greater_than_points = N >= M
if is_pices_greater_than_points:
    print(0)
    exit()

intervals = [X[i] - X[i - 1] for i in range(1, len(X))]
# print(intervals)
intervals.sort(reverse=True)

max_X = max(X)
min_X = min(X)

number_of_moves = max_X - min_X

for i in range(0, N - 1):
    number_of_moves -= intervals[i]

print(number_of_moves)


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

int main() {
	int n;cin>>n;
	string s;cin>>s;
	if(n%2){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[i+n/2]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N, M;
	cin >> N >> M;
	vector<int>k(M);
	vector<vector<int>>s(M);
	rep(i, M) {
		cin >> k[i];
		rep(j, k[i]) {
			int input;
			cin >> input;
			input--;
			s[i].push_back(input);
		}
	}
	vector<int>p(M);
	rep(i, M)cin >> p[i];
	vector<int>swi(N);
	int ans = 0;
	for (int i = 0; i < (1ll << N); i++) {
		rep(j, N)swi[j] = (i >> j) & 1;
		bool can = true;
		rep(j, M) {
			int num = 0;
			rep(l, k[j]) {
				num ^= swi[s[j][l]];
			}
			if (num != p[j])can = false;
		}
		if (can)ans++;
	}
	cout << ans << endl;
}

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

int main(){
	int N,M;
	cin >> N >> M;
	vector<vector<int>> jobs(M+1);
	rep(i,N){
		int a, b;
		cin >> a >> b;
		if(a > M) continue;
		jobs[M-a].push_back(b);
	}
	priority_queue<int> q;
	ll ans(0);
	for(int i(M-1);i>=0;--i){
		for(int j(0);j<jobs[i].size();++j){
			q.push(jobs[i][j]);
		}
		if(!q.empty()){
			ans += q.top();
			q.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<cmath>
int main()
{
	int n;
	int A[10110];
	bool bf = true;
	int res = 0;
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		std::cin >> A[i];
	}
	for (int k = 0; k < n; k++)
	{
		bf = true;
		if (A[k] <= 1)
		{
			bf = false;
			continue;
		}
		for (int j = 2; j <= std::sqrt(A[k]); j++)
		{
			if (A[k] % j == 0)
				bf = false;
				continue;
		}
		if(bf)
			res++;
	}
	std::cout << res << std::endl;
}


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

int main(){
  int N,L;
  cin >> N >> L;
  int sum,min = 100000;

  for(int i = 0;i < N;i++){
    sum+=(L+i);
    if(abs(L+i)<abs(min)){
      min = (L+i);
    } 
  }

  cout << sum-min << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func readline(n int) []int {
	var a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	return a
}

func main() {
	var n int
	fmt.Scan(&n)
	v := readline(n)
	c := readline(n)
	res := 0
	for i := 0; i < n; i++ {
		if v[i]-c[i] > 0 {
			res += v[i] - c[i]
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
//g++  5.4.0

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

const int inf = 1e10;
signed main()
{
    fast;
    int n , k;
    cin >> n >> k;
    int h[n] , dp[n];
    for(int i=0 ; i<n ; i++ ) cin>>h[i];
    dp[0] = 0;
    for(int i=1 ; i<n ; i++ )
    {
        dp[i] = inf;
        for(int j=i-1 ; j>=i-k && j>=0 ; j-- )
            dp[i] = min( dp[i] , dp[j] + abs( h[j] - h[i] ) );
    }
    cout << dp[n-1];
}





Measured memory_bytes: 1792
#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 all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
typedef long long ll;
//

int main(){
   ll n;cin>>n;
   vector<vector<int>> v;
   ll ans=INF;
   ll t,a;
   rep(i,n){
      vector<int> vv;
      int a,b;cin>>a>>b;
      vv.push_back(a);
      vv.push_back(b);
      v.push_back(vv);
   }
   t=v[0][0];
   a=v[0][1];
   ans=t+a;
   if(n==1) {
      cout<<ans<<endl;
      return 0;
   }else{
      rep(i,n-1){
      ll c=max(t/v[i+1][0],a/v[i+1][1]);
      if(c*v[i+1][0]<t||c*v[i+1][1]<a)c++;
      t=c*v[i+1][0];
      a=c*v[i+1][1];
      ans=t+a;
      }
   }
  cout<<ans<<endl;
}

Measured memory_bytes: 3668
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

A, B, C = map(int, raw_input().split())
print min(B*C*(A - A/2*2), C*A*(B - B/2*2), A*B*(C - C/2*2))


Measured memory_bytes: 4008
let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split() |> Array.map int |> Array.toList

let rec loop i items count =
    match items with
    | [head] -> if head = i then count+1 else count
    | head :: [tail] -> if head = i then loop (i+1) [head] (count+1) else loop (i+1) [tail] count
    | head :: sec :: tail -> if i = head then loop (i+1) (head::tail) (count+1) 
                             else loop (i+1) (sec::tail) count

loop 1 A 0 |> stdout.WriteLine

Measured memory_bytes: 31324
// #define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)
#define SPACE ' '

typedef long long ll;

using namespace std;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is something like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif
};

struct edge {
public:
  int h, p;
  edge() { };
  edge(int h, int p): h(h), p(p) { };
};

int main() {
  while (true) {
    int n = Scanner::nextInt();
    int m = Scanner::nextInt();
    int a = Scanner::nextInt();
    if (n + m + a == 0) break;
    
    edge e[1001];
    REP(i, m) {
      int h = Scanner::nextInt();
      int p = Scanner::nextInt();
      int q = Scanner::nextInt();
      e[i] = edge(h, p);
    }
    sort(e, e + m, [](edge e1, edge e2) -> int {
      return (e1.h < e2.h);
    });
    
    int d[102];
    REP(i, n + 1) {
      d[i] = i;
    }
    REP(i, m) {
      int tmp = d[e[i].p];
      d[e[i].p] = d[e[i].p + 1];
      d[e[i].p + 1] = tmp;
    }
    PRINT(d[a]);
  }
  
  return 0;
}

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

int main(){
  int dp[100010];
  dp[0]=0;
  for(int i=1;i<100010;i++){
    dp[i]=i;
    int x=1;
    while(x<=i){
      dp[i]=min(dp[i],dp[i-x]+1);
      x*=6;
    }
    x=1;
    while(x<=i){
      dp[i]=min(dp[i],dp[i-x]+1);
      x*=9;
    }
  }
  int n;
  cin>>n;
  cout<<dp[n]<<endl;
}

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

int main(){
  int n;
  cin >> n;
  
  vector<int> vec(n);
  for(int i = 0;i < n;i ++){
    cin >> vec.at(i);
  }
  
  int count = 0;
  for(int i = 0;i < n;i ++){
    if(((i + 1) + 2) % 2 != 0 && (vec.at(i) + 2) % 2 != 0)count ++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3572
#n=int(input())
k,n=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

mn=min(al)
mx=max(al)
dis=[]
for i in range(n-1):
    dis.append(al[i+1]-al[i])
dis.append(mn+(k-mx))

dis.sort(reverse=False)
ans=0
for i in range(n-1):
    ans+=dis[i]
print(ans)


Measured memory_bytes: 26444