akhauriyash/Code-Regression huggingface dataset:
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    ll n;
    cin >> n;
    vi cnt(100005, 0);
    ll sum = 0;
    for(ll i=0; i<n; i++){
        ll x;
        cin >> x;
        cnt[x]++, sum += x;
    }
    ll q;
    cin >> q;
    while(q--){
        ll b, c;
        cin >> b >> c;
        sum -= cnt[b]*b;
        sum += cnt[b]*c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.


Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n, m;
  cin >> n >> m;
  int s[5];
  char c[5];
  rep(i, m)
  {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  int pow10 = 1;
  rep(i, n) pow10 *= 10;
  int start = (n == 1 ? 0 : pow10 / 10);
  REP(i, start, pow10)
  {
    string st = to_string(i);
    bool valid = true;
    rep(j, m)
    {
      if (st[s[j]] != c[j])
      {
        valid = false;
        break;
      }
    }
    if (valid)
    {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    B.sort()
    C.sort()

    count = 0
    Ai = -1
    Ci = -1
    for i in range(N):
        if Ai<N-1:
            while A[Ai+1]<B[i]:
                Ai += 1
                if Ai == N-1:
                    break
        if Ci<N-1:
            while C[Ci+1]<=B[i]:
                Ci += 1
                if Ci==N-1:
                    break
        count += (Ai+1) * (N-(Ci+1))

    return count

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 24052
#include <stdio.h>

int main(void) {
	char str[100];
	int i,length;
	int exist_o=0;
	int exist_x=0;
	char win='-';
	scanf("%s",str);
	for(i=0;str[i];i++) {
		if(str[i]=='o')exist_o=1;
		if(str[i]=='x')exist_x=1;
	}
	length=i;
	if(!exist_o)win='x';
	else if(!exist_x)win='o';
	else if(str[0]!=str[length-1])win='o';
	else win=str[0];
	printf("%c\n",win);
	return 0;
}

Measured memory_bytes: 536
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(list[K-1])


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <stack>
#include <utility>
#include <cstdlib>

using namespace std;
char S[100];

int main() {
    int N;
    int cnt = 0;
    int first = 0;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> S[i];
        if (S[i] == '(') {
            cnt++;
        }
        else if (S[i] == ')') {
            cnt--;
            if (cnt == -1) {
                cnt++;
                first++;
            }
        }
    }

    for (int i = 0; i < first; i++) {
        cout << '(';
    }
    for (int i = 0; i < N; i++) {
        cout << S[i];
    }
    for (int i = 0; i < cnt; i++) {
        cout << ')';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c, k;std::cin >> a >> b >> c >> k;
  if(k<=a){
    std::cout << k << '\n';
  }else if(k<=a+b){
    std::cout << a << '\n';
  }else{
    std::cout << a - (k - (a+b)) << '\n';
  }
  return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll bg = 1000000007;
#define ff(i,n) for(i=0;i<n;i++) 
void dfs(ll i,ll vis[],ll p[],vector<vector<ll> > &adj,ll par)
{
	vis[i] = 1;
	p[i] = par;
	ll j;
	for(j=0;j<adj[i].size();j++)
	{
		if(vis[adj[i][j]]==0)
		{
			dfs(adj[i][j],vis,p,adj,i);
		}
	}
}
int main()
{
	ll x;
	cin>>x;
	if(x<=599 && x>=400)
	    cout<<8;
	if(x<=799 && x>=600)
	    cout<<7;
		if(x<=999 && x>=800)
	    cout<<6;
		if(x<=1199 && x>=1000)
	    cout<<5;
		if(x<=1399 && x>=1200)
	    cout<<4;
		if(x<=1599 && x>=1400)
	    cout<<3;
		if(x<=1799 && x>=1600)
	    cout<<2;
		if(x<=1999 && x>=1800)
	    cout<<1;    
	return 0;
} 

Measured memory_bytes: 3636
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def query(self,top_num,front_num):

        self.save_data = [i for i in range(6)]
        #元の値の保存
        for i in range(len(self.number)):
            self.save_data[i] = self.number[i]

        ret = -1;

        for i in range(len(self.order)):
            self.roll(self.order[i])
            if self.number[0] == top_num and self.number[1] == front_num:
                ret = self.number[2]
                break

        #元の値の復元
        for i in range(len(self.number)):
            self.number[i] = self.save_data[i]

        return ret;




dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

num_query = int(input())
for loop in range(num_query):
    top_num,front_num = map(int,input().split())
    print("%d"%(dice.query(top_num, front_num)))




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

using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 1; i < s.length(); i++) {
    string s1 = s.substr(0, i);
    string s2 = s.substr(i, s.length() - i);
    set<char> charSet;
    for (int j = 0; j < s1.length(); j++) {
      char c = s1[j];
      for (int k = 0; k < s2.length(); k++) {
        if (c == s2[k]) charSet.insert(c);
      }
    }
    cnt = max(cnt, (int)charSet.size());
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

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

	ll ans = 1, ans1 = 0, ans2 = 0;
	rep(i, N){
		int t, a;
		cin >> t >> a;
		if( i == 0 ){
			ans = t+a;
			ans1 = t; ans2 = a;
		}
		else{
			ll n = max((ans1+(t-1))/t, (ans2+(a-1))/a);
			ans = (t+a)*n;
			ans1 = t*n; ans2 = a*n;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

N=int(input())
dp = [0]*N

E = []
for i in range(N):
    E.append([])

def dfs(cur,pre):
    for r,d in E[cur]:
        if r != pre:
            dp[r] = dp[cur] + d
            dfs(r,cur)


for i in range(N-1):
    x,y,d= list(map(int,input().split()))
    E[x-1].append((y-1,d))
    E[y-1].append((x-1,d))

Q,K = list(map(int,input().split()))

dfs(K-1,-1)

for j in range(Q):
    s,g= list(map(int,input().split()))
    print(dp[s-1]+dp[g-1])

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

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

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

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

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;   // 同じもの同士の組は計算しない
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int a;
  cin>>a;
  cout<<a*(a+1)/2<<endl;

      
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int x, a, b;
    cin >> x >> a >> b;
    cout << (abs(x-a) < abs(x-b) ? 'A' : 'B') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

using Apple = pair<i64, int>;
int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    priority_queue<Apple> q;
    for(int i = 0; i < A + B + C; i++) {
        i64 x;
        cin >> x;
        if(i < A) q.push({x, 0});
        else if (i < A + B) q.push({x, 1});
        else q.push({x, 2});
    }
    i64 ans = 0;
    int r = 0, g = 0, t = 0;
    while(!q.empty() && r + g + t < X + Y) {
        i64 x;
        int c;
        tie(x, c) = q.top(); q.pop();
        if(c == 0) {
            if(r < X) {
                r++;
                ans += x;
            }
        }
        if(c == 1) {
            if(g < Y) {
                g++;
                ans += x;
            }
        }
        if(c == 2) {
            t++;
            ans += x;
        }
    }
    cout << ans << endl;
    return 0;
}



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


int main() {
  int x, n;
  cin >> x >> n;
  vector<int> d(102);
  rep(i,n){
    int p;
    cin >> p;
    d[p] = 1;
  }
  P ans(99999, -1);
  for (int i = 0; i <= 101; ++i){
    if(d[i]==1) continue;
    int dif = abs(x-i); 
    ans = min(ans, P(dif, i));
  }
  cout << ans.second << endl;
  return 0;
}



Measured memory_bytes: 3640
A,B,K=map(int,input().split())
k=K//2
if K%2==0:
    while k>0:
        B=A//2+B 
        A=A//2
        A=B//2+A
        B=B//2
        k-=1
else:
    while k>0:
        B=A//2+B 
        A=A//2
        A=B//2+A
        B=B//2
        k-=1
    B=A//2+B 
    A=A//2
print(A,B)


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
public class Program {
    static void Main (string[] args) {
        var s = Console.ReadLine();
        var k = int.Parse(Console.ReadLine());
        var hs = new HashSet<string>();
        for (int i = 0; i < s.Length; ++i) {
            for (int j = 0; j < k + 1; ++j) {
                if (s.Length > (i + j)) {
                    hs.Add(s.Substring(i, j));
                } else {
                    hs.Add(s.Substring(i, j - ((i + j) - s.Length)));
                }
            }
        }
        var l = hs.ToList();
        l.Sort();
        Console.WriteLine(l[k]);
    }
}


Measured memory_bytes: 14688
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[205];
    for(int i =1; i <= n; i++){
        cin >> a[i];
    }
    
    int ans = 0;
    while(1){
        int flag = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] % 2 != 0)flag = 1;
            else a[i] /= 2;
        }
        if(flag == 1)break;
        ans++;
    }
    
    cout << ans << endl;
}

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

// #define mod (int) 998244353
// #define MOD (int) 1e9+7
// // Big two primes
// #define X 1001100011100001111ll
// #define all(a) a.begin(),a.end()
// #define for0(i, n) for (int i = 0; i < n; i++)
// #define for1(i, n) for (int i = 1; i <= n; i++)
// #define loop(i,a,b) for (int i = a; i < b; i++)
// #define bloop(i,a,b) for (int i = a ; i>=b;i--)
// #define tc(t) int t; cin >> t; while (t--)
// //#define int long long
// #define ll long long
// #define pb emplace_back
// #define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
// #define in(x) scanf("%d", &x)
// #define rr return 0
// #define prec(n) fixed<<setprecision(n)
// #define maxpq priority_queue<int>
// #define minpq priority_queue<int, vector<int>, greater<int> >
// #define inf (int)(1e18)
// #define ini(a, i) memset(a, i, sizeof(a))
// #define vi vector<int>
// #define fi first
// #define se second
// #define endl "\n"
// #define ii pair<int, int>
// #define vii vector<ii>
// #define sz(s) s.size()


int dp[100000+1];
int dfs(int i,vector<int> adj[]){
    if(dp[i]!=-1)
        return dp[i];
    for(auto j=adj[i].begin();j!=adj[i].end();j++){
        
        dp[i]=max(1+dfs(*j,adj),dp[i]);
    }
    if(adj[i].size()==0)
        return dp[i]=0;
    return dp[i];    
}

int main(){
    int n,m,i;
    cin>>n>>m;
    vector<int> adj[n+1];
    for(i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    int ans=0;
    fill_n(dp,100000+1,-1);
    for(i=1;i<=n;i++){
        dfs(i,adj);
    }
    for(i=1;i<=n;i++)
        ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

vector<vector<int>> a;
vector<int> b;

void dfs(int n, int p);

int main()
{
	int n, m;
	cin >> n >> m;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		a[x].emplace_back(y);
		a[y].emplace_back(x);
		b[x] = 1;
		b[y] = 1;
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (b[i] == 1) {
			ans++;
			dfs(i, i);
		} else if (b[i] == 0) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

void dfs(int n, int p)
{
	if (b[n] == 2) {
		return;
	}
	b[n] = 2;

	for (auto & i : a[n]) {
		if (i == p) continue;

		dfs(i, n);
	}
}

Measured memory_bytes: 10752
import sys, math

if(__name__ == "__main__"):
    """
    N, D = map(int, input().strip().split() )
    D_sq = D**2
    xy_list = []
    for i in range(N):
        xy = list( map(int, input().strip().split() ) )
        xy_list.append(xy)
    """
    N = int( input().strip() )
    color_str = input().strip()
    colors = [ 0 ] * N
    #R -> 0, W->1
    for i in range(N):
        if(color_str[i] == "W"):
            colors[i] = 1
    left = 0
    right = N-1
    times = 0
    while(left < right):
        while(left < N-1 and colors[left]==0):
            left += 1
        while(right > -1 and colors[right]==1):
            right -= 1
        if(left < right):
            colors[left], colors[right] = colors[right], colors[left]
            times += 1
    print(times)


Measured memory_bytes: 10724
#include <iostream>

int main()
{
    int A, B, T;
    std::cin >> A >> B >> T;

    int ans = 0;

    int a = 1;
    for (int t = 1; t <= T; ++t)
    {
        if (t >= a * A)
        {
            ans += B;
            ++a;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

int main()
{
    int a,b,c;
    a=b=c=0;
    cin >> a;
    cin >> b;
    cin >> c;
    if ((a < b) && (b < c)) {

            cout << "Yes" << endl;

    }

    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1160
import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }
    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        String str=input.scanString();
        System.out.println(""+str.charAt(0)+str.charAt(1)+str.charAt(2));
    }
}


Measured memory_bytes: 36640
fun main(args: Array<String>) = abc156d()

fun abc156d() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }

    var answer = Mint(2).modPow(n.toLong())
    answer -= 1
    answer -= comb(n, a)
    answer -= comb(n, b)

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private fun modPow(n: Long, p: Long, m: Long = MOD): Long {
    var x = n
    var y = p
    var result = 1L

    x %= m
    while (y > 0) {
        if (y % 2 == 1L)
            result = (result * x) % m
        y = y shr 1
        x = (x * x) % m
    }

    return result
}

// useful for big N, and small K
private fun comb(n: Int, k: Int, m: Long = MOD): Long {
    if (n < k) return 0

    val min = Math.min(k, n - k)
    var value = 1L

    for (i in 1L..min) {
        value *= n - i + 1
        value %= m
        value *= modPow(i, m - 2, m)
        value %= m
    }
    return value
}

private class Mint(value: Long = 0L, val mod: Long = MOD) {
    constructor(other: Mint) : this(other.value)

    private val value = if (value < 0) (value % mod) + mod else value % mod
    operator fun unaryPlus() = this
    operator fun unaryMinus() = Mint(mod - this.value)
    operator fun inc() = this.plus(1)
    operator fun dec() = this.minus(1)
    operator fun plus(other: Long) = Mint(this.value + other)
    operator fun plus(other: Mint) = this.plus(other.value)
    operator fun minus(other: Long) = Mint(this.value - other)
    operator fun minus(other: Mint) = this.plus(-other)
    operator fun times(other: Long) = Mint(this.value * other)
    operator fun times(other: Mint) = this.times(other.value)
    operator fun div(other: Long) = this.times(Mod.modPow(other, mod - 2, mod))
    operator fun div(other: Mint) = this.div(other.value)
    fun modPow(other: Long) = Mint(Mod.modPow(this.value, other, mod))
    override fun toString() = this.value.toString()
    override fun hashCode() = value.hashCode()
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false
        other as Mint
        return value == other.value
    }

    companion object Mod {
        private fun modPow(n: Long, p: Long, m: Long = MOD): Long {
            var x = n
            var y = p
            var result = 1L
            x %= m
            while (y > 0) {
                if (y % 2 == 1L) result = (result * x) % m
                y = y shr 1
                x = (x * x) % m
            }
            return result
        }
    }
}


Measured memory_bytes: 38380
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<long long,int>mp;
int n;
long long s;
long long ans;
int main()
{
	scanf("%d",&n);
	mp[0]=1;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		s+=x;
		ans+=mp[s];
		mp[s]++;
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 12800
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            out.println(6-scan.nextInt()-scan.nextInt());
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n;
    cin >> n;
    int m[5] = {0};
    char a[5] = {'M', 'A', 'R', 'C', 'H'};
    
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, 5) {
            if (s[0] == a[j]) {
                m[j]++;
                break;
            }
        }
    }
    ll ans = 0;
    rep(i, 5) rep3(j, i + 1, 5) rep3(k, j + 1, 5) {
        ans += (ll)m[i] * m[j] * m[k];
    }
    cout << ans << endl;
}


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

int main()
{
	int n, r;
	cin >> n >> r;
	cout << ((n >= 10) ? r : r + 100 * (10 - n)) << endl;
}


Measured memory_bytes: 256
//20181208
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


int main() {

    string s;
    cin >> s;

    int count = 0;
    for(int i=0; i<s.size();i++){
        if(s[i]=='2') count++;
    }

    cout << count << endl;


    return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,a,b;cin>>n>>a>>b;
  cout<<n/(a+b)*a+min(n%(a+b),a)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 101
int main() {
	int in_n, in_m, in_b[MAX], in_A[MAX][MAX] , out_c[MAX] ;
	cin >> in_n >> in_m;
	for (int i = 1; i <= in_n; i++) {
		for (int j = 1; j <= in_m; j++) {
			cin >>in_A[i][j];
		}
	}

	for (int j = 1; j <= in_m; j++) {
		cin >> in_b[j];
	}

	for (int i = 1; i <= in_n; i++) {
		out_c[i] = 0;
		for (int j = 1; j <= in_m; j++) {
			out_c[i] += in_A[i][j] * in_b[j];
		}
		cout << out_c[i] << endl;
	}
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n;
	cin>>n;
	ll ans[105];
	for(int i=0;i<n;i++)
	{
		cin>>ans[i];
	}
	ll sum=0;
	sort(ans,ans+n);
	ll L=ans[0],R=ans[n-1];
	ll minn=0;
	for(int i=0;i<n;i++)
	{
		minn+=(L-ans[i])*(L-ans[i]);
	}
	for(ll i=L+1;i<=R;i++)
	{
		ll temp=0;
		for(int j=0;j<n;j++)
		{
			temp+=(i-ans[j])*(i-ans[j]);
		}
	    if(temp<minn)
	    minn=temp;
	} 
	cout<<minn<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
   string s;
   cin >> s;
   int sum = 0;
   for(char x : s) sum += x - '0';
   if( sum % 9 ==0 ) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3708
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <cassert>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=(a%10/5)+(a%5), a/=10; return res;}

int main() {
  int n,W; cin>>n>>W;
  ll dp[100001]; fill(dp,dp+100001,LINF); dp[0]=0;
  for(int i=0;i<n;i++) {
    ll w,v; cin>>w>>v;
    for(int j=100000-v;j>=0;j--) {
      chmin(dp[j+v],dp[j]+w);
    }
  }
  ll an = 0;
  for(int i=0;i<=100000;i++) {
    if (dp[i] <= W) an = i;
  }
  cout<<an<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 4388
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Linq;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{

    private int A, B, C;

    public void Solve()
    {
        var line = Console.ReadLine().Split(' ');
        A = int.Parse(line[0]);
        B = int.Parse(line[1]);
        C = int.Parse(line[2]);
        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1)
        {
            Console.WriteLine(0);
            return;
        }
        if (A == B && B == C)
        {
            Console.WriteLine(-1);
            return;
        }
        P cc = new P(A, B, C);
        for (int i = 0; i < 10000000; i++)
        {
            if (Bool(cc))
            {
                Console.WriteLine(i);
                return;
            }
            cc = Next(cc);
        }
        Console.WriteLine(-1);

    }

    private P Next(P a)
    {
        P res;
        res.A = (a.B + a.C) / 2;
        res.B = (a.A + a.C) / 2;
        res.C = (a.A + a.B) / 2;
        return res;
    }

    private bool Bool(P c)
    {
        return c.A % 2 == 1 || c.B % 2 == 1 || c.C % 2 == 1;
    }
}

struct P
{
    public int A, B, C;
    public P(int a, int b, int c)
    {
        A = a;
        B = b;
        C = c;
    }
}



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

import sys
import copy

sys.setrecursionlimit(1000000)


# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~


S = input().rstrip()

r = S.count('1')
b = S.count('0')

print(min(r, b) * 2)



Measured memory_bytes: 3700
#define F first
#define S second
#define EPS 1E-10
using namespace std;
#define pb push_back
#define mp make_pair
#define inf 0x3f3f3f3f
#include <bits/stdc++.h>
#define int64 long long int
#define infl 0x3f3f3f3f3f3f3f3fll
#define uint64 unsigned long long int


int n, k, a[100];

int main ()
{
	scanf ("%d %d", &n, &k);
	for (int i = 0; i < n; i++) scanf ("%d", a + i);
	sort (a, a + n);
	reverse (a, a + n);
	int sum = 0;
	for (int i = 0; i < k and i < n; i++) sum += a[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;
//階乗できるよ
ll kaizyo(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  double l; cin >> l;
  double hen = l / 3;
  double ans = pow(hen,3);

  cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 256
N,K = list(map(int, input().split()))

# K b = K+1~N,a = ib+K total:sigma((N-k)//b+1)

if K==0:
        print(N*N)
else:
    ans = 0
    for b in range(K+1, N+1):
        ans += (N//b) * (b-K) + max(0, (N%b) - (K-1))
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define mm map<ii>
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
	fast

	string str;
	cin>>str;


	int len = str.sze;

	int count = 1;
	string x = "",y = "";
	x += str[0];
	for(int i = 1; i < len; i++)
	{
		y = "";
		y += str[i];
		if(x == y)
		{
			if((i+1) < len)
			{
				y += str[i+1];
				i++;
				count++;
			}
		}
		else
		{
			count++;
		}
		x = y;
	}

	cout<<count;

	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)
#define SWAP(x,y) 		((x!=y)&&(x^=y,y^=x,x^=y))

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

int main(int argc, char* argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL A, B;

	cin >> A >> B;

	if (fabs((long double)A - B) / 2 - llabs(A - B) / 2 > 0) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << (A + B) / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#!python3

from collections import defaultdict

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, V = iim()
    AN = 4
    A = [list(iim()) for i in range(AN)]

    def dd(a1, a2):
        d = defaultdict(int)
        for i in a1:
            for j in a2:
                x = i + j
                if x < V:
                    d[x] += 1
        return d

    da, db = dd(A[0], A[1]), dd(A[2], A[3])

    print(sum(v * db[V-k] for k, v in da.items()))

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 298452
#include <bits/stdc++.h>
#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 endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll defeat(ll h) {
    if (h == 1)
        return 1;
    else {
        return 2 * defeat(floor(h/2)) + 1;
    }
}

int main() {
    speed();
    ll H; cin >> H;
    ll attack = defeat(H);
    cout << attack << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc047/tasks/agc047_a
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

// namespace mp = boost::multiprecision;
// using cpp_dec = mp::cpp_dec_float_50;
// using cpp_int = mp::cpp_int;
using namespace std;

#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define Aint(obj) (obj).begin(), (obj).end()
#define AintR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    map<pair<int, int>, int> cnt;
    REP(i, N) {
        // cpp_dec x;
        // cin >> x;
        // int t = static_cast<int>(x * 1e9);
        long double x;
        cin >> x;
        // 入力の小数部は9桁なので10^9倍し、丸め誤差を補正
        int t = llround(x * 1e9);
        // 2で割り切れる回数、5で割り切れる回数
        pair<int, int> p = {-9, -9};
        while (t % 2 == 0) {
            t >>= 1;
            p.first++;
        }
        while (t % 5 == 0) {
            t /= 5;
            p.second++;
        }
        cnt[p]++;
    }
    // mapだと要素指定のアクセスができないのでvectorへ変換
    vector<pair<int, int>> ps;
    vector<int> cs;
    for (auto w : cnt) {
        ps.emplace_back(w.first);
        cs.emplace_back(w.second);
    }

    int ans = 0;
    REP(i, ps.size()) {
        pair<int, int> p = ps[i];
        // 2と5で共に9回以上割り切れるなら整数同士の組み合わせ: nC2
        if (p.first >= 0 && p.second >= 0) {
            ans += cs[i] * (cs[i] - 1) / 2;
        }
        // 2つの異なる数なので、jはi未満
        REP(j, i) {
            // 積が2と5で共に9回以上割り切れるなら整数
            if (p.first + ps[j].first >= 0 && p.second + ps[j].second >= 0) {
                ans += cs[i] * cs[j];
            }
        }
    }

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


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

int main(){
  int N ;
  string S;
  cin >> N >> S ;
  
  if(N % 2 != 0){
    cout << "No" << endl;
  }
  else{
  for (int i = 0;i< N/2;i++){
    if(S.at(i) != S.at(N/2+i)){
      cout << "No" << endl;
      break;
    }
    if(i == N/2-1 && S.at(i) == S.at(N/2+i)){
      cout << "Yes" << endl;
    }
  }
  }
}
    
  
  


Measured memory_bytes: 256