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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  int n;
  cin >> n;
  V<int> a(n);
  V<char> op(n);
  op[0] = '+'; cin >> a[0];
  FOR(i, 1, n) cin >> op[i] >> a[i];

  V<int> b(n); b[0] = a[0];
  FOR(i, 1, n) b[i] = b[i-1] + a[i];

  V<int> v;
  REP(i, n) if(op[i] == '-') v.PB(i);
  v.PB(n);
  V<int> nxt(n);
  REP(i, v.size()-1) nxt[v[i]] = v[i+1];

  int now = 0;
  REP(i, n) {
    if(op[i]=='+') now += a[i];
    else now -= a[i];
  }

  int ret = now; now = 0;
  REP(i, n) {
    if(op[i]=='+') {
      now += a[i];
    } else {
      chmax(ret, now - (b[nxt[i]-1]-b[i-1]) + (b[n-1]-b[nxt[i]-1]));
      now -= a[i];
    }
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 3572
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

VI sz, xs, dist, prv;
VVI edge;
int M;
int dfs(int& i, int cur){
  if(i == SZ(xs)) return cur;
  if(xs[i] < 0){
	cur = prv[cur];
	int d = -xs[i], p = prv[cur];
	while(true){
	  if(dist[cur] - dist[p] == d) break;
	  p = prv[p];
	}

	--sz[cur];
	--sz[p];
	edge[cur].PB(p);
	edge[p].PB(cur);
	++i;
	return -1;
  }
  
  int nxt = cur + 1;
  ++i;
  while(sz[cur] > 0){
	--sz[cur];
	--sz[nxt];
	prv[nxt] = cur;
	dist[nxt] = dist[cur] + 1;
	int nxt_ = dfs(i, nxt);
	if(nxt_ >= 0){
	  edge[cur].PB(nxt);
	  edge[nxt].PB(cur);
	  nxt = nxt_;
	}
	else{
	  ++sz[cur];
	  ++sz[nxt];	  
	  dist[nxt] = 0;
	}
  }

  return nxt;
}

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

  int N; cin >> N;
  while(N--){
	xs.clear();
	sz.clear();
	M = 0;
	while(true){
	  int x;
	  cin >> x;
	  if(x == 0) break;
	  xs.PB(x);
	  if(x > 0){
		sz.PB(x);
		++M;
	  }
	}
	prv.assign(110, -1);
	dist.assign(110, 0);
	edge.assign(110, VI());
	int it = 0, nxt = 0;
	dfs(it,0);

	for(int i=0;i<M;++i){
	  cout << i+1;
	  SORT(edge[i]);
	  for(int j=0;j<SZ(edge[i]);++j)
		cout << " " << edge[i][j]+1;
	  cout << endl;
	}
  }
  
  return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, x;
	cin >> a >> b >> x;
	ll ans = b / x - a / x; 
	if(a % x == 0) ans += 1LL;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;

    V res;

    int i = 1;
    int sum = 0;
    while (sum < n)
    {
        res.push_back(i);
        sum += i;
        i++;
    }

    for (int i : res)
    {
        if (i == sum - n)
            continue;
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    string n;
    cin >> n;
    for (int i=0; i<3; i++) {
        if (n[i] == '1') {
            n[i] = '9';
        } else if (n[i] == '9') {
            n[i] = '1';
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int64 ord2(int64 n){
  int i=0;
  while(n%2==0){
    n=n/2; i++;
  }
  return i;
}

int main(){
  int64 a,b,c;
  cin>>a>>b>>c;
  if(a%2==1 || b%2==1 || c%2==1){
    cout<<0;
  }else if(a==b && b==c){
    cout<<-1;
  }else{
    cout<<min(ord2(b-a),min(ord2(c-a),ord2(c-b)));
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int x,y,mi,ma;
int main()
{
	cin>>x>>y;
	mi=2*x;ma=4*x;
	if(y>=mi&&y<=ma&&(y-mi)%2==0)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  string s = "YES";
  map<int, int> mp;
  rep(i, n){
    int x;
    cin >> x;
    mp[x]++;
    if(mp[x] > 1) s = "NO";
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 12996
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[string]int)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		var s string
		s = sc.Text()
		m[s]++
	}
	fmt.Printf("AC x %d\n", m["AC"])
	fmt.Printf("WA x %d\n", m["WA"])
	fmt.Printf("TLE x %d\n", m["TLE"])
	fmt.Printf("RE x %d\n", m["RE"])
}


Measured memory_bytes: 2184
def r(x,y):
  global b
  for n in range(3):
    b[x+n][y]+=1
    b[x+n][y+2]+=1
  b[x][y+1]+=1
  b[x+2][y+1]+=1
h,w=map(int,input().split())
a=[0]*h
for _ in range(h):
  a[_]=input()
b=[[0]*(w+2) for _ in range(h+2)]
for i in range(h):
  for j in range(w):
    if a[i][j]=='#':
      r(i,j)
c=['']*h
for i in range(h):
  for j in range(w):
    if a[i][j]=='.':
      c[i]+=str(b[i+1][j+1])
    else:
      c[i]+="#"
for _ in range(h):
  print(c[_])
      

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

int main(){
  int n;
  cin>>n;
  map<int,int> odd,even;
  rep(i,n){
    int v; cin>>v;
    if(i%2==0) odd[v]++;
    else even[v]++;
  }
  int cnt_odd1=0, cnt_odd2=0, cnt_even1=0, cnt_even2=0;
  int num_odd1,num_even1;
  for(auto x : odd){
    if(cnt_odd1<x.second){
      cnt_odd2=cnt_odd1;
      cnt_odd1=x.second;
      num_odd1=x.first;
    }else if(cnt_odd2<x.second){
      cnt_odd2=x.second;
    }
  }
  for(auto x : even){
    if(cnt_even1<x.second){
      cnt_even2=cnt_even1;
      cnt_even1=x.second;
      num_even1=x.first;
    }else if(cnt_even2<x.second){
      cnt_even2=x.second;
    }
  }
  int ans=0;
  if(num_odd1==num_even1){
    ans=min(n-cnt_odd1-cnt_even2,n-cnt_odd2-cnt_even1);
  }else{
    ans=n-cnt_odd1-cnt_even1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 8228
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;

multiset<int> ab;
int main() {

	for (int i = 0; i < 3; i++) {
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;

		ab.insert(tmp1);
		ab.insert(tmp2);
	}

	for (int i = 1; i <= 4; i++) {
		if (ab.count(i) == 2) {
			cout << "YES" << endl;

			return 0;
		}
	}

	cout << "NO" << endl;


	return 0;
}



Measured memory_bytes: 256
n = int(input())
l1 = l2 = l3 = 0
l = [int(i) for i in input().split()]
for i in l:
    if i == 1:
        l1 += 1
    elif i == 2:
        l2 += 1
    else:
        l3 += 1
a = l2+l3
dp = [[[0.0]*(l3+1) for i in range(a+1)] for j in range(n+1)]

for i in range(1,n+1):
    for j in range(min(i,a)+1):
        for k in range(min(j,l3)+1):
            s = i-j
            t = j-k
            count = n/(s+t+k)
            if s > 0:
                count += dp[s-1][t][k]*(s/(s+t+k))     
            if t > 0 :
                count += dp[s+1][t-1][k]*(t/(s+t+k))
            if k > 0 :
                count += dp[s][t+1][k-1]*(k/(s+t+k))

            dp[s][t][k] = count

print(dp[l1][l2][l3])




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

int main()
{
  int i, c = 0;
  string n;

  cin >> n;
  for (i = 1; i < 4; i++) {
    if (n[i-1] == n[i]) {
      c++;
    } else {
      c = 0;
    }
    if (c == 2)
      break;
  }
  if (c == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const str = input.split('\n')[0]
    const strArr = str.split('')
    const strArrR = strArr.slice().reverse()
    const strLen = strArr.length

    const Aindex = strArr.indexOf('A')
    const Zindex = strLen - strArrR.indexOf('Z')
    console.log(Zindex - Aindex)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 12956
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

char str[100005];
bool in[100005];
bool ans[100005];

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);
    scanf("%s", str);

    long i;
    for(i=0; i<n; i++) {
        in[i]=(str[i]=='o'? 0: 1);
    }
    in[n]=in[0];
    in[n+1]=in[1];
    
    bool a0[4]={0,0,1,1};
    bool a1[4]={0,1,0,1};
    long k;
    for(k=0; k<4; k++) {
        ans[0]=a0[k];
        ans[1]=a1[k];
        long i;
        for(i=2; i<n+2; i++) {
            if(in[(i-1)%n]==ans[i-1]) ans[i]=ans[i-2];
            else                      ans[i]=!ans[i-2];
        }
        if(ans[0]==ans[n] && ans[1]==ans[n+1]) {
            for(i=0; i<n; i++) {
                if(ans[i]) {
                    printf("W");
                }
                else {
                    printf("S");
                }
            }
            printf("\n");
            return 0;  
        }
    }
    printf("-1\n");

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define MAX 17
#define NUM 100005

ll N,K;
ll POW[MAX+1];
ll dp[NUM][MAX+1];

ll recursive(ll number,ll index){ //number:数 index:何番目の数か

	if(dp[number][index] != -1){

		return dp[number][index];
	}

	if(index == K){

		return 1;
	}

	ll ret = 0;

	for(ll i = 2; (number*i)*POW[K-(index+1)] <= N; i++){

		ret += recursive(number*i,index+1);
	}

	return dp[number][index] = ret;
}

int main(){

	POW[0] = 1;
	for(int i = 1; i <= MAX; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%lld %lld",&N,&K);

	if(K > MAX){

		printf("0\n");
		return 0;

	}else if(K == 1){

		printf("%lld\n",N);
		return 0;
	}

	for(int i = 0; i <= N; i++){
		for(int k = 0; k <= MAX; k++){

			dp[i][k] = -1;
		}
	}

	ll ans = 0;

	for(ll base = 1; base*POW[K-1] <= N; base++){

		ans += recursive(base,1);
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 17140
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {
			// TODO Auto-generated method stub
			try (Scanner sc = new Scanner(System.in)) {
				int N = sc.nextInt();
				int a = 0;
				int b = 0;
				int count = 0;
				String ans = "No";
				for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				}

				System.out.println(ans);
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
}

Measured memory_bytes: 35980
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = do
	n <- readInt
	ls <- readInts
	print $ length $ do
		i <- [ 0 .. n - 1 ]
		j <- [ i + 1 .. n - 1 ]
		k <- [ j + 1 .. n - 1 ]
		let
			[ a, b, c ] = sort $ [ ls !! i, ls !! j, ls !!k  ]
		guard $ a < b && b < c && c < a + b
		return ()

Measured memory_bytes: 5012
(defun main (k hs)
  (let ((sorted (sort hs #'<)))
    (reduce #'min (mapcar #'- (nthcdr (1- k) sorted) sorted))))

(defun repl ()
  (let* ((n (read))
         (k (read))
         (hs (loop :repeat n :collect (read))))
    (format t "~a~%" (main k hs))))

(repl)


Measured memory_bytes: 59752
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
const int N=3e5+5;
int x,y,a[N],b[N],p1,p2,i,j,m;
set<pi> st;
int main()
{
	cin>>x>>y>>m;
	vector<int> l,r;
	for(i=1;i<=m;i++)
	{
		cin>>x>>y;
		st.insert(make_pair(x,y));
		a[x]++;
		b[y]++;
		if(a[x]>p1)
		{
			l.clear();
			p1=a[x];
		}
		if(a[x]==p1)
			l.push_back(x);
		if(b[y]>p2)
		{
			r.clear();
			p2=b[y];
		}
		if(b[y]==p2)
			r.push_back(y);
	}
	for(i=0;i<l.size();i++)
		for(j=0;j<r.size();j++)
			if(st.find(make_pair(l[i],r[j]))==st.end())
			{
				cout<<p1+p2<<endl;
				return 0;
			}
	cout<<p1+p2-1<<endl;
	return 0;
}

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

int N,Y;

int main()
{
    scanf("%d%d",&N,&Y);
    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= N; j++)
        {
            int k = N - i - j;
            if(k >= 0 && k <= N && i * 10000 + j * 5000 + k * 1000 == Y)
            {
                printf("%d %d %d\n",i,j,k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll p10[20];

ll d;
int buf[15],len=0;
void init() {
    p10[0]=1;
    for (int i=1;i<=19;i++) {
        p10[i]=p10[i-1]*10;
    }
    scanf("%lld",&d);
    ll dd=d;
    while (dd>0) {
        buf[len++]=dd%10;
        dd/=10;
    }
}

vector<ll> vec;

ll cal(int k) {
    ll res=0;
    for (int i=0;i<k;i++) {
        if (k%2==1&&i==k/2) continue;
        if (i>(k-1)/2) {
            res-=vec[k-1-i]*p10[i];
        } else {
            res+=vec[i]*p10[i];
        }
    }
    return res;
}

ll f() {
    ll ret=1;
    for (int i=0;i<vec.size();i++) {
        if (i==0) ret*=(9-abs(vec[i]));
        else ret*=(10-abs(vec[i]));
    }
    return ret;
}

ll ans=0;
void dfs(int idx,int k,int flag) {
    if (idx==(k/2+k%2)) {
        if (cal(k)==d) {
            ans+=f();
        }
        return;
    }
    vec.pb((buf[idx]+flag)%10);
    if (buf[idx]+flag==10) dfs(idx+1,k,1);
    else dfs(idx+1,k,0);
    vec.pop_back();

    if (buf[idx]+flag==10||buf[idx]+flag==0) return;

    vec.pb(buf[idx]+flag-10);
    dfs(idx+1,k,1);
    vec.pop_back();
}

int main() {
    init();
    if (buf[0]==0) vec.pb(0);
    else vec.pb(buf[0]-10);
    for (int k=len;k<=2*len;k++) {
        if (buf[0]==0) dfs(1,k,0);
        else dfs(1,k,1);
    }
    printf("%lld\n",ans);
}

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

string itos(int x){
  string res;
  int X=x;
  while(x)res+=x%10+'0',x/=10;
  reverse(res.begin(),res.end());
  if(X==0)res="0";
  return res;
}

int main(){
  set<string> s;
  int n,k,ans=-1;
  string str;
  char c;
  cin>>n;
  for(int i=0;i<n;i++)cin>>c,str+=c;
  for(int i=1;i<N;i++){
    for(int j=0;j+i-1<n;j++)
      s.insert(str.substr(j,i));
    k=1;
    for(int j=0;j<i;j++)k*=10;
    for(int j=0;j<k;j++)
      if(s.find(itos(j))==s.end()){
	ans=j;
	break;
      }
    if(ans>=0)break;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1292
#![allow(unused_imports)]
#![allow(dead_code)]

use std::thread;
use std::io::{ self, Read };
use std::fmt;
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str::*;

#[derive(Default)]
struct Input {
    buf: Vec<String>
}

impl Input {
    fn new() -> Input {
        Input { buf: Vec::new() }
    }

    fn read<T: FromStr>(&mut self) -> T 
    where <T as FromStr>::Err: fmt::Debug {
        self.next().unwrap().parse::<T>().unwrap()
    }

    fn read_n<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where <T as FromStr>::Err: fmt::Debug {
        let mut v = Vec::new();
        for _ in 0..n { v.push(self.read::<T>()); }
        v
    }
}

impl Iterator for Input {
    type Item = String;
    fn next(&mut self) -> Option<String> {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = io::stdin().read_line(&mut s);
            self.buf = s.split_whitespace().map(|s| s.to_owned()).collect::<Vec<_>>();
            self.buf.reverse();
        }
        self.buf.pop()
    }
}

struct UnionFind {
    c: Vec<(usize, usize)>
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        UnionFind { c: (0..n).map(|u| (u, 1)).collect::<Vec<_>>() }
    }

    fn root(&self, u: usize) -> usize {
        let v = self.c[u].0;
        if u == v { u } else { self.root(v) }
    }

    fn is_same(&self, u: usize, v: usize) -> bool {
        self.root(u) == self.root(v)
    }

    fn size(&self, u: usize) -> usize {
        self.c[u].1
    }

    fn unite(&mut self, u: usize, v: usize) {
        let ru = self.root(u);
        let rv = self.root(v);
        let su = self.size(u);
        let sv = self.size(v);
        if su > sv {
            self.c[rv] = (ru, su + sv);
        } else {
            self.c[ru] = (rv, su + sv);
        }
    }
}

fn run() {
    let mut ip = Input::new();
    let n = ip.read::<usize>();
    let m = ip.read::<usize>();
    let mut e = Vec::new();
    for _ in 0..m {
        let u = ip.read::<usize>();
        let v = ip.read::<usize>();
        let w = ip.read::<i64>();
        e.push((w, u, v));
    }
    e.sort();
    let mut uf = UnionFind::new(n);
    let mut y = 0i64;
    for (w, u, v) in e {
        if !uf.is_same(u, v) {
            uf.unite(u, v);
            y += w;
        }
    }
    println!("{}", y);
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(10 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}


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

using namespace std;

int main(){
  int N,flag = 0;string W[101];
  cin >> N;for(int i=0;i<N;i++)cin >> W[i];
  for (int i=0;i < N-1;i++){
    if (W[i].substr(W[i].length()-1,1) != W[i+1].substr(0,1)){
      flag ++;
      break;
    }
  }
  if (flag == 0){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(W[i] == W[i+j+1]){
          flag ++;
          break;
        }
        if (i+j+1 == N){
          break;
        }
      }
      if (flag != 0)break;
    }
  }
  if (flag != 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" <<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}





void solve(){
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];
			}
ll count=0;
unordered_set<ll> s;

for(ll a=0;a<n;a++){
	for(ll b=a+1;b<n;b++){
		for(ll c=b+1;c<n;c++){
			s.clear();

			if(v[a]+v[b]>v[c]&&v[a]+v[c]>v[b]&&v[b]+v[c]>v[a]){
				s.insert(v[a]);
				s.insert(v[b]);
				s.insert(v[c]);
				if(s.size()==3)count++;
			}
		}
	}
}
cout<<count<<endl;




return;
}




int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e5;
#define pi acos(-1)
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int A[5*MAX],B[5*MAX],n,m;
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int k;
    cin>>n>>m>>k;
    for(int i=0; i<n; i++)
        cin>>A[i];
    for(int i=0; i<m; i++)
        cin>>B[i];
    int it=-1,sum=0,i=0,j=0,mx=0,cnt=0;
    for(int i=0; i<n; i++)
    {
        if(sum+A[i]<=k)
        {
            sum+=A[i];
            cnt++;
            mx=max(cnt,mx);
            it=i;
        }
        else
            break;
    }
    for(int i=0; i<m; i++)
    {
        while(sum+B[i]>k && it>=0){
            sum-=A[it];
            cnt--;
            it--;
        }
        if(sum+B[i]<=k)
        {
            sum+=B[i];
            cnt++;
            mx=max(cnt,mx);
        }
        else
            break;

    }
    cout<<mx<<endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int tmp = N;
  int res = 0;
  while(tmp){
    res += tmp % 10;
    tmp /= 10;
  }
  if(N % res == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[3])return!printf("No");
  if(s[0]==s[1]&&s[2]==s[3])printf("Yes");
  else printf("No");
}

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

int main(){
string you[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
string S;
cin >> S;
rep(i,7){
    if(you[i]==S)cout << 7-i<<endl;
}

    return 0;
}

Measured memory_bytes: 256
nm = [int(x) for x in input().split()]
n = nm[0]
m = nm[1]
total = 0
result = 0
votes = [int(x) for x in input().split()]
for vote in votes:
  total+=vote
total/=4*m
for vote in votes:
  if vote>=total:
    result+=1
if result>=m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <stdio.h>

main(){
  int n, data[10][10], p[10][10], count[10];
  int i, j, k, l, m, f=0, a, b, temp;

  scanf("%d", &n);
  
  for(i=0;i<n;i++){
    if(f==1) printf("\n");
    for(j=0;j<9;j++){
      for(k=0;k<9;k++){
	scanf("%d", &data[j][k]);
	p[j][k]=0;
      }
    }
    
    
    for(j=0;j<9;j++){
      for(k=0;k<10;k++){
	count[k]=0;
      }
      for(k=0;k<9;k++){
	temp=data[j][k];
	count[temp]++;
	if(count[temp]>=2){
	  p[j][k]=1;
	  if(count[temp]==2){
	    for(a=0;a<k;a++){
	      if(temp==data[j][a]){
		p[j][a]=1;
	      }
	    }
	  }
	}
      }
    }
    
    for(j=0;j<9;j++){
      for(k=0;k<10;k++){
	count[k]=0;
      }
      for(k=0;k<9;k++){
	temp=data[k][j];
	count[temp]++;
	if(count[temp]>=2){
	  p[k][j]=1;
	  if(count[temp]==2){
	    for(a=0;a<k;a++){
	      if(temp==data[a][j]){
		p[a][j]=1;
	      }
	    }
	  }
	}
      }
    }
    
    for(j=0;j<9;j+=3){
      for(k=0;k<9;k+=3){
	for(l=0;l<10;l++){
	  count[l]=0;
	}
	for(l=j;l<j+3;l++){
	  for(m=k;m<k+3;m++){
	    temp=data[l][m];
	    count[temp]++;
	    if(count[temp]>=2){
	      p[l][m]=1;
	      if(count[temp]==2){
		for(a=k;a<k+3;a++){
		  for(b=j;b<j+3;b++){
		    if(temp==data[b][a]){
		      p[b][a]=1;
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
    }
    
    for(j=0;j<9;j++){
      for(k=0;k<9;k++){
	if(p[j][k]==0) printf(" ");
       	else printf("*");
	printf("%d", data[j][k]);
      }
      printf("\n");
    }
    f=1;
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int s=max(a,max(b,c));
    int t=3*s-a-b-c;
    if(t%2)
    {
        printf("%d",t/2+2);
    }
    else printf("%d",t/2);
}

Measured memory_bytes: 256
x="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
y="DEFGHIJKLMNOPQRSTUVWXYZABC"
n=list(input())
for i in range(len(n)):
    for j in range(len(x)):
        if n[i]==y[j]:
            n[i]=x[j]
            print(n[i],end="")
            break
print()


Measured memory_bytes: 5720
#include<stdio.h>
#include <iostream>
using namespace std;
int main() {
	while (1) {
		int n, k;
		int s[100], b[100];
		bool bo = true;
		scanf("%d %d", &n, &k);
		if (n == 0 && k == 0) break;
		for (int i = 0; i < k; ++i) { scanf("%d", &s[i]); }
		for (int i = 0; i < n; ++i) { 
			for (int j = 0; j < k; ++j) {
				scanf("%d", &b[j]);
				s[j] -= b[j];
				if (s[j] < 0) bo = false;
			}
		}
		if (bo) printf("Yes\n");
		else printf("No\n");
	}
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)

#define FOR(i,m,n) for(int i=(m);i<(n);i++)
#define int long long
#define ALL(x) (x).begin(),(x).end()
typedef pair<int, int> pii;


void solve() {
	int N, M; cin >> N >> M;
    if(N==0)exit(0);
	vector<int>H(N + 1), W(M + 1);
	REP(i, N) {
		cin >> H[i + 1];
	}
	REP(i, M) {
		cin >> W[i + 1];
	}
	REP(i, N) {
		H[i + 1] += H[i];
	}
	REP(i, M) {
		W[i + 1] += W[i];
	}
	map<int, int>mp;
	REP(i, N) {
		FOR(j, i + 1, N + 1) {
			int d = H[j] - H[i];
			mp[d]++;
		}
	}
	int ans = 0;
	REP(i, M) {
		FOR(j, i + 1, M + 1) {
			int d = W[j] - W[i];
			ans += mp[d];
		}
	}
	cout << ans << endl;
}

signed main() {
	while(true)solve();
}



Measured memory_bytes: 26864
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (h, w) = (line[0], line[1]);
    let mut c: Vec<Vec<u64>> = vec![];
    for _ in 0..10{
        c.push(read_as_vec());
    }

    let mut a: Vec<Vec<i64>> = vec![];
    for _ in 0..h{
        a.push(read_as_vec());
    }

    //calculate min costs
    for k in 0..10{
        for i in 0..10{
            for j in 0..10{
                c[i][j] = cmp::min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }


    let mut ans: u64 = 0;
    for i in 0..h{
        for j in 0..w{
            if a[i][j] != -1{
                ans += c[a[i][j] as usize][1];
            }
        }
    }

    print!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int N;
	
	scanf("%d", &N);
	int x = N;
	if(x%2 == 0){
		if(x%N == 0){
			printf("%d\n", N);
		}
	}else{
		printf("%d\n",2*N);
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
template<typename DATA_TYPE, typename LAZY_TYPE, typename F, typename G, typename H, typename P>
class SegmentTree {
  private:
	size_t size;

	F f;
	G g;
	H h;
	P p;

	std::vector<DATA_TYPE> data;
	std::vector<LAZY_TYPE> lazy;
	DATA_TYPE data_init;
	LAZY_TYPE lazy_init;

	SegmentTree() : size(0) {}

	void eval(int length, size_t index) {
		if (lazy[index] == lazy_init) return;
		if (index * 2 + 1 < size * 2 - 1) {
			lazy[index * 2 + 1] = h(lazy[index * 2 + 1], lazy[index]);
			lazy[index * 2 + 2] = h(lazy[index * 2 + 2], lazy[index]);
		}
		data[index] = g(data[index], p(lazy[index], length));
		lazy[index] = lazy_init;
	}

	DATA_TYPE update(size_t begin, size_t end, LAZY_TYPE update_value, size_t index, size_t left, size_t right) {
		eval(right - left, index);
		if (right <= begin || end <= left) return data[index];
		if (begin <= left && right <= end) {
			lazy[index] = h(lazy[index], update_value);
			return g(data[index], p(lazy[index], right - left));
		}
		return data[index] = f(update(begin, end, update_value, index * 2 + 1, left, (left + right) / 2), update(begin, end, update_value, index * 2 + 2, (left + right) / 2, right));
	}

	DATA_TYPE query(size_t begin, size_t end, size_t index, size_t left, size_t right) {
		eval(right - left, index);
		if (right <= begin || end <= left) return data_init;
		if (begin <= left && right <= end) return data[index];
		return f(query(begin, end, index * 2 + 1, left, (left + right) / 2), query(begin, end, index * 2 + 2, (left + right) / 2, right));
	}

  public:
	SegmentTree(size_t data_size, F f, G g, H h, P p, DATA_TYPE data_init, LAZY_TYPE lazy_init) : f(f), g(g), h(h), p(p), data_init(data_init), lazy_init(lazy_init) {
		size = 1;
		while (size < data_size) size <<= 1U;
		data.resize(2 * size - 1, data_init);
		lazy.resize(2 * size - 1, lazy_init);
	}

	void build(std::vector<DATA_TYPE> input_data) {
		if (input_data.size() > size) {
			std::cerr << "segment tree::build : input oversize data\n";
			exit(-1);
		}
		for (int i = 0; i < input_data.size(); ++i) {
			data[i + size - 1] = input_data[i];
		}
		for (int i = size - 2; i >= 0; --i) {
			data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}

	void update(size_t begin, size_t end, LAZY_TYPE update_value) {
		update(begin, end, update_value, 0, 0, size);
	}

	DATA_TYPE query(size_t begin, size_t end) {
		return query(begin, end, 0, 0, size);
	}
};
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	auto f=[](int a,int b){return a+b;};
	auto g=[](int a,int b){return a+b;};
	auto h=[](int a,int b){return a+b;};
	auto p=[](int a,size_t b){return a*b;};
	int n,q;
	cin>>n>>q;
	SegmentTree<int,int,decltype(f),decltype(g),decltype(h),decltype(p)> segTree(n,f,g,h,p,0,0);
	rep(i,q){
	    int qt;
	    cin>>qt;
	    if(qt){
	        int s,t;
	        cin>>s>>t;
	        cout<<segTree.query(s-1,t)<<endl;
	    }
	    else{
	        int s,t,x;
	        cin>>s>>t>>x;
	        segTree.update(s-1,t,x);
	    }
	}
}



Measured memory_bytes: 7084
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]

def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    #t=int(input())
    t=1
    for _ in range(t):
        n=int(input())
        if n>=30:
            print("Yes")
        else:
            print("No")

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threadin.Thread(target=main).start()


Measured memory_bytes: 68676
h,w=gets.split.map &:to_i
c=[];a=[]
c=10.times.map{gets.split.map &:to_i}
a=h.times.map{gets.split.map &:to_i}
for k in 0..9
  for i in 0..9
    for j in 0..9
      c[i][j]=[c[i][k]+c[k][j],c[i][j]].min
    end
  end
end
sum=0
a.each{|b|b.each{|e|
sum+=c[e][1] unless e==-1
}}
p sum

Measured memory_bytes: 3836
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
using namespace std;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

void Main()
{
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int d = 0;
	rep(i, A+1)
	{
		if (500 * i > X) break;
		rep(j, B+1)
		{
			if (500 * i + j * 100 > X) break;
			if (X - 500 * i - j * 100 <= C * 50) ++d;
		}
	}

	cout << d << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll T;cin>>T;while(T--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void solve(){
    int n,ans=200001;
    cin>>n;
    string s;
    cin>>s;
    int dp[n+1][2];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=n;i++){
        dp[i][0]=dp[i-1][0];
        dp[i][1]=dp[i-1][1];
        if(s[i-1]=='.') dp[i][0]++;
        else dp[i][1]++;
    }
    for(int i=0;i<=n;i++){
        ans=min(ans,dp[i][1]+dp[n][0]-dp[i][0]);
    }

    cout<<ans;
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int a, b;
    cin >> a >> b;
    //int ans = ceil((b - 1) * 1.0 / (a - 1));
    int ans = (b - 1 + a - 2) / (a - 1);
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cctype>
#include<cstdlib>
#include<vector>
#include<sstream>
#include<string>
using namespace std;

int one_string_int(string& c, int num) {
	string str[2];
	str[0] = c[num];
	return atoi(str->c_str());
}

int main() {
	string nums; string tmp;  vector<char> anss; stringstream tmp2;
	while(cin>>nums) {
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9 - i; j++) {
				tmp2<<one_string_int(nums, j) + one_string_int(nums, j + 1);
				tmp = tmp2.str();
				tmp2.str("");
				if (tmp.length() == 2)nums[j] = tmp[1];
				else nums[j] = tmp[0];
			}
		}
		anss.push_back(nums[0]);
	}
	for (int i = 0; i < anss.size(); i++){
		cout << anss[i] << endl;
	}
}

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

using namespace std;

int main(){
    string t[4] = {"dreamer","eraser","dream","erase"};
    string s;
    cin >> s;
    int i = 0;

   
   while(s.size() > 4){
       int flag = 0;
        for(int j = 0; j < 4;j++){
            i = s.rfind(t[j]);
           // cout << s << " "<< t[j] << " "<< i<<endl;
            if(i != -1 && s.size()-i == t[j].size()){
                s.erase(i,t[j].size());
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    if(s == "")cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

N,X,M=map(int,input().split())

A=[0]*10**5
A[0]=X
D=dict()
#A=[X]
s=N
for i in range(1,N):
    a=A[i-1]**2%M
    if a in D:
        s=A.index(a)
        break
    else:
        #A.append(a)
        A[i]=a
        D[a]=0

if s==N:
    ans=sum(A)
else:
    A=A[:i]
    Z=[0]*(len(A)+1)
    for i in range(1,len(A)+1):
        Z[i]=Z[i-1]+A[i-1]  

    ans=0
    l=len(A)-s
    #ans+=sum(A[:s])
    ans+=Z[s]
    #S=sum(A[s:])
    S=Z[len(A)]-Z[s]
    T=(N-s)//l
    ans+=T*S
    K=N-s-l*T
    #ans+=sum(A[s:(s+K)])
    ans+=Z[s+K]-Z[s]


print(ans)


Measured memory_bytes: 15972
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int dp[2][6005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, t;
	cin >> n >> t;
	vector<P> v(n);
	rep(i,n) cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end());
	rep(i,n){
		int a = v[i].first;
		int b = v[i].second;
		rep(j,6001){
			chmax(dp[(i+1)%2][j], dp[i%2][j]);
			if(j < t) chmax(dp[(i+1)%2][j+a], dp[i%2][j] + b);
		}
	}
	int ans = 0;
	rep(j,6001) chmax(ans, dp[n%2][j]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 998244353
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
int main()
{
    ios::sync_with_stdio(0) ;
    cin.tie(0); 
    int n,m;
    cin>>n>>m;
    int arr[n];ll s=0;
    for(int i=0;i<n;i++)
    {cin>>arr[i];s+=arr[i];}
    sort(arr,arr+n,greater<int>());
    double u=arr[m-1];
    if(4*m*arr[m-1]>=s)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}
//make all values ll


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    ll F = 0;
    for(int i = 1; i <= N; i++){
    if (i % 3 != 0 && i % 5 != 0) F += i;
    }
    cout << F;
    return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  ll n,k,q;cin>>n>>k>>q;
  ll a[q+10];
  map<ll,ll>mp;
  rep(i,0,q){
    cin>>a[i];
    mp[a[i]]++;
  }

  rep(i,1,n+1){
    if(k-(q-mp[i])<=0)out("No");
    else out("Yes");
  }


  return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

#define mp make_pair
#define fi first
#define se second
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) (((a) * (b)) / (__gcd((a), (b))))
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define setbits(x) __builtin_popcountll(x)
#define unsetend(x) __builtin_ctzll(x)
#define unsetfront(x) __builtin_clzll(x)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define ll long long
#define endl "\n"
#define Endl "\n"

// long long expo(long long a, long long b, long long mod)
// {
//     ll ret = 1;
//     while (b > 0)
//     {
//         if (b % 2 == 1)
//             ret = (((ret)%mod) * ((a)%mod))%mod;
//
//         a = ((a)%mod) * ((a)%mod)%mod;
//         b = b / 2;
//     }
//     return (ret%mod);
// }

// vector<long long> seive()
// {
//    long long i,j;
//    vector<long long> hash(1000001,1);
//    vector<long long> primes;
//
//    for(i=2;i*i<=1000000;i++)
//    {
//        if(hash[i])
//        {
//            for(j=i*i;j<=1000000;j+=i)
//            hash[j]=0;
//        }
//    }
//    for(i=2;i<1000001;i++)
//    {
//        if(hash[i])
//        primes.pb(i);
//    }
//    return primes;
// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int i, j;
    string str1, str2, ans = "";
    cin >> str1;
    cin >> str2;

    int l1 = str1.size(), l2 = str2.size(), n;
    int dp[l1 + 1][l2 + 1];

    for (i = 0; i <= l1; i++)
    {
        for (j = 0; j <= l2; j++)
            dp[i][j] = 0;
    }

    for (i = 1; i <= l1; i++)
    {
        for (j = 1; j <= l2; j++)
        {
            if (str1[i - 1] == str2[j - 1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    // for (i = 0; i <= l1; i++)
    // {
    //     for (j = 0; j <= l2; j++)
    //         cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    int l = dp[l1][l2];
    i = l1;
    j = l2;
    while (l)
    {
        if (str1[i - 1] == str2[j - 1])
        {
            ans.pb(str1[i - 1]);
            i--;
            j--;
            l--;
        }
        else
        {
            if (dp[i - 1][j] > dp[i][j - 1])
            {
                i--;
            }
            else
            {
                j--;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 38788
N, M = list(map(int, input().split()))
K = []
S = []
for i in range(M):
  inp = list(map(int, input().split()))
  K.append(inp[0])
  S.append(inp[1:])
P = list(map(int, input().split()))
res = []
def helper(res, tmp, N):
  if len(tmp)==N:
    res.append(tmp)
    return
  else:
    helper(res, tmp+[0], N)
    helper(res, tmp+[1], N)
helper(res,[],N)
cnt = 0
for item in res:
  flag = True
  for m in range(M):
    a = 0
    for s in S[m]:
      a += item[s-1]
    if (a % 2 != P[m]):
      flag = False
      break
  if flag:
    cnt += 1
print (cnt)

Measured memory_bytes: 3188