akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define vt vector
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;
template<typename T> T power(T a,T b){T r=1;while(b){if(b&1)r*=a;b/=2;a*=a;}return r;}

bool cmp(const pair<int,int> a, const pair<int,int> b)
{
  return abs(a.ff-b.ff)+abs(a.ss-b.ss)>0;
}

int main()
{
  fastio;
  
  int n;
  cin>>n;
  vt<ll> a(n),b(n),c(n);
  range(i,0,n)
  {
    int x,y;
    cin>>x>>y;
    a[i]=(x+y);
    b[i]=(y-x);
    c[i]=(x-y);
  }

  sort(all(a));
  sort(all(b));
  sort(all(c));

  ll ans1=(a.back()-a.front()),ans2=(b.back()-b.front());
  ll ans3=(c.back()-c.front());
  cout<<max({ans1,ans2,ans3});

}

Measured memory_bytes: 7932
#include <stdio.h>
int main(){
  int S,T,i;
  int a[8];
  i = 0;
  while(i<8){
    scanf("%d",&a[i]);
    i++;
  }
  S = a[0] + a[1] + a[2] + a[3];
  T = a[4] + a[5] + a[6] + a[7];
  if(S<T)printf("%d\n",T);
  else printf("%d\n",S);
 return 0;
}

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

using namespace std;
using ll = long long int;

ll powmod(ll base, ll exp, ll mod){
    if(exp == 0){
        return 1;
    }
    if(exp % 2 == 0){
        ll t = powmod(base, exp/2, mod);
        return (t * t) % mod;
    }
    return (base * powmod(base, exp - 1, mod)) % mod;
}

ll mod_combination(ll N, ll A, ll M){
    A = min(A, N - A);
    ll child = 1;
    for(ll k = N - A + 1; k <= N; k++){
        child = (child * k) % M;
    }

    ll mother = 1;
    for(ll k = 1; k <= A; k++){
        mother = (mother * k) % M;
    }
    ll fermat = powmod(mother, M - 2, M);
    return (child * fermat) % M;
}

int main() {
    ll N, A, B;
    ll M = 1000000000 + 7;
    cin >> N >> A >> B;

    ll a, b;
    a = mod_combination(N, A, M);
    b = mod_combination(N, B, M);
    ll ans = powmod(2, N, M);
    ans = ans - a - b - 1;
    while (ans < 0){
        ans += M;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static long maxn = 200005;

    static void solve() {
        int a = ni();
        int b = ni();
        int h = ni();
        out.println((h * (a + b) / 2));
    }
}

Measured memory_bytes: 22996
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// 多重vectorを可変引数テンプレートで http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_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);
}
//

#pragma endregion

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	i64 n;
    cin >> n;
    vector<i64> a(n);
    for(i64 i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    bool flag = false;
    for(i64 i = 0; i < n - 1; ++i) if(a[i] == a[i + 1]) flag = true;
    if(flag) cout << "NO" << endl;
    else cout << "YES" << endl;
}

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

using namespace std;

int main(){
    int A,B,K;

    cin>>A>>B>>K;

    int Ah,Bh;

    for(int i=0;i<K;i++){
        

        if(i%2==1){ 
            if(B%2==1)B--;
            B/=2;
            Bh=B;
            A+=Bh;
        }

        else{ 
            if(A%2==1)A--;
            A/=2;
            Ah=A;
            B+=Ah;
        }
        


    }

    cout<<A<<" "<<B<<endl;

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



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

    vvi s(h, vi(w));
    rep(i, h) {
        rep(j, w) {
            s[i][j] = 0;
        }
    }


    rep(i, h) {
        rep(j, a) {
            s[i][j] = 1;
        }
    }

    rep(i, b) {
        rep(j, w) {
            s[i][j] ^= 1;
        }
    }


    rep(i, h) {
        rep(j, w) {
            cout << s[i][j];
        }
        cout << endl;
    }
}

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

int main()
{
	int i, a, b, count;
	char op;
	a = 0;
	b = 0;
	count = 0;
	int hairetu[20000];
	while (count < 20000)
	{
		cin >> a >> op >> b;
		if (op == '+' )
		{
			hairetu[count] = a + b;
			count++;
		}
		else if (op == '-')
		{
			hairetu[count] = a - b;
			count++;
		}
		else if (op == '*')
		{
			hairetu[count] = a * b;
			count++;
		}
		else if (op == '/')
		{
			hairetu[count] = a / b;
			count++;
		}
		else if (op == '?')
		{
			break;
		}
		
	}
	for (i = 0; i < count; i++)
	{
		cout << hairetu[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3088
def get_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            upper_divisors.append(n//i)
        i += 1
    return [lower_divisors, upper_divisors]

n = int(input())

up = get_divisors(n)[0]
dn = get_divisors(n)[1]

ans = 11
for a, b in zip(up, dn):
    a = str(a)
    b = str(b)
    f = max(len(a), len(b))
    ans = min(ans, f)

print(ans)

Measured memory_bytes: 9100
n=int(input())
a=list(map(int,input().split()))

from collections import deque
q=deque()
q.append(a[0])
for i in range(1,n):
    if i%2==1:
        q.append(a[i])
    else:
        q.appendleft(a[i])
if n%2==0:
    print(*list(q)[::-1])
else:
    print(*q)

Measured memory_bytes: 26020
def main():
    N, K = map(int, input().split())
    S = [int(input()) for _ in range(N)]

    S.sort(reverse=True)

    diff_arr = [S[i] - S[i+K-1] for i in range(len(S)-K+1)]
    print(min(diff_arr))

if __name__ == "__main__":
    main()

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

double a, b, x;

int main() {
    scanf("%lf %lf %lf", &a, &b, &x);
    if (a * a * b / 2.0 > x)
        printf("%0.9lf", 90 - atan(2 * x / (b * b * a)) * 180 / acos(-1));
    else printf("%0.9lf", 90 - atan(a * a * a / 2 / (a * a * b - x)) * 180 / acos(-1));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    while(1){
        int n; cin>>n;
        if(n == 0) return 0;
        for(int i=0; i<n; i++){
            ll x1, y1, z1, w1, x2, y2, z2, w2;
            cin>>x1>>y1>>z1>>w1>>x2>>y2>>z2>>w2;

            ll x3 = x1 * x2 - y1 * y2 - z1 * z2 - w1 * w2;
            ll y3 = x1 * y2 + y1 * x2 + z1 * w2 - w1 * z2;
            ll z3 = x1 * z2 - y1 * w2 + z1 * x2 + w1 * y2;
            ll w3 = x1 * w2 + y1 * z2 - z1 * y2 + w1 * x2;

            cout << x3 << " " << y3 << " " << z3 << " " << w3 << endl;
        }
    }
}


Measured memory_bytes: 3080
import sys
from functools import lru_cache
sys.setrecursionlimit(100000)

N = int(input())
H = [int(h) for h in input().split()]
INF = 10**5+1
#cost = [INF]*N
#cost[0] = 0
#cost[1] = abs(H[0] - H[1])

@lru_cache(maxsize=None)
def dp(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(H[0] - H[1])
  else:
    return min(
      dp(i-1) + abs(H[i-1] - H[i]),
      dp(i-2) + abs(H[i-2] - H[i]))

for i in range(N-1):
  _ = dp(i)
print(dp(N-1))

Measured memory_bytes: 23808
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int N, maxA, minA;
	cin >> N;
	int A[N];
	for(int i = 0; i < N; i++){
		cin >> A[i];
		if(i == 0){
			maxA = A[0];
			minA = A[0];
			continue;
		}
		if(A[i] > maxA){
			maxA = A[i];
		}
		if(A[i] < minA){
			minA = A[i];
		}
	}
	cout << maxA - minA << endl;
	return 0;
}

Measured memory_bytes: 256
//rohitaas_15
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> o_set;
#define ll  long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define f(a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define show(x) cout<<x<<"\n"
#define printvector(v,n) f(0,n-1){cout<<v[i]<<" ";}
#define input(v,n) f(0,n-1){cin>>v[i];}
#define vr vector<ll>
#define check() cout<<"hi"<<"\n"
#define MOD 1000000007
#define endl "\n"
#define maxv(v) *max_element(all(v));
#define minv(v) *min_element(all(v));
#define sumv(v) accumulate(all(v),0)
#define test() ll t;cin>>t;while(t--)
ll search(vr arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
ll CmP(ll n, ll r, ll p=MOD){if (r==0)return 1;ll fac[n+1];fac[0] = 1;for (ll i=1 ; i<=n; i++)fac[i] = fac[i-1]*i%p; return (fac[n]* modInverse(fac[r], p) % p *modInverse(fac[n-r], p) % p) % p; }
int main()
{
	fastio();
	ll k,n;
	cin>>k>>n;
	vr house(n);
	input(house,n);
	sort(all(house));
	ll minn=1e15;
	ll dif=0;
	vr diff;
	f(1,n-1)
	{
		dif+=house[i]-house[i-1];
		diff.push_back(house[i]-house[i-1]);
	}
	dif+=k-house[n-1] +house[0];
	diff.push_back(k-house[n-1] +house[0]);
	f(0,n-1)
	{
		ll t=dif-diff[i];
		if(t<minn)
		{
			minn=t;
		}
	}
	show(minn);
}







Measured memory_bytes: 3956
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!long;
    long n = long.max;
    foreach (_; 0..5) n = min(n, readln.chomp.to!long);
    writeln((N + n - 1) / n + 4);
}

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

using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
vector<int> g[MAXN];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for(int i = 2 ; i <= n ; i++)
    {
        int x;
        cin >> x;
        g[x].push_back(i);
    }
    for(int i = 1; i <= n ;i++)
      cout << g[i].size() << '\n';

    
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, M;
int ANS[60];

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

	cin >> N >> M;
	int s, t;
	rep(i, 0, M)
	{
		cin >> s >> t;
		s--, t--;
		ANS[s]++;
		ANS[t]++;
	}

	rep(i, 0, N)
	{
		cout << ANS[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N;
ll C, X[Nmax], V[Nmax];

int main(){
	cin >> N >> C;
	for(int i=0; i<N; i++) cin >> X[i] >> V[i];

	vector<ll> rmax1(N);
	vector<ll> rmax2(N);
	vector<ll> lmax1(N);
	vector<ll> lmax2(N);
	ll rcum = V[0], lcum = V[N-1];
	rmax1[0] = max(0LL, V[0]-X[0]);
	rmax2[0] = max(0LL, V[0]-2*X[0]);
	lmax1[0] = max(0LL, V[N-1]-(C-X[N-1]));
	lmax2[0] = max(0LL, V[N-1]-2*(C-X[N-1]));
	for(int i=1; i<N; i++){
		rcum += V[i];
		lcum += V[N-1-i];
		rmax1[i] = max(rmax1[i-1], rcum-X[i]);
		rmax2[i] = max(rmax2[i-1], rcum-2*X[i]);
		lmax1[i] = max(lmax1[i-1], lcum-(C-X[N-i-1]));
		lmax2[i] = max(lmax2[i-1], lcum-2*(C-X[N-i-1]));
	}

	ll ans = max(rmax1[N-1], lmax1[N-1]);
	for(int i=0; i<N-1; i++){
		ans = max(ans, rmax1[N-i-2]+lmax2[i]);
		ans = max(ans, lmax1[N-i-2]+rmax2[i]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#define mem(a, b) memset(a, (b), sizeof(a))

using namespace std;


typedef long long ll;
const int Maxn = 1e9 + 10;
const int N = 1e6 + 10;
const int INF=(0x7fffffff)/2;
const int MOD = 1000000007;
const int MaxN = 1000;

char s[10];

int main(){
	scanf("%s", s);
	int sum = 700;
	for(int i = 0; i < 3; i++){
		if(s[i] =='o')
			sum += 100;
	}
	printf("%d\n",sum);
}

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N+1);
	vector<int> B(N);
	for(auto &i:A)cin >> i;
	for(auto &i:B)cin >> i;
	
	long long ans=0;
	for(int i=0;i<N;i++){
		ans+=min(A[i],B[i]);
		B[i]-=A[i];
		if(B[i]>0){
			ans+=min(A[i+1],B[i]);
			A[i+1]=max(0,A[i+1]-B[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    priority_queue<ll> pq;
    for(int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        pq.push(x);
    }

    while(m) {
        ll top = pq.top(); pq.pop();
        m--;
        pq.push(top/2);
    }

    ll soma = 0;
    while(!pq.empty()) {
        ll top = pq.top(); pq.pop();
        soma += top;
    }
    cout << soma << endl;
}


Measured memory_bytes: 1400
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        t: usize
    }
    println!("{}", b * (t / a));
}


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

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

  string s;
  cin >> s;
  
  int count = s.size() - 2;
  
  string ans = s.at(0) + to_string(count) + s.at(s.size() - 1);
  
  cout << ans << endl;

  return 0;
}


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

using namespace std;
#define ll long long int
bool a[100];

int main(){
  int n,l;
  cin >> n >> l;
  vector < string > s(n); 
  for ( int i = 0; i < n; ++ i ) cin >> s[i];

  for ( int i = 0; i < n; ++i ) {
    int temp = 0;
    for ( int k = 0; k < n; ++k ){
      if ( a[k] == false ) {
        temp = k;  
        break;
      }
    }
    for ( int j = 0; j < n; ++j ){
      if( s[j] < s[temp] && a[j] == false && a[temp] == false){
        temp = j;
      }
    }
    a[temp] = true;
    cout << s[temp] ;
    //cout << "--------" << endl;
    //cout << "i = " << i << endl;
    //cout << "temp = " << temp << endl;

  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int n,i,j,k;
	cin >> n;
        i=n;
        while(1){
		j=i%n;
		k=i%2;
		if(j!=0)i+=n-j;
		else if(k!=0)i++;
		else break;
        }
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
/*  ***  In The Name of God ... ***  */
                                      /* Yani mishe mnm shakh sham ? ...  */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bug() cout << "BUG" << endl ;
#define X first
#define Y second
#define sz(x) (int)x.size()
#define per(how) cout << fixed << setprecision(how)
#define bit(a , b) (a >> b) & 1
#define all(v) v.begin() , v.end()
#define LB(x) (x & -x)
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 , MOD = 1e9 + 7 , SQRT = 350 ;
inline void smin(ll &x , ll y) { x = min(x , y) ; }
inline void smax(ll &x , ll y) { x = max(x , y) ; }


const ll MAXN = 2e5 + 100 ; 
ll n , a[MAXN] ; 

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ; 
	for(ll i = 1 ; i <= n ; i++)		cin >> a[i] ; 
	if(n & 1)
	{
		for(ll i = n ; i >= 1 ; i -= 2)		cout << a[i] << " " ; 
		for(ll i = 2 ; i <= n ; i += 2)		cout << a[i] << " " ; 
		cout << endl ; 
		return 0 ; 
	}
	for(ll i = n ; i >= 2 ; i -= 2)		cout << a[i] << " " ; 
	for(ll i = 1 ; i <= n - 1 ; i += 2)		cout << a[i] << " " ; 
	cout << endl ; 
	return 0 ; 
}




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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

#define pow abcdef

int pow(int a, int b) {
  if (b < 0) return 1;
  if (b == 0) return 1;
  int t = pow(a, b / 2);
  t *= t;
  if (b % 2) return a * t;
  return t;
}

void MAIN() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < (1 << (n - 1)); i++) {
    int t = s[0] - '0';
    for (int j = 1; j < n; j++) {
      if ((i >> (j - 1)) & 1) {
        ans += t;
        t = s[j] - '0';
      } else {
        t = t * 10 + (s[j] - '0');
      }
    }
    ans += t;
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3656
MOD = 1000000007

N, M = map(int, input().split())
S = [int(s) for s in input().split()]
T = [int(s) for s in input().split()]

m = [[0] * (M + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, M + 1):
        if S[i-1] == T[j-1]:
            m[i][j] = m[i - 1][j] + m[i][j - 1] + 1
            m[i][j] %= MOD
        else:
            m[i][j] = m[i - 1][j] + m[i][j - 1] - m[i - 1][j - 1]
            m[i][j] %= MOD
print((m[N][M] + 1) % MOD)


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

typedef long long lint;

lint dp[100010][2];
int a[100010],n;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	dp[0][0]=a[0]; dp[0][1]=-1e9;
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][0])+a[i];
		dp[i][1]=max(dp[i-1][1]-a[i]+2*a[i-1],dp[i-1][0]-2*a[i-1]-a[i]);
	}
	cout<<max(dp[n-1][0],dp[n-1][1]);
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int N;

string S;

vector<int> V[3], P;

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

	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') { V[0].push_back(i); }
		else if (S[i] == 'G') { V[1].push_back(i); }
		else { V[2].push_back(i); }
	}

	long long int ans = 0;

	for (int i = 0; i <= 2; i++) { P.push_back(i); }

	do {
		int I = P[0], J = P[1], K = P[2];

		for (int n = 0; n < (int) V[I].size(); n++) {
			int u = V[I][n];
			auto it = lower_bound(V[J].begin(), V[J].end(), u);
			for (; it != V[J].end(); it++) {
				auto itr = lower_bound(V[K].begin(), V[K].end(), *it);
				ans += (V[K].end() - itr);
			}
		}
		//for (auto y : P) { cout << " " << y; } cout << endl;
	} while (next_permutation(P.begin(), P.end()));


	for (int M = 0; M <= N-1; M++) {
		for (int i = 0; i + 2 * M + 2 < N; i++) {
			if ((S[i] != S[i + M + 1]) && ( S[i + M + 1] != S[i + 2 * M + 2]) && (S[i]!=S[i+2*M+2])) { ans--; }
		}
	}


	cout << ans << endl;

	return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <cctype>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string s;
    cin >> s;
    bool ok = true;
    int cnt = 0;
    for (int i = 0; i < (int)s.size(); i++){
        if (i == 0){
            if (s[i] != 'A'){
                ok = false;
            }
        } else if (2 <= i && i <= (int)s.size() - 2){
            if (s[i] == 'C'){
                cnt++;
            } else {
                if (!islower(s[i])){
                    ok = false;
                }
            }
        } else {
            if (!islower(s[i])){
                ok = false;
            }
        }
    }
    if (cnt != 1){
        ok = false;
    }
    if (ok){
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }






    return 0;
}


Measured memory_bytes: 504
#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
#define MOD 1000000007
using namespace std;


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

    long a[105]={0};
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }

    ll mn=LINF;
    long k;
    for(k=-100; k<=100; k++) {
        ll sum=0;
        for(i=0; i<n; i++) {
            sum += (k-a[i])*(k-a[i]);
        }
        mn=MIN(mn,sum);
    }
    printf("%lld\n", mn);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
int N,X,sum_m,m,min_m=INF;
int cunt;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    cin>>N>>X;
    for(int i=0;i<N;i++){
        cin>>m;
        sum_m+=m;
        if(min_m>m)min_m=m;
    }
    
    cunt+=N;
    
    while(sum_m<=X){
        sum_m+=min_m;
        cunt++;
    }
    
    cout<<cunt-1<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define loINF (long)10000000000
#define shINF (short)10000
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(a, b) ((a) < (b) ? (a) : (b))
using namespace std;
typedef vector<long> VL;
typedef vector<VL> VVL;

VVL dist;

short Warshall_Floyd(long V){
	// 頂点は 0 ~ V 
	REP(i,V+1) dist[i][i] = 0;	//初期化
	FOR(i,0,V){
		FOR(j,0,V){
			FOR(k,0,V){
				if (dist[j][i] == loINF || dist[i][k] == loINF) continue;
				dist[j][k] = MIN(dist[j][k],dist[j][i] + dist[i][k]);
				if (dist[j][j] < 0) return (-1);
			}
		}
	}
	return 0;
}

int main(void){
	long V,E;	//頂点数,辺数
	cin >> V >> E;

	dist = VVL(V+1,VL(V+1,loINF));

	REP(i,E){
		long v1,v2,dis;
		cin >> v1 >> v2 >> dis;
		dist[v1][v2] = dis;
	}
	if (Warshall_Floyd(V) == (-1)) cout << "NEGATIVE CYCLE" << endl;
	else {
		REP(i,V){
			REP(j,V){
				if (dist[i][j] == loINF) cout << "INF";
				else cout << dist[i][j];
				if (j != V-1) cout << " ";
			}
			cout << "\n";
		}
	}
	return 0;
}


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

// @@ !! LIM(f:nnDivCeil)
// --> f:nnDivCeil
// ---- inserted function nnDivCeil from util.cc
// Natural Number Division and Ceiling
ll nnDivCeil(ll x, ll y) {
  return (x + (y - 1)) / y;
}
// ---- end nnDivCeil
// @@ !! LIM  -- end mark --

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> C, S, F;
  for (ll i = 0; i < N-1; i++) {
    ll c, s, f; cin >> c >> s >> f;
    C.push_back(c);
    S.push_back(s);
    F.push_back(f);
  }
  for (ll i = 0; i < N; i++) {
    ll t = 0;
    for (ll j = i; j < N-1; j++) {
      ll t1 = nnDivCeil(t, F.at(j)) * F.at(j);
      if (t1 < S.at(j)) t1 = S.at(j);
      t = t1 + C.at(j);
    }
    cout << t << "\n";
  }

  return 0;
}



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

#define fast ios_base::sync_with_stdio; cin.tie(0); cout.tie(0)
#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
//#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{fast;
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 #endif
 ll t=1,n;
 //cin>>t;
 while(t--)
 {cin>>n;
  vll v(n);
  rep(i,0,n){
    cin>>v[i];
  }
  ll ans=0;
  sort(all(v));
  queue<ll> q;
  ll i=n-2;
  q.push(v[n-1]);
  while(i>=0){
    ll x=q.front();
    q.pop();
    ans+=x;
    q.push(v[i]);
    q.push(v[i]);
    i--;
  }
  cout<<ans<<endl;
 }
 return 0;
}


Measured memory_bytes: 6360
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        ArrayList<Integer> l = new ArrayList<>();
        for (int i=0; i<n; i++) {
            int lx = sc.nextInt();
            l.add(lx);
        }
        Collections.sort(l,Collections.reverseOrder());
        int ans =0;
        for (int i=0; i<k; i++) {
            ans += l.get(i);
        }
        
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 35692
A,B = map(float,input().split())
A = int(A)
buf = 0
bbuf = B - int(B)
for i in range(int(B)) :
    buf += A
bbuf = round(bbuf,4)
cbuf = 0
for i in range(int(bbuf * 100)) :
    cbuf += A
cbuf = cbuf // 100
print(buf + cbuf)

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

int dp[2222][2222];
int R[2222][2222];
int S,N,M;
const int INF = (1000000009);

void update(int &a,int b){
  a = min( a, b );
}

int solvek(){
  fill( dp[0],dp[M+1], INF );
  dp[0][0] = 0;
  for(int i=1;i<=M;i++){
    int kid = i-1;
    for(int j=i;j<=N;j++){
      while( kid < j && dp[i][j] > dp[i-1][kid] + R[j][kid] ){
        update( dp[i][j], dp[i-1][kid] + R[j][kid] );        
        kid++;
      }
      kid--;     
    }
  }
  return dp[M][N];
}
int solve(){
  fill( dp[0],dp[M+1], INF );
  dp[0][0] = 0;
  for(int i=1;i<=M;i++){
    for(int j=1;j<=N;j++){
      for(int kid=0;kid<j;kid++)
        update( dp[i][j], dp[i-1][kid] + R[j][kid] );     
    }
    for(int j=0;dp[i][j]!=0;j++)
      dp[i][j] = 0;
  }
  return dp[M][N];
}

int main(){
  cin >> S >> N >> M;
  int X[2222],Y[2222];
  for(int i=0;i<S;i++) cin >> X[i];
  
  for(int i=0;i<N;i++){
    int t,p; cin >> t >> p; p--;
    Y[i] = t-X[p];
  }

  sort( Y,Y+N );

  for(int i=0;i<N;i++){
    int sum = 0;
    //cout << " y " << Y[i] << endl;
    for(int j=i;j>-1;j--){
      sum += Y[i] - Y[j];
      R[i+1][j] = sum;
      //cout << "[ " << j << ", " << i+1 << " ) = " << R[i+1][j] << endl;
    }
  }

  cout << solve() << endl;
  
}

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    string S;
    cin >> S;
    int cnt = 0;
    rep(i, S.length()) { cnt += S[i] == 'x'; }
    if (cnt > 7) { cout << "NO" << endl; }
    else { cout << "YES" << endl; }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int n;
	while(cin >> n) {
		if(n == 0) {
			cout << 1 << endl;
		}
		else if(n == 1) {
			cout << 2 << endl;
		}
		else if(n == 2) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
# -*- coding: utf-8 -*-
import sys;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
a = [x for x in map(int, input().split())]
#n, y = map(int, input().split())

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
print(a, file=sys.stderr)

#surfixes = ("dream", "dreamer", "erase", "eraser")

def doit(l):
  #print(s, file=sys.stderr)
  if l == 0:
    return True;
  for x in surfixes:
    if s[:l].endswith(x):
#      return doit(l-len(x))
      if doit(l-len(x)):
        return True
  return False

try:
  if a[0] > 12:
    print("%d" % a[1])
  elif a[0] > 5:
    print("%d" % (a[1]/2))
  else:
    print("0")
except Exception as e:
  print(e, file=sys.stderr)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int cnt[100002];
int n, a;

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) {
		cin >> a;
		++cnt[a];
		++cnt[a + 1];
		if (a != 0) ++cnt[a - 1];
	}
	int res = 0;
	REP(i, 100001) res = max(res, cnt[i]);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
def main():
    X, N = map(int, input().split())
    if N == 0:
        print(X)
        return

    P = list(map(int, input().split()))

    if not X in P:
        print(X)
        return
    
    for i in range(1, 10000):
        if not X-i in P:
            print(X-i)
            return
        if not X+i in P:
            print(X+i)
            return

main()


Measured memory_bytes: 61932
module ch
  implicit none
  type char
     character(10)      :: chara
  end type char
  type(char),allocatable :: namec(:)
  type(char),allocatable :: namecmax(:)
end module ch
program main
   
  use ch, only : namec, namecmax

  implicit none
  integer :: n
  integer, allocatable :: s(:)
  integer :: i,j,k, maxvals
  
  read(*,*) n
  allocate( s(n) )
  allocate( namec(n) )
  do i = 1, n
    read(*,*) namec(i)%chara
  end do

  call quicksort1( 1, n ) 

  j = 0 
  do i = 1, n
    if( namec(i)%chara /= namec(i+1)%chara ) then
      j = j + 1
    end if 
  end do

  print*,j

end program main
recursive subroutine quicksort1( first, last )

  use ch, only : namec, namecmax

  implicit none
  integer,intent(in)::first,last
  !
  ! Original
  ! https://gist.github.com/t-nissie/479f0f16966925fa29ea
  !
  character(100)::x,t
  integer::i,j

  x = namec((first+last)/2)%chara
  i = first
  j = last
  do
     do while ( LGT( x, namec(i)%chara ) )
        i=i+1
     end do
     do while ( LGT( namec(j)%chara, x ) )
        j=j-1
     end do
     if (i >= j) exit
     t = namec(i)%chara
     namec(i)%chara = namec(j)%chara
     namec(j)%chara = t
     i=i+1
     j=j-1
  end do
  if (first < i-1) call quicksort1( first, i-1  )
  if (j+1 < last)  call quicksort1( j+1  , last )

  return

end subroutine quicksort1


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;
  char c = '.';
  rep(i, n) {
    if (c != s[i]) {
      c = s[i];
      ans++;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 512
from math import gcd
from collections import deque
# = map(int, input().split())
N = int(input())
A = deque(map(int, input().split()))
mA = max(A)
counter = [0 for _ in range(mA+1)]
primenum = [2]
sgn = [-1 for _ in range(int(mA**0.5)+1)]
k = 3
while k**2 <= mA:
  if sgn[k] == -1:
    primenum.append(k)
    add = k*k
    ok = k
    while ok**2 <= mA:
      sgn[ok] = 1
      ok += add
  k += 2
#prime_num が用意されているとき
def factorization(n):
  M = n
  for p in primenum:
    if p**2 > M:
      break
    else:
      if M%p == 0:
        if counter[p] == 0:
          counter[p] = 1
        else:
          return False
        while M%p == 0:
          M //= p

  if M > 1:
    if counter[M] == 0:
      counter[M] = 1
    else:
      return False
  return True



g = A[0]
flag = True
for k in range(N):
  a = A.popleft()
  g = gcd(g, a)
  if flag:
    flag = factorization(a)
  if flag == False:
    if g == 1:
      break


if flag:
  print('pairwise coprime')
  exit()
if g == 1:
  print('setwise coprime')
else:
  print('not coprime')


Measured memory_bytes: 215580
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define erep(i, a, b) for (int i = a; i <= (int)(b); ++i)
#define per(i, a, b) for (int i = (b); i > (a); --i)
#define eper(i, a, b) for (int i = ((int)(a)); i >= b; --i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
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; }
template <typename T>
class union_find
{
    static const ll MAX_N = 100005;
    vector<T> par, rank;
  public:
    union_find(size_t n)
    {
        par.reserve(n + 1);
        rank.reserve(n + 1);
    }

  public:
    void init(T n)
    { // add a set
        rep(i, 0, n + 1)
        {
            par[i] = i;
            rank[i] = 0;
        }
    }

  public:
    T find(T x)
    { // find the parent of x
        if (par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

  public:
    void unite(T x, T y)
    { // unite x and y
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y])
            par[x] = y;
        else
            par[y] = x;
        if (rank[x] == rank[y])
            rank[x]++;
    }

  public:
    bool same(T x, T y)
    { // compare x's parent and y's parent
        return find(x) == find(y);
    }
};
ll n, k, l;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k >> l;
    union_find<ll> road(n);
    union_find<ll> train(n);
    road.init(n);
    train.init(n);
    rep(i, 0, k)
    {
        ll p, q;
        cin >> p >> q;
        road.unite(p, q);
    }
    rep(i, 0, l)
    {
        ll p, q;
        cin >> p >> q;
        train.unite(p, q);
    }
    map<P, ll> m;
    erep(i, 1, n) { m[mp(road.find(i), train.find(i))]++; }
    erep(i, 1, n)
    {
        cout << m[mp(road.find(i), train.find(i))];
        if (i == n)
            cout << '\n';
        else
            cout << " ";
    }
    return 0;
}


Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vll a(m), b(m);
    priority_queue<pll, vector<pll>, greater<pll> > pq;
    rep(i, m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        pq.emplace(a[i], b[i]);
    }
    ll ans = 1;
    ll bmin = INF;
    while(!pq.empty()){
        pll e = pq.top();
        pq.pop();
        if(e.first >= bmin){
            bmin = e.second;
            ans++;
        }else{
            chmin(bmin, e.second);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int main() {
  string s;
  cin >> s;
  if (s == "1") {
    puts("Hello World");
  } else {
    int x, y;
    scanf("%d%d ", &x, &y);
    printf("%d\n", x+y);
  }
  return 0;
}

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

using Graph = vector<vector<int> >;

void bfs(const Graph &G, vector<int> &dist, int start) {
    dist[start] = 0;
    queue<int> q;
    q.push(start);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int i = 0; i < (int)G[v].size(); i++) {
            int next_v = G[v][i];
            if (dist[next_v] != -1) continue;
            dist[next_v] = dist[v] + 1;
            q.push(next_v);
        }
    }
}

void print(vector<int> &dist, int n) {
    for (int i = 0; i < n; i++) {
        cout << i + 1 << " " << dist[i] << endl;
    }
}

int main() {
    int n;
    cin >> n;
    Graph G(n);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            v--;
            G[u].push_back(v);
        }
    }

    vector<int> dist(n, -1);

    bfs(G, dist, 0);

    print(dist, n);

    return 0;
}


Measured memory_bytes: 3156
using System;

namespace _0057
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string now = Console.ReadLine();
                if (now == null)
                {
                    break;
                }
                int n = int.Parse(now);
                int output = 1;
                for (int i = 1; i <= n; i++)
                {
                    output += i;
                }
                Console.WriteLine(output);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9152