akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <string>
#include <climits> //max & min

#define int long long
#define pb(n) push_back(n)
#define ForI(n) for(int i=0;i<n;i++)
#define ForJ(n) for(int j=0;j<n;j++)
#define ForK(n) for(int k=0;k<n;k++)
#define Pr(n) cout<<n<<endl;
#define INS(v,n) for(int i=0;i<n;i++){cin >>v.at(i);}//vector 代入
#define ELM 100001 //問題によっては1000000001に変更
using namespace std;

//int Move(vector<int> v,int n){
//    int m[ELM] ={0};
//    for(int i=0; i<n; i++){
//        m[v[i]]++;
//    }
//    vector<int> s;
//    for (int i=0; i<n; i++) {
//        if (m[v[i]]!=0) {
//            cout<<m[v[i]]<<endl;
//            s.pb(m[v[i]]);
//        }
//    }
//    int move = *max_element(s.begin(), s.end());
//    return move;
//}
signed  main(){
////    ABC124-a
////    int A,B;
////    cin >> A>>B;
////    int ans = 0;
////    sample(2){
////        if(A>B){
////            ans+=A;
////            A--;
////        }else{
////            ans+=B;
////            B--;
////        }
////    }
////    cout<<ans<<endl;
//
////    ABC124-b
//    int ans = 0;
//    int N;
//    cin >> N;
//    vector<int> h(N);
//    INS(h, N);
//    ForI(N){
//        int flag=0;
//        ForJ(N){
//            if (h[i]<h[j]) {
//                flag=1;
//            }
//            if(j>=i){
//                break;
//            }
//        }
//        if(flag==0){
//            ans++;
//        }
//    }
//    Pr(ans);
    
//    ABC124-c
    string s;
    cin >> s;
    int ans[2]={0}; // ans[0] =10101… ans[1]=01010…
    ForI(s.size()){
        if (i%2==0) {//ans[0]==1 ans[1]==0
            if (s[i]=='0'){
                ans[0]++;
            }else{
                ans[1]++;
            }
        }else{
            if (s[i]=='1'){
                ans[0]++;
            }else{
                ans[1]++;
            }
        }
    }
    Pr(min(ans[0], ans[1]))
    return 0;
}



Measured memory_bytes: 512
// Problem : D - Knapsack 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define tc ll t;cin>>t;while(t--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007

int main()
{
	io;
	ll n,W;
	cin>>n>>W;
	vll w(n+1),v(n+1);
	FOR(i,1,n+1)
	{
		cin>>w[i]>>v[i];
	}
	
	vvll dp(n+1,vll(W+1,0));
	
	FOR(i,1,n+1)
	{
		FOR(j,1,W+1)
		{
			dp[i][j]=dp[i-1][j];
			if(j-w[i]>=0){dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);}
		}
	}
	
	cout<<dp[n][W];
	
	return 0;
}


Measured memory_bytes: 80256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define max(a, b) (a > b ? a : b)

int main() {
  int n;
  scanf("%d", &n);
  int a[2][n];
  for (int i=0; i<2; i++)
    for (int j=0; j<n; j++)
      scanf("%d", &(a[i][j]));
  int sum[2][n], ans = 0;
  sum[0][0] = a[0][0];
  sum[1][n-1] = a[1][n-1];
  for (int i=1; i<n; i++) {
    sum[0][i] = sum[0][i-1] + a[0][i];
    sum[1][n-i-1] = sum[1][n-i] + a[1][n-i-1];
  }
  for (int i=0; i<n; i++)
    ans = max(ans, sum[0][i] + sum[1][i]);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#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))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
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);

ii3(n, k, c);
string s; cin >> s;

vi l(n), r(n); //左or右から貪欲で働くときに選ぶことになる'o'の情報を持っておく
int cur = 0;
rep(i,n) {
    if(cur == 0) {
        if(s[i] == 'o') {
            l[i] = 1;
            cur = c;
        }
    }
    else cur--;
}

cur = 0;
drep(i,n) {
    if(cur == 0) {
        if(s[i] == 'o') {
            r[i] = 1;
            cur = c;
        }
    }
    else cur--;
}

vi sl(n+1), sr(n+1);
rep(i,n) sl[i+1] = sl[i] + l[i];
drep(i,n) sr[i] = sr[i+1] + r[i];

rrep(i, n) {
    if(s[i-1] == 'o') {
        if(sl[i-1] + sr[i] < k) cout << i << endl;
    }
}
cout << endl;
return 0;
}

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

signed main() {
	int n, a, cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		while (a % 2 == 0) {
			a /= 2;
			cnt++;
		}
	}

	cout << cnt << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    vector<int> b(M);
    vector<P> p(M);
    for (int i = 0; i < M; i++){
        cin >> a.at(i) >> b.at(i);
        p.at(i) = make_pair(b.at(i), a.at(i));
    }

    sort(p.begin(), p.end());
    
    int start = 1;
    int ans = 0;
    for (int i = 0; i < M; i++){
        if (start <= p.at(i).second){
            start = p.at(i).first;
            ans ++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,m;
  cin>>n>>m;
  int A[m];
  int cnt=0;
  rep(i,m) A[i]=0;
  rep(i,n) {
    int k;
    cin>>k;
    rep(j,k) {
      int a;
      cin>>a;
      A[a-1]++;
    }
  }
  rep(i,m) {
    if(A[i]==n) cnt++;
  }
  cout<<cnt<<endl;
}


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

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

    sort(a, a + 3);

    cout << (a[0] + a[1] == a[2] ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
    
cnt = 0
for i in range(1, N+1):
    if i % 2 != 0 and len(divisor(i)) == 8:
        cnt += 1

print(cnt)

Measured memory_bytes: 62064
#include<bits/stdc++.h>
using namespace std;
// URDL
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main(){
  int n; cin >> n;
  vector<int> w(n);
  int sum = 0;
  for(int i=0; i<n; i++) {
    cin >> w[i];
    sum += w[i];
  }
  int x = 0;
  int ans = 1e9;
  for(int i=0; i<n; i++) {
    x += w[i];
    sum -= w[i];
    ans = min(ans, abs(x-sum));
  }
  cout << ans << endl;

  return 0;
}




// EOF


Measured memory_bytes: 256
n = int(input())
line = list(map(int, input().split()))
ans = 0

line.sort()
line.append(10**9 + 1) # 番兵
prev_num = 0
total = 0
for i in range(n+1):
    if line[i] == prev_num:
        total += 1
    else:
        if prev_num > total:
            ans += total
        else:
            ans += total - prev_num
        total = 1
        prev_num = line[i]


print(ans)


Measured memory_bytes: 63856
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n, a, b;
	cin >>n >>a >>b;
	cout <<((n / (a + b)) * a) + min(n % (a + b), a);
	return 0;
}


Measured memory_bytes: 256
from scipy.sparse import*
f=csgraph.floyd_warshall
t=map(int,open('/dev/fd/0').read().split())
n,m,l=t[:3]
m=m*3+3
for i in f(f(csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1:print i

Measured memory_bytes: 31000
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll rui[222222]={};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    ll l,r;cin>>l>>r;
    rui[l]++;
    rui[r+1]--;
  }
  ll ans=0;
  for(int i=0;i<222222;i++){
    rui[i+1]+=rui[i];
    if(rui[i+1]==m)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2048
#! /usr/bin/env ruby

T = STDIN.read.chomp()

i = T.length - 1

W = "W"
B = "B"

edge_w = nil
nth_b = 0

total = 0

while i >= 0
  t = T[i]

  if t == W && edge_w == nil
    edge_w = i
  end

  if edge_w != nil && t == B
    total = total + (T.length - i - 1) - (T.length - edge_w - 1) - nth_b
    nth_b = nth_b + 1
  end

  i = i - 1
end

puts total

Measured memory_bytes: 2172
package main

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

func main() {
	if resolve(parseProblem(os.Stdin)) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func parseProblem(r io.Reader) []block {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	n := scanInt(sc)
	bs := []block{}
	for i := 0; i < n; i++ {
		t := scanString(sc)
		b := toBlock(t)
		bs = append(bs, b)
	}
	sort.Sort(blockSlice(bs))
	return bs
}

type blockSlice []block

func (b blockSlice) Len() int {
	return len(b)
}

func (b blockSlice) Less(i, j int) bool {
	iP := b[i].r - b[i].l
	jP := b[j].r - b[j].l
	if (iP >= 0 && jP < 0) || (iP < 0 && jP >= 0) {
		// other phase
		return iP > jP
	} else if iP >= 0 {
		// 1st
		return b[i].l < b[j].l
	}
	return b[i].r > b[j].r
}

func (b blockSlice) Swap(i, j int) {
	b[i], b[j] = b[j], b[i]
}

type block struct {
	l, r int
}

func toBlock(s string) block {
	// l ')' num
	// r '(' num
	lc := 0
	rc := 0
	for i := 0; i < len(s); i++ {
		if rc == 0 {
			if s[i] == ')' {
				lc++
			} else {
				rc++
			}
		} else {
			if s[i] == ')' {
				rc--
			} else {
				rc++
			}
		}
	}
	return block{l: lc, r: rc}
}

func resolve(bs []block) bool {
	depth := 0
	for i := 0; i < len(bs); i++ {
		depth -= bs[i].l
		if depth < 0 {
			return false
		}
		depth += bs[i].r
	}
	return depth == 0
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 50636
A,B,K = map(int, input().split(" "))

for i in range(K):
  if i % 2 == 0:
    if A % 2 != 0:
      A -= 1
      A /= 2
      B += A
    else:
      A /= 2
      B += A
  else:
    if B % 2 != 0:
      B -= 1
      B /= 2
      A += B
    else:
      B /= 2
      A += B
print(str(int(A)) + " " + str(int(B)))

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

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

const int INF=1e9;
const int MOD=1e9+7;

struct UnionFind{

    vector<int> par;
    vector<int> sizes;

    UnionFind(int n):par(n),sizes(n,1){
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }
    
    int find(int x) { //xの根を得る
        if (x == par[x]) return x;
        return par[x] = find(par[x]); //根を張り替えながら再帰的に根ノードを探す
    }

    //2つの要素が属する集合を併合
    void unite(int x, int y) { 
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    //2つの要素が同じ集合に属するか判定する
    bool same(int x, int y) {
        return find(x) == find(y);
    }

    //集合のサイズを取得
    int size(int x) {
        return sizes[find(x)];
    }
    
};

int main(){
    int N,M; cin >> N >> M;
    UnionFind uf(N);
    for(int i=0;i<M;i++){
        int a,b; cin >> a >> b; a--; b--;
        uf.unite(a,b);
    }
    int ans=0;
    for(int i=1;i<N;i++){
        if(!uf.same(0,i)){
            uf.unite(0,i);
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long w=sc.nextInt();
		long value[]=new long[n];
		long weight[]=new long[n];
		for(int i=0;i<n;i++){
			weight[i]=sc.nextLong();
			value[i]=sc.nextLong();
		}
		long dp[][]=new long[n+1][(int) (w+1)];
		long ans=knapsack(n,w,weight,value,dp);
		System.out.println(ans);
	}
	public static long knapsack(int n,long w,long []weight,long[]value,long[][]dp){
		if(w==0 || n==0){
			return 0;
		}
		if(dp[n][(int)w]!=0){
			return dp[n-1][(int)w];
		}
		long inc=0,exe=0;
		if(weight[n-1]<=w){
			inc=value[n-1]+knapsack(n-1,w-weight[n-1],weight,value,dp);
			exe=knapsack(n-1,w,weight,value,dp);
		}
		else{
			exe=knapsack(n-1,w,weight,value,dp);
		}
		return dp[n-1][(int)w]=Math.max(inc, exe);
	}
}


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

struct Card{
	char suit;
	int value;
};

void Bubble(struct Card A[], int N)
{
	Card change;
	for (int i = 0; i < N; ++i)
	{
		for (int j = N-1; j > i; --j)
		{
			if (A[j].value < A[j-1].value)
			{
				change = A[j];
				A[j] = A[j-1];
				A[j-1] = change;
			}
		}
	}
}

void Selection(struct Card A[], int N)
{
	int minj;
	for (int i = 0; i < N; ++i)
		{
			minj = i;
			Card change;
			for (int j = i; j < N; ++j)
			{
				if (A[j].value < A[minj].value)
				{
					minj = j;
				}
			}

			change = A[i];
			A[i] = A[minj];
			A[minj] = change;
		}	
}

void ShowCard(struct Card A[],int N)
{
	for (int i = 0; i < N; ++i)
	{
		if (i > 0)
		{
			cout << " ";
		}
		cout << A[i].suit << A[i].value;
	}
	cout << "\n";
}

bool StableJugge(struct Card B[],struct Card S[],int N)
{
	for (int i = 0; i < N; ++i)
	{
		if (B[i].suit != S[i].suit)
		{
			return false;
		}
	}
	return true;
}

int main()
{
	Card C1[36],C2[36];
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> C1[i].suit >> C1[i].value;
	}

	for (int i = 0; i < N; ++i)
	{
		C2[i] = C1[i];
	}

	Bubble(C1,N);
	ShowCard(C1,N);
	cout << "Stable\n";
	Selection(C2,N);
	ShowCard(C2,N);
	if (StableJugge(C1,C2,N))
	{
		cout << "Stable\n";
	}
	else
	{
		cout << "Not stable\n";
	}
	return 0;
}


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

int main()
{
	long long s;
	while(cin >> s, s)
	{
		string ret;
		while(s)
		{
			ret+=s%8LL+'0';
			s/=8LL;
		}
		
		reverse(ret.begin(), ret.end());
		for(int i=0; i<ret.size(); i++)
		{
			int t=ret[i]-'0';
			if(t>=5) t+=2;
			else if(t>=4) t+=1;
			
			
			ret[i]=t+'0';
		}
		
		cout << ret << endl;
	}
}

Measured memory_bytes: 908
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


import math


def sieve_of_eratosthenes(n):
    prime_list = []  # n以下の素数のリスト
    A = [1]*(n+1)    # A[i] = iが素数なら1,その他は0
    A[0] = A[1] = 0
    for i in range(2,math.floor(math.sqrt(n))+1):
        if A[i]:
            prime_list.append(i)
            for j in range(i**2,n+1,i):
                A[j] = 0
    for i in range(math.floor(math.sqrt(n))+1,n+1):
        if A[i] == 1:
            prime_list.append(i)
    return prime_list,A


prime_list,A = sieve_of_eratosthenes(10**5)

B = [0]*(10**5+1)
for p in prime_list:
    if p == 2:
        continue
    else:
        if A[(p+1)//2] == 1:
            B[p] = 1

from itertools import accumulate

C = list(accumulate(B))

Q = I()
for i in range(Q):
    l,r = MI()
    print(C[r]-C[l-1])




Measured memory_bytes: 82340
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
#include <atcoder/all>
using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    // Submit this code from the browser if using ACL!
    ll n, m; cin >> n >> m;
    vector<int> a(n), b(m);
    rep (i, n) cin >> a[i];
    rep (i, m) cin >> b[i];
    for (auto x : convolution<998244353>(a, b)) cout << x << " ";
    cout << "\n";
    return 0;
}

Measured memory_bytes: 19080
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vi a(3), b(2);
  rep(i, 3) cin >> a[i];
  rep(i, 2) cin >> b[i];
  sort(all(a)), sort(all(b));
  cout << a.front() + b.front() - 50 << endl;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int main()
{
	ll x,y;
	while(cin>>x>>y)
	{
		ll ans=(ll)1e18;
		//x<=y才能用op:A 
		if(x<=y)
		ans=min(ans,y-x);
		if(-x<=y)
		ans=min(ans,1+y-(-x));//先变号BA 
		if(x<=-y)
		ans=min(ans,1+(-y-x));//加完后变号AB
		if(-x<=-y)
		ans=min(ans,1+1+(-y)-(-x));//BAB
		
		cout<<ans<<endl;
	} 
	
	return 0;
} 

Measured memory_bytes: 256
#from functools import lru_cache
import sys
from itertools import product
from itertools import combinations
from functools import reduce

def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

k=int(input())
t=0
m=7%k
md=7%k
for i in range(k+1):
    if m==0:break
    else:
        md=(md*10)%k
        m=(m+md)%k
if i==k: i=-2
print(i+1)


Measured memory_bytes: 67724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  vector<string> X(100);
  
  cin >> H >> W;
  for (int i=0; i < H; i++) {
    cin >> X[i];
  }
  for (int i=0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
 
  for (int i=0; i < H; i++) {
    cout << '#' << X[i] << '#' << endl;
  }
  for (int i=0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}

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

using namespace std;

int main() {
    
    int a,b;
    scanf("%d %d", &a, &b);

    if(a < 6) return puts("0"),0;
    if(a >= 6 and a <= 12) return printf("%d\n", b / 2),0;

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


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

long long a[200005];
long long b[200005];
long long c[200005];
int main()
{
    int n;

    cin >> n;

    for(int i = 1 ; i<=n ; i++)
    {
        cin >> a[i];
        b[i] = b[i-1]+a[i];
    }
    for(int i = n ; i>=1 ; i--)
    {
        c[i] = c[i+1]+a[i];
    }

    long long ans = 10100100100100100;


    for(int i = 1 ; i<n ; i++)
    {
        //cout << abs(b[i] - c[i+1]) << endl;
        ans = min(ans , abs(b[i] - c[i+1]));
    }
    cout << ans;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  rep(i,N) cin >> v[i];
  int ans = 1;
  int num = 1;
  rep(i,N){
    ans *= 3;
    if(v[i]%2==0) num*=2;
  }
  cout << ans - num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a,b,c,A=0,B=0;
  scanf("%d %d %d",&a,&b,&c);
  if(a==7)A++;
  if(b==7)A++;
  if(c==7)A++;
  if(a==5)B++;
  if(b==5)B++;
  if(c==5)B++;
  if(A==1&&B==2)
  {printf("YES");}
  else printf("NO");
  return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll l, r;
	ll n = 2019;
    cin >> l >> r;
    if(r - l > n){
        cout << 0 << endl;
        return 0;
    }
    ll tmp = 2019;
    for(ll i = l; i < r; ++i){
    	for(ll j = i + 1; j < r + 1; ++j){
        	tmp = min(tmp, (i * j) % n);
            if(tmp == 0){
            	cout << 0 << endl;
              	return 0;
            }
        }
    }
    cout << tmp << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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 main() {
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll minv = min({a,b,c,d,e});
    ll ans = (n+minv-1)/minv+4;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

import java.io.BufferedReader;
import java.io.FileReader;

public class Main{
	
	public static void main(String[] args) throws IOException, InterruptedException {
		
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			int ds =(int) Math.floor(Math.log(i)/Math.log(10))+1;
			
			if (i == 1000) {
				ds = 4;
			}
			
			if (ds%2 == 1) {
				ans++;
			}
		}
		
		out.print(ans);
		out.flush();
	}
		
}	
	
class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}
	
	public Scanner (String file) throws IOException{
        br=new BufferedReader(new FileReader(file));
	}

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

	public String nextLine() throws IOException {
		return br.readLine();
	}

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

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

	public char nextChar() throws IOException {
		return next().charAt(0);
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public boolean ready() throws IOException {
		return br.ready();
	}

	public void waitForInput() throws InterruptedException {
		Thread.sleep(3000);
	}


}



Measured memory_bytes: 20788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;  
const long long INF = 1LL << 60;


int main() {
    int k, n, ans;
    cin >> k >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ans = a[n-1] - a[0];
    for(int j = 0; j < n - 1; j++) {
        if(a[j] + k - a[j + 1] < ans) ans = a[j] + k - a[j + 1];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N,A,B,C = util.Scan4 int
let xs = util.ScanVecV N int
let BIG = pown 10 9

let rec cost n a b c =
  if n = N
  then // 全ての竹について選択が完了
    if List.exists ((=) 0) [a;b;c] // 一つも材料が無いやつは除外
    then BIG
    else -30 + (List.sumBy abs [a-A;b-B;c-C]) // 端数は伸縮魔法で調整, -10 を補正で入れる(最初の結合にはMP10を使用しない)
  else
    let c1 = cost (n+1) a b c // 非選択
    let c2 = 10 + (cost (n+1) (a+xs.[n]) b c) // Aの材料に
    let c3 = 10 + (cost (n+1) a (b+xs.[n]) c)
    let c4 = 10 + (cost (n+1) a b (c+xs.[n]))
    List.min [c1;c2;c3;c4]

cost 0 0 0 0
|> printfn "%d"


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

int main() {
    int N, K, s;
    cin >> N >> K;
    s = 0;
    for(int i = 0; i < N; i++) {
        int x;
        cin >> x;
        s += 2 * min(x, abs(x - K));
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char s[300];
int main()
{
	int i=1,f=0;
	cin>>s;
	for(i=0;i<300;i++)
	{
		if(s[i-1]=='C')
			f=1;
		if(f==1&&s[i-1]=='F')
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
            int x;
            cin>>x;
            if(x>=30) cout<<"Yes";
            else cout<<"No";  
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3800
n = int(input())
w = list(input() for i in range(n))

if len(w) != len(set(w)):
    print('No')
    exit(0)

for i in range(n - 1):
    if w[i][-1] != w[i + 1][0]:
        print('No')
        exit(0)

print('Yes')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,p;
    cin>>n>>p;
    if(n==1)
    {
        cout<<p<<endl;
        return 0;
    }
    int ma=1;
    for(int i=2;i<=p;i++)
    {
        if(i>1e6+5) break;  // 这个质因数是一个大素数
        int cnt=0;
        while(p%i==0)
        {
            p/=i;
            cnt++;
        }
        if(cnt>=n)
            ma*=pow(i,cnt/n);
    }
    cout<<ma;
}





Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = n % k;
  ans = min(ans, abs(ans - k));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int D;
int N = 26;
vi c;
vvi s;
vi ans;
vi las;



pii rec(int n, int dd, vi lass){
    
    if(dd >= D || n == 5) return {0,1};
    
    int los = 0;
    rep(i,N) los += c[i]*(dd-lass[i]);
    int res = -infi;
    int an = 1;
    set<int> sss;
    ve<pii> AA(N);
    rep(i,N) AA[i] = {s[dd][i],i};
    sort(all(AA));
    rep(i,6) sss.insert(AA[N-i-1].se);
    
    
    rep(i,N){
        if(!sss.count(i)) continue;
        vi la = lass;
        int ddd = s[dd][i]-los+c[i]*(dd-lass[i]);
        la[i] = dd;
        int da = ddd+rec(n+1,dd+1,la).fi;
        if(chmax(res,da)) an = i+1;
        
    }
    
    return {res,an};
    
}



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

    //int ti = clock();
    
    
    cin >> D;
    c.resize(N);
    s.resize(D, vi(N));
    
    in(N,c);
    rep(i,D) rep(j,N) cin >> s[i][j];
    
    ans.resize(D);
    las.assign(N,-1);
    
    
    
    
    
    rep(d,D){
        ans[d] = rec(0,d,las).se;
        las[ans[d]-1] = d;
    }









    
    
    
    rep(i,D) cout << ans[i] << endl;
    
    
    //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);

    return 0;
}


Measured memory_bytes: 3700
#include<cstdio>

using namespace std;
char field[110][110];
static int N, M;
static char state[110][110];
static int dx[4] = { 0,1,0,-1 };
static int dy[4] = { 1,0,-1,0 };
static void dfs(int x, int y, char fruit) {
	state[x][y] = fruit;
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx >= 0 && nx < N&&ny >= 0 && ny < M&&field[nx][ny] == fruit&&state[nx][ny] == '!') {
			dfs(nx, ny, fruit);
		}
	}
}
static void solve() {
	int ret = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (state[i][j] == '!') {
				dfs(i, j, field[i][j]);
				ret++;
			}
		}
	}
	printf("%d\n", ret);
}
int main() {
	while (scanf("%d %d", &N, &M) != EOF) {
		getchar();
		if (N == 0 && M == 0)
			break;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				scanf("%c", &field[i][j]);
				state[i][j] = '!';
			}
			getchar();
		}
		solve();
	}
	return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 200 * 1000 + 13;

int n, k;
int a[N];

bool read () {
	if (scanf("%d%d", &n, &k) != 2)
		return false;
	forn(i, n)
		scanf("%d", &a[i]);
	return true;
}

void solve() {	
	int ans = 0;
	int cur = 0;
	
	bool init = false;
	set<int> nums;
	forn(i, n){
		bool fl = (i >= k);
		
		fl &= (!nums.empty() && a[i] > *nums.rbegin());
		if (i >= k)
			fl &= (a[i - k] == *nums.begin());
		nums.insert(a[i]);
		if (i >= k)
			nums.erase(a[i - k]);
		
		if (i < n && i && a[i] < a[i - 1])
			++cur;
		if (i - k >= 0 && a[i - k + 1] < a[i - k])
			--cur;
		
		//cerr << vector<int>(all(nums)) << " " << !fl << " " << cur << endl;
		
		if (i >= k - 1 && cur == 0)
			init = true;
		
		if (i >= k - 1 && !fl && cur > 0)
			++ans;
	}
	
	ans += init;
	printf("%d\n", ans);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

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

using namespace std;

typedef long long ll;

int main(){
	string s;
	cin >> s;
	int st = -1;
	int ans = 0;
	for(int i = 0; i < (int)s.size(); i++){
		if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
			if(st == -1)st = i;
			ans = max(ans, i-st+1);
		}
		else st = -1;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define HASH 18014398241046527
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
template <typename T>
ll SIZEOF(T a){return (ll)a.size();}

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





void SOLVE(){
    map <ll, ll> m;
    ll sum = 0;
    ll n;
    cin >> n;
    inpv(a, n);
    for(auto i:a){
        sum += i;
        m[i]++;
    }
    ll q;
    cin >> q;
    while(q--){
        inps(x, y);
        sum -= m[x]*x;
        sum += m[x]*y;
        m[y]+=m[x];
        m[x] = 0;
        cout << sum << '\n';
    }
}

int main() {
	fastIO();
	// #ifndef ONLINE_JUDGE
    //     freopen("i.txt", "r", stdin);
    //     freopen("o.txt", "w", stdout);
	// #endif

    ll TC = 1;
    // cin >> TC;
    for(ll tc1=1; tc1<=TC; tc1++){
        // cout << "Case #" << tc1 << ": ";
        SOLVE();
    }
    printclock;
}

Measured memory_bytes: 9928
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut it = buf.split_whitespace();
    let x = it.next().unwrap().parse::<u32>().unwrap();
    let y = it.next().unwrap().parse::<u32>().unwrap();
    let z = it.next().unwrap().parse::<u32>().unwrap();
    println!("{} {} {}", z, x, y);
}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

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; }




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}



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

  vector<int> a(N);
  rep(i, 0, N){
    cin >> a[i];
  }

  int now = 0;
  int check = 1;
  int cnt = 0;
  int ans = 0;

  while(now <= N - 1){
    if(a[now] == check){
      check++;
    }
    now++;
  }

  if(check == 1){
    cout << "-1";
  }else{
    cout << N - (check - 1) << endl;
  }
  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a, b, c;
	int rect = 0;
	int diam = 0;

	while (~scanf("%d,%d,%d", &a, &b, &c)){
		if (hypot(a, b) == c) rect++;
		if (a == b) diam++;
	}
	printf("%d\n%d\n",rect, diam);

	return (0);
}

Measured memory_bytes: 608
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define mset(a,i) memset(a,i,sizeof(a))
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
#define INF 0x3f3f3f3f
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int maxn = 101010;
const int MOD = 1e9 + 7;

int main()
{
    int n;
    int k;
    int ans=0;
    scanf("%d%d",&n,&k);
    rep(i,0,n){
        int x;
        scanf("%d",&x);
        if(x<k-x) ans+=x;
        else ans+=k-x;
    }
    printf("%d\n",2*ans);
}


Measured memory_bytes: 256
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

void solve() {
  string s;
  cin >> s;
  const int n = s.size();
  int res = 0;
  REP(i,n-1) res += (s[i] != s[i+1]);
  cout << res << endl;
  return;
}


Measured memory_bytes: 512