akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	var sum int
	nums := make(map[int]int, 100001)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		nums[a[i]]++
		sum += a[i]
	}
	q := nextInt()
	for i := 0; i < q; i++ {
		// a = quickSort(a)
		b, c := nextInt(), nextInt()
		nums[c] += nums[b]
		sum += (c - b) * nums[b]
		nums[b] = 0
		// for j := 0; j < n; j++ {
		// 	if a[j] == b {
		// 		a[j] = c
		// 	} else if a[j] > b {
		// 		break
		// 	}
		// }
		fmt.Fprintf(out, "%d\n", sum)
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func quickSort(val []int) []int {
	if len(val) < 2 {
		return val
	}

	pivot := val[0]

	left := []int{}
	right := []int{}

	for _, v := range val[1:] {
		if pivot > v {
			left = append(left, v)
		} else {
			right = append(right, v)
		}
	}

	left = quickSort(left)
	right = quickSort(right)

	ret := append(left, pivot)
	ret = append(ret, right...)

	return ret
}

func sum(a []int) int {
	var sum int
	for i := 0; i < len(a); i++ {
		sum += a[i]
	}
	return sum
}


Measured memory_bytes: 9424
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int a[100100];
int af[100100];
int ab[100100];

int main(){
	cin>>n;
	REP(i,n)
		cin>>a[i];
	af[0]=a[0];
	ab[n-1]=a[n-1];
	for(int i=1;i<n;i++){
		af[i]=gcd(a[i],af[i-1]);
	}
	for(int i=n-2;i>=0;i--){
		ab[i]=gcd(a[i],ab[i+1]);
	}
	int ans=max(af[n-2],ab[1]);
	for(int i=0;i<n-2;i++)
		ans=max(ans,gcd(af[i],ab[i+2]));
		
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
A,B,M=map(int,input().split())
a=[int(i)for i in input().split()]
b=[int(i)for i in input().split()]
xyc=[[int(i)for i in input().split()]for j in range(M)]
res=min(a)+min(b)
for x,y,c in xyc:
    tmp=a[x-1]+b[y-1]-c
    res=min(res,tmp)
print(res)

Measured memory_bytes: 37016
<?php
fscanf(STDIN, "%d %d",$a, $b);
$datas = explode(' ',trim(fgets(STDIN)));

$count = 1;
$sum = 0;

foreach($datas as $data) {
  $sum += $data;
  if($sum <= $b){
    $count++;
  }
}
  
echo $count;

Measured memory_bytes: 3700
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100005], t[100005];
	scanf("%s%s", s, t);
	long long int n = strlen(s), m = strlen(t);
	long long int i, j;
	long long int count[30];
	long long int a[30][100005];
	for (i = 0; i < 30; i++)
		count[i] = 0;
	for (i = 0; i < n; i++)
	{
		a[s[i] - 'a'][count[s[i] - 'a']] = i;
		count[s[i] - 'a']++;
	}
	for (i = 0; i < m; i++)
	{
		if (count[t[i] - 'a'] == 0)
		{
			printf("-1\n");
			return 0;
		}
	}
	long long int x, y;
	x = 0;
	y = 0;
	long long int min, mid, max;
	for (i = 0; i < m; i++)
	{
		if (a[t[i] - 'a'][count[t[i] - 'a'] - 1] < y)
		{
			x++;
			y = a[t[i] - 'a'][0] + 1;
		}
		else if (a[t[i] - 'a'][0] >= y)
		{
			y = a[t[i] - 'a'][0] + 1;
		}
		else
		{
			min = 0;
			max = count[t[i] - 'a'];
			while (max - min > 1)
			{
				mid = (max + min) / 2;
				if (a[t[i] - 'a'][mid] < y)
					min = mid;
				else
					max = mid;
			}
			y = a[t[i] - 'a'][max] + 1;
		}
		x += y / n;
		y %= n;
	}
	printf("%lld\n", n * x + y);
	return 0;
}

Measured memory_bytes: 22912
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;
 
int n, d, a[20][20], countt = 0;
double ans = 0;
vector<int> an;
 
signed main() {

	cin >> n >> d;

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


	for(int i = 0; i < n-1; i++) {
		for(int j = i+1; j < n; j++){
			for(int k = 0; k < d; k++){
				double x = pow(a[i][k] - a[j][k], 2);
				ans += x;
			}
			ans = sqrt(ans);
			if(ans - (int)ans == 0) an.push_back(ans); ans = 0;
		}
	}
	
	cout << an.size() << endl;


	//cout << countt << endl;


	return 0;
}

Measured memory_bytes: 256
ARGF.each_line do |line|
  m, f, r = line.split.map(&:to_i)
  
  break if m == -1 && f == -1 && r == -1

  if m == -1 || f == -1
    puts "F"
    next
  end

  m = 0 if m == -1
  f = 0 if f == -1
  sum = m + f
  if sum >= 80
    puts "A"
  elsif sum >= 65
    puts "B"
  elsif sum >= 50
    puts "C"
  elsif sum >= 30 && r >= 50
    puts "C"
  elsif sum >= 30
    puts "D"
  else
    puts "F"
  end
end

Measured memory_bytes: 6104
# 0からnまでの値が素数かどうかの、len=n+1のリストを作った後に、それを使ってn以下の素数のリストを作成
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int(n**0.5) + 1):
        # 既にfalseになってたらスキップ
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

n = int(input())
ans_ls = [0] * n
i = 0
for prime in primes(55555):
    if prime % 5 == 1:
        ans_ls[i] = prime
        i += 1
        if i == n:
            break
print(*ans_ls)

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

using namespace std;


long long calc(vector<long long>& occ) {
  int sz = occ.size();
  long long res = 0;
  for (int i = 0; i < sz; ++i) {
    res += (occ[i] * (occ[i] - 1))/ 2;
  }
  return res;
}


int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  const int N = 2e5 + 1;
  vector<long long> occ(N, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    occ[a[i]]++;
  }
  long long res = calc(occ);
  for (int i = 0; i < n; ++i) {
    long long m = (occ[a[i]] * (occ[a[i]] - 1))/ 2;
    occ[a[i]]--;
    long long n = (occ[a[i]] * (occ[a[i]] - 1))/ 2;
    occ[a[i]]++;
    long long res2 = res - m + n;
    cout << res2 << '\n';
  }

}


Measured memory_bytes: 5760
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def ii(v, n):
	v += 2 ** 15
	ret = bin(v)[-n:]
	#ret = ret[::-1]
	return ret

def vs(a,b):
	return [va+vb for va,vb in zip(a, b)]

def main():
	#a = int(input())
	n, m, x = IN()
	#s = input()
	bb = []
	for _ in range(n):
		dd = LIN()
		bb.append(dd)
	
	min_c = mod
	for i in range(2 ** n):
		c = 0
		mm = [0]*m
		rr = ii(i, n)
		for ik, keta in enumerate(rr):
			if keta == '1':
				l= bb[ik]
				c += l[0]
				mm = vs(mm, l[1:])
		if min(mm) >= x and c < min_c:
			min_c = c
	if min_c < mod:
		return min_c
	else:
		return -1
				
			
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 200010
#define MAX_T 524300

int n;
int szer=1;
LL tree[MAX_T];
int h[MAXSIZE];

LL query(int v,int l,int r,int a,int b){ //[l,r] szukany,[a,b] ogolny
	if(l==a&&b==r)
		return tree[v];

	int mid=(a+b-1)/2;
	if(r<=mid)
		return query(v*2,l,r,a,mid);
	else if(l>mid)
		return query(v*2+1,l,r,mid+1,b);
	else
		return max(query(v*2,l,mid,a,mid),query(v*2+1,mid+1,r,mid+1,b));

}
void ins(int p,LL val){
	p+=szer;
	tree[p]=val;
	p/=2;
	
	while(p){
		tree[p]=max(tree[p*2],tree[p*2+1]);
		p/=2;
	}
}

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	
	while(szer<=n)
		szer*=2;
	
	REP(i,n)
		cin>>h[i];
	
	REP(i,n){
		LL a1;
		cin>>a1;
		LL dp=query(1,1,h[i],0,szer-1);
		ins(h[i],a1+dp);
	}
	
	cout<<query(1,1,n,0,szer-1);
		
	return 0;
}


Measured memory_bytes: 4480
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

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

    int x;
    cin>>x;
    x-=(x%5);
    int t = x%500;
    cout<<2*x - t;

}



Measured memory_bytes: 256
#include <cstdio>
#include <string>

int main() {
  size_t n;
  scanf("%zu", &n);

  char buf[128];
  scanf("%s", buf);
  std::string s = buf;
  scanf("%s", buf);
  std::string t = buf;

  std::string u;
  for (size_t i = 0; i < n; ++i) {
    u += s[i];
    u += t[i];
  }
  printf("%s\n", u.c_str());
}


Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n,x = map(int, input().split())
city = list(map(int,input().split()))

for i in range(n):
    city[i] = abs(city[i]-x)

ans = city[0]
for num in city:
    ans = gcd(ans, num)

print(ans)

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

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

ll lcm(ll a,ll b){
  return a*b / gcd(a,b);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  while(cin >> a >> b) cout << gcd(a,b) << " " << lcm(a,b) << endl;
  return 0;
}

Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main(){
  string str;
  int ans,ans2;
  while(cin>>str){
    ans=ans2=0;
    for(int i=0;i+2<(int)str.size();i++){
      if(str.substr(i,3)=="JOI")ans++;
      else if(str.substr(i,3)=="IOI")ans2++;
    }
    cout<<ans<<endl<<ans2<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>

double w, h;

int main(void){
    double x, y;
    double grad;

    scanf("%lf %lf %lf %lf", &w, &h, &x, &y);

    printf("%f ", w*h/2);
    printf("%d", (x == w/2 && y == h/2) ? 1 : 0);

    return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    string s;
    cin >> n;
    vector<string> st;
    vector<string> ed;
    ll sum(0);
    vector<pair<int, string> > mi;
    int i;
    rep(i, n) {
        cin >> s;
        int rn(0), re(0);
        int j;
        int balance(0);
        int now(0);
        rep(j, sz(s)) {
            if (s[j] == '(') sum++;
            else sum--;
        }
        rep(j, sz(s)) {
            if (s[j] == '(') now++;
            else now--;
            rn = min(rn, now);
        }
        balance = now;
        now = 0;
        for (j = sz(s)-1; j >= 0; j--) {
            if (s[j] == ')') now++;
            else now--;
            re = min(re, now);
        }
        if (rn == 0) {
            st.push_back(s);
        } else if (re == 0) {
            ed.push_back(s);
        } else {
            // mi.push_back({{rn, re}, balance});
            mi.push_back({-balance, s});
        }
    }
    ll r(0), l(0);
    vector<string> w;
    rep(i, sz(st)) w.pb(st[i]);
    sort(mi.begin(), mi.end());
    rep(i, sz(mi)) w.pb(mi[i].second);
    rep(i, sz(ed)) w.pb(ed[i]);
    rep(i, sz(w)) {
        string s(w[i]);
        int j;
        rep(j, sz(s)) {
            if (s[j] == '(') r++;
            else r--;
            if (r < 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if (r != 0) {
        cout << "No" << endl;
        return 0;
    }
    for (i = sz(w)-1; i>=0;i--) {
        string s(w[i]);
        int j;
        for (j = sz(s)-1; j >= 0; j--) {
            if (s[j] == ')') l++;
            else l--;
            if (l < 0) {
                cout << s << ' ' << j << ' ' << l << endl;
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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

int main()
{
   string s;
   cin>>s;
   ll flg=0;
   for(int i=0;i<s.length();i++)
   {
       if(s[i]=='7')
       {
           cout<<"Yes";
           flg=1;
           break;
       }
   }
   if(flg==0)
   cout<<"No";
}


Measured memory_bytes: 3628
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
ll n,m,bil,ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>bil;
        ans+=bil;
    }
    if(ans>n){
        cout<<-1<<endl;
    }
    else cout<<n-ans<<endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int i,j,k,l;
    char an[15],bn[15],c,d;
    for(i=0;i<a;i++)
    {
        bn[i]=b+'0';
    }
    for(i=0;i<b;i++)
    {
        an[i]=a+'0';
    }

    if(a<b)
        {
            for(i=0;i<b;i++)
            printf("%c",an[i]);
            printf("\n");
        }
    else{
        for(i=0;i<a;i++)
            printf("%c",bn[i]);
            printf("\n");
    }


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
//#define endl "\n"
#define show(a) for(int i=0;i<a.size();i++) cout<<a[i & 1]<<" ";
#define fi first
#define se second
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define pb push_back
#define pi pair<int,int>
#define si set<int>
#define sll set<ll>
#define pll pair<ll, ll>
#define sci(x) scanf("%d",&x)
#define scs(x)  scanf("%s", x)
#define scll(x) scanf("%I64d",&x)
#define all(v) v.begin(),v.end()
#define sot(v) sort(v.begin(), v.end())
#define maxheap priority_queue<int>
#define mp make_pair
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);
#define PI 3.1415926535
#define long_zero 0ll
#define long_one 1ll

inline int sbt(int x) {return __builtin_popcount(x);}

using namespace std;
using namespace __gnu_pbds;
#define FOR(i, j, k, in) for ( i=j ; i<k ; i+=in)
#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif
#define N 10003
bool ok;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }

bool Comparator (pair <int, int> x, pair <int, int> y) {
	return x.first < y.first;
}
const int mxN = 2e5;
int n, m;
ll k, a[mxN + 1], b[mxN + 1];

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

	cin >> n >> m >> k;
	for (int i = 0; i < n; ++i) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}
	int ans = 0;
	for (int i = 0, j = m; i <= n; ++i) {
		if (a[i] > k)
			break;
		while (a[i] + b[j] > k)
			--j;
		ans = max(i + j, ans);
	}
	cout << ans;
}

Measured memory_bytes: 6768
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    int sa = b - a;
    for(int i = 0; i <= n - 1; ++i) {
        int j = n - 1 - i;
        int ma = d * i - c * j, mi = c * i - d * j;
        if(mi <= sa && sa <= ma) {
            cout << "YES" << endl;
            return;
        }
    }
    cout << "NO" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    VI w(n); REP(i,n) cin >> w[i];
    VI w2(n); partial_sum(w.begin(), w.end(), w2.begin());
    int ans = SUM(w,0LL);
    REP(i,n) chmin(ans,abs(w2[i]*2-SUM(w,0LL)));
    out(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>

using namespace std;

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

const ll MOD = 1000000007;
const ll INF = 99999999;

ll n, m, a[100001]{};

int main() {
	
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		ll s, t;
		cin >> s >> t;
		a[s] += t;
	}
	ll sum = 0, j = 0;
	while (sum < m) {
		j++;
		sum += a[j];
	}
	cout << j << endl;
	return 0;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
a_list = [0] + list(map(int,input().split()))

town_num_tmp = 1  # 今いる町
seen = [-1]*(n+1) # indexの街に訪れたことがあるか（訪れたことがない: -1）
town_hist_list = []

while seen[town_num_tmp] == -1:
    seen[town_num_tmp] = 1
    town_hist_list.append(town_num_tmp)
    # 更新
    town_num_tmp = a_list[town_num_tmp]

roop_end_index = len(town_hist_list) - 1
roop_start_index = town_hist_list.index(town_num_tmp)
roop_range = roop_end_index - roop_start_index + 1

if k < roop_end_index:
    print(town_hist_list[k])
else:
    print(town_hist_list[(k-roop_start_index)%roop_range+roop_start_index])

Measured memory_bytes: 32292
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  int n;
  cin >> n;
  cout << 180 * (n - 2) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'000;
const int LOGN = 19;

int n, m, k;

int64 pw(int64 a, int64 b) {
  int64 res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= mod;
    }
    a *= a;
    a %= mod;
    b >>= 1;
  }
  return res;
}

int64 inv(int64 a) {
  return pw(a, mod - 2);
}

int64 f(int x) {
  int64 res = 1;
  for (int i = 2; i <= x; ++i) {
    res *= i;
    res %= mod;
  }
  return res;
}

void solve(int test) {
  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= x; ++i) {
    int j = (x - i) / 2;
    if (i + j * 2 == x && i * 2 + j == y) {
      int64 ans = f(i + j) * inv(f(i)) % mod * inv(f(j)) % mod;
      cout << ans << '\n';
      return;
    }
  }
  cout << "0\n";
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A.at(i);
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (A.at(j) < A.at(minj)) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(A.at(i), A.at(minj));
            count++;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << A.at(i);
        if (i != n - 1) {
            cout << " ";
        }
    }
    cout << endl;

    cout << count << endl;
}


Measured memory_bytes: 3132
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<long, long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
long long dist[100010];
int dp[5005][5005];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N; string S;
	cin >> N >> S;

	dp[N - 1][N - 1] = 1;
	for (int i = N-1; 0 <= i; --i) {
		for (int j = N - 1; 0 <= j; --j) {
			if (i == N - 1 && j == N - 1)continue;
			dp[i][j] = S[i] == S[j] ? dp[i + 1][j + 1] + 1 : 0;
		}
	}

	int ans = 0;
	for (int i = 0; i < N;++i) {
		for (int j = 0; j < N;++j) {
			if (i > j)continue;
			ans = max(ans, min(dp[i][j], j-i));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 101248
#include<iostream>
using namespace std;
int prime[300000];
int length = 0;
void insert(int key) { prime[length] = key; length++; }
void makeprime() {
	insert(6);
	for (int i = 7; i <= 300000; i += 7) {
		int key = i + 1;
		for (int j = 0; j < length; j++) 
			if (key%prime[j] == 0)goto end1;
		insert(key);
	end1:;
		key = i + 6;
		for (int j = 0; j < length; j++)
			if (key%prime[j] == 0)goto end2;
		insert(key);
	end2:;
	}
}
int main() {
	makeprime();
	int k;
	while (cin >> k) {
		if (k == 1)return 0;
		cout << k << ':';
		for (int i = 0; i < length; i++) 
			if (k%prime[i] == 0)cout << ' ' << prime[i];
		cout << endl;
	}
}

Measured memory_bytes: 3192
#include<iostream>
#include<string>

using namespace std;

int main() {

	int h, w;

	while (cin >> h >> w) {
		if (h == 0 && w == 0) {
			break;
		}
		string line;
		line.resize(w, '#');

		for (int i = 0; i < h; ++i) {
			cout << line << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int a, b, c; cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
}

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

using namespace std;

const int MAX_N = 200010;
const long long INF = 1000000000000000;
int N;
pair <long long, long long> P[MAX_N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> P[i].first >> P[i].second;
	
	sort(P, P + N);
	
	long long min1 = INF, min2 = INF;
	long long ans = 0LL;
	for (int i = 0; i < N; i++) {
		ans = max(ans, P[i].first + P[i].second - min1);
		ans = max(ans, P[i].first - P[i].second - min2);
		min1 = min(min1, P[i].first + P[i].second);
		min2 = min(min2, P[i].first - P[i].second);
	}
	
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 6776
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

class Combination {
    int powmod(int a, int p) {
        int ans = 1;
        int mul = a;

        for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }

        return ans;
    }
public:
    int N;
    int mod;
    vector<int> fact;
    vector<int> revFact;

    Combination(int n, int m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    int get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, K;
    cin >> N >> K;
    if (K == 1) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    vector<int> S(N+1, 0);
    for (int i = 0; i < N; i++) S[i+1] = S[i] + A[i];

    auto comb = new Combination(300000, MOD);

    int ret = 0;
    for (int width = K - 1; width <= N; width++) {
        if (width < 2) continue;
        int sum = S[N] - S[width-1] - S[N-width+1];
        sum %= MOD;
        sum *= comb->get(width-2, K-2);
        sum %= MOD;

        ret += sum;
        ret %= MOD;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;



int main()
{
	ll k,x,ans;
	
	cin >> k >> x;
	ans = x - (k - 1);
	for (int i = 0; i < (k*2-1); i++) {
		cout << ans << " ";
		ans++;
	}
	
	return 0;
}


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

int main() {
	int n = 0;
	int x[100], y[100];
	cin >> n;

	int t;
	for (int i = 0; i < n; i++) {
		cin >> t;
		x[i] = t;
	}
	for (int i = 0; i < n; i++) {
		cin >> t;
		y[i] = t;
	}

	double z[100];
	for (int i = 0; i < n; i++) {
		z[i] = fabs(x[i] - y[i]);
	}
	double p1 = 0;
	for (int i = 0; i < n; i++) {
		p1 += z[i];
	}

	double p2 = 0;
	for (int i = 0; i < n; i++) {
		p2 += z[i] * z[i];
	}

	double p3 = 0;
	for (int i = 0; i < n; i++) {
		p3 += z[i] * z[i]* z[i];
	}

	double pmax = z[0];
	for (int i = 1; i < n; i++) {
		if (z[i] > pmax) pmax = z[i];
	}
	
	printf("%lf\n%lf\n%lf\n%lf\n", p1, sqrt(p2), pow(p3, 1.0/3.0), pmax);

	return 0;
}


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

int main() {
	long long N, K;
	vector<long long> A;
	cin >> N >> K;
	A.resize(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());
	long long L = -1000000000000000001, R = 1000000000000000000;
	while (R - L > 1) {
		long long MID = (L + R) / 2;
		long long COUNT = 0;
		for (int i = 0; i < N; i++) {
			if (A[i] < 0) {
				long long L2 = -1, R2 = N;
				while (R2 - L2 > 1) {
					long long MID2 = (L2 + R2) / 2;
					if (A[i] * A[MID2] > MID) L2 = MID2;
					else R2 = MID2;
				}
				COUNT += N - R2;
			}
			if (A[i] > 0) {
				long long L2 = -1, R2 = N;
				while (R2 - L2 > 1) {
					long long MID2 = (L2 + R2) / 2;
					if (A[i] * A[MID2] <= MID) L2 = MID2;
					else R2 = MID2;
				}
				COUNT += R2;
			}
			if (A[i] == 0) {
				if (MID >= 0) COUNT += N;
			}
			if (A[i] * A[i] <= MID) COUNT--;
		}
		COUNT /= 2;
		if (COUNT < K) L = MID;
		else R = MID;
	}
	cout << R << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	int n[3];
	int go = 0, nana = 0;
	rep(i, 3)
	{
		cin >> n[i];
		if (n[i] == 5)
			go++;
		if (n[i] == 7)
			nana++;
	}
	if (go == 2 && nana == 1)
		cout << "YES";
	else
		 cout << "NO";
	return (0);
}


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

ll slice_area(ll H, ll W) {
    ll res = H*W;
    if(W <= 2) return res;
    for(ll i = W/3; (i+1)*2 < W; ++i) {
        ll S1 = H*i, S2 = H*(W - 2*i);
        res = min(res, abs(S1 - S2));
    }
    return res;
}

ll T_area(ll H, ll W) {
    ll res = H*W;
    for(ll i = 1; i < W; ++i) {
        ll  S1 = H*i,
            S2 = H/2 * (W - i),
            S3 = (H - H/2)*(W - i);
        ll  mx = max(S1, max(S2, S3)),
            mn = min(S1, min(S2, S3));
        res = min(res, abs(mx - mn));
    }
    return res;
}

int main()
{
    ll H, W;
    cin >> H >> W;
    if(H%3 == 0 || W%3 == 0) { cout << 0 << endl; return 0; }

    ll res = H * W;
    res = min(res, slice_area(H, W));
    res = min(res, slice_area(W, H));
    res = min(res, T_area(H, W));
    res = min(res, T_area(W, H));
    
    cout << res << endl;

    return 0;
}

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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#endif

long long sum(vector<int> &V, int l, int r, int rest) {
    long long res = 0;
    vector<int> st;
    for (int i=0; i<V.size(); ++i) {
        if (i<=l || r<=i) {
            st.push_back(V[i]);
            res += V[i];
        }
    }
    sort(st.begin(), st.end());
    for (int i=0; i<min(rest, (int)st.size()); ++i) {
        if (0 <= st[i]) break;
        res -= st[i];
    }
    return res;
}

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

    int N, K;
    cin >> N >> K;

    vector<int> V(N);
    for (int i=0; i<N; ++i) cin >> V[i];

    long long ans = -1e10;
    for (int l=0; l<=K; ++l) {
        for (int r=0; l+r<=K; ++r) {
            ans = max(ans, sum(V, l-1, N-r, K-l-r));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	static int []ans;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
			
		int [][]like = new int [m][2];
		int [][]dislike = new int [k][2];
		
		Unionfind uf = new Unionfind(n);
		ans = new int [n];
		
		for(int i = 0 ; i < m ;i++) {
			like[i][0] = Integer.parseInt(sc.next());
			like[i][1] = Integer.parseInt(sc.next());
			uf.union(like[i][0]-1, like[i][1]-1);
		}
		
		for(int i = 0 ;i < n ;i++) {
			ans[i] = uf.getSize(i)-1;
		}
		for(int i = 0 ;i < m ;i++) {
				ans[like[i][0]-1]--;
				ans[like[i][1]-1]--;
		}
		for(int i = 0 ;i < k ; i++) {
			dislike[i][0] = Integer.parseInt(sc.next())-1;
			dislike[i][1] = Integer.parseInt(sc.next())-1;
			if(uf.root(dislike[i][0]) == uf.root(dislike[i][1])) {
				ans[dislike[i][0]]--;
				ans[dislike[i][1]]--;
			}
		}
		
		for(int i = 0 ;i < n ;i++) {
			System.out.println(ans[i]);
		}

	}
}

class Unionfind {

	private int[] data;
	private int []size;
	
	public Unionfind(int size) {
		this.data = new int [size];
		this.size = new int [size];
		for(int i = 0 ;i < size ;i++) {
			initnode(i);
		}
		clear();
	}
	
	public void initnode(int i) {
		size[i] = 1;
	}
	
	public void clear() {
		Arrays.fill(data, -1);
	}
	
	public void union(int x , int y ) {
		if((x = root(x)) != (y = root(y))) {
			if(data[y] < data[x]) {
				final int t = x;
				x = y;
				y = t;
			}
			data[x] += data[y];
			size[root(x)] += size[root(y)];
			data[y] = x;
		}
	}
	
	public int getSize(int i) {
		return size[root(i)];
	}
	
	public int root(int x) {
		if(data[x] < 0) {
			return x;
		}
		else {
			return data[x] = root(data[x]);
		}
	}
	
	public boolean same(int x, int y) {
		return root(x) == root(y);
	}
	
}


Measured memory_bytes: 87140
#include <stdio.h>
int main(void){
int h,m,s,a,b,c,d,e;
scanf("%d\n",&a);
h=a/3600;
b=a%3600;
m=b/60;
s=b%60;
printf("%d:%d:%d\n",h,m,s);
return 0;
}

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

ll cmb(ll n) {
  if(n < 0)
    return 0;
  else
    return n * (n - 1) / 2;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }

  map<int, int> cnt;
  rep(i, n) cnt[a[i]]++;

  // map<int, ll> ans;
  // rep(i, cnt.size()) {
  //   int q = cnt[i];
  //   if(q == 0)
  //     continue;
  //   ll aa = cmb(q - 1);
  //   if(ans[q] == 0) {
  //     rep(j, cnt.size()) {
  //       if(j == i)
  //         continue;
  //       aa += cmb(cnt[j]);
  //     }
  //     ans[q] = aa;
  //   }
  // }

  // rep(i, n) cout << ans[cnt[a[i]]] << endl;

  ll ans = 1;
  rep(i, cnt.size()) ans += cmb(cnt[i]);
  rep(i, n) cout << ans - cnt[a[i]] << endl;
}


Measured memory_bytes: 13548
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n;cin>>n;
	int a[10010];
	for(int i=0;i<n;i++)cin>>a[i];
	int s=0;
	for(int i=0;i<n;i++)
	{
		int c=0;
		for(;a[i]%2==0;a[i]/=2,c++);
		s+=c;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 892
// Taken from http://codeforces.com/gym/101681/submission/33993705
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
    ArrayList<Integer>[] g;
    HashSet<Integer> ans = new HashSet<>();
    boolean[] used;
    boolean[] marked;
    int[] someLeaf;
    int[] parent;

    int dfs(int v) {
        used[v] = true;
        int leaf = v;
        for (int i = 0; i < g[v].size(); i++) {
            int to = g[v].get(i);
            if (!used[to]) {
                parent[to] = v;
                leaf = someLeaf[to] = dfs(to);
                marked[v] |= marked[to];
            }
        }
        boolean isFirst = true;
        for (int i = 0; i < g[v].size(); i++) {
            int to = g[v].get(i);
            if (parent[to] != v) {
                continue;
            }
            if (!marked[to]) {
                if (!isFirst) {
                    ans.add(someLeaf[to]);
                    marked[v] = true;
                }
                isFirst = false;
            }
        }
        return leaf;
    }

    public void run() throws IOException {
        MyScanner in = new MyScanner(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        g = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            g[i] = new ArrayList<>();
        }
        for (int i = 0; i < n - 1; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            g[a].add(b);
            g[b].add(a);
        }
        int root = -1;
        for (int i = 0; i < n; i++) {
            if (g[i].size() > 2) {
                root = i;
                break;
            }
        }
        if (root == -1) {
            for (int i = 0; i < n; i++) {
                if (g[i].size() == 1) {
                    out.println("1");
                    //out.println(i + 1);
                    out.close();
                    return;
                }
            }
        }
        parent = new int[n];
        Arrays.fill(parent, -1);
        someLeaf = new int[n];
        used = new boolean[n];
        marked = new boolean[n];
        dfs(root);
        out.println(ans.size());
        //for (int v : ans) {
        //    out.print(v + 1 + " ");
        //}
        out.close();
    }

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

    static class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner(Reader r) {
            br = new BufferedReader(r);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

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


Measured memory_bytes: 58364
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 100100;

struct Sol {
  int sum;
  int cnt_zero;
};

vector<int> E[MAX];
Sol down[MAX], up[MAX];
Sol children[MAX];
int parent[MAX];

void DfsDown(int x) {
  for (int i = 0; i < (int)E[x].size(); ++i) {
    if (E[x][i] == parent[x]) {
      swap(E[x][i], E[x].back());
      E[x].pop_back();
      break;
    }
  }

  for (int y: E[x]) {
    parent[y] = x;
    DfsDown(y);

    if (down[y].sum > 0) {
      children[x].sum += down[y].sum;
    } else {
      children[x].cnt_zero++;
    }
  }

  down[x] = children[x];
  if (down[x].cnt_zero > 1) {
    down[x].sum += down[x].cnt_zero - 1;
  }
}

void DfsUp(int x) {
  Sol tmp = children[x];
  if (parent[x] != -1) {
    if (up[x].sum > 0) {
      tmp.sum += up[x].sum;
    } else {
      tmp.cnt_zero++;
    }
  }

  for (int y: E[x]) {
    up[y] = tmp;
    if (down[y].sum > 0) {
      up[y].sum -= down[y].sum;
    } else {
      up[y].cnt_zero--;
    }
    if (up[y].cnt_zero > 1) {
      up[y].sum += up[y].cnt_zero - 1;
    }
    DfsUp(y);
  }
}

int main(void) {
  int N;
  scanf("%d", &N);
  REP(i, N-1) {
    int a, b;
    scanf("%d %d", &a, &b);
    E[a].push_back(b);
    E[b].push_back(a);
  }

  parent[0] = -1;
  DfsDown(0);
  DfsUp(0);

  int ret = N;
  REP(i, N) {
    if (up[i].sum > 0) {
      down[i].sum += up[i].sum;
    } else {
      down[i].cnt_zero++;
    }

    if (down[i].cnt_zero > 1) {
      down[i].sum += down[i].cnt_zero - 1;
    }

    ret = min(ret, down[i].sum + 1);
  }

  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 13056
def A_DividingaString():
    S = input()
    ans = 0
    tmp,last = "", ""
    for s in S:
        tmp += s
        if tmp != last:
            last = tmp
            tmp = ""
            ans += 1
    print(ans)
    
if __name__ == "__main__":
    A_DividingaString()

Measured memory_bytes: 3500