akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

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

    VAR(int, N, M);
    int minv = INF;
    int maxv = -INF;
    rep(i, 0, M) {
        VAR(int, l, r);
        chmax(maxv, l);
        chmin(minv, r);
    }
    print(max(0, minv - maxv + 1));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c[200000];
	char op[2];

	while(1){
		scanf("%d %s %d",&a,op,&b);
		if(op[0]=='?'){
			break;
		}
		switch(op[0]){
		case '+':
			printf("%d\n",a+b);
			break;
		case '-':
			printf("%d\n",a-b);
			break;
		case '*':
			printf("%d\n",a*b);
			break;
		case '/':
			printf("%d\n",a/b);
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 2112
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    P = list(map(int, input().split()))
    MAX = 10 ** 9 - n
    A = list(range(1, MAX + 2, MAX // (n - 1)))
    T = list(range(1, n + 1))
    B = [0] * n
    for i in range(n):
        idx = P[i] - 1
        B[idx] = T[i] - A[idx]
    mi = min(B)
    if mi <= 0:
        d = mi * -1 + 1
        B = [b + d for b in B]
    print(*A)
    print(*B)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 12812
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int x1, x2;

int main() {

	cin >> x1 >> x2;

	if (x1 > x2)swap(x1, x2);

	cout << x2 - x1 << endl;

	return 0;
}


Measured memory_bytes: 3120
n=int(input())
x,y=[list(map(int,input().split()))for _ in range(2)]
d=[abs(s-t)for s,t in zip(x,y)]
f=lambda n:sum(s**n for s in d)**(1/n)
print(f(1),f(2),f(3),max(d),sep='\n')


Measured memory_bytes: 5652
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

int main(){
    ll N, M, X; cin >> N >> M >> X;
    vll C(N); vvll A(N, vll(M));
    for(int i=0; i<N; i++){
        cin >> C[i];
        for(int j=0; j<M; j++){
            cin >> A[i][j];
        }
    }
    ll mini = 1000000000000;
    for(int i=0; i<powl(2,N); i++){
        Radix r; 
        string s = r.to(i, 2);
        ll p = N - s.size();
        string h = "";
        for(int i=0; i<p; i++){
             h += '0';
        }
        string v = h + s;
        vll g(M, 0);
        ll m = 0;
        for(int j=0; j<N; j++){
            if(v[j] == '1'){
                for(int k=0; k<M; k++){
                    g[k] += A[j][k];
                }
                m += C[j];
            }
        }
        bool n = true;
        for(int j=0; j<M; j++){
            if(g[j] < X){
                n = false;
            }
        }
        if(n){
            if(m < mini){
                mini = m;
            }
        }
    }
    if(mini == 1000000000000){
        cout << -1;
    }else{
    cout << mini;
    }
}

Measured memory_bytes: 3756
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	int a, b, x;
	cin >> a >> b >> x;
	int B = b / x + 1;
	int A;
	if (a == 0)A = 0;
	else A = (a - 1) / x + 1;
	int ans = B - A;
	cout << ans;
}

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

using namespace std;

int main(void){

    int n;
    cin >> n;
    int ans = 1;

    for(int i = 2;i < sqrt(n) + 1;i++){
        int temp = i;
        while(1){
            if(temp <= n){
                ans = max(ans, temp);
            }else{
                break;
            }

            temp *= i;
        }
    }

    cout << ans << endl;

    return 0;
}

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

vector<int> Input(const int n)
{
    vector<int> W;
    for(int i = 0; i < n; i++){
        int w;
        cin >> w;
        W.push_back(w);
    }
    return W;
}
 
bool IsAllLoaded(int& P, vector<int>& W, int& k)
{
    int TrackIndex = 0;
    int CurrentSum = 0;
    int i = 0;
    int n = W.size();
    for(i = 0; i < n; i++){
        if(W[i] > P){
            return false;
        }
        if(CurrentSum + W[i] > P){
            TrackIndex++;
            if(TrackIndex == k){
                return false;
            }
            CurrentSum = 0;
        }
        CurrentSum += W[i];
    }
    return true;
}
 
int Calc(vector<int>& W, int& k)
{
    int Sum = accumulate(W.begin(), W.end(), 0 );
    int max = *std::max_element(W.begin(), W.end());
    int P = std::max((Sum + k - 1) / k, max);
    while(!IsAllLoaded(P, W, k)){
        P++;
    }
    return P;
}
 
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> W = Input(n);
    int P = Calc(W, k);
    cout << P << endl;
    return 0;
}

Measured memory_bytes: 3528
import sys
sys.setrecursionlimit(10 ** 9)

import numpy as np
from heapq import heappush, heappop

N, M, = map(int, input().split())
graph = [[] for _ in range(N+1)] # graph[0]は使わない

for _ in range(M):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))

def dijkstra(start, c):
    INF = float('inf')
    dist = [-INF] * (N+1) # dist[0]は使わない
    dist[start] = 0
    que = [(start, 0, c)]
    while que:
        place, score, count = heappop(que) # placeは現在地
        if score < dist[place] or count > 3000: # 前来た時より点数が悪いか、無限ループしている場合continue
            continue
        for next_node, weight in graph[place]:
            score2 = score + weight
            if next_node == N and count > 1000: # いくらでも大きくなる場合
                print('inf')
                exit()
            if dist[next_node] < score2: # 点数が良くなるなら、データを更新
                dist[next_node] = score2
                heappush(que, (next_node, score2, count+1))
    return dist

d1 = np.array(dijkstra(1, 0))
print(int(d1[N]))


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

int main(){
        int q;
        cin >> q;
        for(int k = 0; k < q; k++){
                string x, y;
                cin >> x >> y;
                int n = x.size(), m = y.size();
                int l[n + 1][m + 1];
                for(int j = 0; j <= m; j++){
                        for(int i = 0; i <= n; i++){
                                if(i == 0 || j == 0) l[i][j] = 0;
                                else if(x[i - 1] == y[j - 1]) l[i][j] = 1 + l[i - 1][j - 1];
                                else l[i][j] = max(l[i - 1][j], l[i][j - 1]);
                        }
                }
                cout << l[n][m] << endl;
        }
        return 0;
}



Measured memory_bytes: 7052
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

min_temp = 1000
for i in range(N):
    c = T - (H[i] * 0.006)
    if abs(A - c) < min_temp:
        ans = i
        min_temp = abs(A - c)

print(ans+1)

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

int main(void)
{
    int inputN;
    int *inputD;
    long total = 0;

    scanf("%d", &inputN);
    inputD = (int *)malloc(sizeof(int) * inputN);
    for (int index = 0; index < inputN; index++)
    {
        scanf("%d", &inputD[index]);
    }

    for (int index = 0; index < inputN - 1; index++)
    {
        for (int count = index + 1; count < inputN; count++)
        {
            total += inputD[index] * inputD[count];
        }
    }

    printf("%ld", total);

    free(inputD);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

class DisjointSet {
 public:
  vector<int> rank, p;

  DisjointSet() {}
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    for (int i = 0; i < size; i++) makeSet(i);
  }

  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }

  bool same(int x, int y) { return findSet(x) == findSet(y); }

  void unite(int x, int y) { link(findSet(x), findSet(y)); }

  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
  }

  int findSet(int x) {
    if (x != p[x]) {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};

int main() {
  int n, a, b, q;
  int t;

  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);

  for (int i = 0; i < q; i++) {
    cin >> t >> a >> b;
    if (t == 0) {
      ds.unite(a, b);
    } else if (t == 1) {
      if (ds.same(a, b))
        cout << 1 << endl;
      else
        cout << 0 << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3208
#include <stdio.h>

int main(void) {
    int x[5], i;
    scanf ("%d %d %d %d %d", &x[0], &x[1], &x[2], &x[3], &x[4]);
    for (i = 0 ; i <= 4 ; i++) {
        if (x[i] == 0) break;
    }
    printf ("%d", i + 1);
    return 0;
}

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

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

  int a, cnt = 0;;
  rep(i,0,N-1) {
    cin >> a;
    if (i % 2 == 0 && a % 2 == 1) cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
int compare(const int *x,const int *y){
return *y-*x;
}
int main(){
int w[10],k[10],i,j;
for(i=0;i<10;i++){
scanf("%d",&w[i]);
}
for(i=0;i<10;i++){
scanf("%d",&k[i]);
}
qsort(w,10,sizeof(int),compare);
qsort(k,10,sizeof(int),compare);
printf("%d %d\n",w[0]+w[1]+w[2],k[0]+k[1]+k[2]);
return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int func1(int N, vector<int> h) {
		int E=0, V=0;

		for ( int i = 0; i < N; i++ ) {
				V += h[i];
		}

		for ( int i = 1; i < N; i++ ) {
				int x = 0;
				x = min(h[i-1], h[i]);
				E += x;
		}

		return V-E;
}

int main() {
		int N;
		vector<int> h;

		scanf("%d", &N);
		for ( int i = 0; i < N; i++ ){
				int x;
				scanf("%d", &x);
				h.push_back(x);
		}

		printf("%d\n", func1(N, h));

		return 0;
}


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

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  int a = (A - 1 + D) / D;
  int t = (C - 1 + B) / B;
  if (t <= a) cout << "Yes" << endl;
  else cout << "No" << endl; 
}



Measured memory_bytes: 3632
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100

int ans = 0;
int N,M;
int table[NUM][NUM];

void recursive(int index,vector<int> Party){

	if(index == N){
		if(Party.size() <= 1)return;

		int tmp_sum = 0,tmp_minimum;

		for(int i = 0; i < Party.size(); i++){
			tmp_minimum = BIG_NUM;
			for(int k = 0; k < Party.size(); k++){
				if(i == k)continue;
				tmp_minimum = min(tmp_minimum,table[Party[i]][Party[k]]);
			}
			tmp_sum += tmp_minimum;
		}
		ans = max(ans,tmp_sum);
		return;
	}

	recursive(index+1,Party);

	int tmp_minimum = BIG_NUM;
	for(int i = 0; i < Party.size(); i++){
		tmp_minimum = min(tmp_minimum,table[index][Party[i]]);
	}

	if(tmp_minimum == 0)return;

	vector<int> NextParty;
	for(int i = 0; i < Party.size(); i++)NextParty.push_back(Party[i]);
	NextParty.push_back(index);

	recursive(index+1,NextParty);
}


int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)table[i][k] = 0;
	}

	int A,B,value;
	for(int loop = 0; loop < M; loop++){
		scanf("%d %d %d",&A,&B,&value);
		A--;
		B--;
		table[A][B] = value;
		table[B][A] = value;
	}

	vector<int> first_IN,first_OUT;
	first_IN.push_back(0);

	recursive(1,first_IN);
	recursive(1,first_OUT);

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

	return 0;
}



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

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

int main()
{
    int N;
    cin >> N;
    int x[N], y[N];
    rep(i, N){
        cin >> x[i] >> y[i];
    }
    auto dist = [&](int i, int j) {
        double dx = x[i] - x[j];
        double dy = y[i] - y[j];
        return sqrt(dx * dx + dy * dy);
    };
    double len = 0;
    rep(i, N){
        rep(j, i){
            len += dist(i, j);
        }
    }
    double ans = ((double)2 / (double)N) * len;
    printf("%.10f\n", ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)

{

  int i,x;

  for(i=1;;i++)

  {

    scanf("%d",&x);

    if(x!=0)

      {

	printf("Case %d: %d\n",i,x);

      }

    else

      {

	

	break;

      }

  }

  return 0;

}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll A, B, C;
    cin>>A>>B>>C;
    cout<<min(B/A, C)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    lint N, K;
    cin >> N >> K;
    lint R, S, P;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    vector<bool> given(N, false);
    lint ans = 0;
    REP(i, N) {
        if(i >= K && T[i] == T[i-K] && !given[i-K]) {
            given[i] = true;
        } else {
            if(T[i] == 'r') {
                ans += P;
            } else if(T[i] == 's') {
                ans += R;
            } else {
                ans += S;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int R[] = new int[N];
    int maxv = -2000000000;
    for(int i=0;i<N;i++){
      R[i] = sc.nextInt();
    }
    int minv = R[0];
    for(int j=1;j<N;j++){
      maxv = Math.max(maxv,R[j]-minv);
      minv = Math.min(minv,R[j]);
    }
    System.out.println(maxv);
  }
}


Measured memory_bytes: 101508
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';
using namespace std;

unordered_map<ll, ll> soinsu;

void bunkai_to_prime(ll index){
    reps(i, 2, sqrt(index)+1){
        while(index%i==0){
            index/=i;
            soinsu[i]++;
        }
        if(index==1) break;
    }
    if(index!=1) soinsu[index]++;
}

int main(void){
    ll N;
    cin>>N;
    bunkai_to_prime(N);
    //cout<<N<<endl;
    ll count=0;
    for(auto a : soinsu){
        //cout<<a.second<<sp;
        count+=(ll)((sqrt(1+8*(double)a.second)-1)/2);
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3736
#include <iostream>
using namespace std;
string a;
int v[99];
int main() {
	cin>>a;
	for(int i=0; a[i]; i++) v[a[i]] = 1;
	cout<<(v['N']^v['S'] || v['E']^v['W'] ? "No":"Yes");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int N, Y;
    cin >> N >> Y;

    bool f = true;
    REP(i, N + 1) {
        REP(j, N - i + 1) {
            if (Y - i * 10000 - j * 5000 == (N - i - j) * 1000) {
                cout << i << " " << j << " " << N - i - j << endl;
                f = false;
                break;
            }
        }
        if (!f) break;
    }

    if (f) cout << -1 << " " << -1 << " " << -1 << endl;



}


Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))


ans=0
for i in range(N-2):
  if P[i]<P[i+1] and P[i+1]<P[i+2]:
    ans += 1
  elif P[i]>P[i+1] and P[i+1]>P[i+2]:
    ans += 1
    
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[],int N) {
    int i;
    for(i=0;i<N;i++) {
        /* 隣接する要素の間に1つの空白を出力 */
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

/* 挿入ソート(0オリジン配列) */
void insertionSort(int A[], int N) {
    int i,j,v;
    for(i=1;i<N;i++) {
        v=A[i];
        j=i-1;
        while(j>=0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(void)
{
    int N, i;
    int A[100];
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

int main()
{
  int n, k, s;
  while (n = in(), k = in(), s = in(), n || k || s){
    int dp[16][999] = {};
    dp[0][0] = 1;
    for (int j = 1; j <= n; j++){
      for (int i = k; i > 0; i--){
        for (int x = 0; x < 255; x++){
          dp[i][x + j] += dp[i - 1][x];
        }
      }
    }
    printf("%d\n", dp[k][s]);
  }
  return 0;
}

Measured memory_bytes: 1244
import math
from fractions import gcd
from functools import reduce
n,x = map(int, input().split())
y_ls = list(map(int, input().split()))
y_ls.sort()
d_ls = [0] * (n-1)

if n != 1:
    first_ls = []
    for i in range(n):
        first = abs(x - y_ls[i])
        first_ls.append(first)

    for i in range(n-1):
        distance = y_ls[i+1] - y_ls[i] 
        d_ls.append(distance)

    points_gcd = reduce(gcd, d_ls)
    ans = 0
    for i in range(n):
        D = gcd(points_gcd, first_ls[i])
        if D > ans:
            ans = D

else:
    ans = abs(x - y_ls[0])

print(ans)


Measured memory_bytes: 19608
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int N;
cin >> N;

cout << N*N*N;










	return 0;

}



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

L = tuple(map(int, input().split()))

if len(L)==n:
  ans = 0
  for i in range(len(L)):
    for j in range(len(L)):
      for k in range(len(L)):
        if i<j and j<k:
          if L[i]==L[j]: continue
          if L[i]==L[k]: continue
          if L[k]==L[j]: continue
          if L[i]+L[j]+L[k] <= max(L[i], L[j], L[k])*2: continue
          ans +=1
print(ans)

Measured memory_bytes: 9072
#include <cstdio>
#include <cmath>

struct line{
	double gr,in;
	int dir;
	line(){}
	line(double gradient,double intercept,int direction){
		gr=gradient;
		in=intercept;
		dir=direction;
	}
};

struct point{
	double x,y;
	point(){}
	point(double xx,double yy){
		x=xx;
		y=yy;
	}
};


double x[4],y[4];

line make_line(int i,int j){
	if(x[i]==x[j]){
		return line(0.0,x[i],1);
	}
	line l;
	l.gr=(y[j]-y[i])/(x[j]-x[i]);
	l.in=y[i]-x[i]*l.gr;
	l.dir=0;
	return l;
}

point cross(line a,line b){
	if(a.dir==1)return point(a.in,b.gr*a.in+b.in);
	if(b.dir==1)return point(b.in,a.gr*b.in+a.in);
	point p;
	p.x=-(b.in-a.in)/(b.gr-a.gr);
	p.y=a.gr*p.x+a.in;
	return p;
}

bool check(line a,int i,int j){
	line b=make_line(i,j);
	point p=cross(a,b);
	//printf("%d %d %f %f\n",i,j,p.x,p.y);
	if(b.dir==1){
		if((p.y-y[i])*(p.y-y[j])>=0.0)return false;
	}else{
		if((p.x-x[i])*(p.x-x[j])>=0.0)return false;
	}
	return true;
}

int main(void){
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])){
		bool flag=true;
		line l1=make_line(0,2),l2=make_line(1,3);
		if(!check(l1,1,3) || !check(l2,0,2))flag=false;
		printf("%s\n",flag?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 1036
N,H=map(int,input().split())
X=[tuple(map(int,input().split())) for i in range(N)]
A=[x[0] for x in X]
B=[x[1] for x in X]
amax=max(A)
B.sort(reverse=True)
ans=0
for b in B:
    if H<=0 or b<=amax:
        break
    if b>amax:
        ans+=1
        H-=b
if H<=0:
    print(ans)
else:
    ans+=(H+amax-1)//amax
    print(ans)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a,b; // 入力値
      int x;   // 平均値（整数）
      
      cin >> a >> b;
	  x = (a+b)/2.0 + 0.9;
      cout << x << endl;
      
    }


Measured memory_bytes: 256
using System;
using System.Linq;

namespace CodeFest2016
{
	class Program
	{
		static void Main(string[] args)
		{
			var debug = false;

			var n = debug ? 4 : int.Parse(Console.ReadLine());

			var rabbits = (debug ? "2 1 4 3" : Console.ReadLine()).Split(" ".ToCharArray()).Select(num => int.Parse(num)-1).ToArray();

			var pairs = 0;
			for (int i = 0; i < n; i++)
			{
				if (rabbits[i] == -1) continue;
				if (i == rabbits[rabbits[i]])
				{
					pairs++;
					rabbits[rabbits[i]] = -1;
					rabbits[i] = -1;
				}
            }

			Console.WriteLine(pairs);
		}
	}
}


Measured memory_bytes: 10968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int X;
    cin >> X;
    int tmp = 100;
    int ans = 0;
    while (tmp < X)
    {
        tmp = tmp + tmp / 100;
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
using System;

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            int a = int.Parse(Console.ReadLine());
            if (a == 0) {  break; }
            string s = Convert.ToString((a), 8);
            s = s.Replace("7", "9");
            s = s.Replace("6", "8");
            s = s.Replace("5", "7");
            s = s.Replace("4", "5");
            Console.WriteLine(s);
        }
    }
}

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

int main() {
    ll N; cin >> N;
    map<string, vector<pair<ll, ll> > > m;

    for(int i = 1; i <= N; ++i){
        string s; ll point;
        cin >> s >> point;
        m[s].push_back(make_pair(point, i));
    }

    for(auto i:m){
        sort(i.second.begin(), i.second.end());
        reverse(i.second.begin(), i.second.end());
        for(auto j:i.second) cout << j.second << endl;
    }
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

tuple<int, vector<int>> bubbleSort(vector<int> a, int n){
  bool flag = true;
  int swaps = 0;
  while (flag) {
    flag = false;
    for (int j=n-1; j>=1; --j) {
      if (a[j] < a[j-1]) {
	int tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	flag = true;
	swaps++;
      }
    }
  }
  return forward_as_tuple(swaps, a);
}

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

  vector<int> ans;
  int times;
  tie(times, ans) = bubbleSort(a, n);
  rep(i, n) printf("%d%c", ans[i], i == n-1 ? '\n':' ');
  cout << times << endl;
  return 0;
}



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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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){
  ios::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  REP(i, N){cin >> h[i];}


  sort(h.begin(), h.end());
  ll ans = 0;
  FOR(i, K, N){
    int ind = N - i - 1;
    ans += h[ind];

  }

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



Measured memory_bytes: 1024
use proconio::input;
// ordtools {{{
#[allow(dead_code)]
mod ordtools {
    pub trait Ordtools: PartialOrd + Clone + Sized {
        fn change_min(&mut self, rhs: &Self) {
            if rhs < self {
                *self = rhs.clone();
            }
        }

        fn change_max(&mut self, rhs: &Self) {
            if rhs > self {
                *self = rhs.clone();
            }
        }
    }

    impl<T: PartialOrd + Clone + Sized> Ordtools for T {}
}
// }}}
use ordtools::Ordtools;
fn main() {
    input!(s: String);
    let a = std::iter::once(0)
        .chain(s.as_bytes().iter().map(|&c| (c - b'0') as u32))
        .collect::<Vec<u32>>();
    let mut dp = [0, std::u32::MAX];
    for &x in &a {
        let mut swp = [std::u32::MAX, std::u32::MAX];
        swp[0].change_min(&(dp[0] + x));
        swp[0].change_min(&(dp[1].saturating_add(10 - x)));
        swp[1].change_min(&(dp[0] + x + 1));
        swp[1].change_min(&(dp[1].saturating_add(9 - x)));
        std::mem::swap(&mut dp, &mut swp);
    }
    dp[1] += 1;
    println!("{}", (dp[0]).min(dp[1]).min(a.iter().sum::<u32>()));
}


Measured memory_bytes: 7928
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
const int N=50005;
//Code begin....

char s[60], ans[60];

int main ()
{
    scanf("%s",s);
    int len=strlen(s);
    FOR(i,0,len-9) ans[i]=s[i];
    ans[len-8]='\0';
    puts(ans);
    return 0;
}


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


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)


int main()
{
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // LOCAL
    string s;
    cin >> s;
    for (char& ch : s) {
        if (ch == '?') ch = 'D';
    }
    cout << s << endl;
}

Measured memory_bytes: 3756
# tokenakatta ...
def main():
    N, X = map(int, input().split())
    a, p = [1],[1]
    for i in range(N):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)
    return bur(N, X, a, p)
def bur(N, X, a, p):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X == 1:
        return 0
    elif X <= 1 + a[N-1]:
        return bur(N-1, X-1, a, p)
    elif X == 2 + a[N-1]:
        return p[N-1] + 1
    elif X <= 2 + 2 * a[N-1]:
        return p[N-1] + 1 + bur(N-1, X-2-a[N-1], a, p)
    else:
        return 2 * p[N-1] + 1
print(main())


Measured memory_bytes: 3064
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;  
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) {
	ll ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

void solve() {
	int x,y;
	cin >> x >> y;
	for (int i = 0; i <= x; ++i) {
		if (2*i + 4*(x-i) == y) {
			cout << "Yes" << endl;
			return;
		}
	}		
	cout << "No" << endl;
}

int main() {
	fast_io();
	int t = 1;
	// cin >> t;
	while (t--) solve();
	return 0;
}

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

signed main(void)
{
	int a, b, k, cnt;
	cin >> a >> b >> k;
	cnt = 0;
	for(int i = a; i <= b; i++)
	{
		if (cnt < k || cnt > b - a - k)
			cout << i << endl;
		cnt++;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
long long a[100000];
int main()
{
	int N;
	int count = 1;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &a[i]);
	}
	sort(a, a + N);
	long long number = a[0];
	long long bit;
	int count0 = 1;
	int count1 = 0;
	int count2 = 0;

		if (a[0] == 0) {
			for (int i = 1; i < N; i++) {
				if (a[i] == 0) {
					count0++;
				}
				if (a[i] != number) {
					number = a[i];
					count++;
				}
			}
			if (count == 2 && count0 == N / 3 && N % 3 == 0) {
				printf("Yes");
				return 0;
			}
			if (count0 == N) {
				printf("Yes");
				return 0;
			}
		}
		else {
			for (int i = 1; i < N; i++) {
				if (a[i] == a[0]) {
					count0++;
				}
				if (a[i] == a[N / 3]) {
					count1++;
				}
				if (a[i] == a[N / 3 * 2]) {
					count2++;
				}
				if (a[i] != number) {
					number = a[i];
					count++;
				}
			}
			if (count == 3 && count0 == N / 3 && count1 == N / 3 && count2 == N / 3) {
				bit = a[0] ^ a[N / 3];
				if (bit == a[N / 3 * 2]) {
					printf("Yes");
					return 0;
				}
			}
		}
	printf("No");
	return 0;
}

Measured memory_bytes: 896
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, K;
	cin >> N >> K;
	VI A(N);
	int i = 0;
	for (int n = 0; n < N; n++) {
		cin >> A[n];
		if (A[n] == 1)i = n;
	}
	int ans = 100000;
	for (int l = max(0, i - K + 1); l <= min(N - 1, i); l++) {
		int temp = 1;
		temp += l / (K - 1);
		if (l % (K - 1) != 0)temp++;
		temp += (N - K - l) / (K - 1);
		if ((N - K - l) % (K - 1) != 0)temp++;
		ans = min(ans, temp);
	}
	cout << ans << "\n";
	return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 1e8;
const int INF = 1e9;
const int MOD = 998244353;


void out(char c) {
    cout << char(c - 'a' + 'A');
    exit(0);
}

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    int turn = 'a';
    while (true) {
        if (turn == 'a') {
            if (a.empty())
                out(turn);
            turn = a[0];
            a.erase(a.begin());
        }
        else if (turn == 'b') {
            if (b.empty())
                out(turn);
            turn = b[0];
            b.erase(b.begin());
        }
        else if (turn == 'c') {
            if (c.empty())
                out(turn);
            turn = c[0];
            c.erase(c.begin());
        }
    }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  for (int i = 0; i < N; i++) {
    if (ans < K)
      ans *= 2;
    else
      ans += K;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n;
  int i,j;
  string str;
  cin>>str;
  n=str.size();
  int sum=0;
  rep(i,n-1)
    if(str[i]!=str[i+1])sum++;
  cout<<sum<<endl;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
k = int((10**9 + 8)/2)
sum = 0
sum_1 = 0

for i in range(N):
    sum += A[i]
sum = (sum**2)%mod

for j in range(N):
    sum_1 += A[j]**2
sum_1 = (sum_1)%mod

ans = sum - sum_1
ans = (ans*k)%mod

print(ans)


Measured memory_bytes: 30996
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int N, a[100], ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a, a + N);
    for (int i = 0; i < N; i++) ans += (i % 2) ? -a[N-i-1] : a[N-i-1];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  int a[N],b[N],c[M],d[M];
  for(int i=0;i<N;i++) cin >> a[i] >> b[i];
  for(int i=0;i<M;i++) cin >> c[i] >> d[i];

  for(int i=0;i<N;i++){
    int mn = 1000000000;
    int ans;
    for(int j=0;j<M;j++){
      int dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(dist < mn){
        mn = dist;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


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

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)

using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-8;
const ll MOD = 1000000007;

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

  ll n;
  cin>>n;
  string s = "No";
  FOR(i,1,10) {
    if(n/i<10 && n%i==0)s = "Yes";
  }
  cout<<s<<endl;
}


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

using namespace std;

long long int kaijo(int a){
	if(a==0){
		return 1;
	}
	else {
		return a*kaijo(a-1);
	}
	
}

int main(){
	int n;
	cin>>n;
	cout<<kaijo(n)<<endl;
	return 0;
}

Measured memory_bytes: 0
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#define INF 100000000000000
using namespace std;

int main(){
    long long n, q;
    long long ans;
    cin >> n;
    vector<long long> S(n);
    for(int i=0; i<n; i++){
        cin >> S[i];
    }
    cin >> q;
    vector<long long> T(q);
    for(int i=0; i<q; i++){
        cin >> T[i];
    }
    for(int i=0; i<T.size(); i++){
        long long right=n;
        long long left=0;
        long long mid;
        while(left<=right){
            mid = (right+left)/2;
            if(S[mid]==T[i]){
                ans = ans + 1;
                break;
            }else if(S[mid]>T[i]){
                right = mid-1;
            }else{
                left  = mid +1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3784
import java.math.*;
import java.io.*;
class Main{
 public static void main(String args[])throws IOException{
  int i,n;
  BigInteger fact=BigInteger.valueOf(1);
  BufferedReader br=
   new BufferedReader(new InputStreamReader(System.in));
  n=Integer.parseInt(br.readLine());
  for(i=2;i<=n;i++) fact=fact.multiply(BigInteger.valueOf(i));
  System.out.println(fact);
 }
}

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

int main(void){
  int n;
  string s;
  
  cin >> n >> s;
  for (int i=0; i<s.size(); i++){
    char c = (s[i]-'A'+n)%26+'A';
    cout << c;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

void bubbleSort( vector<string> &cards )
{
	for( int i=0; i<cards.size( ); i++ ) {
		for( int j=cards.size( )-1; i<j; j-- ) {
			if( cards[j][1]< cards[ j-1 ][1] ) {
				swap( cards[j], cards[ j-1 ] );
			} 
		}	
	}
	return;
}

void selectionSort( vector<string> &cards )
{
	int mini;
	for( int i=0; i<cards.size( ); i++ ) {
		mini = i;
		for( int j=i; j<cards.size( ); j++ ) {
			if( cards[j][1] < cards[mini][1] ) {
				mini = j;
			} 
		}
		swap( cards[i], cards[ mini ] );
	}
	return;
}

void print( vector<string> &cards )
{
	for( int i=0; i<cards.size( ); i++ ) {
		cout<<cards[i];
		if( i != cards.size( )-1 ) { cout<<" "; }
	}
	cout<<endl;
	
	return;
}

int main( )
{	
    int n;
    cin>>n;
    
    vector<string> cards(n);
    vector<string> cards2(n);
    for( int i=0; i<n; i++ ) {
    	cin>>cards[i];
    }
    cards2 = cards;
	bubbleSort( cards );
	print( cards );
    cout<<"Stable"<<endl;

	selectionSort( cards2 );
	print( cards2 );
	bool isStabe = true;
	for( int i=0; i<cards2.size( ); i++ ) {
		if( cards2[i].at( 0 ) != cards[i].at( 0 ) ) { 
			isStabe = false;
			break;
		}
	}
	if( isStabe ) {
		cout<<"Stable"<<endl;
	} else {
		cout<<"Not stable"<<endl;
	}
	
	return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	string s; cin >> s;

	int ans = 0;
	int N = s.length();

	REP(i,N/2){
		if(s[i] != s[N-i-1])  ans++;
	}
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#define ll long long

using namespace std;


int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (x-r>=0 && x+r<=W && y-r>=0 && y+r <= H) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}




Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
	int N; cin >> N;
	vector<ll> a(3*N);
	rep(i,3*N) cin >> a[i];
	sort(a.begin(),a.end());
	ll ans = 0;
	int cnt = 0;
	for(int i = 3*N-2; i >= 0; i-=2){
		ans += a[i];
		cnt++;
		if(cnt == N) break;
	}
	cout << ans << endl;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int A, B, C, D; cin >> A >> B >> C >> D;

	int res = -1;
	if (B <= C || D <= A){
		res = 0;
	}else{
		res = min(B, D) - max(A, C);
	} // end if

	cout << res << endl;
	
	return 0;
}

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

using namespace std;

int main() {
	string a;
	string b;
	cin>>a>>b;
	string c;
	int i=0,k=0,p=0;
	while(i<(a.size()+b.size())){
	if(i%2==0){
	    cout<<a[k];
	    k++;
	}
	else {cout<<b[p];p++;}
	i++;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
ll n,m,i,j,k,l,t,arr[sz],brr[sz],x,y,z;
vector<ll>v,v1;
char c[sz];
int main()
{
   scanf("%lld %s",&n,&c);
   m=strlen(c);
   for(i=0;i<min(n,m);i++)
    printf("%c",c[i]);
  if(n<m)
    printf("...");
   printf("\n");
    return 0;
}


Measured memory_bytes: 3832