akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;


int main(){
    ll n,m,s,t;
    cin >> n >> m >> s >> t;
    s--;
    t--;
    
    pair<ll, ll> uv[2*m];
    ll yen[2*m], snuke[2*m];
    
    for(ll i=0; i<m; i++){
        cin >> uv[i].first >> uv[i].second;
        uv[i].first--;
        uv[i].second--;
        
        
        uv[i+m].first=uv[i].second;
        uv[i+m].second=uv[i].first;
        
        cin >> yen[i] >> snuke[i];
        yen[i+m]=yen[i];
        snuke[i+m]=snuke[i];
    }
    
    pair<pair<ll,ll> , ll> train[2*m];
    for(ll i=0; i<2*m; i++){
        train[i].first.first=uv[i].first;
        train[i].first.second=uv[i].second;
        train[i].second=i;
    }
    
    sort(train,train+2*m);
    
    ll idx[n+1];
    for(ll i=2*m-1; i>=0; i--){
        idx[train[i].first.first]=i;
    }
    idx[n]=2*m;
    
    ll yenFromS[n];
    yenFromS[s]=0;
    
    ll snukeFromT[n];
    snukeFromT[t]=0;
    
    ll checked1[n];
    ll checked2[n];
    for(ll i=0; i<n; i++){
        checked1[i]=0;
        checked2[i]=0;
    }
    ll c1=n, c2=n;
    
    priority_queue< pair<ll,ll>, vector<pair<ll,ll> >, greater<pair<ll,ll> > > q1;
    q1.push(make_pair(0,s));
    while(c1>0){
        while(checked1[q1.top().second]==1){
            q1.pop();
        }
        ll now=q1.top().second;
        yenFromS[now]=q1.top().first;
        q1.pop();

        checked1[now]=1;
        for(ll i=idx[now]; i<idx[now+1]; i++){
            ll to=train[i].first.second;
            
            if(checked1[to]==1){
                continue;
            }
            
            q1.push(make_pair(yenFromS[now]+yen[train[i].second],to));
        }
               
        c1--;
    }
    
    priority_queue< pair<ll,ll>, vector<pair<ll,ll> > ,greater<pair<ll,ll> > > q2;
    q2.push(make_pair(0,t));
    while(c2>0){
        while(checked2[q2.top().second]==1){
            q2.pop();
        }
        ll now=q2.top().second;
        snukeFromT[now]=q2.top().first;
        q2.pop();
        
        checked2[now]=1;
        for(ll i=idx[now]; i<idx[now+1]; i++){
            ll to=train[i].first.second;
            
            if(checked2[to]==1){
                continue;
            }
            
            q2.push(make_pair(snukeFromT[now]+snuke[train[i].second],to));
        }
        
        c2--;
    }
    
    ll money=1e+15;
    
    //exchange at city i
    ll cost[n];
    for(ll i=0; i<n; i++){
        cost[i]=yenFromS[i]+snukeFromT[i];
    }
    
    for(ll i=n-2; i>=0; i--){
        cost[i]=min(cost[i],cost[i+1]);
    }
    
    for(ll i=0; i<n; i++){
        cout<< money-cost[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 18548
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
struct Data{
	int id;
	ll val;
}a[maxn];
ll b[maxn],d[maxn],u[maxn];
int n,m;
bool cmp(Data a,Data b){return a.val>b.val;}
int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++)
		b[i]=read(),d[i]=read(),u[i]=read();
	for(int i=1;i<=n;i++)
		a[i].id=i,a[i].val=(ll)u[i]*(m-b[i])+(ll)d[i]*b[i];
	std::sort(a+1,a+n+1,cmp);
	ll l=0,r=(ll)n*m;
	while(l<r){
		ll mid=(l+r)>>1,sum=0;
		// printf("%lld %lld %lld ****\n",l,r,mid);
		int k=mid%m,cnt=mid/m;
		for(int i=1;i<=n;i++)
			if(i<=cnt)sum+=(ll)u[a[i].id]*(m-b[a[i].id]);
			else sum-=(ll)d[a[i].id]*b[a[i].id];
		// printf(": %lld\n",sum);
		ll mx=sum;
		if(k){
			for(int i=1;i<=n;i++){
				ll t=sum;
				if(i<=cnt)t+=a[cnt+1].val-a[i].val;
				t+=(ll)d[a[i].id]*b[a[i].id];
				// printf("%d %lld\n",i,t);
				if(k>b[a[i].id])t+=(ll)u[a[i].id]*(k-b[a[i].id]);
				else t+=(ll)d[a[i].id]*(k-b[a[i].id]);
				// printf("%d %lld\n",i,t);
				mx=std::max(mx,t);
			}
		}
		if(mx>=0)r=mid;
		else l=mid+1;
	}
	writeln(l);
	return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <string.h>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
	int n,a[100000],b[100000]={0},i,j,k;
	cin>>n>>k;
	for(i=0;i<n;i++)
		cin>>a[i];
	b[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++){
		b[i]=1000000000;
		for(j=1;j<=k && i-j>=0;j++)
		{
			b[i]=min(b[i],b[i-j]+abs(a[i]-a[i-j]));
		}
		}
	cout<<b[n-1]<<endl;
		
	
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<chrono>
#define ll long long
#define mod 1000000007
#define endl '\n'
#define tab ' '
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pi 3.141592653589793238460
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define RF(i,a,b) for(int i=(int)a;i>=(int)b;i--)
// a.exe < "C:/Users/Piyush Naithani/Desktop/Codechef/Testfiles/icpc2.txt"
using namespace std;

void solve()
{
    ll n;
    cin>>n;

    ll ans = n/10;

    ll multi = 50;

    if(n&1)
    {
        cout<<"0";
    }
    else{

    while(multi <= n)
    {
        ans += n/multi;
        multi *= 5;
    }

    cout<<ans;
}
}


int main(){
    // fast;
    #ifndef ONLINE_JUDGE
      // freopen("C:\Users\Piyush Naithani\Desktop\Codechef\Testfiles\icpc2.txt","r",stdin);
    
    // freopen("file name","w",stdout);
    #endif

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

string s[3];

int main(){
    rep(i, 3) cin >> s[i];
    cout << "A" << s[1][0] << "C" << endl;
    return 0;
}


Measured memory_bytes: 3592
A = {}
while True:
    S = input()
    if S == '':
        break
    x,y = map(int,S.split(','))
    if x in A:
        A [x] += 1
    else:
        A [x] = 1

B = {}
while True:
    try:
        x,y = map(int,input().split(','))
    except EOFError:
        break
    if x in B:
        B [x] += 1
    else:
        B [x] = 1

for i in A.keys():
    if i in B:
        print(i,A [i] + B [i])

Measured memory_bytes: 7676
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}
int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}
/*
 
 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
int a=0, b=0, c = 0;

int main(void) {
	Rapid;//固定高速

	int n;
	cin >> n;
	vint a(n);
	vcin(a, n);
	sort(a);
	cout << a[a.size() - 1] - a[0] << rt;

	please AC;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
using namespace std;
int main() {
    int n, b;
    cin >> n;
    int h[n];
    for (int i=0;i<n;i++) {
        cin >> b;
        h[i] = b;
    }
    long long int dp[1000000];
    for (int i=0;i<n;i++) {
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    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] << endl;
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramE
    {
        private class Num
        {
            public long Min {get;set;}
            public long Max {get;set;}
        }
        static void Main()
        {
            int n = NextInt;
            var up = TakeLine(n).Select(l => new Num{Min = l[0], Max = l[1]}).OrderBy(x => x.Min).ThenBy(x => x.Max).ToArray();
            var down = up.OrderByDescending(x => x.Max).ThenByDescending(x => x.Min).ToArray();

            if (n % 2 == 0)
            {
                long min = up[n / 2].Min + up[n / 2 - 1].Min;
                long max = down[n / 2].Max + down[n / 2 - 1].Max;
                System.Console.WriteLine(max - min + 1);
            }
            else
            {
                long min = up[(n - 1) / 2].Min;
                long max = down[(n - 1) / 2].Max;
                System.Console.WriteLine(max - min + 1);
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 60752
n = int(input())

li = [int(i) for i in input().split()]

sortli = sorted(li)

count = 0

for i in range(n):
    if li[i] == sortli[i]:
        count += 1

if count == n:
    print('YES')


elif count + 2 == n:
    print('YES')
else:
    print('NO')


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

int main(){
    vector<int> a(10);
    for(int i=0;i<10;i++) cin >> a[i];
    sort(a.begin(),a.end());
    for(int i=9;i>6;i--) cout << a[i] << endl;
}

Measured memory_bytes: 3096
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n

dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])


Measured memory_bytes: 13928
#include <stdio.h>
#include <string.h>
int main(void){
  int a;
  char S[11];
  scanf("%d",&a);
  scanf("%s",S);
  if(a>=3200){
    printf("%s",S);
  }
  else{
    printf("red\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long L[] = new long[87];

        L[0] = 2;
        L[1] = 1;

        for(int i =2;i<=86;i++){
           L[i] = L[i-1]+L[i-2];
        }
        System.out.println(L[N]);
    }
}

Measured memory_bytes: 21844
/*
    WRITER:kakitamasziru/OxOmisosiru
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;
typedef pair<long,long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    //n!はi = 1;i<=nでする
    for (long long i = n-r+1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    long long ans = 0;
    int K;cin >> K;
    for(int i = 1;i<=K;i++){
        for(int j = 1;j<=K;j++){
            for(int l = 1;l<=K;l++){
                ans += gcd(gcd(i,j),l);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
INTEGER N(1000000)
READ*,N(1)
DO I=2,1000000
  IF(MOD(N(I-1),2)==0)THEN
    N(I)=N(I-1)/2
  ELSE
    N(I)=N(I-1)*3+1
  END IF
  DO J=1,I-1
    IF (N(I)==N(J))THEN
      PRINT"(I0)",I
      STOP
    ENDIF
  END DO
END DO
END

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll n;  cin >> n;
    vector<pair<ll, ll> >ta(n);
    rep(i, n)   cin >> ta[i].first >> ta[i].second;
    //solve
    pair<ll, ll>ans(1, 1);
    rep(i, n){
        ll maxn = max((ans.first+(ta[i].first-1))/ta[i].first, (ans.second+(ta[i].second-1))/ta[i].second);
        ans.first = maxn*ta[i].first;
        ans.second = maxn*ta[i].second;
    }
    cout << ans.first+ans.second << endl;
}


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

const int MOD = 1e9 + 7, MAXN = 2e5 + 10;
long long ans, k, fi[MAXN], f[MAXN];
int n, m;
long long ch(long long a, long long b) {
	return f[a] * fi[a - b] % MOD * fi[b] % MOD;
}

int main() {
	cin >> n >> m >> k;
	fi[1] = 1;
	for (int i = 2; i < MAXN; i++)
		fi[i] = -(MOD / i) * fi[MOD % i] % MOD;
	fi[0] = f[0] = 1;
	for (int i = 1; i < MAXN; i++) {
		fi[i] *= fi[i - 1], fi[i] %= MOD;
		f[i] = f[i - 1] * i % MOD;
	}
	long long sum = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			sum += i + j;
	for (int i = 0; i < n; i++) {
		long long bf = sum;
		for (int j = 0; j < m; j++) {
			ans += ch(n * m - 2, k - 2) * (sum % MOD) % MOD;
			ans %= MOD;
			sum += -(m - 1 - j) * n + (j + 1) * n;
		}
		sum = bf;
		sum += -(n - 1 - i) * m + (i + 1) * m;
	}
	ans *= fi[2], ans %= MOD;
	if (ans < 0)
		ans += MOD;
	cout << ans;
}

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

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

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int n;
map <int,int> mp;

int main(){
  cin >> n;
  REP(i,n){
    int x;
    cin >> x;
    if(mp.count(x) == 0){
      mp[x] = 1;
    }else{
      mp[x]++;
    }
  }
  ll ans = 0;
  for(auto &x: mp){
    if(x.first > x.second){
      ans += x.second;
    }else if(x.first < x.second){
      ans += x.second -x.first;
    }
  }
  cout << ans <<endl;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll k, a, b;
  cin >> k >> a >> b;
  cout << ((a - 1) / k < b / k ? "OK" : "NG") << endl;
}

Measured memory_bytes: 3564
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int S = scan.nextInt();
        int W = scan.nextInt();
        if(S<=W){
        System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}


Measured memory_bytes: 35548
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;


int32_t main(){

    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    string s;
    cin>>s;

    int l = s.length();
    string pre = "#";
    string now = "";
    int ans = 0;
    for(int i = 0;i<l; i++){
        now+=s[i];
        if(now!=pre){
            pre = now;
            ans++;
            now = "";
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;



int main()
{
	long N, Y;
	cin >> N >> Y;
	
	
	for(int a = 0; a <= N; a++){
		for(int b = 0; b <= N - a; b++){
			int money = 10000 * a + 5000 * b + 1000 * (N - a - b);
			if(money == Y){
				cout << a << " " << b << " " << N - a - b << endl;
				return 0;
			}
		}
	}

	cout << "-1" << " " << "-1" << " " << "-1" << endl;
	return 0;
}

Measured memory_bytes: 256
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	ll n,k;
	cin>>n>>k;
	if(k!=1)
		cout<<n-k<<endl;
	else
		cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 764
#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 SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;


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

int l,r,d;
cin >> l >> r >> d;
cout << r/d - (l-1)/d << endl;

return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int n,q;
  cin>>n>>q;
  vector<list<int> > L(n);
  
  while(q--){
    int cmd;
    cin>>cmd;
    
    if(cmd == 0){
      int t, x;
      cin>>t>>x;
      L[t].push_back(x);
    }
    if(cmd == 1){
      int t;
      cin>>t;
      prArr(L[t]);
    }
    
    if(cmd == 2){
      int s, t;
      cin>>s>>t;
      L[t].splice(L[t].end(), move(L[s]));
    }
  }


  
  return 0;
}



Measured memory_bytes: 34412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int W,H,N;
    cin >> W >> H >> N;
    int wi = 0,hi = 0,wa = W,ha = H;
    REP(i,N){
        int x,y,a;
        cin >> x >> y >> a;
        if(a == 1){
            chmax(wi,x);
        }else if(a == 2){
            chmin(wa,x);
        }else if(a == 3){
            chmax(hi,y);
        }else{
            chmin(ha,y);
        }
    }
    cout << max(0,ha-hi)*max(0,wa-wi) << "\n";
}

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

accum = []
csum = 0
for a in al:
    csum += a
    accum.append(csum)

asum = accum[-1]
ans = 10**10
for a in accum[:-1]:
    x = a
    y = asum-x
    ans = min(ans, abs(x-y))

print(ans) 

Measured memory_bytes: 102992
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define gao(x,y) (x==1||x==n||y==1||y==m)
#define dis(x,y) ((i%2==0?(x==n-p[i][0]+1||y==p[i][1]):(x==p[i][0]||y==m-p[i][1]+1))?(abs(x-p[i][0])+abs(y-p[i][1])):(n+n+m+m-4-abs(x-p[i][0])-abs(y-p[i][1])))
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
int main()
{	int n,m,QAQ,x1,y1,x2,y2; cin>>n>>m>>QAQ; ++n,++m;
	int p[4][2]={{1,1},{1,m},{n,m},{n,1}}; vector<pii> v[4],fuck[4];
	for(rint qaq=1;qaq<=QAQ;qaq++)
	{	scanf("%d%d%d%d",&x1,&y1,&x2,&y2); x1++;y1++;x2++;y2++;
		if(!gao(x1,y1)||!gao(x2,y2)) continue;
		if(x1==x2)
		{	if(x1==1) fuck[0].push_back(mp(abs(y1-p[0][1]),abs(y2-p[0][1])));
			else fuck[2].push_back(mp(abs(y1-p[2][1]),abs(y2-p[2][1])));
			continue;
		}
		if(y1==y2)
		{	if(y1==m) fuck[1].push_back(mp(abs(x1-p[1][0]),abs(x2-p[1][0])));
			else fuck[3].push_back(mp(abs(x1-p[3][0]),abs(x2-p[3][0])));
			continue;
		}
		for(rint i=0;i<=3;i++)
		{	if((i%2==0&&x1!=p[i][0])||(i%2==1&&y1!=p[i][1])) continue;
		//	if(i==0) debug((i%2==0?abs(y1-p[i][1]):abs(x1-p[i][0]))),debug(dis(x2,y2));
			v[i].push_back(mp(i%2==0?abs(y1-p[i][1]):abs(x1-p[i][0]),dis(x2,y2)));
		}
		for(rint i=0;i<=3;i++)
		{	if((i%2==0&&x2!=p[i][0])||(i%2==1&&y2!=p[i][1])) continue;
		//	if(i==0) debug((i%2==0?abs(y2-p[i][1]):abs(x2-p[i][0]))),debug(dis(x1,y1));
			v[i].push_back(mp(i%2==0?abs(y2-p[i][1]):abs(x2-p[i][0]),dis(x1,y1)));
		}
	}
	for(rint i=0;i<4;i++)
	for(rint j=0;j<fuck[i].size();j++)
	if(fuck[i][j].first>fuck[i][j].second) swap(fuck[i][j].first,fuck[i][j].second);
	for(rint i=0;i<4;i++)
	sort(v[i].begin(),v[i].end()),sort(fuck[i].begin(),fuck[i].end());
	for(rint i=0;i<4;i++)
	for(rint j=0;j+1<v[i].size();j++)
	if(v[i][j].second>v[i][j+1].second) return !printf("NO");
	for(rint i=0;i<4;i++)
	for(rint j=0;j<fuck[i].size();j++)
	for(rint k=j+1;k<fuck[i].size();k++)
	if(fuck[i][k].first<fuck[i][j].second&&fuck[i][j].second<fuck[i][k].second)
	return !printf("NO");
//	for(rint i=0;i<4;i++)
//	for(rint j=0,k=0;j<fuck[i].size();j=k)
//	{	for(k=j+1;k<fuck[i].size()&&fuck[i][k].second<=fuck[i][j].second;k++);
//		if(k<fuck[i].size()&&fuck[i][k].first<fuck[i][j].second&&fuck[i][j].second<fuck[i][k].second)
//		return !printf("NO");
//	}
	for(rint i=0;i<4;i++)
	for(rint j=0,k=0;j<fuck[i].size();j++)
	{	for(;k<v[i].size()&&v[i][k].first<fuck[i][j].second;k++)
		{
	//	cerr<<fuck[i][j].first<<" "<<v[i][k].first<<" "<<fuck[i][j].second<<endl;
		if(fuck[i][j].first<v[i][k].first&&v[i][k].first<fuck[i][j].second)
		return !printf("NO");
		}
	//	exit(0);
	}
	printf("YES");
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  cout<<fixed<<setprecision(20);
  cin.tie(0);ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int n=s.size(),m=0;
  rep(i,n){
    if(s[i]=='p'){
      m++;
    } 
  }
  cout<<n/2-m<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int prime[1000005];
int pr[1000005],x=0;
int main(){
	long long n,p;
	cin>>n>>p;
	memset(prime,0,sizeof(prime));
	for(int i=2;i<=1000000;i++){
		if(!prime[i]){
			x++;
			pr[x]=i;
			for(int j=i+i;j<=1000000;j+=i){
				prime[j]=1;
			}
		}
	}
	long long ans=1;
	for(int i=1;i<=x;i++){
		if(p==1){
			cout<<ans<<endl;
			return 0;
		}
		int xx=0;
		while(p%pr[i]==0){
			p/=pr[i];
			xx++;
		}
		for(int j=1;j<=xx/n;j++){
			ans*=pr[i];
		}
		//if(xx)cout<<xx<<" "<<pr[i]<<endl;
	}
	if(p!=1){
		if(n==1){
			ans*=p;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6272
package main

import (
	"fmt"
)

func main() {
	var (
		a, b, c, x, ans int
	)
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i < a+1; i++ {
		for o := 0; o < b+1; o++ {
			for p := 0; p < c+1; p++ {
				if x == 500*i+100*o+50*p {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n;
    cin>>n;
    cout<<(n % 2 == 0 ? 0.5 : (n + 1.0) / n / 2)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 101
#define WHITE 0
#define BLACK 2
#define GRAY 1
int time,n,g[MAX][MAX] = {0};
int d[MAX],f[MAX],color[MAX] = {WHITE};

void visit(int u){
  int i;

  color[u] = GRAY;
  d[u] = ++time;

  for(i=0;i<n;i++){
    if(g[u][i] == 0)
      continue;
    if(color[i] ==WHITE)
      visit(i);
  }

  color[u] = BLACK;
  f[u] = ++time;
}

void dfs(void){
  int i;
  time = 0;

  for(i=0;i<n;i++)
    if(color[i] == WHITE)
      visit(i);

  for(i=0;i<n;i++)
    printf("%d %d %d\n",i+1,d[i],f[i]);
}

int main(){
  int i,j,x,y,z;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&x,&y);
    for(j=0;j<y;j++){
      scanf("%d",&z);
      g[x-1][z-1] = 1;
    }
  }

  dfs();
  return 0;
}


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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

int n, q;
vector<vector<int>> tree(202020);
vector<int> parent(202020);
vector<ll> counter(202020);
vector<ll> add(202020);

void make_parent(int a){
    for(auto x: tree.at(a)){
        if(x != parent.at(a)){
            parent.at(x) = a;
            make_parent(x);
        }
    }
}

void addcount(int a){
    counter.at(a) = add.at(a) + counter.at(parent.at(a));
    for(auto x: tree.at(a)){
        if(x != parent.at(a)) addcount(x);
    }
}


int main() {
    scanf("%d%d", &n, &q);
    rp(i, 0, n-1){
        int a, b;
        scanf("%d%d", &a, &b);
        tree.at(a).emplace_back(b);
        tree.at(b).emplace_back(a);
    }
    make_parent(1);
    rp(i, 0, q){
        int p;
        ll x;
        scanf("%d%lld", &p, &x);
        add.at(p) += x;
    }
    addcount(1);
    rp(i, 1, n+1) printf("%lld ", counter.at(i));
    return 0;

}


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

int main() {
    int n, m, cnt=0;
    int sum = 0;
    string ans;
    cin >> n >> m;
    vector<int> a(n);

    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    for(int i=0; i<n; i++) {
        sum += a[i];
    }
    double border = sum/((double) 4*m);

    for(int i=0; i<n; i++){
        if (a[i] >= border) {
            cnt++;
        }
    }
    if (cnt >= m) {
        ans = "Yes";
    } else {
        ans = "No";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#l=list(map(int, input().split()))
n,k,q=map(int, input().split())

l = []
for i in range(n):
    l.append(k)

for a in range(q):
    j = int(input())
    l[j-1] += 1

for i in l:
    if (i - q > 0):
        print("Yes")
    else:
        print("No")



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

using namespace std;
typedef long long ll;

ll dp[3010][3010];

int main() {
	string a,b;
	cin >> a >> b;
	
	memset(dp, 0,sizeof(dp));
	
	for(int i=1; i <= a.length(); i++) {
		for(int j=1; j <= b.length(); j++) {
			if(a[i-1] == b[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
			dp[i][j] = max(dp[i][j], dp[i-1][j]);
			dp[i][j] = max(dp[i][j], dp[i][j-1]);
		}
	}
	
	string s;
	int i = a.length(), j = b.length();
	
	while(i > 0 && j > 0) {
		if(dp[i][j] - dp[i-1][j-1] == 1 && a[i-1] == b[j-1]) {
			i--;
			j--;
			s += a[i];
		}
		else if(i > 0 && dp[i][j] == dp[i-1][j]) i--;
		else j--;
	}
	reverse(s.begin(), s.end());
	
	cout << s;

	return 0;
}

Measured memory_bytes: 71040
#include <stdio.h>

int main(void) {
	int score, judge, point;
	int i, sum, max, min;
	while(scanf("%d", &judge) && judge) {
		sum = 0;
		max = 0;
		min = 1000;
		for(i = 0; i < judge; i++) {
			scanf("%d", &point);
			sum += point;
			max = (max < point) ? point : max;
			min = (min > point) ? point : min;
		}
		score = sum - min - max;
		score /= (judge - 2);
		printf("%d\n", score);
	}
	return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse4,avx,avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <chrono>
#include <random>
#include <string>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <sstream>
#include <numeric>
#include <complex>
#include <immintrin.h>
#include <unordered_set>

using namespace std;

using ll = long long;
using ld = long double;
using VectorType = ld;
using ull = unsigned long long;

const ll INF = 1e15;
const ld eps = 1e-7;
const ld pi = atan2(0, -1);
const ll mod = 1e9 + 7;
const ll P = 179, Q = 239;
const ll A = 26;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

ll sign(ll a) {
	if (a < 0) return -1;
	if (a == 0) return 0;
	return 1;
}

bool equal(ld a, ld b) {
	return abs(a - b) < eps;
}

struct query {
	ll l, r, i;

	query(ll l = 0, ll r = 0, ll i = 0) : l(l), r(r), i(i) {};
};

bool mini(ll &a, ll b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

bool maxi(ll &a, ll b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool mini(ld &a, ld b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

ll mmax(ll a, ll b) {
	if (a > b) return a;
	return b;
}

ll mmin(ll a, ll b) {
	if (a < b) return a;
	return b;
}

ld mmax(ld a, ld b) {
	if (a > b) return a;
	return b;
}

ld mmin(ld a, ld b) {
	if (a < b) return a;
	return b;
}

bool maxi(ld &a, ld b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

ll sub(ll a, ll b) {
	a -= b;
	if (a < 0) {
		a += mod;
	}
	return a;
}

ll add(ll a, ll b) {
	a += b;
	if (a > mod) {
		a -= mod;
	}
	return a;
}

ll mul(ll a, ll b) {
	return (a * b) % mod;
}

ll n, m;
ll k;
vector <vector <ll>> vec;
vector <bool> used;
vector <vector <ll>> g;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll x, y;
	cin >> n >> x >> y;
	g.resize(n);
	--x; --y;
	vector <vector <ll>> dist(n, vector <ll>(n, INF));
	for (int i = 0; i < n - 1; ++i) {
		g[i].push_back(i + 1);
		g[i + 1].push_back(i);
	}
	g[x].push_back(y);
	g[y].push_back(x);
	for (int i = 0; i < n; ++i) {
		queue <ll> q;
		q.push(i);
		used.assign(n, false);
		used[i] = true;
		dist[i][i] = 0;
		while (!q.empty()) {
			ll v = q.front();
			q.pop();
			for (auto &u : g[v]) {
				if (!used[u] && mini(dist[i][u], dist[i][v] + 1)) {
					used[u] = true;
					q.push(u);
				}
			}
		}
	}
	vector <ll> ans(n);
	for (auto &x : dist) {
		for (auto &y : x) {
			ans[y]++;
		}
	}
	for (int i = 1; i < n; ++i) {
		cout << ans[i] / 2 << '\n';
	}
	return 0;
}

Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
ll mod=1e9+7;


int main(){
    int n;
    cin>>n;
    vector<int> x(n);
    rep(i,n) cin>>x.at(i);
    int ans=1001001001;

    for(int P=1;P<=100;P++){
        int cost=0;
        rep(i,n){
            cost+=(x[i]-P)*(x[i]-P);
        }
        ans=min(ans, cost);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# B - 105
N = int(input())

ans = 0
if N < 105:
    print(0)
    exit()
else:
    for i in range(105,N+1,2):
        count = 0
        for j in range(1, i+1):
            if i % j == 0:
                count += 1
            else:
                pass
        if count == 8:
            ans += 1
        else:
            pass

print(ans)

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

int main() {
	// your code goes here
	int h,w,a,b,i,j;
	cin >> h >> w >> a >> b;
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			if(i<=b&&j<=a) cout << "1";
			else if(i>b&&j>a) cout << "1";
			else cout << "0";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;
typedef long long ll;

int main()
{
    ll a, b, c, cnt = 0;
    cin >> a >> b >> c;
    if(a == 0) cnt = b / c + 1;
    else cnt = b / c - (a - 1) / c;
    cout << cnt;
    return 0;
}


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

using namespace std;
 
#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	    unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      	    cout<<"#x "<<x<<"\n";
#define trace(x,y)  	    cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn          	    cout<<"\n";


bool SBF(const pair <int,int>& a, const pair<int,int>& b){return a.F<b.F;}
bool SBS(const pair <int,int>& a, const pair<int,int>& b){return a.S<b.S;}


const long double PI  = 3.1415926535;
const long long   mod = 1e9+ 7; 
const int 	  mxN = 1000;













void solve(){
	string s;
	cin >> s;
	string ret = "";
	for(int i=0;i<s.length(); i++){
		if(s[i] == ',')ret += " ";
		else ret += s[i];
	}
	cout<<ret<<"\n";
}
int main(){
	solve();
	return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n)	 for(int i = 0; i < (n); i++)
#define all(a)		 begin(a), end(a)

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll x, ll y) {
	int group[12] = { 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
	if(group[x - 1] == group[y - 1]) printf("Yes");
	else printf("No");
}

int main() {
	ll x;
	ll y;
	scanf("%lld", &x);
	scanf("%lld", &y);
	solve(x, y);
	return 0;
}


Measured memory_bytes: 256
while line = gets
  n = line.chomp.to_i
  break if n == 0

  answer_p = 0
  answer_d = -Float::INFINITY
  n.times do
    p, d1, d2 = gets.chomp.split.map(&:to_i)
    d = d1 + d2
    if answer_d < d
      answer_p = p
      answer_d = d
    end
  end

  puts "#{answer_p} #{answer_d}"
end

Measured memory_bytes: 8660
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int a, b;

int main()
{
	cin >> a >> b;
	cout << b + (b - a)<<endl;

	return 0;
}

Measured memory_bytes: 256
while True:
        (H, W) = [int(i) for i in input().split()]
        if H == W == 0:
            break
        print ("\n".join(["".join(["#" if i == 0 or i == W - 1 or j == 0 or j == H - 1 else "." for i in range(W)]) for j in range(H)]))
        print()

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


// ll gcd(ll a,ll b){
//     ll x = max(a,b); 
//     ll y = min(a,b);
//     ll r = x % y;
//     while(r != 0){
//         x = y;
//         y = r;
//         r = x % y;
//     }
//     return b;
// }

// ll lcm(ll a,ll b){
//     return a / gcd(a,b) * b;
// }
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 f(int x){
    int res = 0;
    while(x % 2 == 0){
        x /= 2;
        res++;
    }
    return res;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    rep(i,n) a.at(i) /= 2;
    
    int t = f(a.at(0));
    rep(i,n){
        int l = f(a.at(i)); 
        if(l != t){
            cout << 0 << endl;
            return 0;
        }
        a.at(i) >>= t;
    }
    m >>= t;
    ll l = 1;
    rep(i,n){
        l = lcm(l,a.at(i));
        if(l > m){
            cout << 0 << endl;
            return 0;
        }
    }
    m /= l;
    ll ans = (m + 1) / 2;
    cout << ans << endl;
    return 0;
}

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

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

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

  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S') {
      int tem;
      tem = a[1];
      a[1] = a[0];
      a[0] = a[4];
      a[4] = a[5];
      a[5] = tem;
    }
    if (s[i] == 'E') {
      int tem;
      tem = a[2];
      a[2] = a[0];
      a[0] = a[3];
      a[3] = a[5];
      a[5] = tem;
    }
    if (s[i] == 'N') {
      int tem;
      tem = a[4];
      a[4] = a[0];
      a[0] = a[1];
      a[1] = a[5];
      a[5] = tem;
    }
    if (s[i] == 'W') {
      int tem;
      tem = a[3];
      a[3] = a[0];
      a[0] = a[2];
      a[2] = a[5];
      a[5] = tem;
    }
  }

 cout << a[0] << endl;
} 


Measured memory_bytes: 3216
#include <iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	
	int K[100], P[1000];
	for (int i = 0; i < N; i++){
		cin >> K[i] >> P[i];
		if (K[i] % P[i] == 0){
			cout << P[i] << endl;
		}
		else {
			cout << K[i] % P[i] << endl;
		}
	}
}

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

const int m = 2019;

int main() {
  string S;
  cin >> S;
  vector<int> R(m, 0);
  int n = S.size();
  int sum = 0, x = 1;
  for (int i = n - 1; i >= 0; i--) {
    sum += (S.at(i) - '0') * x;
    sum %= m;
    R.at(sum)++;
    x = x * 10 % m;
  }
  R.at(0)++;

  int ans = 0;
  for (auto r : R) {
    if (r > 1) ans += r * (r - 1) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3736
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

memo = defaultdict(int)

for d in D:
    memo[d] += 1

for t in T:
    memo[t] -= 1

memo = list(memo.values())
memo.sort()

print("YES" if memo[0] >= 0 else "NO")

Measured memory_bytes: 41700
N = int(input())
S = [str(input()) for i in range(N)]

ans_list = [0 for i in range(5)]
carList = ['M', 'A', 'R', 'C', 'H']
for s in S:
    for i, c in enumerate(carList):
        if s[0] == c:
            ans_list[i] += 1

ans_list = [a for a in ans_list if a != 0]
ans = 1
for i, v in enumerate(ans_list):
    ans *= v

if len(ans_list) < 3:
    print(0)
elif len(ans_list) == 3:
    print(ans_list[0]*ans_list[1]*ans_list[2])
elif len(ans_list) == 4:
    tmp = 0
    for i, v in enumerate(ans_list):
        tmp += ans // v
    print(tmp)
else:
    tmp = 0
    for i in range(5):
        for j in range(5):
            if i != j:
                tmp += ans // (ans_list[i]*ans_list[j])
    print(tmp//2)

Measured memory_bytes: 9772
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
input = [a,b,c,d,e]
answer = "Yay!"

for count1 in range(0,5):
    for count2 in range(0,5):
        stock = input[count2] - input[count1]
        if stock > k:
            answer = ":("
            break
print(answer)

Measured memory_bytes: 3064
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
  const numbers = line.split(' ');
  let sorted = numbers.sort();

  sorted.forEach((item, index) => sorted[index] = item.toString());

  const output = 
  	sorted[0] + ' ' + sorted[1] + ' ' + sorted[2];

  console.log(output);
} 


Measured memory_bytes: 15116
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++)  cin >> a[i], a[i]-=i+1;
    sort(a, a+n);
    ll ans = 1ll<<60;
    for(int j = n/2; j <= n/2+1; j++){
        ll tmp = 0;
        for(int i = 0; i < n; i++)  tmp += abs(a[i]-a[j]);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792