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

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define input(a) scanf("%lld", &(a))
#define print(a) printf("%lld\n", (a))

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

#define dump(a, h, w)                                                          \
    rep(i, h) {                                                                \
        rep(j, w) cerr << a[i][j] << space;                                    \
        cerr << endl;                                                          \
    }
#define lldump(a, n) dump(vector<vector<ll>>{a}, 1, n)

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC optimization_level 3
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

def in() {
    ll A;
    cin >> A;
    return A;
}

string S, T;
ll A[26];
signed main() {
    cin >> S;
    rep(i, S.size()) A[S[i] - 'a']++;
    rep(i, 26) {
        if (A[i] == 0) {
            char append = 'a' + i;
            cout << S << append << endl;
            return 0;
        }
    }
    if (S == "zyxwvutsrqponmlkjihgfedcba")
        cout << -1 << endl;
    else {
        T = S;
        next_permutation(all(T));
        rep(i, 26) {
            if (S[i] != T[i]) {
                cout << T[i];
                break;
            }
            cout << T[i];
        }
        cout << endl;
    }
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    for (int i = 0; i < 10; i++) {
        c = a * c - b;
        cout << c << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){

    int n, i, j, r;
    int t;
    int a[100000];

    scanf( "%d", &n );

    for( i=0; i<n; i++ )
        scanf( "%d", &a[i] );


    r = n-1;
    i=-1;

    for( j=0; j<(n-1); j++ ){
        if( a[j] <= a[r] ){
            i++;
            t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
    }
    i++;
    t = a[i]; a[i]=a[n-1]; a[n-1]=t;

    for( j=0; j<n; j++ ){
        if( j ) printf( " " );
        if( j == i ) printf( "[%d]", a[j] );
        else printf( "%d", a[j]  );
    }
    printf( "\n" );
    

    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N;
    cin >> N;
    ll C[200001];
    for(int i=0; i<N; i++){
        cin >> C[i];
    }
    
    int prev[200001];
    for(int i=0; i<=200000; i++){
        prev[i]=-1;
    }
    
    
    ll dp[200001]={};
    dp[0]=1;
    prev[C[0]]=0;
    
    for(int i=1; i<N; i++){
        if(prev[C[i]]==-1){
            dp[i] = dp[i-1];
        }else if(prev[C[i]]==i-1){
            dp[i] = dp[i-1];
        }else{
            dp[i] = dp[i-1] + dp[prev[C[i]]];
        }
        
        dp[i] %= MOD;
        prev[C[i]]=i;
    }
    
    cout << dp[N-1] << endl;
    return 0;
}


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

int main(){
  char S[111111];
  cin >> S;
  int i;
  int count = 0;
  int N = 0;
  while(S[N]) N++;
  for(i=0;i<=N-2;i++)
    if((S[i]=='B' && S[i+1]=='W') || (S[i]=='W' && S[i+1]=='B'))
      count++;
  cout << count << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT
 
using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;
 
template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
 
int n;
int m;
 
int main () {
    cin >> n >> m;
    int ans = n, best = 1e9;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        best = min (best, x);
        m -= x;
    }
    ans += m / best;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
// typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);

int len[52], P[52];
int dfs(int n, int x){
    if(n == 0) return 1;
    if(x == 1) return 0;
    if(x <= len[n-1]+1) return dfs(n-1, x-1);
    if(x == len[n-1]+2) return P[n-1]+1;
    if(x <= len[n-1]*2+2) return P[n-1]+1+ dfs(n-1, x-len[n-1]-2);
    return P[n];
}
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int N, X;
    cin >> N >> X;
    len[0] = 1;
    P[0] = 1;
    for(int i=1;i<=50;i++){
        len[i] = len[i-1]*2+3;
        P[i] = P[i-1]*2+1;
    }
    cout << dfs(N, X) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
const int N = 2e5 + 10;
int n,x[N],y[N];
int32_t main()
{
 int n; cin >> n;
 int mn = 1e18, mx = 0;
 fr(i,n) cin >> x[i] >> y[i];
 int res = 0, smallest, cur;
        for (int p : {1, -1}) {
            for (int q : {1, -1}) {
                smallest = p * x[0] + q * y[0] + 0;
                for (int i = 1; i < n; ++i) {
                    cur = p * x[i] + q * y[i] ;
                    res = max(res, cur - smallest);
                    smallest = min(smallest, cur);
                }
            }
        }
        cout << res;
}

Measured memory_bytes: 6712
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = 0;
		for(int i=0; i<n; i++){
			sum += sc.nextInt();
		}
		System.out.println(sum - n);
	}
}

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

int main(){
	int a[4],b[2];
	for(int i = 0;i < 4;i++) cin >> a[i];
	cin >> b[0] >> b[1];
	sort(a,a + 4);
	sort(b,b + 2);
	cout << a[3] + a[1] + a[2] + b[1] << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int s, w;
  cin >> s >> w;
  if(s <= w){
    cout << "unsafe\n";
  } else {
    cout << "safe\n";
  }
  return 0;
}


Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] a = {in.nextInt(), in.nextInt(), in.nextInt()};
            Arrays.sort(a);
            out.println(a[0] + a[1]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
for i in range(n):
    if a[i]>=b[i]:
        c = c + b[i]
        a[i] = a[i]-b[i]
        b[i] = 0
    else:
        c = c + a[i]
        b[i] = b[i]-a[i]
        a[i] = 0
        
        if a[i+1]>=b[i]:
            c = c + b[i]
            a[i+1] = a[i+1]-b[i]
            b[i] = 0
        else:
            c = c + a[i+1]
            b[i] = b[i]-a[i+1]
            a[i+1] = 0
            
print(c)

Measured memory_bytes: 19004
n=int(input())
a=list(map(int,input().split()))
if n==1:
    print(1)
    exit()
ans=1
pre=a[0]
sw=0
for i in range(1,n):
    if sw==0:
        if a[i-1]<a[i]:
            sw=1
        elif a[i-1]>a[i]:
            sw=-1
    elif sw==1 and a[i-1]>a[i]:
        ans+=1
        sw=0
    elif sw==-1 and a[i-1]<a[i]:
        ans+=1
        sw=0
print(ans)

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

int main(){
    string str;
    getline(cin, str);
    // ASCII CODE は A- が 65- a- が 97-
    // よって小文字から大文字は-32（逆は+32）
    for (int i=0; i<str.size(); i++){
        if (str[i]>='a' && str[i]<='z') str[i] += 'A'-'a';  //""は文字リテラルを表す
        else if (str[i]>='A' && str[i]<='Z') str[i] += 'a'-'A';
        }
    cout << str << endl;
}


Measured memory_bytes: 3148
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

    if (N < 1000) {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
    int a,b,c,d=0,e;
    scanf("%d%d%d",&a,&b,&c);
    for(int i=1;i<=a;i++){
        scanf("%d",&e);
        if(e<b||e>=c) d++;
    }
    printf("%d\n",d);
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int SZ = 1 << 18;

struct segtree_max {
	vector<ll> dat;

	void init() {
		dat.resize(SZ * 2);
		rep(i, SZ * 2) dat[i] = LLONG_MIN;
	}

	void update(int pos, ll x) {
		pos += SZ - 1;
		dat[pos] = x;

		while (pos > 0) {
			pos = (pos - 1) / 2;
			dat[pos] = max(dat[pos * 2 + 1], dat[pos * 2 + 2]);
		}
	}

	ll get(int a, int b, int k = 0, int l = 0, int r = SZ) {
		if (b <= l || r <= a) return LLONG_MIN;
		if (a <= l && r <= b) return dat[k];
		return max(get(a, b, k * 2 + 1, l, (l + r) / 2), get(a, b, k * 2 + 2, (l + r) / 2, r));
	}
} seg;

int main() {
	seg.init();
	int N; cin >> N;
	vi h(N);
	vector<ll> a(N);

	rep(i, N) {
		cin >> h[i];
		--h[i];
	}

	rep(i, N) cin >> a[i];

	vector<ll> dp(N);

	ll ans = 0;

	rep(i, N) {
		ll v = seg.get(0, h[i]);
		ll t = (v != LLONG_MIN ? v : 0LL);
		dp[i] = t + a[i];
		ans = max(ans, dp[i]);
		seg.update(h[i], dp[i]);
	}

	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

const ll LLINF = 4e18;
const int INF = 1e9;
const ll SHIFT = 2.01e9;

const int MAXK = 1010;
int K;

const int MAXN = 2 * MAXK;
int N, M;
int S, T;

struct edge {
	int nxt, rev, cap; ll dist;
	edge() {}
	edge(int nxt_, int rev_, int cap_, ll dist_) : nxt(nxt_), rev(rev_), cap(cap_), dist(dist_) { }
};

vector<edge> adj[MAXN];

void add_edge(int a, int b, int c, ll d) {
	adj[a].push_back(edge(b, int(adj[b].size()), c, d));
	adj[b].push_back(edge(a, int(adj[a].size()) - 1, 0, -d));
}

bool vis[MAXN];
ll dist[MAXN];
int ptr[MAXN];

bool reach() {
	vector<int> q;
	q.push_back(S);
	fill_n(dist, N, -LLINF);
	fill_n(vis, N, false);
	dist[S] = 0;
	for (size_t i = 0; i < q.size(); i++) {
		int cur = q[i]; vis[cur] = false;
		for (size_t j = 0; j < adj[cur].size(); j++) {
			edge& e = adj[cur][j];
			if (!e.cap || dist[e.nxt] >= dist[cur] + e.dist) {
				continue;
			}
			dist[e.nxt] = dist[cur] + e.dist;
			if (!vis[e.nxt]) {
				vis[e.nxt] = true;
				q.push_back(e.nxt);
			}
		}
	}
	return dist[T] != -LLINF;
}

int dfs(int cur, int rem) {
	if (cur == T) {
		return rem;
	}
	int tot = 0;
	vis[cur] = true;
	for (int& i = ptr[cur]; i < int(adj[cur].size()); i++) {
		edge& e = adj[cur][i];
		if (!e.cap || vis[e.nxt] || dist[e.nxt] != dist[cur] + e.dist) {
			continue;
		}
		ll d = dfs(e.nxt, min(rem - tot, e.cap));
		tot += d;
		e.cap -= d;
		adj[e.nxt][e.rev].cap += d;
		if (tot == rem) {
			vis[cur] = false;
			break;
		}
	}
	return tot;
}

ll mcf(int rem = INF) {
	int totflow = 0; ll totcost = 0;
	while (reach()) {
		fill_n(ptr, N, 0);
		int d = dfs(S, rem - totflow);
		totflow += d;
		totcost += d * dist[T];
	}
	return totcost;
}

int main() {
	scanf("%d", &K);
	S = 0, T = 1;
	N = 2 * K + 6;
	int tot = 0;
	for (int i = 0; i < K; i++) {
		ll x, y; int c; scanf("%lld %lld %d", &x, &y, &c);
		tot += c;
		add_edge(S, 6+i, c, 0);
		add_edge(6+i, 2, INF, x + y);
		add_edge(6+i, 3, INF, x - y);
		add_edge(6+i, 4, INF, -x + y);
		add_edge(6+i, 5, INF, -x - y);
	}
	for (int i = 0; i < K; i++) {
		ll x, y; int c; scanf("%lld %lld %d", &x, &y, &c);
		add_edge(6+K+i, T, c, 0);
		add_edge(2, 6+K+i, INF, -x - y);
		add_edge(3, 6+K+i, INF, -x + y);
		add_edge(4, 6+K+i, INF, x - y);
		add_edge(5, 6+K+i, INF, x + y);
	}

	ll ans = mcf(tot);
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		double n = sc.nextLong();
		double l = n/3;
		System.out.printf("%.12f\n",Math.pow(l, 3));
		sc.close();
	}


}


Measured memory_bytes: 22996
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#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 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;



int main()
{
    int K,X;
    scanf("%d%d", &K, &X);

    int i;
    for(i=MAX(-1000000,X-(K-1)); i<=MIN(1000000,X+K-1); i++) {
        printf("%d ", i);
    }
    printf("\n");


    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int[] s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            double T = s[0];
            double X = s[1];

            Console.WriteLine(T / X);
        }
    }
}

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;

    string s;
    cin>>s;

    int ans = 1;

    for(int i = 1; i < n; i++) {
        if(s[i] != s[i-1]) {
            ans++;
        }
    }

    cout<<ans<<endl;
    


}


Measured memory_bytes: 512
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include "bitset"
#include "cmath"
#include "list"
#include "complex"
#include <cassert>
#include "deque"
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
//#define mp make_pair
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vc visit(sze, false);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;

int dp[2][sze];

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

	cin >> n >> m;
	int f = 0, s = 1;

	for (int i = 0; i < n; i++)
	{
		int w, c;
		cin >> w >> c;

		for (int j = 0; j <= m; j++)
		{
			maxi(dp[s][j], dp[f][j]);
			if (j >= w)
			{
				maxi(dp[s][j], dp[f][j - w] + c);
			}
		}

		for (int j = 0; j <= m; j++)
		{
			dp[f][j] = 0;
		}

		swap(f, s);
	}
	
	int ans = 0;

	for (int i = 0; i <= m; i++)
	{
		maxi(ans, dp[f][i]);
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n,m;
bitset<500> b[510];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> n >> m,n) {
    REP(i,n) cin >> b[i];
    int ans = 0;
    if (n < m) {
      REP(ms,POW(n)) {
        bitset<500> c;
        REP(i,n) if (ms >> i & 1) c ^= b[i];
        if (c.count() == 0) CHMAX(ans,(int)__builtin_popcount(ms));
      }
    } else {
      vector<vector<int>> dp(2,vector<int>(POW(m),-1));
      dp[0][0] = 0;
      int cur = 0, nxt = 1;
      REP(i,n) {
        REP(ms,POW(m)) dp[nxt][ms] = -1;
        REP(ms,POW(m)) if (dp[cur][ms] >= 0) {
          CHMAX(dp[nxt][ms],dp[cur][ms]);
          CHMAX(dp[nxt][ms^b[i].to_ullong()],dp[cur][ms]+1);
        }
        swap(cur,nxt);
      }
      ans = dp[cur][0];
    }
    cout << ans << endl;
  }

  return 0;
}


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

int main(){
    string s;
    cin >> s;

    ll q;
    cin >> q;
    int k;
    int flag = 0;
    deque<char> ans;
    for(ll i = 0; i < s.length(); i++){
        ans.push_back(s[i]);
    }

    for(ll i = 0; i < q; i++){
        cin >> k;
        if(k == 1){
            if(flag == 0){
                flag = 1;
            }else{
                flag = 0;
            }
        }else{
            int j;
            cin >> j;
            char c;
            cin >> c;

            if(j == 1){
                if(flag == 0){
                    ans.push_front(c);
                }else{
                    ans.push_back(c);
                }
            }else{
                if(flag == 0){
                    ans.push_back(c);
                }else{
                    ans.push_front(c);
                }
            }
        }
    }

    ll size = ans.size();
    if(flag == 0){
        for(ll i = 0; i < size; i++){
            cout << ans[i];
        }
        cout << endl;
    }else{
        for(ll i = size - 1; i >= 0; i--){
            cout << ans[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 896
#include<stdio.h>
int d[666001];
int n[6];
int min(int a,int b){return a<b?a:b;}
int main(){
	int p;
	int i,j;
	int m;
	while(1){
	scanf("%d %d %d %d %d %d %d",&p,&n[0],&n[1],&n[2],&n[3],&n[4],&n[5]);
	if(p==0)return 0;
	m=n[0]+5*n[1]+10*n[2]+50*n[3]+100*n[4]+500*n[5];
	int res;
	int c;
	for(i=0;i<=m;i++){
		res=0;
		c=i;
		res+=min(n[5],(int)c/500);c-=min(n[5],(int)c/500)*500;
		res+=min(n[4],(int)c/100);c-=min(n[4],(int)c/100)*100;
		res+=min(n[3],(int)c/50);c-=min(n[3],(int)c/50)*50;
		res+=min(n[2],(int)c/10);c-=min(n[2],(int)c/10)*10;
		res+=min(n[1],(int)c/5);c-=min(n[1],(int)c/5)*5;
		res+=min(n[0],(int)c);c-=min(n[0],(int)c);
		if(c!=0)res=10000;
		d[i]=res;
	}
	int ans=10000;
	for(i=p;i<=m;i++)ans=min(ans,d[i]+d[i-p]);
	printf("%d\n",ans);
	}
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

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

int main() {
  int h,w ;
  cin >> h >> w ;

  for(int i = 0 ; i<h ;i++)
    scanf("%s",a[i]) ;

  for(int i = 0 ;i<h ;i++){
    for(int j = 0 ; j<w ; j++){
      if(a[i][j] == '#'){
        bool ok = false ;

        for(int k = 0 ;k<4 ;k++){
          int x = i+dx[k] ;
          int y = j +dy[k] ;

          if(x <0 || x>h || y < 0 || y > w) continue ;
          if(a[x][y] == '#'){
            ok = true ;
            break ;
          }
        }
        if(!ok){
          cout <<"No"<<endl ;
          return 0 ;
        }
      }
    }
  }

  cout << "Yes"<< endl ;

  return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <numeric>

using namespace std;

class Solution {
private:
public:
    int gcd(int k) {
        int ret = 0;
        for(int i = 1; i <= k; ++i) {
            for(int j = i; j <= k; ++j) {
                for(int l = j; l <= k; ++l) {
                    int cur = std::gcd(std::gcd(i, j), l);
                    int p = 1;
                    if(i != j && j != l) p = 6;
                    else if((i == j && j != l) || (i != j && j == l)) p = 3;
                    ret += p * cur;
                }
            }
        }
        return ret;
    }
};

int main() {
    int k;
    cin >> k;
    Solution sol;
    cout << sol.gcd(k) << endl;
}

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

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

	string d = "";

	for (int i = 0; i < n; i++) {
		int digit;
		cin >> digit;
		d += char(digit + '0');
	}

	for (int num = 0; ; num++) {
		string m = to_string(num);
		if (d.find(m) == string::npos) {
			cout << m << endl;
			return 0;
		}
	}

	return 0;
}
    

Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
typedef long long ll;
const ll INF=1e18;
const ll MOD=1e9+7;

int main(){
    ll N,M;cin>>N>>M;
    map<ll,vector<ll>> list;
    rep(i,N){
        ll a,b;cin>>a>>b;
        list[a].push_back(b);
    }
    ll res=0;
    priority_queue<ll> que;
    rep1(i,M){
        for(const auto& e : list[i]){
            que.push(e);
        }
        if(!que.empty()){
            res+=que.top();
            que.pop();
        }
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

int n, m;
vector<bool> f;
vector<vector<int>> a;

int lp(int u = 1, int p = 0) {
    int mx = 0, mx1 = 0;
    for (int v : a[u]) if (v != p) {
        int t = lp(v, u);
        if (t > mx) {
            mx1 = mx;
            mx = t;
        } else if (t > mx1) mx1 = t;
    }
    m = max(m, mx + mx1 + 1);
    return mx + 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n + 2);
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    lp();
    f.resize(m + 2);
    f[1] = true;
    f[2] = false;
    for (int i = 3; i <= m; ++i)
        if (f[i - 1] && f[i - 2]) f[i] = false;
        else f[i] = true;
    cout << (f[m] ? "First\n" : "Second\n");
    return 0;
}

Measured memory_bytes: 23168
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

#define ll long long 
#define fr(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define inf (1<<31)

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	unsigned long long int a,b,c,k;
	
	cin>>a>>b>>c;
	if(a%2==0 || b%2==0 || c%2==0)
		k=0;
	else{
		k=min(a*b,min(b*c,c*a));
	}	
	cout<<k;
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;

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

    vector<ll> vs(n);
    for (auto &v : vs) {
        cin >> v;
    }

    ll min_val = 10000000000000ll;

    for (int i = 0; i < n - (k - 1); i++) {
        ll dist = min(abs(vs[i]), abs(vs[i + k - 1])) + vs[i + k - 1] - vs[i];
        min_val = min(min_val, dist);
    }
    cout << min_val << endl;
}

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

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

ll n,w;
ll weight[105],value[105];
ll dp[105][100005];

ll find(ll n, ll w){
	if (n<=0)return 0;
	if (w==0)return 0;
	if (dp[n][w]!=-1)return dp[n][w];
	dp[n][w]=find(n-1,w);
	if (w>=weight[n-1]){
		dp[n][w]=max(dp[n][w],value[n-1]+find(n-1,w-weight[n-1]));
	}
	return dp[n][w];
}

void solve() {
    cin>>n>>w;
    rep(i,0,n){
    	cin>>weight[i]>>value[i];
    }
    memset(dp,-1,sizeof dp);
    cout<<find(n,w)<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

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

int main() {
    int N, D;
    cin >> N >> D;
    int ans=0;

    vector<vector<int>> x(N);

    for (int i = 0; i < N; ++i) {
      x[i].resize(D);
      for (int j = 0; j < D; ++j) {
        cin >> x[i][j];
      }
    }

    double tmp;
    for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
        tmp=0.0;
        for(int k=0;k<D;k++){
          tmp+=pow((x[i][k]-x[j][k]),2.0);
        }
        if(pow(tmp,0.5)==int(pow(tmp,0.5))) ans++;
      }
    }
   cout << ans << endl;
   return 0;
 }

Measured memory_bytes: 512
A, B = map(int, input().split())
if A>1 and B>1:
    if A>B:
        print('Alice')
    elif A<B:
        print('Bob')
    else:
        print('Draw')
else:
    if A==1 and B>1:
        print('Alice')
    elif B==1 and A>1:
        print('Bob')
    else:
        print('Draw')

Measured memory_bytes: 3060
N = int(input())
ans = [11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381]
print(*ans[:N])

Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int d, e, f;
    d = abs(a - b);
    e = abs(b - c);
    f = abs(c - a);
    cout << min(min(d + e, e + f), f + d) << endl;
}

Measured memory_bytes: 256
def quick_sort(array, left_pos, right_pos)
	return array if array.size == 0
	if left_pos < right_pos
	i, j = left_pos, right_pos
	pivot = array[(left_pos + right_pos)/2]
	while i <= j
		while array[i] < pivot
			i = i + 1
		end
		while array[j] > pivot
		j = j - 1
		end
		if i <= j
		array[i], array[j] = array[j], array[i]
		i = i + 1
		j = j - 1
		end
	end
	quick_sort(array, left_pos, j)
	quick_sort(array, i, right_pos)
	end
	return array
end

# str = Array.new(10)
str=[]
for i in 0..9 do
	str.push(gets.to_i)
end
str1 = [1819,2003,876,2840,1723,1673,3776,2848,1592,922]
# puts str.size
ans = quick_sort(str, 0, str.size-1)
puts ans[9]
puts ans[8]
puts ans[7]

Measured memory_bytes: 6104
#include<stdio.h>
#include<math.h>
int main(void)
{
	int a,c,i,j;
	scanf("%d", &a);
	c=a;
	int b[a];
	for(i=0; i<a; i++){
		scanf("%d", &b[i]);
			if(b[i]==2){
			}
			else if(b[i]<2 || b[i]%2==0)
			{
				c--;
			}
		else
		{
			j=3;
			int x;
			x=sqrt(b[i]);
			while(j<=x){
				if(b[i]%j==0){
				c--;
				break;
				}
				j=j+2;
			}
		}
	}
		
	printf("%d\n",c);
	return 0;
}



Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, K; cin >> N >> K;
	vector<int>p(N);
	rep(i, 0, N) {
		cin >> p[i];
	}
	sort(all(p));
	int ans = 0;
	rep(i, 0, K)ans += p[i];
	cout << ans << "\n";

	return 0;
}

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

int main() {
  int n,r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r << endl;
  } else {
    cout << r + (100 * (10 - n)) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
#define O(i, a, b) for(int i = a; i <= b; ++i)
#define R(i, a, b) for(int i = a; i >= b; --i)
#define S(n) scanf("%d", &n)
using namespace std;

int a, b;

int main(){
	ios::sync_with_stdio(false);
	S(a), S(b);
	O(i, 1, max(a, b))
		if (abs(a - i) == abs(b - i)){
			printf("%d\n", i);
			return 0;
		}
	printf("IMPOSSIBLE\n");
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String N = scanner.nextLine();
		int Num = Integer.parseInt(N);
		int length = String.valueOf(N).length();

		int num = 0;

//		StringBuilder sb = new StringBuilder(N);

		ArrayList<Integer> numbers = new ArrayList<Integer>();

		for(int i = 0; i < length;) {
			String S = N.substring(i, ++i);
			int j = Integer.parseInt(S);
			numbers.add(j);
		}

		for (int k : numbers) {
			num += k;
		}

		if (Num % num == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}


	}

}

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

int digsum(int n) {
    int ret = 0;
    while(n) {
        ret += n%10;
        n /= 10;
    }
    return ret;
}

int main() {
    int n, a, b, ans = 0;
    cin >> n >> a >> b;
    for(int i = 1; i <= n; ++i) {
        int x = digsum(i);
        if(x >= a && x <= b) ans += i;
    } 
    cout << ans << '\n';
    return 0;
}


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

int n, m;
bool vis[200005];
vector<int>E;

int main(){
    scanf("%d%d",&n,&m);
    E.push_back(1);
    while(m--){
        int x,y;
        scanf("%d%d",&x,&y);
        if(x == n) vis[y] = true;
        if(y == n) vis[x] = true;
        if(x == 1) E.push_back(y);
        if(y == 1) E.push_back(x);
    }
    for(auto Pos : E){
        if( vis[Pos] == true ){
            printf("POSSIBLE");
            exit(0);
        }

    }
    printf("IMPOSSIBLE");
    return 0;

}


Measured memory_bytes: 1020
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>D(k);
    rep(i,k){
        cin>>D.at(i);
    }
    bool check = false;
    while(!check)
    {
        int temp = n++;
        bool check_temp = true;
        while(temp){
            rep(i,k){
                if(temp%10==D.at(i)){
                    check_temp = false;
                    break;
                }
            }
            temp/=10;
            if(check_temp == false){
                break;
            }
        }
        if(check_temp==true){
            check = true;
        }
    }
    cout<<n-1<<endl;
    return 0; 
}




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

using namespace std ;

const int MAX = 1e6 + 10 ;

int arr[MAX] , freq[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	int g = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x ;
		cin>>x ;
		freq[x]++ ;
		g = __gcd(g , x) ;
	}
	bool flag = true ;
	for(int i = 2 ; i < MAX ; ++i)
	{
		int cnt = 0 ;
		for(int j = i ; j < MAX ; j += i)
			cnt += freq[j] ;
		if(cnt > 1)
		{
			flag = false ;
			break ;
		}
	}
	if(flag == true)
		cout<<"pairwise coprime\n" ;
	else if(g == 1)
		cout<<"setwise coprime\n" ;
	else
		cout<<"not coprime\n" ;
	return 0 ;
}		

Measured memory_bytes: 7540
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) { for (auto& e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S; cin >> S;
	bool f = true;
	if (S.size() % 2 != 0) {
		f = false;
	}
	else {
		rep(i, 0, S.size()) {
			if (S[i] == 'h' && S[i + 1] == 'i') {
			}
			else {
				f = false;
			}
			i++;
		}
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int a, b, c;

	std::cin >> a >> b >> c;
	
	int cnt = 0;
	for(int i = a; i <= b; i++)
	{
		if( c % i == 0 )
			cnt++;
	}
	
	std::cout << cnt << std::endl;
	
	return 0;
}


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

int main() {
    long long int N, K;
    cin >> N >> K;
    long long int S[200001] = {};
    long long int P[200001] = {};
    for(int i=1;i<=N;i++) {
        long long int a;
        cin >> a;
        S[i] = S[i-1] + a;
        P[i] = (S[i] - i) % K;
    }
    map<long long int, int> S_nums;
    S_nums[0]=1;
    long long int ans=0;
    for(int j=1;j<=N;j++) {
        if(j-K>=0) S_nums[P[j-K]]--;
        ans += S_nums[P[j]];
        S_nums[P[j]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=1;
	cin >>n;
	V a(n);
	rep(i,n){
		cin>>a[i];
	}
	V dp(n,INF);
	rep(i,n){
		
	//	clog<<dp[i]<<" ";
	}
//	clog<<endl;
	rep(i,n){
		*lower_bound(all(dp),a[i])=a[i];
	}
	for(int i=0;dp[i]!=INF and i < n;i++)
	{
		ans=i+1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4392
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;

struct Node{
	int key;
	Node *parent;
	Node *left;
	Node *right; 
};
Node *root, *NIL;
void insert(int k){
	Node *x = root,*y = NIL,*z;
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while(x!=NIL){
		y = x;
		if(z->key<x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;
	if(y==NIL)
		root = z;
	else{
		if(z->key<y->key)
			y->left = z;
		else
			y->right = z;
	}
}
int find(Node *n,int key){
	while(n!=NIL){
		if(key<n->key)
			n = n->left;
		else if(key>n->key)
			n = n->right;
		else
			return 1;
	}
	return 0;
}
void pre(Node *n){
	if(n==NIL) return;
	printf(" %d",n->key);
	pre(n->left);
	pre(n->right);
}
void in(Node *n){
	if(n==NIL) return;
	in(n->left);
	printf(" %d",n->key);
	in(n->right);
}
int main() {
	int n,x;
	char s[10];
	scanf("%d",&n);
	while(n--){
		scanf("%s",s);
		if(s[0]=='i'){
			scanf("%d",&x);
			insert(x);
		}else if(s[0]=='p'){
			in(root);
			printf("\n");
			pre(root);
			printf("\n");
		}else{
			scanf("%d",&x);
			if(find(root,x))
				printf("yes\n");
			else
				printf("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 21888
# ABC074D
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



def main():
    n = int(input())
    d = [None]*n

    for i in range(n):
        d[i] = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(n):
                if k in (i,j):
                    continue
                if (d[i][j]>d[i][k]+d[j][k]) or (d[i][k]>d[i][j]+d[j][k]) or (d[k][j]>d[i][k]+d[j][i]):
                    print(-1)
                    return
                if d[i][j]==d[i][k]+d[j][k]:
                    break
            else:
                ans += d[i][j]
    print(ans)
main()

Measured memory_bytes: 42972
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size();
const int INF=INT_MAX;
int main(){
  ll n,k;cin>>n>>k;
  ll d=n/k,ans=d*d*d;
  if(k%2==0){
    if(n%k>=k/2){d++;}
    ans+=d*d*d;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import math

N,D=map(int, input().split())
X=[list(map(int, input().split())) for _ in range(N)]

count=0
for i in range(N):
    for j in range(i+1,N):
        d2=0
        for dim in range(D):
            d2+=(X[i][dim]-X[j][dim])**2
        d=math.sqrt(d2)
        if (round(d) == d):
            count+=1
print(count)


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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    FAST;
    set<int>s;
    for(int i=1;i<=3;i++)
    {
        int in;
        cin>>in;
        s.insert(in);
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 256