akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}


int main()
{
  ios::sync_with_stdio(0);
  int a,b,c,k;
  cin >> a >> b >> c >>k;
  ll sum = 0;
  sum += min(k, a);
  k -= min(k, a);
  k -= min(k, b);
  sum -= min(k, c);
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static long[][] memo;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int W = scanner.nextInt();
        int[] w = new int[n+1];
        int[] v = new int[n+1];
        for (int i = 1; i <= n; i++) {
            w[i] = scanner.nextInt();
            v[i] = scanner.nextInt();
        }
        memo = new long[n+1][W+1];
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= W; j++){
                memo[i][j] = -1;
            }
        }
        System.out.println(knapsack(W, n, w, v));
    }

    public static long knapsack(int W, int n, int[] w, int[] v){
        if(W==0||n==0) return 0;
        if(memo[n][W]!=-1) return memo[n][W];
        long take = -1;
        if(W-w[n]>=0){
            take = v[n] + knapsack(W-w[n], n-1, w, v);
        }
        long dont = knapsack(W, n-1, w, v);
        long res = Math.max(take, dont);
        memo[n][W] = res;
        return res;
    }
}

Measured memory_bytes: 125012
#include<iostream>

using namespace std;

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

    switch(n%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        cout << "hon" << endl;
        break;
        case 3:
        cout << "bon" << endl;
        break;
        default:
        cout << "pon" << endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

void call(int n) {
  int x;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0) {
      std::cout << " " << i;
      continue;
    }

    x = i;
    while (x > 0) {
      if (x % 10 == 3)
        break;
      x /= 10;
    }
    if (x > 0) {
      std::cout << " " << i;
      continue;
    }
  }
  std::cout << std::endl;
}

int main() {
  int n;
  std::cin >> n;
  call(n);
}



Measured memory_bytes: 3104
using System;

public class Test
{
	public static void Main()
	{
		// your code goes here
		string[] s = Console.ReadLine().Split(' ');
		int[] n = new int[s.Length];
		for(int i = 0; i < s.Length; i++) {
			n[i] = int.Parse(s[i]);
		}
		
		while(n[0] != 0 || n[1] != 0){
			Array.Sort(n);
			Console.WriteLine(string.Format("{0} {1}", n[0], n[1]) );
			s = Console.ReadLine().Split(' ');
			for(int i = 0; i < s.Length; i++) {
				n[i] = int.Parse(s[i]);
			}
		}
	}
}

Measured memory_bytes: 9492
n, m = map(int, input().split())
a = [[] for _ in range(n)]
for i in range(n):
  a[i] = list(map(int, input().split()))
b = [0 for _ in range(m)]
for i in range(m):
  b[i] = int(input())
for i in range(n):
  c = 0
  for j in range(m):
    c += a[i][j]*b[j]
  print(c)


Measured memory_bytes: 6020
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 == 0 || i % 5 == 0) continue;
            sum+=i;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 35544
import java.util.Scanner;

public class Main {

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

		if(S.contains("a") && S.contains("b") && S.contains("c")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

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

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

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

	int N=in();
	vector<vector<int>> M(N,vector<int>(N,0));
	REP(i,N){
		int v=in()-1,k=in();
		REP(j,k){
			M[v][in()-1] = 1;
		}
	}

	REP(i,N){
		REP(j,N-1){
			cout << M[i][j] << ' ';
		}
		out(M[i][N-1]);
	}
	return 0;
}



Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    val B = readLine()!!.split(" ").map { it.toInt() }.toMutableList()

    // 前から詰めていけばよいのでは？？
    // -> 計算を用意してO(1) で各ステップ完了できればOK
    var cnt = 0L

    for (i in 0 until n) {
        val minus = Math.min(A[i], B[i])
        A[i] -= minus
        B[i] -= minus
        cnt += minus

        val minusPost = Math.min(A[i + 1], B[i])
        A[i + 1] -= minusPost
        B[i] -= minusPost
        cnt += minusPost
    }

    println(cnt)
}

Measured memory_bytes: 85352
#include<bits/stdc++.h>
using namespace std;
int n,d,a[15][15];
int ans;
bool ywt(int m,int n) {
	int z=0;
	for(int i=1;i<=d;i++) z+=(a[m][i]-a[n][i])*(a[m][i]-a[n][i]);
	for(int i=1;;i++) 
		if(i*i==z) return true;
		else if(i*i>z) return false;
}
int main() {
	cin>>n>>d;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++) cin>>a[i][j];
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++) 
			if(ywt(i,j)) ans++; 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
    int e;
    int temp_e;
    int min;
    while (1) {
        std::cin >> e;
        if (e == 0) {
            break;
        }
        min = 1e09;
        for (int z = 100; z >= 0; z--) {
            temp_e = e;
            int z_3 = z * z * z;
            if (z_3 > temp_e) {
                continue; 
            } else {
                temp_e -= z_3;
            }

            for (int y = 1000; y >= 0; y--) {
                temp_e = e - z_3;;
                int y_2 = y * y;
                if (y_2 > temp_e) {
                    continue; 
                } else {
                    temp_e -= y_2;
                }
                int x = temp_e;
                if (x + y + z < min) {
                    min = x + y + z; 
                }
            }
        }
        cout << min << endl;
    }
    return 0;
}

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

vector<int64_t> divisor(int64_t n){
  vector<int64_t> div;
  for(int64_t i=1;i*i<= n;++i) {
    if(n%i==0) {
      div.push_back(i);
      if(i*i!=n) div.push_back(n/i);
    }
  }
  sort(begin(div),end(div));
  return (div);
}


int main(){
  int64_t N;
  cin>>N;

  int64_t ans=0;
  vector<int64_t> v,w;
  v=divisor(N),w=divisor(N-1);
  for(int i=1;i<v.size();++i){
    int64_t n=N,m=v[i];
    while(n%m==0){
      n /= m;
    }
    n %= m;
    if(n==1) ++ans;
  }

  for(int i=1;i<w.size();++i){
    ++ans;
  }

  cout<<ans<<endl;
}

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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = 1e18;
const lint MOD = 1e9 + 7;
const lint inv = MOD - 2;

int main(){
    lint n;
    cin >> n;
    n++;
    lint res = n, ans = 0;
    while(res > 0LL){
        if(res < 10LL){
            ans *= 9LL;
            ans += res - 1LL;
        }else{
            ans++;
        }
        res /= 10LL;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  float div = ceil(N/1000.0);
  int T;
  T = 1000*div;
  cout << T-N << endl;
}

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

int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b == c + d) {
    cout << "Balanced" << endl;
  } else if (a + b > c + d) {
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  vb a(n);
  rep(_,k){
    ll d; cin>>d;
    rep(i,d){
      ll x; cin>>x; x--;
      a[x]=true;
    }
  }
  ll ans=0;
  rep(i,n) if(!a[i]) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3660
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    def get_cost(l,r):
        if r-l==1:return 0
        if r-l==2:return rc[l][0]*rc[r-1][0]*rc[r-1][1]
        if cost[l][r]!=-1:
            return cost[l][r]
        res=cost[l][r]=min(get_cost(l,m)+get_cost(m,r)
                           +rc[l][0]*rc[m][0]*rc[r-1][1] for m in range(l+1,r))
        return res

    n=int(input())
    rc=[list(map(int,input().split())) for _ in range(n)]
    cost=[[-1]*(n+1) for _ in range(n)]
    print(get_cost(0,n))

main()



Measured memory_bytes: 6008
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
 
using namespace std;
 
typedef long long ll;
 
const ll INF = 1e9, MOD = 1e9 + 7;

ll a[3000], n, q, pw, inv2;

ll qpow (ll a, ll b)
{
	ll s = 1;

	while (b)
	{
		if (b & 1) s = s * a % MOD;
		b >>= 1;
		a = a * a % MOD;
	}

	return s;
}

ll d[3000][3000];

ll div2 (ll a)
{
	return {a * inv2 % MOD};
}

ll sum (ll a, ll b)
{
	return {(a + b) % MOD};
}

int main ()
{
	cin >> n >> q;

	pw = qpow (2, q);
	inv2 = qpow (2, MOD - 2);


	for (int i = 0; i < n; i++)
		scanf ("%lld", &a[i]);

	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			if (a[i] > a[j]) {
				d[i][j] = pw;
			}
			else if (a[i] < a[j]) {
				d[j][i] = pw;
			}

	for (int i = 0; i < q; i++) {
		int x, y;
		scanf ("%d%d", &x, &y);
		x--;
		y--;

		for (int j = 0; j < n; j++)
			if (j != x && j != y) {

				auto xj = d[x][j], yj = d[y][j], jx = d[j][x], jy = d[j][y];

				d[x][j] = div2 (sum (xj, yj));
				d[y][j] = div2 (sum (xj, yj));
				d[j][x] = div2 (sum (jx, jy));
				d[j][y] = div2 (sum (jx, jy));
			}

		auto xy = d[x][y], yx = d[y][x];

		d[x][y] = div2 (sum (xy, yx));
		d[y][x] = div2 (sum (xy, yx));
	}

	ll ans = 0;

	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
		{
			ans += d[i][j];
			if (ans >= MOD) ans -= MOD;
		}

	cout << ans;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG




int main() {
  ll H, A;
  cin >> H >> A;


  ll ans;

  if(H%A==0)ans = H/A;
  else ans = H/A+1;

  cout << ans << endl;

  return 0;
}


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

int main(){
  int k,s;
  cin >> k >> s;
  int count = 0;
  for(int i= 0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(s-i-j >=0 && s-i-j <=k){
        count++;
      }
    }
  }
  cout << count << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int n,m;
    cin >> n;
    unordered_map<string,int> money;
    string s;
    rep(i,n){
        cin >> s;
        money[s]++;
    }
    cin >> m;
    rep(i,m){
        cin >> s;
        money[s]--;
    }
    int ans = -1000;
    for(auto itr = money.begin();itr != money.end(); ++itr){
        chmax(ans,itr->second);
    }
    PRINT(max(ans,0));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll m,d;
  cin >> m >> d;
  ll ans=0;
  REP(x,1,m+1) {
    REP(y,10,d+1) {
      ll z=1,yy=y;
      while(yy) {
        if(yy%10<2) goto next;
        z*=yy%10;
        yy/=10;
      }
      if(x==z) {
        ans++;
      }
    next:;
    }
  }
  pr(ans);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  long long A,B,K;
  cin>>A>>B>>K;
  
  
  if(K%2==0){
    for(int i=0;i<K/2;i++){
      if(A%2==1){
        A--;
      }
      B+=A/2;
      A/=2;
      if(B%2==1){
        B--;
      }
      A+=B/2;
      B/=2;
    }
    
    cout<<A<<" "<<B;
  }
  else{
    for(int i=0;i<K/2;i++){
       if(A%2==1){
        A--;
      }
      B+=A/2;
      A/=2;
      if(B%2==1){
        B--;
      }
      A+=B/2;
      B/=2;
    }
     if(A%2==1){
        A--;
      }
      B+=A/2;
      A/=2;
    
    cout<<A<<" "<<B;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V< bitset<2000> > a(n);
  for (int i = 1; i < n; ++i) {
    string s; cin >> s;
    for (int j = 0; j < i; ++j) {
      a[i][j] = s[j] == '1';
      a[j][i] = s[j] == '0';
    }
  }
  V< bitset<2000> > dp(n);
  for (int i = 0; i < n; ++i) {
    dp[i][i] = true;
    if (i) dp[i - 1][i] = a[i][i - 1];
    if (i + 1 < n) dp[i + 1][i] = a[i][i + 1];
  }
  for (int w = 2; w < n; ++w) {
    for (int i = 0; i < n; ++i) {
      int j = i + w;
      if (j < n) {
        dp[j][i] = (a[i] & dp[i + 1] & dp[j])._Find_next(i) <= j;
      }
      j = i - w;
      if (j >= 0) {
        dp[j][i] = (a[i] & dp[i - 1] & dp[j])._Find_next(j - 1) <= i - 1;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n; ++i) res += dp[0][i] and dp[n - 1][i];
  cout << res << '\n';
}

Measured memory_bytes: 1280
N=io.read"*n"
io.read()
S={}
for i=1,N do table.insert(S,io.read())end

local lr={}

local ls=string.byte"("
local rs=string.byte")"

for i,s in ipairs(S)do
	local b={s:byte(1,#s)}
	local l,r=0,0
	for j,v in ipairs(b) do
		if(v==ls)then
			r=r+1
		else
			if(r>0)then r=r-1
			else l=l+1 end
		end
	end
	if(l~=0 or r~=0)then table.insert(lr,{l,r})end
end

if(#lr==0)then print"Yes"return end

do
local s=0
for _,v in ipairs(lr)do
	s=s+v[1]-v[2]
end
if(s~=0)then print"No"return end
end

local bl,br=-1,-1
for i,v in ipairs(lr)do
	if(v[1]==0)then bl=i end
	if(v[2]==0)then br=i end
end
if(bl==-1 or br==-1)then print"No"return end

local s=lr[bl][2]
table.remove(lr,math.max(bl,br))
table.remove(lr,math.min(bl,br))
table.sort(lr,function(a,b)return a[1]-a[2]<b[1]-b[2]end)

for i,v in ipairs(lr)do
	s=s-v[1]
	if(s<0)then print"No"return end
	s=s+v[2]
end

print"Yes"

Measured memory_bytes: 81508
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long cnt;

void main()
{
    auto s = sread();
    if(s[2] == s[3] && s[4] == s[5])
        writeln("Yes");
    else
        writeln("No");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ll long long
#define vi  vector<int>
#define vl vector<ll>
#define Graph  vector<vi>  // vi <=> vl
#define vb  vector<bool>
#define boolGraph  vector<vb>
#define P  pair<int, int>  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

vl fac, finv, inv;

void com_init(const int MAX) {
  fac.resize(MAX);  fac[0] = fac[1] = 1;
  finv.resize(MAX); finv[0] = finv[1] = 1;
  inv.resize(MAX);  inv[1] = 1;
  for (int i=2; i<MAX; ++i) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}

ll combination(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

int main() {
  int n; cin >> n;
  vi arr(n+1);
  rep(i,n+1) cin >> arr[i];

  com_init(n+5);

  int dist;
  map<int, int> counter;
  rep(i,n+1) {
    if (counter.count(arr[i])) {
      dist = i - counter[arr[i]];
      break;
    }

    counter[arr[i]] = i;
  }

  vl ans(n+1);
  rep(r,n+1) ans[r] = combination(n+1, r+1);
  rep(r,n+1-dist) (ans[r] += MOD - combination(n-dist, r)) %= MOD;
  rep(i,n+1) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 9472
# 2019-11-17 10:52:21(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    s, t = [s.rstrip() for s in sys.stdin.read().split()]
   
    if set(t) - set(s):
        print(-1)
        sys.exit()

    count = 0
    l = 0
    i = 0
    current = t[i]
    all_found = False
    while not all_found:
        j = s.find(current, l, len(s))
        if j == -1:
            count += len(s)
            l = 0
        else:
            if i == len(t) - 1:
                count += j + 1
                all_found = True
            else:
                if j == len(s) - 1:
                    count += len(s)
                    l = 0
                else:
                    l = j + 1
                i += 1
                current = t[i]
    print(count)



if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    int coins[m];
    for (int i = 0; i < m; ++i) {
        cin >> coins[i];
    }
    sort(coins, coins + m, greater<>());

    int dp[m + 1][50001];
    for (int i = 0; i <= 50000; ++i) {
        if (i == 0) dp[m][i] = 0;
        else dp[m][i] = 1'000'000'000;
    }

    for (int i = m - 1; i >= 0; --i) {
        for (int j = 0; j <= n; ++j) {
            if (j < coins[i]) {
                dp[i][j] = dp[i + 1][j];
            } else {
                dp[i][j] = min(dp[i + 1][j], dp[i][j - coins[i]] + 1);
            }
        }
    }

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


Measured memory_bytes: 7216
def gcd(a,b):
  if(a<b):
    a,b=b,a
  if(b==0):
    return a
  c= a%b
  return gcd(b,c)

n=int(input())
hoge=list(map(int,input().split()))
hoge.sort()
for i in range(n-1):
  hoge[i+1]=gcd(hoge[i],hoge[i+1])
  
print(hoge[-1])

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string s,t,tmp,ans="No";
    cin>>s>>t;
    REP(i,s.size()){
        if(s==t){
            ans="Yes";
            break;
        }
        s=s.at(s.size()-1)+s.substr(0,s.size()-1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);


int main(){
  int N; cin >> N;
  ll X[N];
  for (int i = 0; i < N; i++) cin >> X[i];

  ll ans = 1e9;
  for (int i = 1; i <= 100; i++){
    ll sum = 0;
    for (int j = 0; j < N; j++){
      sum += (X[j] - i) * (X[j] - i);
    }
    ans = min(sum, ans);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    print(if (req1(s)&&req2(s)&&req3(s)) "AC" else "WA")
}

fun req1(s: String): Boolean {
    return s[0] == 'A'
}

fun req2(s: String): Boolean {
    val len = s.substring(2 until s.length-1).filter{it == 'C'}.length
    return len == 1
}

fun req3(s: String): Boolean {
    return s.filter{(it != 'A' && it != 'C')}.all{it.isLowerCase()}
}


Measured memory_bytes: 33792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC147C - HonestOrUnkind2
  // 「正直者か不親切な者の二択」で、N=15なのでbit全探索を行う
  // bitが1のとき正直者、0のとき不親切な者であるとして、「正直者の全ての証言」が矛盾していないか確認する
  // 不親切な者の証言は、真偽不明なので検証しなくてもよい
  // 1 << Nは、2^Nと同じ、(i >> j) & 1 = 1は、j番目のbitが1のときの条件式
  int N;
  cin >> N;
  // データ構造としてそれぞれ配列にしている
  vector<int> A(N);  // A[i]:i番目の人の証言の個数
  vector<vector<int>> x(N, vector<int>());  // x[i][j]:i番目の人のj個目の証言【x[i][j]番目の人】
  vector<vector<int>> y(N, vector<int>());  // y[x][j]:i番目の人のj個目の証言【x[i][j]番目の人が正直者か不親切な者か】
  REP(i, N){
    cin >> A[i];
    REP(j, A[i]){
      int tmpx, tmpy;
      cin >> tmpx >> tmpy;
      x[i].push_back(tmpx-1);
      y[i].push_back(tmpy);
    }
  }
  // 以下、bitで正直者・不親切な者を仮定して、矛盾がないか探索していく
  int ans = 0;
  REP(i, 1 << N){
    bool flag = true;  // 一旦、仮定が正しいとする
    REP(j, N){
      if(!(i >> j & 1)) continue;  // 不親切な者の証言はスルー
      REP(k, A[j]){  // 証言の個数分繰り返す
        if((i >> x[j][k] & 1) ^ y[j][k]) flag = false;
      }
    }
    if(flag){  // 正直者の数をカウントする
      int tmp = 0;
      REP(j, N){
        if(i >> j & 1) tmp++;
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
}


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

int n, k;

int main() {
    cin >> n >> k;
    // Sum of arithmetic sequences
    int sas = (n - 2) * (n - 1) / 2;
    if (k > sas) {
        cout << -1 << endl;
        return 0;
    }
    int m = n - 1 + sas - k;
    cout << m << endl;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (m == 0) break;
            printf("%d %d\n", i, j);
            m--;
        }
    }
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }
    ll g = A[0];
    REP(i, N) {
        g = gcd(A[i], g);
    }

    bool e = false;
    REP(i, N) {
        if (A[i] - K >= 0 && (A[i] - K) % g == 0)
            e = true;
    }
    if (e)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

const int inf = 1e9 + 7;

struct Node {
    int v, refuel, cost;
    bool operator<(const Node &o) const {
        return refuel != o.refuel ?
            refuel > o.refuel :
            cost > o.cost;
    }
};

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

    int n, m, l;
    cin >> n >> m >> l;
    vt<vt<pii>> adj(n);
    while (m--) {
        int u, v, w;
        cin >> u >> v >> w;
        if (w > l) continue;
        u--, v--;

        adj[u].emplace_back(v, w);
        adj[v].emplace_back(u, w);
    }

    vt<vt<pii>> cost(n, vt<pii>(n, {inf, 0}));
    for (int s = 0; s < n; s++) {
        cost[s][s] = {0, 0};
        priority_queue<Node> q;
        q.push({s, 0, 0});
        while (!q.empty()) {
            Node cur = q.top();
            q.pop();

            if (pii{cur.refuel, cur.cost} != cost[s][cur.v]) continue;

            for (pii &v : adj[cur.v]) {
                pii newCost = {cur.refuel, cur.cost + v.se};
                if (newCost.se > l) {
                    newCost.fi++;
                    newCost.se = v.se;
                }

                if (newCost < cost[s][v.fi]) {
                    cost[s][v.fi] = newCost;
                    q.push({v.fi, newCost.fi, newCost.se});
                }
            }
        }
    }

    int q;
    cin >> q;
    while (q--) {
        int u, v;
        cin >> u >> v;
        u--, v--;

        int c = cost[u][v].fi;
        cout << (c == inf ? -1 : c) << '\n';
    }
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define nl '\n'
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cerr << #x << " = " << (x) << endl;

// template starts
typedef long long int ll;

// template ends here

void solve(){
	// code starts from here
	int n;
	cin >> n;
	vector<pair<int,int>> vec(n);
	for(int i = 0; i < n; i++) cin >> vec[i].first >> vec[i].second;
	
	bool ok = false;
	for(int i = 0; i+2 < n; i++){
		if(vec[i].first == vec[i].second && vec[i+1].first == vec[i+1].second && vec[i+2].first == vec[i+2].second) ok = true;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//startTime = clock();
	
	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	
	//cout << getCurrentTime() << endl;
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,a,b)	for(int i=a;i<=b;i++)
#define rrep(i,a,b)	for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=1e5+5,inf=0x3f3f3f3f;
int mp[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,x,res=0;
	cin>>n;
	rep(i,1,n)
		cin>>x,mp[x]++;
	rep(i,1,100)
		if(mp[i])
			res++;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,min=1000000,max=-1000000,i,a;
    long long sum = 0;
    scanf("%d\n",&n);
    if(0<n<=10000){
        for(i=1;i<=n;i++){
            scanf("%d ",&a);
            sum+=a;
            if(a>max){
            max=a;
            }
            if(a<min){
            min=a;
            }
        }
            printf("%d %d %lld\n",min,max,sum);
    }
       
    return 0;
    
}


Measured memory_bytes: 2136
module Main where

import Data.Functor

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  { [w,h,x,y,r] <- getInts
  ; putStrLn (check (w,h,x,y,r))
  }

check :: (Int,Int,Int,Int,Int) -> String
check (w,h,x,y,r)
  | x < r     = "No"
  | y < r     = "No"
  | x > w-r   = "No"
  | y > h-r   = "No"
  | otherwise = "Yes"

check' :: (Int,Int,Int,Int,Int) -> String
check' (w,h,x,y,r)
  | r <= x && x <= w - r && r <= y && y <= h - r = "Yes"
  | otherwise                                    = "No"

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

LL wari = 1e9 + 7;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

LL kaijo(LL n){
	if(n == 0) return 1;
	return n*kaijo(n-1)%wari;
}

int main(){
	// sengen
	LL s;
	// nyuryoku
	cin >> s;
	LL ans = 0;
	LL minl,maxl;
	maxl = s/3;
	minl = 1;
	// keisan
	for(LL i = minl;i<=maxl;i++){
		LL amari = s - 3*i;
		LL zen = amari + i - 1;
		LL add = kaijo(zen)*modinv(kaijo(amari),wari)%wari;
		add = add*modinv(kaijo(i-1),wari)%wari;
		ans = ans + add;
		ans = ans%wari;
	}
	// syutsuryoku
	cout << ans << endl;
}

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

signed main(){
	vector<pair<int,int> > v;
	int n;
	cin>>n;
	int s=0,res=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		v.push_back(make_pair(x,y));
	}
	if(v[0].first==v[0].second) s=1;
	for(int i=1;i<n;i++){
		if(v[i].first==v[i].second){
			s++;
		} 
		else if(v[i].first!=v[i].second&&v[i-1].first==v[i-1].second){
			if(s>res){
				res=s;
			} 
			s=0;
		}
	}
	if(res>=3||s>=3){
		cout<<"Yes";
		return 0;
	} 
	for(int i=2;i<n;i++){
		if(v[i-2].first==v[i-1].first&&v[i-2].first==v[i].first){
			if(v[i-2].second==v[i-1].second&&v[i-2].second==v[i].second){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3636
using System;

class Program{
    class Node{
        public int key;
        public Node parent;
        public Node left;
        public Node right;
    }

    static void Insert(Node root, Node z){
        Node y=null;
        var x=root.left;
        while (x!=null) {
            y=x;
            if (z.key<x.key) {
                x=x.left;
            } else {
                x=x.right;
            }
        }
        z.parent=y;
        if (y==null) {
            root.left=z;
        } else if (z.key<y.key) {
            y.left=z;
        } else {
            y.right=z;
        }
    }

    static bool Find(Node node, int key){
        if (node.key==key) {
            return true;
        } else {
            if (node.key>key) {
                return node.left!=null && Find(node.left, key);
            } else {
                return node.right!=null && Find(node.right, key);
            }
        }
    }

    static void WalkPreorder(Node node){
        Console.Write(" "+node.key);
        if(node.left!=null){
            WalkPreorder(node.left);
        }
        if(node.right!=null){
            WalkPreorder(node.right);
        }
    }

    static void WalkInorder(Node node){
        if(node.left!=null){
            WalkInorder(node.left);
        }
        Console.Write(" "+node.key);
        if(node.right!=null){
            WalkInorder(node.right);
        }
    }

    public static void Main(){
        var m=int.Parse(Console.ReadLine());
        var root=new Node();
        for (var i=0; i<m; i++) {
            var s=Console.ReadLine().Split(' ');
            if (s[0][0]=='i') {
                var node=new Node();
                node.left=null;
                node.right=null;
                node.key=int.Parse(s[1]);
                Insert(root, node);
            } else if (s[0][0]=='f') {
                Console.WriteLine(Find(root.left, int.Parse(s[1])) ?
                        "yes" : "no");
            } else {
                WalkInorder(root.left);
                Console.WriteLine();
                WalkPreorder(root.left);
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 39196
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n;cin >>n;
  vector<ll> a(n);
  map<ll,ll> mp;
  rep(i,1000000)mp[i]=0;
  ll ans=0;
  rep(i,n){
    cin >>a[i];
    mp[a[i]]++;
    ans+=a[i];
  }
  ll q; cin >>q;
  vector<ll> b(q),c(q);
  rep(i,q) cin >>b[i]>>c[i];
  
  rep(i,q){
    ll r=mp[b[i]];
    ans-=b[i]*r;
    ans+=r*c[i];
    mp[c[i]]+=r;
    mp[b[i]]=0;
    cout <<ans<<endl;
  }  
}
    
  
  

Measured memory_bytes: 68180
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int maxn = 5000;
const ll INF = 1e18 + 7;
ll dp[55][5050], ans[55];
struct path{
	int st;
	int nd;
	ll val;
	bool operator < (const path &o) const{
		return val > o.val;
	}
};


std::vector<path> gr[60];
pii ex[60];

int main(){
	int n, m, sil, x, y;
	ll z;
	scanf("%d %d %d", &n, &m, &sil);
	for(int i = 1; i <= m; i++){
		int u, v, a;
		ll b;
		scanf("%d %d %d %lld", &u, &v, &a, &b);
		gr[u].push_back({v, a, b});
		gr[v].push_back({u, a, b});
	}
	for(int i = 1; i <= n; i++){
		ans[i] = INF;
		for(int j = 0; j <= 5000; j++){
			dp[i][j] = INF;
		}
	}
	for(int i = 1; i <= n; i ++){
		scanf("%d %d", &ex[i].st, &ex[i].nd);
	}
	priority_queue<path> pq;
	pq.push({1,min(sil, maxn), 0});
	int cnt = 0;
	while(!pq.empty()){
		path p = pq.top();
		pq.pop();
		x  = p.st, y = p.nd, z = p.val;
		if(dp[x][y] != INF){
			continue;
		}
		//printf("at %d %d %lld\n", x, y, z);
		dp[x][y] = z;
		if(ans[x] == INF) ans[x] = z, cnt++;
		if(cnt == n) break;
		int ma = min(y + ex[x].st, 5000);
		if(dp[x][ma] == INF) pq.push({x, ma, z + ex[x].nd});
		for(auto it: gr[x]){
			if(it.nd > y) continue;
			if(dp[it.st][y - it.nd] == INF){
				pq.push({it.st, y - it.nd, z + it.val});
			}
		}
	}
	for(int i = 2; i <= n; i++){
		printf("%lld\n", ans[i]);
	}

}

Measured memory_bytes: 13504
#include <stdio.h>

int main(){
	char S, A, B;
	scanf("%c%c%c", &S, &A, &B);
	if(S, A != B){
		printf("Yes\n");
	}else if(S, B != A){
		printf("Yes\n");
	}else if(A, B != S){
		printf("Yes\n");
	}else if( S == A, A == B){
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}





int main(){
  int X,Y;
  bool f = false;
  cin >> X >> Y;
  rep(i,X+1){
    if(i*2 + (X-i)*4 == Y) f = true;
  }
  cans(f);
  return 0;
}


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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

const int maxn = 1e5+5;
int n;
int arr[maxn];


int main(){
	scanf("%d",&n);
	int ret = 0;
	rep(k,0,n){
		scanf("%d",&arr[k]);
	}
	rep(k,0,n){
		int i = k+1;
		while(i<n && arr[i]==arr[i-1]){
			i++;
		}
		
		int cur = arr[i]>arr[k];
		while(i<n && ((cur==(arr[i]>arr[i-1])) || arr[i]==arr[i-1]))i++;
		k=i-1;ret++;
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-

from math import ceil

n, h = map(int, input().split())
a_li = []
b_li = []
for _ in range(n):
    a, b = map(int, input().split())
    a_li.append(a)
    b_li.append(b)

a_max = max(a_li)
b_li.append(a_max)
b_li.sort()

cnt = 0
while h > 0:
    b_max = b_li.pop()
    if b_max == a_max:
        cnt += ceil(h / a_max)
        break
    else:
        h -= b_max
        cnt += 1

print(cnt)


Measured memory_bytes: 11316
H,W = map(int,input().split())
S = [input() for i in range(H)]

dxy = [(0,1),(1,0),(0,-1),(-1,0)]
from collections import deque
ans = 0
for y in range(H):
    for x in range(W):
        if S[y][x] == '#': continue
        dist = [[0]*W for i in range(H)]
        visited = [[0]*W for i in range(H)]
        visited[y][x] = 1
        q = deque([(x,y)])
        while q:
            x,y = q.popleft()
            for dx,dy in dxy:
                nx,ny = x+dx,y+dy
                if not 0 <= nx < W: continue
                if not 0 <= ny < H: continue
                if visited[ny][nx]: continue
                if S[ny][nx] == '#': continue
                visited[ny][nx] = 1
                dist[ny][nx] = dist[y][x] + 1
                q.append((nx,ny))
        ans = max(ans, max(max(row) for row in dist))
print(ans)

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



int main() {
	// freopen("input.in", "r", stdin);
	// freopen("output.o", "w", stdout);
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int num = 100 * a + 10 * b + c;
	if (num % 4 == 0) {
		puts("YES");
	} else puts("NO");
}

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

int main(){
  string S;
  cin >> S;
  int i,j;
  i=0;
  j=S.size()-1;
  int ans = 0;
  while(i<j){
   if(S.at(i)!=S.at(j)){
     ans++;
   }
    i++;
    j--;
  }
  cout << ans << endl;
}

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

#define ll long long
#define f first
#define s second
#define inf 1e15

#define N 300005

int n,m,x,y;
int a[N];

int visited[1001][1001];

int dr[]={0,0,-1,1};
int dc[]={-1,1,0,0};

int valid(ll x,ll y){
    return (x>=0 && x<n && y>=0 && y<m);
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--){
	    
	    //input
	    cin>>n>>m;
	    
	    int mat[n][m];
	    
	    int a,b,c,d;
	    cin>>a>>b>>c>>d;
	    
	    a--;b--;c--;d--;
	    
	    string s;
	    
	    for(int i=0;i<n;i++){
	        cin>>s;
	        for(int j=0;j<m;j++){
	            mat[i][j]=(s[j]=='.');
	        }
	    }
	    
	    deque<pair<pair<ll,ll>,ll>>q;
	    
	    q.push_front({{a,b},0});
	    
	    while(!q.empty()){
	        
	       // cout<<"hello\n";
	        pair<pair<ll,ll>,ll> x=q.front();
	        
	        q.pop_front();
	        
	        pair<ll,ll> pos=x.f;
	        
	        if(pos.f==c && pos.s==d){
	            cout<<x.s;
	            return 0;
	        }
	       // cout<<"start\n";
	        if(visited[pos.f][pos.s]){
	            continue;
	        }
	       // cout<<"end\n";
	        visited[pos.f][pos.s]=1;
	        
	        //0
	        for(int i=0;i<4;i++){
	            
	            int u=pos.f+dr[i];
	            int v=pos.s+dc[i];
	            
	            
	            if(valid(u,v) && !visited[u][v] && mat[u][v] ){
	                
	               // cout<<"hello2\n";
	                q.push_front({{u,v},x.s});
	            }
	        }
	        //1
	        for(int dr=-2;dr<=2;dr++){
	            for(int dc=-2;dc<=2;dc++){
	            
	            int u=pos.f+dr;
	            int v=pos.s+dc;
	            
	            if(valid(u,v) && !visited[u][v] && mat[u][v] ){
	                
	                q.push_back({{u,v},x.s+1});
	            }
	         }
	        }
	        
	    
	    
	    }
	    cout<<-1<<"\n";
	    
	    
	}
	return 0;
}


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

using namespace std;

#define ll long long

int main() {
	string s;
	int i, j;
	int ans = 0;
	int buf = 0;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'R') {
			buf++;
			if (buf > ans)ans = buf;
		}
		else buf = 0;
	}
	cout << ans<< endl;
	
	return 0;

}

Measured memory_bytes: 3592
#include <atcoder/segtree>
#include <iostream>
#include <cmath>
#include <vector>
using namespace atcoder;
using namespace std;

int op(int a, int b) { return max(a, b); }

int e() { return 0; }

int main(void)
{
    const int MAX = 300'000;

    int n, k;
    cin >> n >> k;

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

    int overall_max_len = 0;
    segtree<int, op, e> seg(MAX + 1);

    for (auto &&a : arr)
    {
        const int max_len = seg.prod(max(0, a - k), min(MAX + 1, a + k + 1)) + 1;
        seg.set(a, max_len);
        overall_max_len = max(overall_max_len, max_len);
    }
    
    cout << overall_max_len << endl;
}


Measured memory_bytes: 9560
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define tp          tuple<int,int,int>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

///a^b % MOD
ll bigMod(ll a , ll b) {

    ll p ;
    if( b == 0) return 1;
    p = ( bigMod(a , b/2) % MOD );
    p = ( p * p) % MOD;
    if( b & 1 ) p = ( p * a) % MOD;
    return p;
}
/// (1/x) % MOD
ll modInverse( ll x ) {
    return bigMod(x, MOD-2);
}


int main()  {
    fastio;
    int n;
    cin>>n;
    vector<ll>vec(n);
    ll tot = 0;
    ll baad = 0;

    for(int i =0 ; i  < n ; i++ ) {
        cin>>vec[i];
        tot += vec[i];
        baad += vec[i]*vec[i];
        tot %= MOD;
        baad %= MOD;
    }

    tot *= tot;
    tot %= MOD;
    tot -= baad;
    tot %= MOD; 

    if(tot < 0 ) tot += MOD;

    ll ret = (tot * modInverse(2))%MOD;
    cout<<ret<<'\n';
    return 0;
    
    
}

Measured memory_bytes: 4752
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>, int> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;
 
int k, a ,b;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> k >> a >> b;
    if (a + 2 >= b) return cout << k + 1, 0;
    ll ans = 1;
    if (k < a - 1) return cout << k + 1, 0;
    ans += a - 1;
    k -= a - 1;
    assert(k > 0);
    if (k == 1) return cout << ans + 1, 0;
    ans += b - a;
    k -= 2;
    ll add = (ll) k / 2 * (b - a);
    ans += add;
    if (k % 2 == 1) ++ans;
    cout << ans;
}

Measured memory_bytes: 256
s=input()
k=int(input())
sl=[]
n=len(s)
for i in range(n):
  if s[i]!='a':
    if 26-(ord(s[i])-97)<=k:
      sl.append('a')
      k-=26-(ord(s[i])-97)
    else:
      sl.append(s[i])
  else:
    sl.append(s[i])
if k>0:
  if k%26!=0:
    sl[n-1]=chr(ord(sl[n-1])+k%26)
print(''.join(sl))

Measured memory_bytes: 4212
n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))

ans = 0
killed = 0
for i in range(n):
    rem_a = al[i] - killed
    if bl[i] >= rem_a:
        ans += rem_a
        rem_b = bl[i] - rem_a
        if rem_b >= al[i+1]:
            ans += al[i+1]
            killed = al[i+1]
        else:
            ans += rem_b
            killed = rem_b
    else:
        ans += bl[i]
        killed = 0
print(ans)

Measured memory_bytes: 97640