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

using namespace std;

bool ok;
int n; char ch[302][302];
long long sol;

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      cin >> ch[i][j];
  for (int k = 0; k < n; k++) {
    ok = 1;
    for (int i = 0; i < n && ok; i++) {
      for (int j = 0; j < n; j++)
        if (ch[i][(j + k) % n] != ch[j][(i + k) % n]) {ok = 0; break;}
    }
    if (ok)
      sol++;
  }
  cout << sol * n;
  return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto & a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define endl "\n"
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int MAXN = 500'010;

int N, Q;
int cnt[MAXN], C[MAXN];
int diff = 0;

void add(int ind) {
  if(++cnt[C[ind]] == 1) diff++;
} // add a[ind]
void del(int ind) {
  if(--cnt[C[ind]] == 0) diff--;
} // remove a[ind]
int calc() { return diff; } // compute current answer

vi mo(vector<pii> Q) {
	int L = 0, R = 0, blk = 350; // ~N/sqrt(Q)
	vi s(sz(Q)), res = s;
#define K(x) pii(x.first/blk, x.second ^ -(x.first/blk & 1))
	iota(all(s), 0);
	sort(all(s), [&](int s, int t){ return K(Q[s]) < K(Q[t]); });
	trav(qi, s) {
		pii q = Q[qi];
		while (L > q.first) add(--L);
		while (R < q.second) add(R++);
		while (L < q.first) del(L++);
		while (R > q.second) del(--R);
		res[qi] = calc();
	}
	return res;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);

	cin >> N >> Q;
	fill(cnt, cnt+N+1, 0);

	rep(i, 0, N) cin >> C[i];

	vector<pii> Qs(Q);
	trav(q, Qs) cin >> q.first >> q.second, --q.first;

	vi ans = mo(Qs);
	rep(i, 0, Q) cout << ans[i] << endl;
}


Measured memory_bytes: 18712
#include <cstdio>
#include <vector>

using namespace std;

const int MAXN=3e3+5;
typedef long long int ll;
const ll MOD=998244353;
ll dp[MAXN][MAXN];

int N,S;
int A[MAXN];

int main(){
    scanf("%d%d",&N,&S);

    for(int i=0;i<N;i++) scanf("%d",A+i);

    dp[0][0]=1ll;

    for(int i=0;i<N;i++){
        for(int cost=0;cost<=S;cost++){
            int incr[]={A[i],0,0};
            for(int k=0;k<3;k++){
                auto target=cost+incr[k];
                if (target>S) continue;
                dp[i+1][target]=(dp[i+1][target]+dp[i][cost])%MOD;
            }
        }
    }

    printf("%lld\n",dp[N][S]);

    return 0;
}

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

namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            if(Console.ReadLine()=="1")
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                Console.WriteLine(int.Parse(Console.ReadLine()) + int.Parse(Console.ReadLine()));
            }
            
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>



int partition(int *A,int p,int r){

  int x,tmp,j,i;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      tmp=A[j];
      A[j]=A[i];
      A[i]=tmp;
    }
  }
  tmp=A[r];
  A[r]=A[i+1];
  A[i+1]=tmp;

  return i+1;
}

int main(){

  int n,i,x;

  scanf("%d",&n);

  int A[n];

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  x=partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(i==x)
      printf("[%d]",A[i]);
    else
      printf("%d",A[i]);
    if(i<n-1)
      printf(" ");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 992
n, m, Q = map(int, input().split())
v = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    l, r = map(int, input().split())
    v[r - 1][l - 1] += 1
    


for i in range(1, n):
    for j in range(n):
        v[i][j] += v[i - 1][j]



for i in range(n):
    for j in range(1, n):
        k = n - j - 1
        v[i][k] += v[i][k + 1]



for i in range(Q):
    p, q = map(int, input().split())
    print(v[q-1][p-1])

Measured memory_bytes: 10584
# next_combination:
# given an integer cur, next_combination returns an integer nxt s.t.
#   nxt has the same number of 1s as cur
#   nxt is bigger than cur
#   no integer between cur and nxt has the same number of 1s as cur (and nxt)
def next_combination(cur):
    r1 = cur & -cur      # extracts the rightmost 1
    moved1 = cur + r1    # cancel the rightmost run of 1s and put 1 on its left
    rm1s = cur & ~moved1 # extracts the rightmost run of 1s
    reset = (rm1s // r1) >> 1 # the run of 1s moved to LSD and made its length decreased by 1
    nxt = moved1 | reset # new combination
    return nxt

# the next is i-th, with a[k] for k > i to win
# at most 4 wins for each: about 4^9 = 2^18 states?
while True:
    n=int(input())
    if n == 0: break
    
    m=int(input())
    # wons and loses so far
    wons=[ 0 for _ in range(n) ]
    loses=[ 0 for _ in range(n) ]
    for i in range(m):
        x,y=map(int,input().split())
        wons[x-1] |= (1<<(y-1))
        loses[y-1] |= (1<<(x-1))
	
    memo = tuple({} for _ in range(9) )
	
    
    def rec(i,ws):
        if i >= n: return 1
        if n - 1 - i < ws[i]: return 0
        if tuple(ws) in memo[i]:
            return memo[i][tuple(ws)]
        # possible assignments of ws[i] wins matching with the input
        k = ws[i]
        win = ((1<<k) - 1) << (i+1)   # beginning: k wins against i+1,...,i+k
        fin = win << (n-1-k-i)        # end: k wins against n-k+1...,n-1
        cnt = 0
        while True:
	    # print("win = {0}".format(bin(win)))
	    # print("fin = {0}".format(bin(fin)))
	    # consistency check with wons and loses 
            mask = (1<<n) - (1<<(i+1))  # i+1, ..., n-1
            won = wons[i]
            lose = loses[i]
            if (won & win) == (won & mask) and (lose & win) == 0:
                ok = True
                for j in range(i+1,n):
                    if (1<<j) & win == 0:
                        if ws[j] == 0: ok = False
                        ws[j] -= 1
                if ok: cnt += rec(i+1, ws)
                for j in range(i+1,n):
                    if (1<<j) & win == 0:
                        ws[j] += 1
            if win == fin: break
            win = next_combination(win)
        
        memo[i][tuple(ws)] = cnt
        return cnt
    
    ans=rec(0, [ n//2 for _ in range(n)] )	
    print(ans)



Measured memory_bytes: 12304
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;
int n;
int lowbit(int x) { return x & (-x); }
int arr[26][500005];
void add(int id, int x, int v) { x++;
    while (x <= n)
        arr[id][x] += v, x += lowbit(x);
}
int query(int id, int x) { // [0, x)
    int ret = 0;
    while (x > 0)
        ret += arr[id][x], x -= lowbit(x);
    return ret;
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    string s; cin >> s;
    memset(arr, 0, sizeof(arr));
    for (int i = 0 ; i < n ; i++)
        add(s[i] - 'a', i, 1);
    int q; cin >> q; while (q--) {
        int op; cin >> op;
        if (op == 1) {
            int x; char c; cin >> x >> c; x--;
            add(s[x] - 'a', x, -1);
            add(c - 'a', x, 1);
            s[x] = c;
        } else if (op == 2) {
            int cnt = 0;
            int l, r; cin >> l >> r; l--;
            for (int i = 0 ; i < 26 ; i++)
                if (query(i, r) - query(i, l) >= 1)
                    cnt++;
            cout << cnt << '\n';
        }
    }
}


Measured memory_bytes: 51740
A,B,K=map(int, input().split())

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

def yakusuu(n):
    y=[]
    for i in range(1,-(-n//2)+1):
        if n%i==0:
            y.append(i)
            y.append(n//i)
        y=list(set(y))
        y.sort()
    return(y)
        
print(yakusuu(gcd(A,B))[-K])

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
int H=0 ,A=0;
scanf("%d %d",&H ,&A);
//cin >> H,A;
int amari = 0;
double a;
a = H % A;
if(H%A != 0){
    amari = 1;
}
//printf("%d,%d\n", H,A);
printf("%d\n", H/A+amari);
}


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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A

bool map[100][100];
int main() {
	int n;
	cin >> n;
	//bool map[n][n] = {0};
	for (int i = 0; i < n; i++) {
		int a, c;
		cin >> a >> c;
		for (int j = 0; j < c; j++) {
			int b;
			cin >> b;
			map[a - 1][b - 1] = true;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << (map[i][0] ? "1" : "0");
		for (int j = 1; j < n; j++) {
			cout << " " << (map[i][j] ? "1" : "0");
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

int N, Q;
string S;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Q;
  cin >> S;
  S = "x" + S;
  vector<int> c_sum(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    if (S[i - 1] == 'A' && S[i] == 'C') {
      c_sum[i] = c_sum[i - 1] + 1;
    } else {
      c_sum[i] = c_sum[i - 1];
    }
  }

  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << c_sum[r] - c_sum[l] << endl;
  }

  return 0;
}

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

import fileinput
import math

def main():
    number = int(input())
    for line in fileinput.input():
        tokens = list(map(int, line.strip().split()))

        tokens.reverse()

        for i in range(number):
            if(i == number-1):
                print('%d' % (tokens[i]), end='')
            else:
                print('%d ' % (tokens[i]), end='')

        print('')

if __name__ == '__main__':
    main()

Measured memory_bytes: 7852
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        int A, B, S;
        cin >> A >> B;
        
        for (int i = 0; i < 2; ++i){
            if (A > B){
                S += A--;
            }else{
                S += B--;
            }
        }

        cout << S << endl;
    }

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H, W; cin >> H >> W;
    vs S(H+2); 
    S[0] = string(W + 2, '.');
    FOR(i,1,H+1) {
        cin >> S[i];
        S[i] = "." + S[i] + ".";
    }
    S[H+1] = string(W + 2, '.');

    bool ok = true;
    FOR(i,1,H+1){
        FOR(j,1,W+1){
            if (S[i][j]=='#' &&
                S[i-1][j]=='.' && S[i+1][j]=='.' &&
                S[i][j-1]=='.' && S[i][j+1]=='.') {
                ok = false;
                break;
            }            
        }
        if (!ok) break;
    }

    string ans = ok ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi v(n), c(n);
	rep(i, n)cin >> v[i];
	rep(i, n)cin >> c[i];
	
	int ans = 0;
	rep(i, n)ans += max(v[i] - c[i], 0);
	cout << ans << endl;
}

Measured memory_bytes: 3632
def make(n)
    if n == 1
        return [[''],['+']]
    else
        a = make(n-1)
        res = []
        a.size.times do |i|
            res << a[i]+['']
            res << a[i]+['+']
        end
        return res
    end
end

s = gets.chomp.split(//)

if s.size == 1
    puts s[0]
    exit
end

a = make(s.size-1)
sum = 0
a.each do |e|
    expr = ''
    e.size.times do |i|
        expr += s[i]+e[i]
    end
    expr += s[-1]
    sum += eval(expr)
end
p sum

Measured memory_bytes: 2428
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::string s; int k; std::cin >> s >> k;
  int n = s.length();
  std::vector<std::string> sub;
  rep(i,0,n) rep(j,1,k+1) {
    sub.push_back(s.substr(i,j));
  }
  std::sort(all(sub));
  debug(sub);
  sub.resize(std::unique(all(sub)) - sub.begin());
  debug(sub);
  auto ans = sub.at(k-1);
  std::cout << ans << std::endl;
  return 0;
}

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

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

using namespace std;

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

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

i64 dp[101][100001];

void solve() {
  int N, W;
  cin >> N >> W;
  rep(i, 101) rep(j, 100001) dp[i][j] = -1e9;
  dp[0][0] = 0;
  rep(i, N) {
    int w, v;
    cin >> w >> v;
    rep(j, 100001) {
      if (dp[i][j] == -1e9) continue;
      amax(dp[i + 1][j], dp[i][j]);
      if (j + w <= W) amax(dp[i + 1][j + w], dp[i][j] + v);
    }
  }
  i64 ans = -1e9;
  repc(j, W) amax(ans, dp[N][j]);
  cout << ans << endl;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define M 500000
#define MAX 10000000000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll bs(pair<ll,ll>p[],ll start,ll end,ll x)
{
	ll ans =  -1;
	while(start<=end)
	{
		ll mid = (start+end)>>1;
		if(p[mid].ff <= x)
		{
			ans = mid;
			start = mid+1;
		} 
		else
		{
			end = mid-1;
		}
		
	}
	return ans;
}

int main()
{
	ll n,d,a;
	cin>>n>>d>>a;
	pair<ll,ll>p[n+1];
	for(int i=1;i<=n;i++)
		cin>>p[i].ff>>p[i].ss;
	sort(p+1,p+n+1);
	ll pre[n+2] = {0},ans = 0,cnt=0;
	for(int i=1;i<=n;i++)
	{
		cnt = pre[i];
		if(p[i].ss-cnt > 0)
		{
			ll temp = p[i].ss-cnt;
			ll temp2 = temp/a;
			if(temp%a)
				temp2++;
			pre[i] += a*temp2;
			ans += temp2;
			ll ind = bs(p,i,n,p[i].ff+2*d);
			// cout<<ans<<" "<<i<<" "<<ind<<endl;
			pre[ind+1] -= a*temp2;
		}
		pre[i+1] += pre[i];
	}
	// for(int i=1;i<=n;i++)
	// 	cout<<pre[i]<<" ";
	// cout<<endl;

	cout<<ans<<endl;
	return 0;
}

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

int main()
{
  ll x, y; cin>>x>>y;

  ll ans = 0;
  while (x <= y) {
    x *= 2;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  ll a,p;
  cin>>a>>p;
  op((a*3+p)/2);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<vector<int>> t(n);
    vector<int> color(n,-1);//白は1,黒は0
    map<pair<int,int>,ll> mp;
    rep(i,n-1){
        ll w;
        int a,b;cin>>a>>b;
        a--;b--;
        cin>>w;
        mp[{a,b}]=w%2;
        mp[{b,a}]=w%2;
        t[a].push_back(b);
        t[b].push_back(a);
        //cout<<a<<" "<<b<<" "<<w%2<<endl;
    }
    color[0]=0;
    queue<int> que;
    que.push(0);
    while(que.size()>0){
        int from=que.front();que.pop();
        int nowc=color[from];
        for(int i=0;i<t[from].size();i++){
            int to=t[from][i];
            if(color[to]!=-1)continue;
            ll w=mp[{from,to}];
            if(w==0)color[to]=nowc;
            else color[to]=1-nowc;
            que.push(to);
        }
    }
    rep(i,n){
        cout<<color[i]<<endl;
    }
}

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

using namespace std;
typedef long long ll;


ll N, M;

map<int,set<int>> to;
map<int,set<int>> from;
set<int> need_test;

void remove_node( int i ){
	if ( to.count(i) ){
		for ( auto it : to[i] ){
			from[it].erase(i);
			if ( from[it].size() == 0 )
				from.erase(it);
			need_test.insert(it);
		}
		to.erase(i);
	}
	if ( from.count(i) ){
		for ( auto it : from[i] ){
			to[it].erase(i);
			if ( to[it].size() == 0 )
				to.erase(it);
			need_test.insert(it);
		}
		from.erase(i);
	}
}


// 入次数か出次数が0の頂点を削除
bool remove_order0(){
	bool removed = false;
	while ( !need_test.empty() ){
		int i = *need_test.begin();
		need_test.erase(i);
		
		auto it_to = to.find(i);
		auto it_from = from.find(i);
		
		if ( it_to != to.end() && it_from == from.end()
		  || it_to == to.end() && it_from != from.end() ){
			remove_node(i);
		}
		
	}
	return removed;
}

void bfs( int i ){
	set<int> searched;
	queue<pair<int,int>> q; // node, parent_node
	
	q.push({i,-1});
	
	while ( !q.empty() ){
		auto f = q.front();
		q.pop();
		int node = f.first;
		int parent_node = f.second;
		
		if ( searched.count(node) ){
			if ( node != i ){
				remove_node(parent_node);
				return;
			}
		}
		else {
			searched.insert(node);
			for ( auto it : from[node] )
				q.push({it,node});
		}
	}
}


void dump_nodes(){
	cout << "dump_nodes" << endl;
	for ( auto it : from ){
		cout << "from " << it.first << ":";
		for ( auto i : it.second ){
			cout << " " << i;
		}
		cout << endl;
	}
	for ( auto it : to ){
		cout << "to " << it.first << ":";
		for ( auto i : it.second ){
			cout << " " << i;
		}
		cout << endl;
	}
}

int main(){
	cin >> N >> M;
	
	for ( int i = 0; i < M; i++ ){
		int A, B;
		cin >> A >> B;
		A--;
		B--;
		to[A].insert(B);
		from[B].insert(A);
	}
	
	
	for ( int i = 0; i < N; i++ ){
		need_test.insert(i);
	}
	remove_order0();
	
	while ( true ){
		set<int> out2; // 出次数が2以上の頂点
		for ( auto it : from ){
			if ( it.second.size() >= 2 )
				out2.insert(it.first);
		}
		if ( out2.size() == 0 )
			break;
		
		for  ( auto i : out2 ){
			if ( from.count(i) != 0 && from[i].size() >= 2 ){
				bfs(i);
				remove_order0();
			}
		}
	}
	
	if ( from.size() == 0 ){
		cout << "-1" << endl;
	}
	else {
		vector<int> v;
		auto it = to.begin();
		int first_i = it->first;
		for ( int i = first_i; ; ){
			v.push_back(i);
			i = *to[i].begin();
			if ( i == first_i )
				break;
		}
		cout << v.size() << endl;
		for ( auto it : v )
			cout << (it+1) << endl;
	}

	return 0;
}

/*

6 7
1 2
2 3
3 4
4 5
1 5
5 6
6 1

*/


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  float x,y;
  cin>>x>>y;
  float a=((4*x-y)/2);
  float b=((y-2*x)/2);
  if(a!=(int)a || b!=(int)b || a<0 || b<0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef pair<int, int> P;
typedef long long ll;

class ANumberOfMultiples {
public:
	void solve(std::istream& cin, std::ostream& cout) {
	  int L, R, d, cnt = 0;
	  cin >> L >> R >> d;
	  FOR(i, L, R+1) {
	    if (i % d == 0) {
	      cnt++;
	    }
	  }
	  cout << cnt << endl;
	}
};

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

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d[256],j=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d,d+n);
  if(d[0]==d[n]){
    cout<<1<<'\n';
  }
  for(int i=0;i<n;i++){
    if(d[i]==d[i+1]){
      j+=0;
      continue;
    }
    j++;
  }
  cout<<j<<'\n';
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[100005];
int sum[100005];
int main()
{
	int count=0;
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&arr[i]);
		if(i%2!=0&&arr[i]%2!=0)
		count++;
	}
	printf("%d\n",count);
}



Measured memory_bytes: 3764
// Problem: E - Bomber
// Contest: AtCoder - AtCoder Beginner Contest 176
// URL: https://atcoder.jp/contests/abc176/tasks/abc176_e
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>inline void read(T &FF){
	T RR=1;FF=0;char CH=getchar();
	for(;!isdigit(CH);CH=getchar())if(CH=='-')RR=-1;
	for(;isdigit(CH);CH=getchar())FF=(FF<<1)+(FF<<3)+(CH^48);
	FF*=RR;
}
set<int>v[300010];
struct aakt{
	int s,x;
}a[300010];
bool cmp(aakt a,aakt b){
	return a.s>b.s;
}
int main(){
	int n,m,k,s=0;read(n);read(m);read(k);
	for(int i=1;i<=k;i++){
		int x,y;
		read(x),read(y);
		v[x].insert(y);
		a[y].s++;
	}
	for(int i=1;i<=m;i++)a[i].x=i;
	sort(a+1,a+m+1,cmp);
	for(int i=1;i<=n;i++){
		// sort(v[i].begin(),v[i].end());
		int ans=0;
		for(int j=1;j<=m;j++)
			if(a[j].s<=ans)break;
			else{
				int az;
				if(v[i].find(a[j].x)!=v[i].end())ans=max(ans,a[j].s-1),az=a[j].s-1;
				else ans=max(ans,a[j].s),az=a[j].s;
				// cout<<a[j].s<<" "<<a[j].x<<" "<<az<<endl;
			}
		s=max(s,ans+(int)v[i].size());
		// cout<<ans<<" "<<v[i].size()<<endl;
	}cout<<s;
	return 0;
}

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

int main(){
    int n;
    long long ans =0;
    cin >> n;
    string s;
    cin >> s;
    int r_c=0,g_c=0,b_c=0;
    for (int i = 0; i < n; i++){
        if (s[i] == 'R'){
            r_c++;
        }else if (s[i] == 'G'){
            g_c++;
        }else{
            b_c++;
        }
    }
    /*for (int i = 0; i < n; i++){
        s[n+i] = '0';
    }*/
    int count = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == 'R'){
            ans = ans + g_c * b_c;
            r_c--;
            for (int j = i + 1; j < n; j++){
                if (s[j] == 'G' && 2 * j - i < n){
                    if (s[2 * j - i] == 'B'){
                        count++;
                    }
                }else if (s[j] == 'B' && 2 * j - i < n){
                    if (s[2 * j - i] == 'G'){
                        count++;
                    }
                }
            }
        }else if (s[i] == 'G'){
            ans = ans + r_c * b_c;
            g_c--;
            for (int j = i + 1; j < n; j++){
                if (s[j] == 'R' && 2 * j - i < n){
                    if (s[2 * j - i] == 'B'){
                        count++;
                    }
                }else if (s[j] == 'B' && 2 * j - i < n){
                    if (s[2 * j - i] == 'R'){
                        count++;
                    }
                }
            }
        }else{
            ans = ans + r_c * g_c;
            b_c--;
            for (int j = i + 1; j < n; j++){
                if (s[j] == 'G' && 2 * j - i < n){
                    if (s[2 * j - i] == 'R'){
                        count++;
                    }
                }else if (s[j] == 'R' && 2 * j - i < n){
                    if (s[2 * j - i] == 'G'){
                        count++;
                    }
                }
            }
        }
    }
    /*
    int count = 0;
    int zyu = 0;
    for (int i = (n-1)/2; i > 0; i--){
        for (int j = 0; j = zyu; j++){
            if (n % 2 ==0){
                int x = n/2 + j;
                int y = n/2 - j;
                if (s[n/2-i] != s[n/2+i] && s[n/2-i] != s[n/2] && s[n/2+i] != s[n/2]){
                count++;
                }
                if (s[0] != s[n] && s[0] != s[n/2-1] && s[n] != s[n/2-1]){
                    count++;
                }
            }else{
                if (s[0] != s[n] && s[0] != s[n/2] && s[n] != s[n/2]){
                    count++;
                }
            }
        }
    }*/
    cout << ans - count << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/*
 public class abc079d {

 }

 */
public class Main {
  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    int h = in.readInteger();
    int w = in.readInteger();

    int[][] c = new int[10][10];

    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        c[i][j] = in.readInteger();
      }
    }

    for (int k = 0; k < 10; k++) {
      for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
          c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
        }
      }
    }

    long ans = 0;

    int[][] a = new int[h][w];

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        a[i][j] = in.readInteger();

        if (a[i][j] != -1 && a[i][j] != 1) {
          ans += c[a[i][j]][1];
        }
      }
    }

    System.out.println(ans);
    // end here
  }

  public static void main(String[] args) throws FileNotFoundException {
    (new Main()).solve();
  }

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}


Measured memory_bytes: 27140
//Author : Vipul Sharma
 
// LIBRARIES

#include<iostream>
#include<set>
#include<algorithm>
#include<map>
#include <bits/stdc++.h>
 
// MACROS
#define ll long long int
#define ld long double
#define rep(i, a, b) for ( i = a; i < b; i++)
#define rev(i,b,a) for( i=b-1;i>=a;i--)
#define eqrep(i,b) for( i=1;i<=b;i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ld long double
#define pb push_back
#define eb emplace_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
using namespace std;
long long cost = 1e18;

bool comp(ll a,ll b)
{
	if(a>b) return true;
	return false;
}

void solve()
{
	ll n;
	cin>>n;
	if(n>=400 and n<=599) cout<<"8"<<endl;
	if(n>=600 and n<=799) cout<<"7"<<endl;
	if(n>=800 and n<=999) cout<<"6"<<endl;
	if(n>=1000 and n<=1199) cout<<"5"<<endl;
	if(n>=1200 and n<=1399) cout<<"4"<<endl;
	if(n>=1400 and n<=1599) cout<<"3"<<endl;
	if(n>=1600 and n<=1799) cout<<"2"<<endl;
	if(n>=1800 and n<=1999) cout<<"1"<<endl;
} 

 
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	booster;
	solve();
    return 0;
}

Measured memory_bytes: 3556
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    ms <- replicateM 5 getInt
    print $ (n-1) `div` (minimum ms) + 5

Measured memory_bytes: 380
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
 *
 * @author Jaynil
 */
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);
        CRectangleCutting solver = new CRectangleCutting();
        solver.solve(1, in, out);
        out.close();
    }

    static class CRectangleCutting {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            double w = in.nextInt();
            double h = in.nextInt();
            double x = in.nextInt();
            double y = in.nextInt();
            int o = 0;
            if (x == (w) / 2 && y == h / 2) {
                o = 1;
            }
            out.println((w * h) / 2 + " " + o);
        }

    }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22868
import bisect as bs
import collections

n = int(input())
alist = [0]*n
for i in range(n):
    alist[i] = int(input())

col = collections.deque()
min_ = 10000000000

for a in alist:
    if a <= min_:
        col.appendleft(a)
    else:
        index = bs.bisect_left(col, a) - 1
        col[index] = a
    min_ = col[0]

print(len(col))


Measured memory_bytes: 47448
#include<cstdio>
#include<algorithm>

int ans;
int Min=0x7fffffff;

int main(){
	int n,a;
	while(scanf("%d",&n)!=EOF){
		Min=0x7fffffff;
		ans=-Min;
		for(int i=1;i<=n;i++){
			scanf("%d",&a);
			ans=std::max(ans,a-Min);
			Min=std::min(Min,a);
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 2756
#include <iostream>
#include <vector>
#include <climits>
#include <set>


using namespace std;


static const int MAX = 50000;


int main()
{
    int n, m;
    set<int> coins;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int c;
        cin >> c;
        coins.insert(c);
    }

    vector<int> dp(MAX + 1, INT_MAX);
    for (auto it = coins.begin(); it != coins.end(); ++it)
        dp[*it] = 1;

    for (int i = 1 ; i <= n; i++) {
        for (auto it = coins.begin(); it != coins.end(); ++it) {
            if (i - *it >= 1 && dp[i - *it] < INT_MAX) {
                dp[i] = min(dp[i], dp[i - *it] + 1);
            }
        }
    }

    cout << dp[n] << endl;

    return 0;
}



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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    cin >> N;
    N %= 10;
    if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9)
        cout << "hon";
    if (N == 0 || N == 1 || N == 6 || N == 8)
        cout << "pon";
    if (N == 3)
        cout << "bon";
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    int W, H, N;

    cin >> W >> H >> N;

    vector<int> x(N), y(N), a(N);
    vector<int> A = {W, H};
    vector<int> B = {0, 0};

    for (int i = 0; i < N; i++) {
        cin >> x.at(i) >> y.at(i) >> a.at(i);
    }

    for (int i = 0; i < N; i++) {
        switch(a.at(i)) {
            case 1:
                if (B.at(0) < x.at(i)) B.at(0) = x.at(i);
                break;
            case 2:
                if (A.at(0) > x.at(i)) A.at(0) = x.at(i);
                break;
            case 3:
                if (B.at(1) < y.at(i)) B.at(1) = y.at(i);
                break;
            case 4:
                if (A.at(1) > y.at(i)) A.at(1) = y.at(i);
                break;
            default:
                break;
        }
    }

    if ((A.at(0) - B.at(0) > 0) && (A.at(1) - B.at(1) > 0)) {
        cout << (A.at(0) - B.at(0)) * (A.at(1) - B.at(1)) << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

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

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

    int num[110] = {0};
    for (int i = 0; i < N; ++i) {
        num[d[i]]++;
    }

    int res = 0;
    for (int i = 1; i <= 100; ++i) {
        if (num[i]) {
            ++res;
        }
    }
    cout << res << endl;
}

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

using namespace std;

inline int read()
{
    int ret=0,flag=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')flag=-1;c=getchar();}
    while(c>='0'&&c<='9')ret=ret*10+(c^'0'),c=getchar();
    return flag*ret;
}

struct use
{
    int x,d;
};

const int N=2e3+5;
int n,px,py;
queue<use> q;
int dis[N];
int ans[N];

void bfs(int k)
{
    memset(dis,-1,sizeof(dis));
    dis[k]=0;
    q.push((use){k,0});
    while(q.empty()==0)
    {
        int x=q.front().x,d=q.front().d;
        q.pop();
        ++ans[d];
        if(x>1&&dis[x-1]<0)
        {
            dis[x-1]=d+1;
            q.push((use){x-1,d+1});
        }
        if(x<n&&dis[x+1]<0)
        {
            dis[x+1]=d+1;
            q.push((use){x+1,d+1});
        }
        if(x==px&&dis[py]<0)
        {
            dis[py]=d+1;
            q.push((use){py,d+1});
        }
        if(x==py&&dis[px]<0)
        {
            dis[px]=d+1;
            q.push((use){px,d+1});
        }
    }
}

int main()
{
    n=read(),px=read(),py=read();
    for(int i=1;i<=n;i++)
    {
        bfs(i);
    }
    for(int i=1;i<n;i++)printf("%d\n",ans[i]>>1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    if (n == 2 && s[0] == s[1]) {
        cout << 1 << endl;
        return;
    }
    VVI dp(n,VI(3));
    dp[0][1] = dp[0][2] = 1;
    REP(i,1,n) {
        if (s[i] != s[i-1]) dp[i][1] = dp[i-1][1] + 1;
        if (i < n - 1) dp[i][2] = dp[i-1][1] + 1;
        if (i > 1) {
            dp[i][1] = max(dp[i][1], dp[i-2][2] + 1);
            if (i < n - 1 && s.substr(i-2,2) != s.substr(i,2)) {
                dp[i][2] = max(dp[i][2], dp[i-2][2] + 1);
            }
        }
    }
    cout << max(dp[n-1][1], dp[n-2][2]) << endl;
    

    
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 11396
#include<stdio.h>
int main(){
	int a,b,c,d,p,x,y;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);
	x=p*a;
        if(p<c){
           y=b;
        }else{
           y=b+(p-c)*d;
	}
   	if(x<y){
		printf("%d\n",x);
	}else{
		printf("%d\n",y);
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main{
    public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        String X = sc.next(), Y = sc.next();
        int x = check(X), y = check(Y);
        //System.out.println(x + " " + y);
        if(x>y){
            System.out.println(">");
        }else if(x<y){
            System.out.println("<");
        }else {
            System.out.println("=");
        }
    }
    
    public static int check(String str){
        int s=0;
        if(str.equals("A"))s=10;
        else if(str.equals("B"))s=11;
        else if(str.equals("C"))s=12;
        else if(str.equals("D"))s=13;
        else if(str.equals("E"))s=14;
        else if(str.equals("F"))s=15;
        return s;
    }
}

Measured memory_bytes: 21972
import itertools

N = int(input())
F = [0] * N
P = [0] * N 
for i in range(N):
    F[i] = list(map(int, input().split()))
for i in range(N):
    P[i] = list(map(int, input().split()))

#print(F)
#print(P)

l = list(itertools.product(range(2), repeat=10))
l.pop(0)

ans = []
for i in range(len(l)):
    tmp = 0
    for j in range(N):
        count = 0
        for k in range(10):
            if l[i][k] == 1 and F[j][k] == 1:
                count += 1
        tmp += P[j][count]
    ans.append(tmp)

ans = max(ans)
print(ans)



Measured memory_bytes: 3304
from collections import defaultdict

def main():
    n = int(input())
    ans = defaultdict(lambda: 0)
    for _ in range(n):
        s = input()
        ans[s] += 1
    print(f"AC x {ans['AC']}")
    print(f"WA x {ans['WA']}")
    print(f"TLE x {ans['TLE']}")
    print(f"RE x {ans['RE']}")
        
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 69800
N = int(input())
print(N*(N-1)//2-N//2)
if N%2 == 0:
  s = N+1
else:
  s = N
for i in range(1, N+1):
  for j in range(1, N+1):
    if i == j or i == s-j:
      pass
    else:
      if i > j:
      	print("{} {}".format(i, j))

Measured memory_bytes: 44380
//CazadorDivino
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<long,long> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}



int main(){
	int a, b;
	cin>> a >> b;
	if(b%a == 0)
		cout<< a+b;
	else 
		cout<< b - a;
	
	return 0;
}


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

int main() {
  long long N, C, K;
  cin >> N >> C >> K;
  long long time = 0;
  long long ninzu = 0;
  long long count = 0;
  long long T[N];
  for (int i = 0; i < N; i++) cin >> T[i];
  sort(T, T + N);
  for (long long i = 0; i < N; i++){
    if (ninzu == 0){
      time = T[i];
      ninzu++;
    }
    else {
      ninzu++;
    }
    if (T[i] > time + K){
      time = T[i];
      count++;
      ninzu = 1;
    }
    else if (ninzu == C){
      ninzu = 0;
      count++;
    }
  }
  if (ninzu >= 1) count++;
  
  cout << count << endl;
}

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


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

   }
  
  int sum = 0;
  
  for(int i = 1;i<n-1;i++){
     
     
      if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i-1]>a[i]&&a[i]>a[i+1])){
       
        sum++;
      }

   }
  
  cout << sum << endl;
   
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int
main()
{
        char search[11];
        char *itr, *itr2;
        char buf;
        char test[21];
        int i, cnt = 0;
 
        scanf("%s\n", search);
        scanf("%d\n", &i);
        while (i > 0) {
                itr = test;
                itr2 = test + 10;
                while (scanf("%c", &buf), buf != '\n') {
                        *itr++ = buf;
                        *itr2++ = buf;
                }
                if (strstr(test, search) != NULL) cnt++;
                i--;
        }
        printf("%d\n", cnt);
        return 0;
}

Measured memory_bytes: 604