akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    string s;
    cin >> s;
    ll sl = len(s);
    vector<vector<ll>> dp(sl + 1, vector<ll>(4, 0));
    dp[0][0] = 1;
    rep(i, sl) {
        rep(ii, sz(dp[i + 1])) {
            if (s[i] == '?') dp[i + 1][ii] = (dp[i][ii] * 3) % mod;
            else dp[i + 1][ii] = dp[i][ii];
        }
        if ((s[i] == 'A') || (s[i] == '?')) dp[i + 1][1] = (dp[i + 1][1] + dp[i][0]) % mod;
        if ((s[i] == 'B') || (s[i] == '?')) dp[i + 1][2] = (dp[i + 1][2] + dp[i][1]) % mod;
        if ((s[i] == 'C') || (s[i] == '?')) dp[i + 1][3] = (dp[i + 1][3] + dp[i][2]) % mod;
    }
    cout << dp[sl][3] << endl;
    return 0;
}


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

#define int long long int
#define double long double
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define endl "\n"

// const int N = 1e5 + 5;
//int a[N];

int32_t main()
{
	IOS;
	//int a;
	double a, b;
	cin >> a >> b;
	int zero = 0;
	if (a == 0 || b == 0)
		zero = 1;
	// int val = 1e18 * 1e18;
	// if (1e18 > 9223372036854775807)
	// 	cout << val << endl;
	if (zero)
	{
		cout << "0" << endl;
	}
	else
	{
		//sort(a + 1, a + n + 1);
		double ans = a * b;
		int val = floor(ans);
		cout << val << endl;
	}

	return 0;
}

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

#define int long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);

int v[50], c[50];
signed main () {
	IOS;
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);	 
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif	

	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 1) cin >> v[i];
	for (int i = 1; i <= n; i += 1) cin >> c[i];
	for (int i = 1; i <= n; i += 1) {
		if (v[i] > c[i]) ans += (v[i] - c[i]);
	}
	cout << ans;
}	

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
int a, b;
int add, sub, mul;
int ans;
int main() {
	scanf("%d%d", &a, &b);
	add = a + b;
	sub = a - b;
	mul = a * b;
	ans = max(max(add, sub), mul);
	printf("%d", ans);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
  int n,d,a;
  cin >> n >> d;

  a=n/(d*2+1);
  if(n%(d*2+1)) a++;

  cout << a << endl;
}

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 20;

int N, M;
vector<int> v;
deque<int> dq[MAX_N+1];

int main(){
	cin>>N;
	M = N;	
	N = (1<<N);
	for(int i=1; i<=N; i++){
		int x; scanf("%d", &x);
		v.pb(x);
	}
	sort(v.begin(), v.end());
	for(int i=0; i<N/2; i++){
		int tmp = v[i];
		v[i] = v[N-1-i];
		v[N-1-i] = tmp;
	}
	for(int i=1; i<=M; i++){
		dq[i].pb(v[0]);
	}
	for(int i=1; i<N; i++){
		bool tf = false;
		for(int j=1; j<=M; j++){
			if(!dq[j].empty() && dq[j].front()>v[i]){
				dq[j].pop_front();
				for(int k=j+1; k<=M; k++){
					dq[k].pb(v[i]);
				}
				tf = true;
				//cout<<j<<endl;
				break;
			}
		}
		if(!tf){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 1912
import java.util.*;
class Main{
  static int[] a;
  static int[] b;
  static Map<Integer, List<Integer> > aToPos = new HashMap<>();
  static boolean[] ban;
  static Set<Integer> used = new HashSet<>();
  static Queue<Integer> que = new ArrayDeque<>();
  public static int dfs(int v){
    int res = 1;
    if(used.contains(a[v]))return res;
    used.add(a[v]);
    for(int pos: aToPos.get(a[v])){
      if(!ban[pos]){
        que.add(pos);ban[pos]=true;
      }
    }
    while(!que.isEmpty())res+=dfs(que.poll());
    return res;
  }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
  	a = new int[n+1];
    b = new int[n+1];
    for(int i=0;i<n;++i){
      a[i]=Integer.parseInt(sc.next());a[n]^=a[i];
    }
    for(int i=0;i<n;++i){
      b[i]=Integer.parseInt(sc.next());b[n]^=b[i];
    }
    int[] aa = new int[n+1];
    int[] bb = new int[n+1];
    for(int i=0;i<=n;++i)aa[i]=a[i];
    for(int i=0;i<=n;++i)bb[i]=b[i];
    Arrays.sort(aa);Arrays.sort(bb);
    for(int i=0;i<=n;++i)if(aa[i]!=bb[i]){
      System.out.println(-1);return;
    }
    ban = new boolean[n+1];
    for(int i=0;i<n;++i)if(a[i]==b[i])ban[i]=true;
    for(int i=0;i<=n;++i){
      if(i<n&&ban[i])continue;
      if(!aToPos.containsKey(b[i])){
        aToPos.put(b[i], new ArrayList<>());
      }
      aToPos.get(b[i]).add(i);
    }
    int ans = 0;
    if(a[n]==b[n] && aToPos.get(a[n]).size()==1){
      for(int i=0;i<n;++i)if(!ban[i]){
        ban[i]=true;
        ans += dfs(i)+1;
      }
    }else{
      ban[n]=true;
      ans += dfs(n)-1;
      for(int i=0;i<n;++i)if(!ban[i]){
        ban[i]=true;
        ans += dfs(i)+1;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 94044
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int max= sc.nextInt();
		int current=sc.nextInt();
		int c=sc.nextInt();
		if(c-(max-current)<0){
			System.out.println(0);
		}else {
		System.out.println(c-(max-current));
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, R;
    cin >> N >> R;

    if(N < 10){
        cout << R + 100 * (10-N) << endl;
    } else {
        cout << R << endl;
    }

}


Measured memory_bytes: 256
from math import ceil
from heapq import *

n, m = map(int, input().split())
a_s = [-int(a) for a in input().split()]
heapify(a_s)

for _ in range(m):
	amax = heappop(a_s)
	heappush(a_s, ceil(amax / 2))

res = sum([-heappop(a_s) for _ in range(n)])
print(res)

Measured memory_bytes: 14380
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
	ll h,a;
	cin>>h>>a;
	cout<<ceil((double)h/(double)a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    string s;
    while (cin >> s) {
        int n = s.size(), joi = 0, ioi = 0;
        for (int i = 2; i < n; i++) {
            if (s[i - 2] == 'J' && s[i - 1] == 'O' && s[i] == 'I') joi++;
            else if (s[i - 2] == 'I' && s[i - 1] == 'O' && s[i] == 'I') ioi++;
        }
        cout << joi << '\n' << ioi << endl;
    }
}


Measured memory_bytes: 3124
n = int(input())
a = list(map(int, input().split()))

babies = [(a, i) for i, a in enumerate(a)]
babies.sort(reverse=True)

dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
ans = 0
for l in range(n):
  for r in range(n):
    if l+r == n:
      ans = max(ans, dp[l][r])
      break
    activeness, ind = babies[l+r]
    dp[l+1][r] = max(dp[l+1][r], dp[l][r] + activeness * abs(ind - l))
    dp[l][r+1] = max(dp[l][r+1], dp[l][r] + activeness * abs(ind - (n - 1 - r)))
print(ans)


Measured memory_bytes: 101900
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  vector<int> rate(9);
  rep(i,n){
    cin >> a.at(i);
    if(a.at(i)>=3200) rate.at(8)++;
    else rate.at(a.at(i)/400)++;
  }

  int Min=0,Max=0,no=0;

  rep(i,8){
    if(rate.at(i)>0) Min++;
    else if(rate.at(i)==0) no++;
  }


  if(Min==0){
    Min=1;
    Max=rate.at(8);
  }else{
    Max=Min+rate.at(8);
  }

  cout << Min << " " << Max <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

const int mod = 998244353;

int dpp(vector<vector<int>> &dp, int c, int d) {
  if(dp[c][d] != 0) return (dp[c][d])%mod;
  else {
    dp[c][d] = (dpp(dp, c-1, d)*d + dpp(dp, c, d-1)*c + (-dpp(dp, c-1, d-1)*(c-1)*(d-1))%mod)%mod;
    if(dp[c][d] < 0) dp[c][d] += mod;
    return (dp[c][d])%mod;
  }
}

signed main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  
  
  vector<vector<int>> dp(C+1, vector<int>(D+1, 0));
  dp[A][B] = 1;
  rep(i, C-A) dp[A+i+1][B] = (B*dp[A+i][B])%mod;
  rep(i, D-B) dp[A][B+i+1] = (A*dp[A][B+i])%mod;
  
  
  
  cout << dpp(dp, C, D) << endl;
  
  /*rep(i, C+1) {
    rep(j, D+1) cout << dp[i][j] << " ";
    cout << endl;
  }*/
  
}

Measured memory_bytes: 74192
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std ;

long long a0 ;
long long t1[255] ;
long long t2[320000] ;

bool cmp(long long a,long long b){
	return a < b ;
}

long long gcd(long long a,long long b){
	return b?gcd(b,a%b):a;
}

int main(){
	long long n ;
	long long i , j , k ;
	long long top1 ;
	long long top2 ;
	while(scanf("%lld",&n)!=EOF){
		if(n == 0)
			break ;
		top1 = 0 ;
		top2 = 0 ;
		for(i = 0 ; i <= (n*(n+1)/2-1) ; i++){
			long long c ;
			scanf("%lld",&c) ;
			if(c%2)
				t2[top2++] = c ;
			else
				t1[top1++] = c ;
		}
		sort(t1,t1+top1,cmp) ;
		sort(t2,t2+top2,cmp) ;
		long long t = gcd(t1[0],t1[1]) ;
		long long g1 = t1[0] / t ;
		long long g2 = t1[1] / t ;
		long long q = (long long)sqrt(t2[0]/(g1*g2)*1.0) ;
		a0 = t / q ;
		printf("%lld\n",a0) ;
		for(i = 0 ; i < n ; i++){
			if(i == 0){
				printf("%lld",t1[i] / a0) ;
			}
			else
				printf(" %lld",t1[i] / a0) ;
		}
		puts("") ;
	}
	return 0 ;
}

Measured memory_bytes: 1464
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int d, n;
  cin >> d >> n;
  int c = n == 100 ? 1 : 0;
  ll ans = (n+c) * pow(100, d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3764
import math
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
time = 0
lists = [A,B,C,D,E]
MinMove = min(lists)
ans = math.ceil(N / MinMove) + 4
print(ans)
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector <int> p(m);
    vector <int> y(m);
    vector < vector<int> > data(n + 1);

    for(int i = 0; i < m; i++){
        cin >> p[i] >> y[i];
        
        data[p[i]].push_back(y[i]);
    }

    for(int i = 0; i < n + 1; i++){
        sort(data[i].begin(), data[i].end());
    }

    for(int i = 0; i < m; i++){
        int k = lower_bound(data[p[i]].begin(), data[p[i]].end(), y[i]) - data[p[i]].begin() + 1;
        printf("%06d%06d\n", p[i], k);
    }

    return 0;
}

Measured memory_bytes: 7808
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
const ll mod = 998244353;
//#define int ll
int n, m, a[3002];
ll s;
bitset<4000002> dp[2];

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i], s+=1LL*a[i];
    dp[0][0]=1;
    for(int i=1; i<=n; i++){
        dp[1]=(dp[0]|(dp[0]<<a[i]));
        dp[0]=dp[1];
        //for(int j=0; j<=10; j++) cout<<dp[i][j]; cout<<endl;
    }
    for(int i=(s+1)/2; i<=s; i++){
        if(dp[0][i]) return cout<<i, 0;
    }
}


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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define inf			1e12
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

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

	vector<int> v(n + 1);

	for (int i = 1; i <= n; i++) {
		cin >> v[i];
	}

	for (int i = k + 1; i <= n; i++) {
		if (v[i] > v[i - k])
			cout << "Yes\n";
		else
			cout << "No\n";
	}

	return 0;
}

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

int main(){
  string s;
  cin>> s;
  int a[26] = {};
  for(int i=0;i<s.size();i++){
    a[s.at(i) - 'a']++;
  }
  for(int i=0;i<26;i++){
    if(a[i] == 0){
      char ans = 'a'+i;
      cout << ans << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line[] = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			if(n==0){break;}

			String keep = br.readLine();
			ArrayList<Integer> answer = new ArrayList<Integer>();
			for(int i=0; i<keep.length(); i++){
				answer.add(Integer.parseInt(keep.substring(i, i+1)));
			}

			for(int i=0; i<n; i++){
				ArrayList<Integer> result = new ArrayList<Integer>();
				int previous = 0;
				int count = 0;

				for(int j=0; j<answer.size(); j++){
					int now = answer.get(j);
					if(now == previous){
						count++;
					}else{
						if(count!=0){
							result = tryadd(result,count);
							result.add(previous);
							}
						previous = now;
						count = 1;
					}
				}
				result = tryadd(result,count);
				result.add(previous);
				answer = result;
			}
			for(Integer ans: answer){
				System.out.print(ans);
			}
			System.out.println();
		}
	}

	static ArrayList<Integer> tryadd(ArrayList<Integer> list, int a ){
		int moto = a;
		int count = 0;
		if( moto >=10){
			while(moto>=10){
				moto /= 10;
				count++;
			}
			list.add(moto);
			return tryadd(list, a-moto*(int)Math.pow(10, count));
		}else{
			list.add(moto);
			return list;
		}
	}
}

Measured memory_bytes: 38384
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner scanner = new Scanner(System.in);
		int count = scanner.nextInt();
		int flag = 0;
		int[] numList = new int[count];

		for (int i = 0; i < count; i++) {
			numList[i] = scanner.nextInt();
		}
		Tool.shellSort(numList, count, flag);

		for (int i = 0; i < count; i++) {
			System.out.println(numList[i]);
		}
	}
}

class Tool {

	static int inssertionSort(int[] numList, int count, int distance, int flag) {

		for (int i = distance; i < count; i++) {
			int temp = numList[i];
			int j = i - distance;
			while (j >= 0 && numList[j] > temp) {
				numList[j + distance] = numList[j];
				j = j - distance;
				flag++;
			}
			numList[j + distance] = temp;
		}
		return flag;
	}

	static void shellSort(int[] numList, int count, int flag) {

		int m = 0;
		int[] distanceList = new int[15];
		for (int i = 1; i < count; i = i * 3 + 1) {
			for (int j = m; j > 0; j--) {
				distanceList[j] = distanceList[j - 1];
			}
			distanceList[0] = i;
			m++;
		}
		if (m == 0) {
			distanceList[0] = 1;
			m = 1;
		}

		for (int i = 0; i < distanceList.length; i++) {
			flag =	inssertionSort(numList, count, distanceList[i], flag);
		}
		System.out.println(m);
		System.out.print(distanceList[0]);
		for (int i = 1; i < distanceList.length; i++) {
			if (distanceList[i] == 0) {
				break;
			}
			System.out.print(" " + distanceList[i]);
		}
		System.out.println("\n" + flag);
	}
}

Measured memory_bytes: 298896
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if (k<=a)
		cout<<k;
	else if (k>a&&k<=a+b)
		cout<<a;
	else
		cout<<2*a+b-k;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3096
#!/usr/bin/perl

my ($n) = map {$_ - 0} split(/\s+/o,<STDIN>);
my @xy = ();
for(my $i=0;$i<$n;$i++){
  my ($x,$y) = map {$_ - 0} split(/\s+/o,<STDIN>);
  push(@xy,+[$x,$y]);
}

if( $n==1 or $n==2 ){
  print "1\n";
  exit(0);
}
my $mincnt = 10**9;
for(my $i=0;$i<$n-1;$i++){
  for(my $j=$i+1;$j<$n;$j++){
    my $cnt = $n;
    my $vx = $xy[$i]->[0] - $xy[$j]->[0];
    my $vy = $xy[$i]->[1] - $xy[$j]->[1];
    for(my $k=0;$k<$n-1;$k++){
      for(my $l=$k+1;$l<$n;$l++){
        my $vx1 = $xy[$k]->[0] - $xy[$l]->[0];
        my $vy1 = $xy[$k]->[1] - $xy[$l]->[1];
        if( ( $vx == $vx1 and $vy == $vy1 ) or ( $vx == - $vx1 and $vy == - $vy1 ) ){
          $cnt --;
        }
      }
    }
    $mincnt = $cnt if $cnt < $mincnt;

  }
}
print "$mincnt\n";

exit(0);



Measured memory_bytes: 640
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9+7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def dfs_1(s,p): #部分木のサイズを数えるdfs
    par[s] = p
    for v in edges[s]:
        if v == p:
            continue
        size[s] += dfs_1(v,s)
    return size[s]

def dfs_2(s,p): #1を根としたときに進む向きのdp計算用dfs
    dp1[s] = fact[size[s]-1]
    for v in edges[s]:
        if v == p:
            continue
        dp1[s] = (dp1[s]*dfs_2(v,s))%mod
        dp1[s] = (dp1[s]*pow(fact[size[v]], mod-2, mod))%mod
    return dp1[s]

def comb(n,r):
    return fact[n]*pow(fact[r],mod-2,mod)*pow(fact[n-r],mod-2,mod) % mod

def bfs(s):
    que = deque()
    que.append((s,-1))
    while que:
        v,p = que.popleft()
        if v == 0:
            dp2[v] = dp1[v]
        else:
            inv = (dp2[p]*pow((dp1[v]*comb(n-1,size[v]))%mod,mod-2,mod)) % mod
            dp2[v] = (dp1[v]*inv*comb(n-1,size[v]-1)) % mod
        for u in edges[v]:
            if u == p:
                continue
            que.append((u,v))
n = I()
fact = [1]*(n+1)
par = [None]*n
for i in range(1,n+1):
    fact[i] = i*fact[i-1]
    fact[i] %= mod

edges = [[] for _ in range(n)]
size = [1]*n
dp1 = [0]*n #1を根としたときに進む向きのdp
for _ in range(n-1):
    a,b = LI()
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

dfs_1(0,-1)
dfs_2(0,-1)
dp2 = [0]*n
bfs(0)
for i in dp2:
    print(i)




Measured memory_bytes: 151260
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main(){

    int n,r; cin >> n >> r;

    if(n<10)
        cout << r+100*(10-n) << endl;
    else
        cout << r << endl;

     return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}


mt19937 engine(0);
uniform_int_distribution<> dist(0, 1);      


const int len = 1000;
const int hash_len = 30;
using BO = bitset<len>;
using BH = bitset<hash_len>;

vector<BO> base_vec;

void init(int m){
	rep(i, m) {
		BO tmp;
		rep(j, len) tmp[j] = dist(engine);
		base_vec.push_back(tmp);
	}
}


BH get_hash(BO bst) {
	BH ret;
	rep(i, hash_len) {
		BO tmp = bst & base_vec[i]; 
		ret[i] = tmp.count() & 1;
	}
	return ret;
}



void alice_bob_process(int n) {
	init(hash_len);

	string ret = "";

	rep(i, n){
		string tmp;
		cin >> tmp;
		BO bit_orignal  = BO(tmp);
		BH bit_hash = get_hash(bit_orignal);
		ret += bit_hash.to_string();
	}

	cout << ret << endl << flush;
}

void charlie_process(int n) {
	init(hash_len);
	string x, y;
	cin >> x >> y;

	vector<BH> xary, yary;
	rep(i, n) {
		xary.push_back(BH(x.substr(hash_len * i, hash_len)));
		yary.push_back(BH(y.substr(hash_len * i, hash_len)));		
	}

	rep(i, n) {
		string c;
		cin >> c;
		BO bit_orignal  = BO(c);
		BH bit_hash = get_hash(bit_orignal);

		rep(j, n) rep(k, n) {
			BH tmp = xary[j] ^ yary[k];
			if(tmp == bit_hash) {
				cout << j + 1 << " " << k + 1 << endl;
				j = n, k = n;
			}
		}
	}

	cout << flush;
}

int main(void){
	string who;
	cin >> who;
	if(who == "Alice" or who == "Bob") {
		alice_bob_process(100);
	} else {
		charlie_process(100);
	}
	return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
long long dp[402][402];
long long a[402];
long long ps[402];

int main(){
	int n;
	cin >> n;
	memset(dp, 0x3f3f3f3f, sizeof dp);
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		dp[i][i] = 0;
		
		if(i > 0){
			dp[i - 1][i] = a[i - 1] + a[i];
		}
	}
	partial_sum(a, a + n + 1, ps);
	
	for(int l = 2; l <= n + 1; l++){
		for(int i = 1; i <= n - l + 1; i++){
			for(int j = 0; j < l; j++){
				dp[i][i + l] = min(dp[i][i + l], dp[i][i + j] + dp[i + j + 1][i + l] + ps[i + j] - ps[i - 1] + ps[i + l] - ps[i + j]);
			}
		}
	}
	cout << dp[1][n];
}





Measured memory_bytes: 1536
//Fibonacci Number
#include <iostream>

using namespace std;

const int NIL = -1;

int fibonacci(int n) {
    if(n == 0 || n == 1) return 1;

    int dp[n+1];
    dp[0] = 1; dp[1] = 1;
    for(int i=2; i<n+1; i++) dp[i] = dp[i-1] + dp[i-2];
    return dp[n];
}

int main() {
    int n;
    cin >> n;
    cout << fibonacci(n) << endl;
}


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



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

    cout << min(a,b)+ min(c,d)<<endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b,c; cin>>a>>b>>c;
	cout<<min({a,b,c})<<" "s<<a+b+c-min({a,b,c})-max({a,b,c})<<" "s<<max({a,b,c})<<"\n"s;
}


Measured memory_bytes: 3232
while True:
    n, m, p = [int(i) for i in input().split()]
    if n == 0 and m == 0 and p == 0:
        break
    x = [int(input()) for i in range(n)]
    s = sum(x)
    print(s*(100 - p) // x[m - 1]) if x[m - 1] != 0 else print(0)
    



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

int main(int argc, char* argv[]) {
  int A, B;
  cin >> A >> B;

  int fee;
  if (A >= 13)
    fee = B;
  else if (A >= 6)
    fee = B / 2;
  else
    fee = 0;

  cout << fee << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;
 
void solve(){
  int n,k,r,s,p; cin >>n >>k >>r >>s >>p;
  int ans=0; string te="";
  map<char,char>win;
  win['r']='p'; win['s']='r'; win['p']='s';
  string t; cin >>t;
  for(int i=0; i<n; i++){
    te+=win[t[i]];
    if(i>=k&&te[i]==te[i-k]) te[i]='x';
    if(te[i]=='r') ans+=r;
    else if(te[i]=='s') ans+=s;
    else if(te[i]=='p') ans+=p;
  }
  cout <<ans;
}

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

Measured memory_bytes: 3760
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] v = new int[N];
		for(int i = 0; i < N; i++)
			v[i] = sc.nextInt();
		Arrays.sort(v);
		double ans = v[0];
		for(int i = 1; i < N; i++)
			ans = (ans + v[i])/2;
		System.out.println(ans);

	}

}


Measured memory_bytes: 21844
import numpy as np

def dist(d1, d2):
    return abs(d1[0]-d2[0]) + abs(d1[1]-d2[1])

n = int(input())
list1 = np.zeros((n))
list2 = np.zeros((n))
xy_list = []
for i in range(n):
    x, y = map(int, input().split())
    xy_list.append([x, y])
    list1[i] = x+y
    list2[i] = x-y

num = np.zeros((4), dtype=int)
num[0] = np.argmax(list1)
num[1] = np.argmax(list2)
num[2] = np.argmin(list1)
num[3] = np.argmin(list2)

ans = 0
for d1 in range(4):
    for d2 in range(d1+1, 4):
        # print(num[d1], num[d2], dist(xy_list[num[d1]], xy_list[num[d2]]))
        ans = max(ans, dist(xy_list[num[d1]], xy_list[num[d2]]))

print(ans)

Measured memory_bytes: 60332
/*
      author  : nishi5451
      created : 15.08.2020 13:33:09
*/

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


int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    string ans;
    rep(i,n){
        ans+=s[i];
        ans+=t[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> dp(n+1, INT_MAX);
    dp[0] = 0;
    vector<int> h(n+1);
    for (int i = 0; i < n; i++) cin >> h[i];

    for (int i = 0; i < n; i++) {
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]-h[i]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
    }

    cout << dp[n-1];
}


Measured memory_bytes: 1024
from collections import Counter
from scipy.misc import comb
c=Counter()
n,m=map(int,input().split())
t=2
while(t**2 <= m):
    if m%t:
        t+=1
        continue
    while m%t==0:
        c[t]+=1
        m//=t
if m>1:c[m]+=1
a=1
for i in c:
    a=a*comb(n+c[i]-1,n-1,exact=1)%(10**9+7)
print(a)

Measured memory_bytes: 13528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;

set<int> st;
rep(i,N) {
    int d;
    cin >> d;
    st.insert(d);
}

int ans = st.size();
cout << ans << endl;


return 0;
}

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

int res[MAXN];
int main() {
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif
	string word;
	cin >> word;

	int ere[MAXN], ele[MAXN];
	int n = word.size();
	
	for (int i=n-1; i>=0; i--) {
		if (word[i] == 'L') ele[i] = i;
		else ele[i] = ele[i+1];
	}

	for (int i=0; i<n; i++) {
		if (word[i] == 'R') ere[i] = i;
		else ere[i] = ere[i-1];
	}
	

	for (int i=0; i<n; i++) {
		if (word[i] == 'L') {
			int dist = abs(i - ere[i]);
			if (dist & 1) res[ere[i]+1]++;
			else res[ere[i]]++;
		} else {
			int dist = abs(i - ele[i]);
			if (dist & 1) res[ele[i]-1]++;
			else res[ele[i]]++;
		}
	}

	for (int i=0; i<n; i++) {
		printf("%d%c", res[i], " \n"[i==n-1]);
	}

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
    int f[100] = {0}, n;
    f[0] = 0;
    f[1] = 0;
    f[2] = 0;
    f[3] = 0;
    f[4] = 0;
    f[5] = 0;
    f[6] = 14;
    f[7] = 9;
    f[8] = 4;
    f[9] = 0;
    f[10] = 0;
    f[11] = 8;
    f[12] = 3;
    f[13] = 2;
    f[14] = 0;
    f[15] = 0;
    f[16] = 15;
    f[17] = 10;
    f[18] = 15;
    f[19] = 10;
    f[20] = 6;
    f[21] = 12;
    f[22] = 7;
    f[23] = 9;
    f[24] = 11;
    f[25] = 6;
    f[26] = 23;
    f[27] = 18;
    f[28] = 13;
    f[29] = 8;
    f[30] = 3;
    f[31] = 23;
    f[32] = 18;
    f[33] = 13;
    f[34] = 8;
    f[35] = 3;
    f[36] = 34;
    f[37] = 29;
    f[38] = 24;
    f[39] = 22;
    f[40] = 17;
    f[41] = 28;
    f[42] = 23;
    f[43] = 24;
    f[44] = 19;
    f[45] = 27;
    f[46] = 34;
    f[47] = 29;
    f[48] = 35;
    f[49] = 30;
    f[50] = 28;
    f[51] = 31;
    f[52] = 28;
    f[53] = 23;
    f[54] = 24;
    f[55] = 28;
    f[56] = 42;
    f[57] = 37;
    f[58] = 32;
    f[59] = 27;
    f[60] = 22;
    f[61] = 42;
    f[62] = 37;
    f[63] = 32;
    f[64] = 27;
    f[65] = 22;
    f[66] = 53;
    f[67] = 48;
    f[68] = 43;
    f[69] = 41;
    f[70] = 36;
    f[71] = 47;
    f[72] = 42;
    f[73] = 43;
    f[74] = 38;
    f[75] = 46;
    f[76] = 64;
    f[77] = 59;
    f[78] = 54;
    f[79] = 49;
    f[80] = 44;
    f[81] = 61;
    f[82] = 56;
    f[83] = 51;
    f[84] = 46;
    f[85] = 44;
    f[86] = 72;
    f[87] = 67;
    f[88] = 62;
    f[89] = 57;
    f[90] = 52;
    f[91] = 72;
    f[92] = 67;
    f[93] = 62;
    f[94] = 57;
    f[95] = 52;
    f[96] = 83;
    f[97] = 78;
    f[98] = 73;
    f[99] = 71;
    while(cin >> n){
        cout << f[n] << endl;
    }
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=300000+10;
const ll inf=1000000000000000000;
ll sum[maxn],f[maxn],g[maxn],h[maxn],L[maxn],R[maxn],ans[maxn];
int dl[maxn],xy[maxn];
int i,j,k,l,r,t,n,m,head,tail;
ll num;
void revsum(){
	fd(i,n,1) sum[i]-=sum[i-1];
	reverse(sum+1,sum+n+1);
	fo(i,1,n) sum[i]+=sum[i-1];
}
void revLR(){
	fo(i,0,n+1) swap(L[i],R[n+1-i]);
}
ll S(int x){
	return (ll)x*(x+1)/2;
}
int getxy(int x,int y){
	/*int l=y+1,r=n+1,mid;
	while (l<r){
		mid=(l+r)/2;
		if (f[x]-sum[x]+S(mid-x)>=f[y]-sum[y]+S(mid-y)) r=mid;else l=mid+1;
	}
	return l;*/
	ll xx=f[x]-sum[x]+(ll)x*(x-1)/2;
	ll yy=f[y]-sum[y]+(ll)y*(y-1)/2;
	return int(max(min((yy-xx)%(y-x)==0?(yy-xx)/(y-x):(yy-xx)/(y-x)+1,(ll)n+1),(ll)y+1));
}
int getbest(int id){
	while (head<tail&&xy[tail-1]<=id) tail--;
	return dl[tail];
}
void put(int id){
	while (head<tail&&xy[tail-1]<=getxy(dl[tail],id)) tail--;
	dl[++tail]=id;
	if (head<tail) xy[tail-1]=getxy(dl[tail-1],id);
}
void dp(){
	f[0]=0;
	head=1;
	dl[tail=1]=0;
	fo(i,1,n){
		j=getbest(i);
		f[i]=f[j]+S(i-j)+sum[i]-sum[j];
		f[i]=max(f[i],f[i-1]);
		put(i);
	}
}
void solve(int l,int r,int c){
	if (l==r){
		g[l]=max(g[l],sum[l]-sum[l-1]+L[l-1]+R[l+1]+1);
		return;
	}
	int mid=(l+r+c)/2;
	int i,j,k;
	head=1;tail=0;
	fo(i,l-1,mid-1){
		f[i]=L[i];
		put(i);
	}
	fo(i,mid+1,r){
		j=getbest(i);
		h[i]=f[j]+S(i-j)+sum[i]-sum[j]+R[i+1];
	}
	fd(i,r-1,mid+1) h[i]=max(h[i],h[i+1]);
	fo(i,mid+1,r) g[i]=max(g[i],h[i]);
	solve(l,mid,c);solve(mid+1,r,c);
}
int main(){
	//freopen("genocide.in","r",stdin);freopen("genocide.out","w",stdout);
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d",&t);
		t*=-1;
		sum[i]=sum[i-1]+(ll)t;
	}
	dp();
	fo(i,0,n) L[i]=f[i];
	revsum();
	dp();
	fo(i,0,n) R[n+1-i]=f[i];
	revsum();
	fo(i,1,n) g[i]=-inf;
	solve(1,n,0);
	fo(i,1,n) ans[i]=g[i];
	revsum();
	revLR();
	fo(i,1,n) g[i]=-inf;
	solve(1,n,-1);
	fo(i,1,n) ans[i]=max(ans[i],g[n-i+1]);
	revsum();
	revLR();
	fd(i,n,1) sum[i]-=sum[i-1];
	scanf("%d",&m);
	while (m--){
		scanf("%d%d",&j,&t);
		t*=-1;
		num=max(L[j-1]+R[j+1],ans[j]+t-sum[j]);
		printf("%lld\n",num);
	}
}

Measured memory_bytes: 19200
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    ls = [int(input().rstrip('\n')) for _ in range(5)]
    m_t = min(ls)
    print((n + m_t - 1) // m_t + 4)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
a = gets.to_i
a.times do |i|
  if (i != 0) && ((i % 3) == 0) || (i.to_s =~ /3/)
    print " #{i}"
  end
end
if ((a % 3) == 0) || (a.to_s =~ /3/)
  print " #{a}"
end
puts

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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s;
	int ans = 1;
	cin >> s;
	for (int i=1; i<s.size(); i++) {
		if (s[i] == '-') continue;
		if (s[i-1] == '-' || s[i-1] != s[i]) {
			ans ++;
		} else {
			if (i == s.size()-1) break;
			s[i+1] = '-';
			ans ++;
		}
	}
	cout << ans;
	return 0;
}


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

int a, b;

int main() {
    cin >> a >> b;

    int diff = b - a;
    int Hb = 0;
    for (int i = 1; i <= diff; i++) Hb += i;
    cout << Hb - b << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int k,t,a;
	cin >> k >> t;
	int maxq=-1;
	int sum=0;
	FOR(i,t){
		cin >> a;
		sum+=a;
		maxq=max(a,maxq);
	}
	cout << max(0,2*maxq-sum-1);

	return 0;
}

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

using namespace std;

typedef long long ll;

const int maxn=1e5+5;

char s[maxn];

int main(){
	scanf("%s",s);
	int n=strlen(s);
	int ans=0;
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[n-1-i]) ans++;
	}
	printf("%d",ans);
	return 0;
}

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

const long long mod=1e9+7;

long long modpow(long long x, long long y){
	long long ret=1;
	while (y>0){
		if (y&1){
			ret*=x;
			ret%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return ret;
}

long long modinv(long long x){
	x%=mod;
	x+=mod;
	x%=mod;
	return modpow(x,mod-2);
}

int n, k, zero=0;
long long ans=1;
vector<long long>neg, pos;

int main(){
	cin >> n >> k;
	for (int i=0;i<n;i++){
		long long a;
		cin >> a;
		if (a<0) neg.push_back(a);
		else if (a>0) pos.push_back(a);
		else zero++;
	}
	if (n-zero<k){
		cout << 0 << "\n";
		return 0;
	}
	if (pos.size()==0 && k%2==1 && zero>0){
		cout << 0 << "\n";
		return 0;
	}
	if (n-zero==k){
		for (long long u : pos){
			ans*=u;
			ans%=mod;
		}
		for (long long u : neg){
			ans*=u;
			ans%=mod;
			ans+=mod;
			ans%=mod;
		}
		cout << ans << "\n";
		return 0;
	}
	if (pos.size()==0 && k%2==1){
		if (zero>0) ans=0;
		sort(neg.rbegin(),neg.rend());
		for (int i=0;i<k;i++){
			ans*=neg[i];
			ans%=mod;
			ans+=mod;
			ans%=mod;
		}
		cout << ans << "\n";
		return 0;
	}
	sort(pos.rbegin(),pos.rend());
	sort(neg.begin(),neg.end());
	int a=0, b=0;
	while (k>1){
		if (a+1<pos.size() && b+1<neg.size()){
			if (pos[a]*pos[a+1]>neg[b]*neg[b+1]){
				ans*=pos[a];
				ans%=mod;
				ans+=mod;
				ans%=mod;
				ans*=pos[a+1];
				ans%=mod;
				ans+=mod;
				ans%=mod;
				a+=2;
			}
			else{
				ans*=neg[b];
				ans%=mod;
				ans+=mod;
				ans%=mod;
				ans*=neg[b+1];
				ans%=mod;
				ans+=mod;
				ans%=mod;
				b+=2;
			}
		}
		else if (a+1<pos.size()){
			ans*=pos[a];
			ans%=mod;
			ans+=mod;
			ans%=mod;
			ans*=pos[a+1];
			ans%=mod;
			ans+=mod;
			ans%=mod;
			a+=2;
		}
		else if (b+1<neg.size()){
			ans*=neg[b];
			ans%=mod;
			ans+=mod;
			ans%=mod;
			ans*=neg[b+1];
			ans%=mod;
			ans+=mod;
			ans%=mod;
			b+=2;
		}
		k-=2;
//		cout << k << " ";
	}
	if (k==1){
		if (a<pos.size()){
			ans*=pos[a];
			ans%=mod;
		}
		else{
			if (a>0) ans*=modinv(pos[a-1]);
			else ans*=pos[a];
			ans%=mod;
			ans*=neg[b];
			ans%=mod;
			ans+=mod;
			ans%=mod;
			ans*=neg[b+1];
			ans%=mod;
			ans+=mod;
			ans%=mod;
		}
	}
	cout << ans << "\n";
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll a, b, c, d, e, n;
ll x[555555];

int digit(int n) {
   int ret = 0;
   while (n > 0) {
      ret++;
      n /= 10;
   }
   return ret;
}

int f(int n) {
   int z = digit(n);
   int sum = 0;
   rep (i, z) {
      sum += n % 10;
      n /= 10;
   }
   return sum;
}

int main() {
   cin >> n;
   int ans = 1e8;
   for (int i = 1; i < n; i++) {
      int b = n-i;
      ans = min(ans, f(i)+f(b));
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int K = scan.nextInt();
			int []d = new int[K];
			int[][]A = new int[K][N];
			Map<Integer,ArrayList<Integer>>map = new TreeMap<Integer,ArrayList<Integer>>();
			
			for(int i = 0;i<N;i++) {
				map.put(i,new ArrayList<Integer>());
			}
			
			for(int i = 0;i<K;i++) {
				d[i] = scan.nextInt();//i番目のお菓子もらえる人数
				for(int j = 0;j<d[i];j++) {
					A[i][j] = scan.nextInt();//もらえる奴ら
					map.get(A[i][j]-1).add(i+1);
					
				}		
			}
			
			int count = 0;
			
			for(int i = 0;i<map.size();i++) {
				if(map.get(i).size()==0)count++;
				
				/*
				for(int j = 0;j<map.get(i).size();j++) {
					System.out.print(map.get(i).get(j));
				}
				System.out.println();
				*/
			}
			
			System.out.println(count);
			
		}
		
		
	}
		

}


Measured memory_bytes: 46536
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
ll mod=1000000007;
const ll N=100005;
int main()
{
fast;
    ll x;
    cin>>x;
    if(x>=400 && x<600)
        cout<<8;
    if(x>=600 && x<800)
        cout<<7;
    if(x>=800 && x<1000)
        cout<<6;
    if(x>=1000 && x<1200)
        cout<<5;
    if(x>=1200 && x<1400)
        cout<<4;
    if(x>=1400 && x<1600)
        cout<<3;
    if(x>=1600 && x<1800)
        cout<<2;
    if(x>=1800 && x<2000)
        cout<<1;
    
    
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,A,B,C,D;
  cin >> N >> A >> B;
  C=0;
  D=0;

 if (N%(A+B)>=A) {C=A;}
 else {C=N%(A+B);} 
  
  D=(N-N%(A+B))/(A+B);
  D=D*A +C;
 cout << D << endl; 
 
 
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける

//////////////////
//  A
/*int main(void){
    int n,k;
    string s;
    cin >> n>>k>>s;

    for(int i=0 ;i<n;i++){
        if(i+1==k){
            if(s[i]=='A') cout<<'a';
            else if(s[i]=='B') cout<<'b';
            else cout<<'c';
        }else{
            cout<<s[i];
        }
    }
    cout<<endl;

    return 0;
}*/
//////////////////
//  B
/*int main(void){
    string s;
    cin >> s;
    int a=stoi(s)/100,b=stoi(s)%100;

    if(a==0){
        if(b==0) cout << "NA" <<endl;
        else if(b<=12) cout << "YYMM" <<endl;
        else cout<<"NA"<<endl;
    }else if(a<=12){
        if(b==0) cout << "MMYY" <<endl;
        else if(b<=12) cout << "AMBIGUOUS" <<endl;
        else cout<<"MMYY"<<endl;
    }else{
        if(b==0) cout << "NA" <<endl;
        else if(b<=12) cout << "YYMM" <<endl;
        else cout<<"NA"<<endl;
    }
    return 0;
}*/
//////////////////
//  C
int main(void){
    int n,k;
    cin>>n>>k;
    double ret=0;
    double tmp;
    int point;
    for(int i=1;i<=n;i++){
        point=i;
        tmp=1.0/n;
        while(point<k){
            tmp/=2;
            point*=2;
        }
        ret+=tmp;
    }
    cout <<setprecision(11)<<ret<<endl;
    return 0;
}
//////////////////
//  D
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


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

int main() {
 int N,n=1,ans=0;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  auto itr=a.begin();
  for(int i=0;i<N;i++){
    if(*itr==n){
      n++;
    }
    else{
      ans++;
    }
    *itr++;
  }
  if(n==1){
    cout<<-1;
  }
  else{
  cout<<ans;
  }
}


Measured memory_bytes: 1024