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

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

    vector<int> kushi;
    for (int i = 0; i < in * 2; i++) {
        int k;
        cin >> k;
        kushi.push_back(k);
    }
    sort(kushi.begin(), kushi.end(), greater<int>());

    int sum = 0;
    for (int i = 0; i < in * 2; i = i + 2) {
        auto m = min(kushi.at(i), kushi.at(i + 1));
        sum += m;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
using namespace std;

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
#define     PW2(a)          (long long)1<<a


vector<long long> vc;
multimap<long long, int> mp;
int main()
{
    long long i,j,k,l,m,n,o,p,q,r,tst,ans=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>k;
        vc.push_back(k);
    }
    for(i=0; i<n; i++)
    {
        auto it=mp.lower_bound(vc[i]-1);
        if(it==mp.end())
        {
            if(mp.size()) { it--; mp.erase(it); }
            mp.insert({vc[i],i});

        }
        else if(it->first==vc[i]-1)
        {
            mp.erase(it);
            mp.insert({vc[i],i});
        }
        else if(it==mp.begin())
            mp.insert({vc[i],i});
        else
        {
            it--;
            mp.erase(it);
            mp.insert({vc[i],i});
        }

//        for(auto K: mp)
//        cout<<K.first<<'-'<<K.second<<' ';
//        cout<<endl;
    }


    cout<<mp.size()<<endl;
    return 0;
}

//5, 2, 6, 4, 3


Measured memory_bytes: 7284
price :: [Int] -> Int
price = iter 0 [] where
    iter m l [] = div m 2 + sum l
    iter m l (x:xs)
        | x > m     = iter x (m:l) xs
        | otherwise = iter m (x:l) xs

readData :: Int -> IO [Int]
readData 0 = return []
readData n = do
    x <- readLn :: IO Int 
    fmap (x:) $ readData (n-1)
        
main :: IO() 
main = do
    n <- readLn :: IO Int
    l <- readData n
    let ans = price l 
    print ans
    

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
int H, W;
cin >> H >> W;

char S[H + 2][W + 2];
bool flag = true;
for(int i = 1; i <= H; i++){ 
     for(int j = 1; j <= W; j++) cin >> S[i][j];
}

for(int i = 1; i <= H; i++){ 
     for(int j = 1; j <= W; j++) {
         if(S[i][j] == '#'){
             if (S[i][j] == '#' && S[i][j - 1] != '#' && S[i - 1][j] != '#' && S[i][j + 1] != '#' && S[i + 1][j] != '#') flag = false;
         }
     }
}


if(flag) yes;
else no;

}

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



int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    
    int cnt = 0;
    
    for (int i=0; i*R<=N; i++) {
        for (int j=0; i*R+j*G<=N; j++) {
            if ((N-i*R-j*G) % B == 0) cnt++;
        }
    }
    
    cout << cnt << endl;
}

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

using namespace std;
int a[100];
int main(){
	int n;
		int now=0;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		if(a[i]!=i) now++;
	}
	if(now>2){
		puts("NO");return 0;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 256
import heapq

n = int(input().strip())
a = list(map(int, input().split()))
pre = a[:n]
heapq.heapify(pre)
suf = list(map(lambda x: -x, a[(2 * n):]))
heapq.heapify(suf)
left = {}
right = {}
pre_sum = sum(pre)
suf_sum = -sum(suf)
left[n - 1] = pre_sum
right[2 * n] = suf_sum
for i in range(n, 2 * n):
    heapq.heappush(pre, a[i])
    pre_sum = pre_sum + a[i] - heapq.heappop(pre)
    left[i] = pre_sum
for i in range(2 * n - 1, n - 1, -1):
    heapq.heappush(suf, -a[i])
    suf_sum = suf_sum + a[i] + heapq.heappop(suf)
    right[i] = suf_sum
ans = -float('inf')
for i in range(n - 1, 2 * n):
    ans = max(ans, left[i] - right[i + 1])
print(ans)


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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() 
{
	

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    string s,a="s",b="es";
	cin>>s;
	if(s.back()=='s')
		s.append(b);
	else
		s.append(a);
	cout<<s<<endl;

}

Measured memory_bytes: 3668
import bisect
N = int(input())
n_list = list(map(int, input().split()))

n_list.sort()
while(len(n_list) > 1):
    min_n = n_list[0]
    for i in range(1, len(n_list)):
        n_list[i] = n_list[i] % min_n
    n_list.sort()
    index = bisect.bisect(n_list, 0)
    n_list = n_list[index:]
    # print(n_list)

print(n_list[0])


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

int main(int argc, char *argv[]){
  int A,B;
  cin>>A;
  cin>>B;
  int sum=0;
  int count=0;
  while(true){
    if(B==1) break;
    sum+=A;
    count++;
    if(sum<B){
      sum=sum-1;
      
      continue;
    }
    else if(sum>=B) break;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
n,m=map(int, input().split())
a=1
b=0
while b==0:
    for i in range(int(m**0.5)*10,1,-1):
        if m%i==0 and m>=(i*n):
            a*=i
            m=m//i
            break
    else:b=1
print(a)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll n;
const int k=100010;
const int maxn=200020;
int seg[5000010];
int a[100010];
int a2[100010];
int b[100010];

void postavi(int t, int l, int r)
{
    seg[t]=0;
    if(l==r) return;
    int mid=(l+r)/2;
    postavi(2*t,l,mid);
    postavi(2*t+1,mid+1,r);
}

void update(int t, int l,int r, int x)
{
    seg[t]++;
    if(l==r) return;
    int mid=(l+r)/2;
    if(x<=mid) update(2*t,l,mid,x);
    else update(2*t+1,mid+1,r,x);
}

ll sum(int t, int l, int r, int L, int R)
{
    if(l>R || L>r)
        return 0;
    if(l>=L && r<=R)
        return seg[t];
    int mid=(l+r)/2;
    return sum(2*t,l,mid,L,R)+sum(2*t+1,mid+1,r,L,R);
}

ll cnt(int br)
{
    ll sol=0;
    for(int i=0;i<n;i++)
        if(a[i]>=br) b[i]=1;
        else b[i]=-1;
    for(int i=1;i<n;i++)
        b[i]+=b[i-1];
    postavi(1,1,maxn);
    update(1,1,maxn,k);
    for(int i=0;i<n;i++)
    {
        sol+=sum(1,1,maxn,1,b[i]+k);
        update(1,1,maxn,b[i]+k);
        //if(a[i]>=br && i>0) sol++;
    }
    return sol;
}


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

	cin>>n;
	for(int i=0;i<n;i++)
        cin>>a[i];

	for(int i=0;i<n;i++)
        a2[i]=a[i];

    sort(a2,a2+n);

    int l=0;
    int r=n-1;
    ll m=(n*(n+1))/2;

    /*cout<<m<<" "<<(m+1)/2<<endl;
    for(int i=0;i<n;i++)
        cout<<a2[i]<<" "<<cnt(a2[i])<<endl;*/

    while(l<r)
    {
        int sr=(l+r+1)/2;
        if(cnt(a2[sr])>=(m+1)/2)
            l=sr;
        else
            r=sr-1;
    }

    cout<<a2[l];

	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const int INF = 1LL << 30;
int main(){
    int a,b,m;
    cin >> a >> b >> m;
    vector<int> A(a), B(b);
    rep(i,a) cin >> A[i];
    rep(i,b) cin >> B[i];
    int mina = INF, minb = INF;
    rep(i,a) chmin(mina, A[i]);
    rep(i,b) chmin(minb, B[i]);
    int mn = mina + minb;
    rep(mi,m){
        int x,y,c;
        cin >> x >> y >> c;
        x--; y--;
        chmin(mn,A[x]+B[y]-c);
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 1024
a,b=map(int,input().split())
m=1e10
for i in range(1,a):
    l=[i*b,(a-i)*(b//2),(a-i)*(b-b//2)]
    if sum(l)==a*b:
        m=min(m,max(l)-min(l))
    o=[i*b,b*(a-i)//2,b*(a-i-(a-i)//2)]
    if sum(o)==a*b:
        m=min(m,max(o)-min(o))

for i in range(1,b):
    l=[i*a,(b-i)*(a//2),(b-i)*(a-a//2)]
    if sum(l)==a*b:
        m=min(m,max(l)-min(l))
    o=[i*a,a*(b-i)//2,a*(b-i-(b-i)//2)]
    if sum(o)==a*b:
        m=min(m,max(o)-min(o))
        
print(m)


Measured memory_bytes: 3064
#include <stdio.h>
#include <cmath>
#include <math.h>
#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;


struct Info{
	char word[16],length,T;
};

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

bool is_match(char left,char right){

	if(left >= 97)left -= 32;
	if(right >= 97)right -= 32;

	return left == right;
}

int main(){

	int N,H;
	scanf("%d %d",&N,&H);

	Info info[N];
	int tmp_length;
	for(int i = 0; i < N; i++){
		scanf("%s %d",info[i].word,&info[i].T);
		for(tmp_length = 0; info[i].word[tmp_length] != '\0'; tmp_length++);
		info[i].length = tmp_length;
	}

	char buf[16];
	strcpy(buf,info[0].word);

	int word_index = 0;
	int loc = 0; //?¬????????????´???

	char resp[2];

	int true_num = 0,wrong_num = 0;

	while(true){

		printf("? %s\n", buf); fflush(stdout);
		scanf("%s",resp);

		if(is_match(buf[loc],resp[0])){ //??£?§£
			buf[loc++] = '_';
			true_num++;
			if(loc == info[word_index].length){ //?????????????????????????????´???
				if(word_index == N-1){ //????????????????????´???
					//printf("! Game Clear %.1lf\n", (double)true_num*100.0/(double(true_num+wrong_num))); fflush(stdout);
					printf("! Game Clear %.1lf\n", floor((double)true_num/(true_num+wrong_num)*1000)/10); fflush(stdout);
					return 0;
				}else{ //?¬?????????????
					word_index++;
					loc = 0;
					strcpy(buf,info[word_index].word);
				}
			}
		}else{
			wrong_num++;
			info[word_index].T--;
			if(info[word_index].T == -1){ //??????????????????????????°????¶?????????´???
				if(H == 1){
					printf("! Game Over\n"); fflush(stdout);
					return 0;
				}else{
					H--;
					//?¬?????????????
					if(word_index == N-1){ //????????????????????´???
						//printf("! Game Clear %.1lf\n", (double)true_num*100.0/(double(true_num+wrong_num))); fflush(stdout);
						printf("! Game Clear %.1lf\n", floor((double)true_num/(true_num+wrong_num)*1000)/10); fflush(stdout);
						return 0;
					}else{ //?¬?????????????
						word_index++;
						loc = 0;
						strcpy(buf,info[word_index].word);
					}
				}
			}
		}
	}

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const ll INF = 1ll<<61;

struct BellmanFord {
private:
    int N;
    vvii E;

    void init(int n) {
        E.resize(0); E.clear();
        N = n; E.resize(n);
    }

public:
    BellmanFord() {}
    BellmanFord(int n) { init(n); }

    void add(int from, int to, int cost) {
        E[from].push_back(ii(to, cost));
    }

    vi solve(int s) {
        vi ret(N, INF);
        ret[s] = 0;
        REP (rep, N-1) {
            REP (n, N) if (ret[n] < INF) FORE (e, E[n]) {
                CHMIN(ret[e.first], ret[n] + e.second);
            }
        }

        vector<bool> isInf(N);
        REP (rep, N) {
            REP (n, N) if (ret[n] < INF) FORE (e, E[n]) {
                if (isInf[n] || ret[e.first] > ret[n] + e.second) {
                    isInf[e.first] = true;
                }
            }
        }

        REP (i, N) if (isInf[i]) ret[i] = -INF;

        return ret;
    }
};

const int MAX = 2525;

ll N, M, P;
vii edges[MAX];

ll solve() {
    BellmanFord bf(N);
    REP (i, N) FORE (e, edges[i]) {
        bf.add(i, e.first, P - e.second);
    }

    ll res = bf.solve(0)[N-1];
    if (res == -INF) return -1;
    else if (res > 0) return 0;
    return -res;
}

int main() {
    cin >> N >> M >> P;
    REP (i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edges[a].push_back(ii(b, c));
    }
    cout << solve() << endl;
}

Measured memory_bytes: 640
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n;
    cin >> n;
    int num[] = {n%10, n%100/10, n%1000/100, n/1000};
    int t[10] = {};
    rep(i, 10){
        for(int a : num){
            if(a == i){
                t[i]++;
            }
        }
    }
    bool flag = false;
    rep(i, 10){
        if(t[i] == 3 && (num[0] != num[3])) flag = true;
        if(t[i] == 4) flag = true;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

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

  for (int i = 0; i < s.size(); i++) {
    int index = s[i] + N - 'A';
    s[i] = alpha[index % 26];
  }

  cout << s << endl;
  return 0;
}


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

using namespace std;

const int N = 1e5+7;

int n, m, v, p;
int a[N];
long long s[N];

int main()
{
    cin >> n >> m >> v >> p;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a+1, a+n+1);
    reverse(a+1, a+n+1);
    for (int i = 1; i <= n; ++i) s[i] = s[i-1]+a[i];
    int res = p;
    while (res < n && a[res+1] == a[p]) ++res;
    while (res < n) {
        int i = res+1;
        if (a[i]+m < a[p]) break;
        // add m to [1, p-1] and i
        long long now = 1ll*p*m;
        // add m to [i+1, n]
        now += 1ll*(n-i)*m;
        // add  [p, i-1] to <= a[i]+m
        now += 1ll*(i-p)*(a[i]+m)-(s[i-1]-s[p-1]);
        if (now < 1ll*m*v) break;
        ++res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1536
let () =
  let n = read_int () in
  for _ = 0 to n - 1 do
    let (x1, y1, x2, y2, x3, y3) = Scanf.scanf "%f %f %f %f %f %f " (fun x1 y1 x2 y2 x3 y3 -> x1, y1, x2, y2, x3, y3) in
    let a11 = 2. *. (x2 -. x1) in
    let a12 = 2. *. (y2 -. y1) in
    let a21 = 2. *. (x3 -. x2) in
    let a22 = 2. *. (y3 -. y2) in
    let b1 = x2 *. x2 +. y2 *. y2 -. x1 *. x1 -. y1 *. y1 in
    let b2 = x3 *. x3 +. y3 *. y3 -. x2 *. x2 -. y2 *. y2 in
    let det = a11 *. a22 -. a12 *. a21 in
    let x = a22 /. det *. b1 -. a12 /. det *. b2 in
    let y = a11 /. det *. b2 -. a21 /. det *. b1 in
    (x1 -. x) ** 2. +. (y1 -. y) ** 2.
    |> sqrt
    |> Printf.printf "%.3f %.3f %.3f\n" x y
  done

Measured memory_bytes: 2404
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n-1,0,-1):
    a[i] = sum(a[i::i+1]) % 2
a[0] = sum(a) % 2
ans = []
for i in range(n):
    if a[i] == 1:
        ans.append(i+1)
print(len(ans))
if len(ans) != 0:
    print(' '.join(map(str,ans)))

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

int main() {
	int s;
	cin >> s;
	int result = 0;
	int temp = s / 100;
	result += temp;
	s -= 100 * temp;
	temp = s / 10;
	result += temp;
	s -= 10 * temp;
	result += s;
	cout << result << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
s=list(input())
t=list(input())
change_st=defaultdict(int)
change_ts=defaultdict(int)
for i in range(len(s)):
    if change_st[s[i]]==0:
        change_st[s[i]]=t[i]
    else:
        if change_st[s[i]]!=t[i]:
            print("No")
            break
    if change_ts[t[i]]==0:
        change_ts[t[i]]=s[i]
    else:
        if change_ts[t[i]]!=s[i]:
            print("No")
            break
else:
    print("Yes")
        


Measured memory_bytes: 12460
def func(x, y)
  mod = 1000000007
  return 1 if  y == 0
  return func(x, y / 2) ** 2 % mod if y % 2 == 0
  return func(x, (y - 1) / 2) ** 2 * x % mod
end

m, n = gets.split(' ').map(&:to_i)
puts func(m,n)



Measured memory_bytes: 6868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//---------------------------------------------------------------------------------------------------
ll MOD = 1000000007;
ll f[101010], rf[101010];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < 101010; i++) f[i] = (f[i - 1] * i) % MOD;
    for(int i = 0; i < 101010; i++) rf[i] = inv(f[i]);
}
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * bc) % MOD;
}
//---------------------------------------------------------------------------------------------------

int main()
{
    init();
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    int left = 0;
    int right = 0;
    for(int i = 0; i < n+1; i++)
    {
        ll b;
        cin >> b;
        if(a[b] == 0)
        {
            a[b] = i+1;
        }
        else
        {
            left = a[b];
            right = i+1;
        }
    }
    int all = left + n - right;
    cout << n << endl;
    for(int k = 2; k <= n+1; k++)
    {
        ll sum = C(n+1, k);
        ll dec = 0;
        if(all >= k-1)
        {
            dec = C(all, k-1);
        }
        cout << (sum-dec+MOD) % MOD << endl;
    }
}


Measured memory_bytes: 3584
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

a,b,x=MI()
ans=b//x-(a-1)//x
print(ans)
    

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

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}


#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main() 
{
    fast();
    string s;
    cin>>s;
    if(s[0]>='A' && s[0]<='Z')
        cout<<"A\n";
    else
        cout<<"a\n";
}


Measured memory_bytes: 3608
from collections import defaultdict
from bisect import *

N = int(input())
S = input()
idx = defaultdict(list)

for i in range(N):
    idx[int(S[i])].append(i)

ans = 0

for i in range(1000):
    n1 = i//100
    n2 = (i-n1*100)//10
    n3 = (i-n1*100-n2*10)
    
    if len(idx[n1])==0:
        continue
    
    m1 = bisect_right(idx[n2], idx[n1][0])
    
    if m1==len(idx[n2]):
        continue
    
    m2 = bisect_right(idx[n3], idx[n2][m1])
    
    if m2==len(idx[n3]):
        continue
    
    ans += 1

print(ans)

Measured memory_bytes: 40304
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int retdigit(int s)
{
	int d = 1;

	while (s / 10 != 0) {
		s /= 10;
		d++;
	}

	return d;
}

int mypow(int x, int y)
{
	int r = 1;

	rep(i, y) {
		r *= x;
	}

	return r;
}

int vec_sum(vector<int> vec)
{
	int sum = 0;

	rep(i, vec.size()) {
		sum += vec[i];
	}

	return sum;
}

int main()
{
	while (true) {
		int t, s;

		cin >> t >> s;

		if (t == 0 && s == 0) {
			break;
		}

		int digit = retdigit(s);
		int dif = 10000000;
		int ans;
		bool errorflag = true;
		bool rejectflag = false;
		vector<int> ans_splits;

		rep(i, (1 << (digit - 1))) {
			int temp = s;
			vector<int> splits;
			int count = 0;

			rep(j, digit - 1) {
				if ((i >> j) % 2 == 1) {
					splits.push_back(temp%mypow(10, count + 1));
					temp /= mypow(10, count + 1);
					count = 0;
				}
				else {
					count++;
				}
			}

			splits.push_back(temp);

			int split_sum = vec_sum(splits);

			if (split_sum > t) {
				continue;
			}
			
			if (t - split_sum < dif) {
				dif = t - split_sum;
				ans = split_sum;
				ans_splits = splits;
				errorflag = false;
				rejectflag = false;
			}
			else if (t - split_sum == dif) {
				rejectflag = true;
			}
		}

		if (errorflag == true) {
			cout << "error" << endl;
		}
		else if (rejectflag == true) {
			cout << "rejected" << endl;
		}
		else {
			cout << ans;

			for (int i = ans_splits.size() - 1; i >= 0; i--) {
				cout << " " << ans_splits[i];
			}

			cout << endl;
		}

	}
	
	return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
    int n,m;
    int a;
    cin>>n>>m;
    vector<ll> dp(n+1,0);
    vector<bool> issafe(n+1,true);
    for(int i=0;i<m;i++)
    {
        cin>>a;
        issafe[a] = false;
    }
    dp[0] = 1;
    if(issafe[1]) dp[1] = 1;

    for(int i=2;i<=n;i++)
    {
        if(issafe[i-1]) dp[i]+=dp[i-1];
        if(issafe[i-2]) dp[i]+=dp[i-2];
        dp[i] = dp[i]%1000000007;
    }
    cout<<dp[n]<<endl;
}


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

int main(){
  int N,ans=0,count=0;
  cin>>N;
  for(int i=1;i<=N;i++){
   if(i%2==1){
     for(int j=1;j<=i;j++)
      if(i%j==0)
        count++;
   }
   if(count==8)
    ans++;
   count=0;
  }
  cout <<ans<<endl;
}


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

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

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  int c[N][N];
  REP(i,N){
    REP(j,N)c[i][j]=0;
  }
  REP(i,M){
    int a,b;
    cin>>a>>b;
    c[a-1][b-1]=1;
    c[b-1][a-1]=1;
  }
  stack<pair<int,vector<int> > > s;
  vector<int> v;
  s.push(make_pair(0,v));
  int ans=0;
  while(!s.empty()){
    pair<int,vector<int> > p=s.top();
    s.pop();
    int pi=p.first;
    vector<int> pv=p.second;
    pv.push_back(pi);
    if(pv.size()==N)ans++;
    REP(i,N){
      if(c[pi][i] and find(ALL(pv),i)==pv.end()){
        s.push(make_pair(i,pv));
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<stdio.h>
#include<string.h>


using namespace std;

int main() {	
	char input[1001] = { 0 };
	int inputlen = 0,number=0,SON=0;
	while (scanf("%s", input) == 1) {
		if (input[0] == '0')break;
		inputlen = strlen(input);
		for (int i = 0; i < inputlen; i++) {
			if (48 <= input[i] && input[i] <= 57) {
				number = input[i] - 48;
			}
			SON += number;
		}
		printf("%d\n", SON);
		SON = 0;
	}
	return 0;
}

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

int main() 
{
	int a,b=0;
	cin >> a;
	vector<int>x(a);
	for (int i = 0; i < a; i++)
	{
		cin >> x[i];
	}

	for (int i = 0; i < a; i++)
	{
		if (x[i] % 2 == 0)
		{
			if (x[i] % 3 == 0 || x[i]%5==0)
			{

			}
			else
			{
				b++;
			}
		}
	}

	if (b > 0)
	{
		cout << "DENIED" << endl;;
	}
	else
	{
		cout << "APPROVED"<<endl;
	}
	



}


Measured memory_bytes: 3128
def main():

    N, M = map(int, input().split())
    sc = []
    for _ in range(M):
        s, c = map(int, input().split())
        sc.append([s, c])

    start = pow(10, N-1)
    if N == 1: start = 0
    
    for v in range(start, pow(10, N)):
        t = str(v)
        if all(t[s-1] == str(c) for s, c in sc):
            return v
    return -1

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
ll n;
vector<ll> r(100), c(100);
vector<vector<ll> > dp(101, vector<ll>(101, -1));
int dfs(int v, int w) {
    // cout << v << ":" << w << endl;
    if(dp[v][w] != -1) {
        return dp[v][w];
    } else {
        ll tmp = INT_MAX / 3;
        for(int i = v + 1; i < w; i++) {
            tmp = min(tmp, dfs(v, i) + dfs(i, w) + r[v] * r[i] * c[w - 1]);
        }
        dp[v][w] = tmp;
        return tmp;
    }
}
int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> r[i] >> c[i];
    }
    for(int i = 0; i < n; i++) {
        dp[i][i] = 0;
        dp[i][i + 1] = 0;
    }
    dfs(0, n);
    cout << dp[0][n] << endl;
}


Measured memory_bytes: 3236
using System;

namespace ConsoleApplication17
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            if (a < b){
                Console.WriteLine("a < b");
            }
            else if (a > b){
                Console.WriteLine("a > b");
            }
            else if( a == b ){
                Console.WriteLine("a == b");
            }
         }
     }
    
}

Measured memory_bytes: 8716
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int n;
    cin >> n;
    map<int, ll> mp;
    rep(i, n) {
        ll tmp_num;
        cin >> tmp_num;
        ++mp[tmp_num];
    }
    ll ans = 0;
    for ( auto tmp_mp : mp ) {
        if ( tmp_mp.first > tmp_mp.second ) {
            ans += tmp_mp.second;
        }
        else {
            ans += tmp_mp.second - tmp_mp.first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6272
using System;

class Program {
    static void Main() {
        for (string line; (line = Console.ReadLine()) != "0";) {
            var n = int.Parse(line);
            var ages = new int[7];

            for (var i = 0; i < n; i++) {
                var age = int.Parse(Console.ReadLine());
                ages[age >= 60 ? 6 : (age / 10)] ++;
            }

            foreach (var count in ages) {
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 9220
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		String line;
		String[] data;
		while (sc.hasNext() == true) {
			line = sc.nextLine();
			
			data = line.split(",");
			
			int[] cards = new int[data.length];
			for (int i = 0; i < data.length; i++) {
				cards[i] = Integer.parseInt(data[i]);
			}
			Arrays.sort(cards);
			
			int pre = 0;
			boolean straight = true;
			
			int[] point = new int[14];
			for (int i = 0; i < cards.length; i++) {
				int tmp = cards[i];
				point[tmp]++;
				
				if (pre != 0) {
					if ((pre + 1) != tmp) {
						if ((pre != 1) || (tmp != 10)) straight = false;
					}
				}
				pre = tmp;
			}
			
			int[] judge = new int[5];
			for (int i = 0; i < point.length; i++) {
				judge[point[i]]++;
			}
			
			if (judge[4] == 1) {
				System.out.println("four card");
			} else if ((judge[2] == 1) && (judge[3] == 1)) {
				System.out.println("full house");
			} else if (judge[1] == 5) {
				if (straight == true) System.out.println("straight");
				else System.out.println("null");
			} else if (judge[3] == 1) {
				System.out.println("three card");
			} else if (judge[2] == 2) {
				System.out.println("two pair");
			} else if (judge[2] == 1) {
				System.out.println("one pair");
			} else {
				System.out.println("null");
			}
		}
	}
}

Measured memory_bytes: 25912
#include <bits/stdc++.h> 
    #include <ext/pb_ds/assoc_container.hpp> // Common file  
    #include <ext/pb_ds/tree_policy.hpp>  
    #include <functional>
    #include <unistd.h>
    using namespace std; 
    using namespace std::chrono; 
    using namespace __gnu_pbds;
    typedef tree<int, null_type, less<int>, rb_tree_tag,  
                tree_order_statistics_node_update>  
        ordered_set;  
    #define ll long long int 
    ll brr[200005];
    void addEdge(vector<ll> adj[], ll u, ll v) 
    { 
        adj[u].push_back(v); 
        adj[v].push_back(u); 
    } 
     
int main() 
{ 
	ll n;
	cin>>n;
	vector<ll>v;
	map<ll,ll>m;
	set<ll>s;
	for(ll i=0,temp;i<n;i++){
			cin>>temp;
			s.insert(temp);
			v.push_back(temp);
			m[temp]++;
	} 
	ll final1=0;
	for(auto x:s){
		ll x1=m[x];
		final1+=(x1*(x1-1))/2;
	}
	for(ll i=0;i<n;i++){
		cout<<final1-m[v[i]]+1<<" ";
	}
	cout<<endl;
	//cout<<final1<<endl;
	
  return 0; 
} 


Measured memory_bytes: 18544
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    string S;
    while(1) {
        cin >> S;
        if(S.at(0) == '0')
            break;
        int t = 0;
        rep(i, S.length()) t += S.at(i) - '0';
        cout << t << endl;
    }
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    int A[1000];
    A[0]=0;
    for(int i=1;i<1000;i++){
        A[i]=A[i-1]+i;
    }
    int a,b;
    cin >> a >> b;
    int s=b-a;
    cout << A[s]-b << endl;
}

Measured memory_bytes: 3548
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
 
NodePointer listSearch(int key){
  NodePointer n;
  n=nil->next;
  while(n!=nil && n->key!=key){
    n = n->next;
  }
  return n;
}
 
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
 
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer t){
 t->prev->next = t->next;
 t->next->prev = t->prev;
 free(t);
}
 
void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}
 
void deleteLast(){
  NodePointer n=nil->prev;
  if(n==nil) return;
  deleteNode(n);
}
 
void delete(int key){
  NodePointer x;
  x = listSearch(key);
  if( x == nil ) return;
  deleteNode(x);
}
 
 
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next=x;
  x->prev = nil;
}
 
int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {
      insert(key); 
      np++; 
      size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); 
	nd++; 
      }
      size--;
    }
  }
  printList();
  return 0;
}

Measured memory_bytes: 31660
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    
    int a,b;
    char op;
    
    while(1){
         cin>>a>>op>>b;
if ( op == '+' ){
cout<<a+b<<endl;
} else if ( op == '-' ){
cout<<a-b<<endl;
} else if ( op == '*' ){
cout<<a*b<<endl;
} else if ( op == '/' ){
cout<<a/b<<endl;
}
else {
  break;
}
}
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <algorithm>

int main() {

    int N, W, w, v, sum = 0;
    scanf("%d %d", &N, &W);

    long long answer[100001] = {};
    while(N--) {
        scanf("%d %d", &w, &v);
        for(int i = std::min(W - w, sum); i >= 0; --i) 
            if(answer[i + w] < answer[i] + v) answer[i + w] = answer[i] + v;
        sum += w;
        if(sum > W) sum = W;
    }

    long long ans = 0;
    for(int i = 0; i <= W; ++i)
        if(ans < answer[i]) ans = answer[i];
    printf("%lld\n", ans);

}


Measured memory_bytes: 896
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<deque>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

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

	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3652
# N, W = 3, 8
# ARR = [
#     [3, 30],
#     [4, 50],
#     [5, 60],
# ]
# #
# N, W, = 6, 15
# ARR = [
#     [6, 5],
#     [5, 6],
#     [6, 4],
#     [6, 6],
#     [3, 5],
#     [7, 2],
# ]



N,W = map(int,input().split())
ARR = []

for i in range(N):
    ARR.append(list(map(int,input().split())))

def calculate(n, w, arr):
    srr = [[0] * (w+1) for i in range(n+1)]

    for i in range(1, n + 1):
        for j in range(1, w + 1):
            if j - arr[i-1][0] >= 0:
                s1 = srr[i - 1][j]
                s2 = srr[i - 1][j - arr[i-1][0]] + arr[i-1][1]
                srr[i][j] = max(s1, s2)
            else:
                srr[i][j] = srr[i - 1][j]

    print(srr[-1][-1])

calculate(N, W, ARR)


Measured memory_bytes: 119404
N = int(input())
edges = set()
X = 10**5
if N % 2 == 1:
    for i in range(N//2):
        i_ = i+1
        j_ = N-i-1
        # print(i_,j_)
        edges.add(min(i_,j_)*X+max(j_,i_))
else:
    for i in range(N//2):
        i_ = i+1
        j_ = N-i
        # print(i_,j_)
        edges.add(min(i_,j_)*X+max(j_,i_))
        
# print(edges)

print(N*(N-1)//2-len(edges))
for i in range(N):
    for j in range(i+1,N):
        i_ = i+1
        j_ = j+1
        if i_*X + j_ in edges:
            continue
        else:
            print(i_,j_)
        

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

using namespace std;

int main () {
    while (true) {
        string str;
        cin >> str;
        
        if (str == "-") break;

        int m;
        cin >> m;
        for (int i = 0; i < m; i++) {
            int h;
            cin >> h;

            string head = str.substr(0, h);
            string tail = str.substr(h);
            str = tail + head;
        }

        cout << str << endl;
    }
}


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

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

#define LL long long
#define FI ios_base::sync_with_stdio(false); cin.tie(NULL);
#define PREC cout << setprecision(10) << fixed;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const int MX = 1e5 + 5;

int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		cout << "ACL";
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	k := nextInt()
	xlist := make([]int, n)

	for i := 0; i < n; i++ {
		xlist[i] = nextInt()
	}

	run := 0
	for i := 0; i < n; i++ {
		x := xlist[i]

		// 近い線判定
		run += 2 * min(x, k-x)
	}

	fmt.Println(run)

}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	int n, k;

	std::cin >> n >> k;

	std::vector<long long> v(n);

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v[i];
	}

	long long sum = 0;

	for (size_t i = 0; i < n; i++)
	{
		if (v[i] < k - v[i]) {
			sum += v[i] * 2;
		}
		else {
			sum += (k - v[i]) * 2;
		}
	}

	std::cout << sum << std::endl;

	return 0;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  int ans = (A+B)/2;
  if((A+B)%2==0){
    cout << ans << endl;
  } 
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	int a,b,c,d;
	a=n%10;n/=10;
	b=n%10;n/=10;
	c=n%10;n/=10;d=n;
	//cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
	if(a==b||b==c||c==d) cout<<"Bad";
	else cout<<"Good";
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
const int N = 105;
int a[N];
void solve() {  
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (i % 2 and a[i] % 2)
            ++ans;
    }
    cout << ans;
}       

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	char a[105],b[105];
	cin >> n;
	scanf("%s",a);
	scanf("%s",b);
	for(int i=0;i<n;i++){
		printf("%c%c",a[i],b[i]);
	}
	cout << endl;
	return 0;
} 

Measured memory_bytes: 256
import numpy as np
import collections

N = int(input())
A = list(map(int, input().split()))
ans = 0
dists_A2i = []

for i in range(1, N+1):
    dist_A2i = A[i-1] - i
    dists_A2i.append(dist_A2i)

dists_A2i = np.array(dists_A2i)
dists_median = np.median(dists_A2i)
dists_A2i = abs(dists_A2i - dists_median)
ans = sum(dists_A2i)
print(int(ans))


Measured memory_bytes: 34160
#include<bits/stdc++.h>
#define INF 2147483640
using namespace std;
int main()
{
	//freopen("out.txt","w",stdout);
	long long a,ans=0,b=0;
	string k;
	cin >> a >> k;
	b=((k[2]-'0')*10+(k[3]-'0'))*a;
	cout << a*(k[0]-'0') + (b/100);
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r, D, x2000;
  cin >> r >> D >> x2000;
  int x = x2000;
  for (int i = 0; i < 10; i++) {
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
    ll x,y; cin >> x >> y;
    ll ans = 0;
    ll num = x;
    while (num <= y){
        ans++;
        num *= 2;
    }
    print(ans);
}


Measured memory_bytes: 256
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for a, b, c in zip(A, B, C):
    if a != b and b != c and c != a:
        ans += 2
    elif a == b and b == c and c == a:
        pass
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3060
# include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N = 105;
const i64 INF = 1e9;
const int MOD = 323232323;

vector<int> E[N];
int edge[N][2], dep[N], dee[N];
i64 ans = INF, node;

int dfs(int x, int fa, int d) {
    int sz = 0;
    for (auto i: E[x]) {
        if (i == fa) continue;
        ++sz;
        dfs(i, x, d + 1);
    }
    dep[d] = max(dep[d], sz);
}
int main ()
{
    int n, u, v;
    scanf("%d", &n);
    for (int i = 1; i < n; ++i) scanf("%d %d", &edge[i][0], &edge[i][1]), E[edge[i][0]].push_back(edge[i][1]), E[edge[i][1]].push_back(edge[i][0]), ++dee[edge[i][0]], ++dee[edge[i][1]];
    for (int i = 1; i <= n; ++i) {
        memset(dep, -1, sizeof(dep));
        dfs(i, 0, 1);
        i64 tmp = 1;
        int p = -1;
        for (int i = n; i >= 1; --i) {
            if (dep[i] != -1 && p == -1) p = i;
            if (dep[i] != -1 && p != -1 && i < p) {
                tmp = tmp * dep[i];
            }
        }
        if (dee[i] == 1) ++tmp;
        if (ans > p) ans = p, node = tmp;
        else if (ans == p) node = min(node, tmp);
    }
    for (int i = 1; i < n; ++i) {
        u = edge[i][0]; v = edge[i][1];
        memset(dep, -1, sizeof(dep));
        dfs(u, v, 1); dfs(v, u, 1);
        i64 tmp = 1;
        int p = -1;
        for (int i = n; i >= 1; --i) {
            if (dep[i] != -1 && p == -1) p = i;
            if (dep[i] != -1 && p != -1 && i < p) {
                tmp = tmp * dep[i];
            }
        }
        if (ans > p) ans = p, node = tmp * 2;
        else if (ans == p) node = min(node, tmp * 2);
    }
    printf("%lld %lld", ans, node);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[4], t[4];
int main () {
	scanf("%s%s", s, t);
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i]) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    d = defaultdict(int)
    ans = 0
    for _ in range(N):
        S=str(sorted(ST()))
        ans += d[S]
        d[S]+=1
    print(ans)
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 108504
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){

    string S;
    int zero=0,one=0;

    cin >> S;

    int len = S.length();
    
    REPI(len){
        if(S[i]=='0')
            zero++;
        else
            one++;                        
    }
    
    cout << min(zero,one)*2 << endl;
    
    return 0;

}




Measured memory_bytes: 512
def bubbleSort(a, n)
  flag = 0
  for i in 0...n
    for j in 1..(n-i-1)
      if a[n-j] < a[n-j-1]
        a[n-j], a[n-j-1] = a[n-j-1], a[n-j]
        flag += 1
      end
    end
  end
  puts a.join(' '), flag
end

n = gets.to_i
a = gets.split(" ").map(&:to_i)
bubbleSort(a, n)



Measured memory_bytes: 6868