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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    /* Credits: Thomas Draper */
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1){
        if (*--itr1 < *itr2){
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            rotate(itr1,j,last);
            while (last != j){
                ++j;
                ++itr2;
            }
            rotate(k,itr2,last);
            return true;
        }
    }
    rotate(first,k,last);
    return false;
}

int main(void){
    int N,M,Q; cin >> N >> M >> Q;
    int v[Q][4]; REP(i,Q)REP(j,4) cin >> v[i][j];

    VI c(N+M-1); REP(i,N+M-1) c[i] = i;
    ll ans = 0;
    do{
        VI a(N);
        REP(i,N) a[i] = c[i]+1-i;

        ll tmp = 0;
        REP(i,Q){
            if(a[v[i][1]-1] - a[v[i][0]-1] == v[i][2]) tmp += v[i][3];
        }
        chmax(ans, tmp);
    }while(next_combination(c.begin(), c.begin()+N, c.end()));

    cout << ans << en;
    return 0;
}

Measured memory_bytes: 3628
from collections import Counter
from itertools import combinations

N = int(input())
S = [input()[0] for _ in range(N)]
counts = Counter([c for c in S if c in "MARCH"])
ans = 0
if counts:
    for c in combinations("MARCH", 3):
        ans += counts[c[0]] * counts[c[1]] * counts[c[2]]
print(ans)


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
N, T = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

max_diff = 0
max_value = A[-1]
for i in range(N-2, -1, -1):
    if A[i] > max_value:
        max_value = A[i]
        buf = [i]
    elif A[i] == max_value:
        pass
    else:
        max_diff = max(max_diff, max_value - A[i])


indices = set()
buf = [N-1]
max_value = A[-1]
for i in range(N-2, -1, -1):
    if A[i] > max_value:
        max_value = A[i]
        buf = [i]
    elif A[i] == max_value:
        pass
    else:
        if max_value - A[i] == max_diff:
            indices.add(i)

# print(indices)
print(len(indices))


Measured memory_bytes: 60968
#include<iostream>
#include<cstdio>

using namespace std;

long long ans;
int n;

int main() {
	cin >> n;
	for(register int i=1;i<=n;++i)
		if ((i % 3) != 0 && (i % 5) != 0)
			ans += i;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=5e3+7;
const int mod=1e9+7;
int f[maxn][2];
int dp[maxn][2];
int main()
{
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    if(a>b) swap(a,b);
    dp[0][0]=dp[0][1]=1;
    f[0][1]=1;
    for(int i=0;i<=b+1;i++)
    {
        for(int j=a;i+j<=b+1;j++)
            f[i+j][1]=(f[i+j][1]+f[i][0])%mod;
        for(int j=1;i+j<=b+1;j++)
            f[i+j][0]=(f[i+j][0]+f[i][1])%mod;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<a&&i+j<=n;j++)
            dp[i+j][0]=(dp[i+j][0]+dp[i][1])%mod;
        for(int j=1;j<b&&i+j<=n;j++)
        {
            dp[i+j][1]=(dp[i+j][1]+(ll)dp[i][0]*f[j+(i==0)+(i+j==n)][0]%mod)%mod;
        }
    }
    int tot=1;
    for(int i=1;i<=n;i++) tot=tot*2%mod;
    print((tot-(dp[n][0]+dp[n][1])%mod+mod)%mod);
}

Measured memory_bytes: 3672
#!/usr/bin/env python3
import sys


def solve(N: int, i: int):
    print(N-i+1)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    i = int(next(tokens))  # type: int
    solve(N, i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as BS
main=do
 [n,m]<-map (read . BS.unpack) . BS.words <$> BS.getLine
 a<-map (read . BS.unpack) . BS.words <$> BS.getLine
 cb<-replicateM m ((\x->(x!!1,x!!0)).map (read . BS.unpack) . BS.words <$> BS.getLine)
 print(f n m (reverse(sort cb)) (reverse(sort a)) 0)
  where f 0 _ _ _ i = i
        f n 0 _ a i = i+(sum(take n a))
        f n m ((c,0):cb) a i = f n (m-1) cb a i
        f n m ((c,b):cb) (j:a) i = if c>j then(f(n-1)m((c,b-1):cb)(j:a)(i+c))else(f(n-1)m((c,b):cb)a(i+j))

Measured memory_bytes: 92028
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

LL gcd(LL a, LL b) {
  return b ? gcd(b, a%b) : a;
}

bool go() {
  LL A, B, C, D;
  scanf("%lld%lld%lld%lld", &A, &B, &C, &D);

  if (A < B) return false;

  LL g = gcd(B, D);
  B /= g;
  D /= g;
  if (C % g >= A % g) {
    C /= g;
  } else {
    C /= g;
    --C;
  }

  return D >= B && C+1 >= B;
}

int main() {
  // ios_base::sync_with_stdio(0);

  int T;
  scanf("%d", &T);
  while (T--) {
    printf(go() ? "Yes\n" : "No\n");
  }
}


Measured memory_bytes: 256
def geti; gets.to_i end
def getis; gets.split.map &:to_i end
def getin n;  n.times.map{geti}  end
def getisn n; n.times.map{getis} end
YES = "YES"; NO = "NO"; Yes = "Yes"; No = "No";

a,b,c = getis
p [a,b,c].any?(&:even?) ? 0 : [a*b,b*c,c*a].min

__END__

a,b=getis
puts a > 0 ? 'Positive' : b >= 0 ? 'Zero' : (b - a) % 2 == 1 ? 'Positive' : 'Negative'


Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main() {
	int n; std::cin >> n;
	std::vector<std::pair<int, int>> edges;
	if (n % 2 == 0) {
		for (auto i = 1; i <= n; ++i) {
			for (auto j = i + 1; j <= n; ++j) {
				if (i + j != n + 1) {
					edges.emplace_back(i, j);
				}
			}
		}
	}
	else {
		for (auto i = 1; i < n; ++i) {
			for (auto j = i + 1; j <= n; ++j) {
				if (i + j != n) {
					edges.emplace_back(i, j);
				}
			}
		}
	}
	std::cout << edges.size() << std::endl;
	for (auto &e: edges) {
		std::cout << e.first << " " << e.second << std::endl;
	}
}

Measured memory_bytes: 384
n = gets.to_i
abs = []
(n-1).times {
  abs << gets.split.map {|x| x.to_i}
}
cs = gets.split.map {|x| x.to_i}

cs.sort!

edges = []
eedges = []
(n+1).times {
  edges << []
  eedges << []
}
#p edges
abs.each { |ab|
  edges[ab[0]] << ab[1]
  edges[ab[1]] << ab[0]
}

act = []
edges.each_with_index { |v,i|
  if v.size == 1
    act << i
  end
}

d = []
csi = 0
while act.size > 0
  next_act = []
  #p act
  #p edges
  #p eedges
  act.each { |i|
    d[i] = cs[csi]
    csi += 1
    if edges[i].size - eedges[i].size > 0
      j = (edges[i] - eedges[i]).first
      #p j
      #edges[j].delete(i)
      eedges[j] << i
      if (edges[j].size - eedges[j].size == 1)
        next_act << j
      end
    end
  }
  act = next_act
end
#p d

def min(x,y)
  return x > y ? y : x
end
sum = 0
abs.each { |ab|
  sum += min(d[ab[0]],d[ab[1]])
}

puts sum
d.shift
puts d.join(" ")


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int res[10], a[10], n, a1, b1, p[10], q[10], vis[10], cnt;
 
bool same(int a[], int b[]) {
	bool ok = true;
	forn(i, n) {
		ok &= (a[i] == b[i]);
	}
	return ok;
}
void dfs(int po) {
	if (po == n) {
		++cnt;
		if (same(res, p)) {
			a1 = cnt;
		}
		if (same(res, q)) {
			b1 = cnt;
		}
		return;
	}
	forn(i, n) {
		if (!vis[i]) {
			vis[i] = 1;
			res[po++] = a[i];
			dfs(po);
			--po;
			vis[i] = 0;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	ms(vis, 0);
	cnt = 0;
	cin >> n;
	forn(i, n) {
		cin >> p[i];
		a[i] = p[i];
	}
	forn(i, n) {
		cin >> q[i];
	}
	sort(a, a + n);
	dfs(0);
	cout << abs(a1 - b1) << '\n';
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())

Y = X

if X < 0:
    X = -X

i = 0
posA = X % D
posB = posA - D
i = X // D + 1

if K >= i:
    if K % 2 == i % 2:
        print(abs(posB))
    else:
        print(abs(posA))
else:
    print(abs(X-D*K))

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

const long long MOD = 1000000007;

typedef long long ll;
ll powmod(ll x, ll y){
    ll res = 1;
    for(ll i=0;i<y;i++){
        res=res*x%MOD;
    }
    return res;
}


void solve(long long N){
    ll tmp =  powmod(10,N) - powmod(9,N) - powmod(9,N) + powmod(8,N);
    tmp%=MOD;
    tmp = (tmp + MOD)%MOD;
    cout << tmp << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main()
{
	vector<int64_t> ps;
	ps.emplace_back(2);
	for (int64_t i = 3; i <= 55555; i += 2)
	{
		bool f = true;
		for (auto &p : ps)
		{
			f &= 0 < i % p;
		}
		if (f)
		{
			ps.emplace_back(i);
		}
	}
	int n;
	cin >> n;
	int count = 0;
	for (auto &p : ps)
	{
		if (p % 5 == 1)
		{
			cout << p << ' ';
			count++;
		}
		if (count == n)
		{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
char str[1000];

int main(){
	scanf("%s",str);
	for(int i=0;i<strlen(str);i++){
		str[i]-=3;
		if(str[i]<65)str[i]+=26;
	}
	printf("%s\n",str);
	return 0;
}

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

int main(){
  int h,w;

  cin >> h >> w;

  vector<string> name(h);

  for(int i=0;i<h;i++){
    cin >> name.at(i);
  }

  for(int i=0;i<w;i++){
    if(i==0)
      cout << "#";
    cout << "#";
    if(i == w-1)
      cout << "#" ;
  }
  
  cout << endl;
  
  for(int j=0;j<h;j++){
    cout << "#" << name.at(j) << "#" << endl;
  }

  for(int i=0;i<w;i++){
    if(i == 0)
      cout << "#";
    cout << "#";
    if(i == w-1)
      cout << "#" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0){
        cout<<(a+b)/2<<endl;
    }
    
    else if((a+b)%2!=0){
        cout<<"IMPOSSIBLE"<<endl;
    }
    
}


Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
int anyDigitSum(int n) {
	int res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}

void Solve() {

	string s;
	cin >> s;
	if (s.size() == 3) {
		reverse(s.begin(), s.end());
		
	}
	cout << s;
	cout << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int n,a,b;
  scanf("%d %d %d", &n, &a, &b);
  if( (b) >= (n*a)) {
      printf("%d\n", n*a);
  } else {
       printf("%d\n", b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,i,k;
   cin>>n;
   int a[n],sum=0;
   for(i=0;i<n;i++)
   {
       cin>>a[i];
       sum+=a[i];
   }
   float s,m;
   s=float(sum)/n;
   m=abs(a[0]-sum);
   k=0;
   for(i=0;i<n;i++)
   {
       if(m>abs(float(a[i])-s))
       {
           m=abs(float(a[i])-s);
           k=i;
       }
   }
   cout<<k<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
   int n;int d;cin>>n>>d;
   int ans=0;
   for(int i=1;i<=n;i++)
   {
       int x;int y;cin>>x>>y;
       int dist=x*x + y*y;
       if(dist<=(d*d))
       ans++;
   }
   cout<<ans<<endl;
    
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
      t=1;
    while(t--)
    solve();
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  ll n, m;
  cin >> n >> m;
  vector<ll> v(n);
  ll sum = 0;
  rep(i, n) {
    cin >> v[i];
    sum += v[i];
  }

  sort(all(v), greater<ll>());

  ll res = 0;

  rep(i, m) {
    debug(v[i]);
    if (v[i] * (m * 4) >= sum) {
      res++;
    }
  }

  if (res == m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int tax(int p, int x){
	return p*(double)(100+x)/(double)100;
}

int main(){
	int x, y, s;
	while(cin >> x >> y >> s, x+y+s){
		int ret = 0;
		rep(i, 1010)rep(j, 1010){
			if(i == 0 || j == 0) continue;
			if(tax(i, x)+tax(j, x) == s) ret = max(ret, tax(i, y)+tax(j, y));
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 1160
#line 1 "main_c.cpp"
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

#line 2 "/home/imperi/cp-library/lib/UnionFind/UnionFind.hpp"

#include <cstddef>
#line 6 "/home/imperi/cp-library/lib/UnionFind/UnionFind.hpp"

class UnionFind {
 public:
  using size_t = std::size_t;

 private:
  std::vector<size_t> par, sz;
  size_t group;

 public:
  UnionFind(size_t n = 0) : par(n, 0), sz(n, 1), group(n) {
    std::iota(par.begin(), par.end(), 0);
  }

  size_t root(size_t n) {
    if (par[n] == n) return n;
    return par[n] = root(par[n]);
  }

  bool unite(size_t a, size_t b) {
    a = root(a);
    b = root(b);
    if (a == b) return false;
    group--;
    if (sz[a] < sz[b]) std::swap(a, b);
    sz[a] += sz[b];
    par[b] = a;
    return true;
  }

  size_t size() { return par.size(); }
  size_t groups() { return group; }
  size_t group_size(size_t n) { return sz[root(n)]; }

  bool same(size_t a, size_t b) { return root(a) == root(b); }
};
#line 85 "main_c.cpp"

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

  i64 n,m;
  std::cin>>n>>m;

  UnionFind uni(n);

  rep(i,0,m){
    i64 a,b;
    std::cin>>a>>b;
    a--;b--;
    uni.unite(a,b);
  }

  std::cout<<uni.groups()-1<<"\n";
  
  return 0;
}


Measured memory_bytes: 4748
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
using namespace std;
using ll = long long;

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

	cout << n - i + 1 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 4e5 + 9;

int n, h[N], t, S, Sa[N], Sb[N], i, j, Ta[N], Tb[N];
long long ans = 8e18;

struct pa { int a, b; }p[N];
bool operator < (const pa &A, const pa &B) { return A.a < B.a; }

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d%d", &p[i].a, &p[i].b), h[++t] = p[i].a, h[++t] = p[i].b;
	sort(h + 1, h + t + 1);
	S = t = unique(h + 1, h + t + 1) - h - 1;
	for (i = 1; i <= n; ++i) {
		if (p[i].a > p[i].b) p[i].a ^= p[i].b ^= p[i].a ^= p[i].b;
		p[i].a = lower_bound(h + 1, h + t + 1, p[i].a) - h;
		p[i].b = lower_bound(h + 1, h + t + 1, p[i].b) - h;
		S = min(S, max(p[i].a, p[i].b));
	}
	sort(p + 1, p + n + 1);
	for (Sa[S + 1] = t, i = S, j = n; i; --i) for (Sa[i] = Sa[i + 1], Ta[i] = Ta[i + 1]; j && p[j].a >= i; --j) {
		if (p[j].b < Sa[i]) Sa[i] = p[j].b;
		if (p[j].a > Ta[i]) Ta[i] = p[j].a;
	}
	for (Sb[0] = t, i = 1, j = 1; i <= S; ++i) {
		for (Sb[i] = Sb[i - 1], Tb[i] = Tb[i - 1]; j <= n && p[j].a < i; ++j) {
			if (p[j].a < Sb[i]) Sb[i] = p[j].a;
			if (p[j].b > Tb[i]) Tb[i] = p[j].b;
		}
		if (1ll * (h[t] - h[min(Sb[i], Sa[i])]) * (h[max(Ta[i], Tb[i])] - h[i]) < ans) ans = 1ll * (h[t] - h[min(Sb[i], Sa[i])]) * (h[max(Ta[i], Tb[i])] - h[i]);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 10752
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005

int n,m;
int a[maxn];

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read(); int ans=0;
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	for (int i=1,j=1;i<=n;i=j){
		for (;j<=n&&a[j]==a[i];++j);
		ans+=(j-i)>=a[i]?j-i-a[i]:j-i;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define mod(d) d%1000000007
#define loop(i,s,e) for(ll i=s;i<e;i++)
#define vll vector<ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int dp[1000000];

int MinimJumpCost(ll n,ll pos,int* A){
	if(pos>=n-1)return 0;
	if(dp[pos]!=-1)return dp[pos];
	int ans1=0;
	int ans2=0;
	int ans=0;
	if(pos<n-2){
    ans1+=abs(A[pos]-A[pos+1])+MinimJumpCost(n,pos+1,A);
    ans2+=abs(A[pos]-A[pos+2])+MinimJumpCost(n,pos+2,A); 
    ans=min(ans1,ans2);
    }
    else {
    	ans+=MinimJumpCost(n,pos+1,A)+abs(A[pos]-A[pos+1]);
    }
	return dp[pos] = ans;
}

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

    memset(dp,-1,sizeof(dp));

    int* A= new int[n];
    loop(i,0,n)cin>>A[i];

    cout<<MinimJumpCost(n,0,A)<<endl;

}



Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;
 
 
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int A,B,C;
  cin >> A >> B >> C;
  if(A+B+C>21){
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    string S;
    cin >> S;
    cout << (S[0] == S[1] && S[1] == S[2] ? "No" : "Yes") << endl;
    
    return 0;
}

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

/*条件から、最大値以外の番号の出力はすべて最大値となるはず
    最大値の番号は2番目に大きい数...最大値なるものを持つ番号が2つ以上ある
    ならば全部最大値出力となる*/

int main(){
  int N, D;
  cin >> N;
  vector<pair<int, int>> element(N);        //入力情報を格納する配列

  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    element[i] = make_pair(A, i);
  }

  sort(element.begin(), element.end());   //昇順　最大値はelement[N-1]に存在

  if(element[N-2].first == element[N-1].first){       //最大値なるものが2つ
    for(int i = 0; i < N; i++)
      cout << element[N-1].first << endl;             //element[N-1]かelement[N-2]でおk
  }else{
    for(int i = 0; i < N; i++){
      if(i == element[N-1].second)                           //element[N-1]の部分だけ別の値
        cout << element[N-2].first << endl;
      else
        cout << element[N-1].first << endl;
    }
  }

  return 0;

}

Measured memory_bytes: 3200
var a,b,c,d,e,f,g,h,j,k,s,sum : longint ;
begin
 readln(k,s);
 for a:=0 to k do
  for b:=0 to k do
   begin
    if a+b=s then
     c:=0
    else if a+b<s then
     c:=s-a-b;
    if (c<=k)and(a+b+c=s) then
     begin
      sum:=sum+1;
     end;
   end;
 writeln(sum);
end.


Measured memory_bytes: 128
import java.io.*;
import java.util.*;
class Main {
	public static final int MAX = 1000000005;
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input1[] = (br.readLine()).trim().split("\\s+");
		int n = Integer.parseInt(input1[0]);
		int k = Integer.parseInt(input1[1]);
		String input2[] = (br.readLine()).trim().split("\\s+");
		int ar[] = new int[n];
		for(int i = 0; i < n; i++) {
			ar[i] = Integer.parseInt(input2[i]);
		}
		int dp[] = new int[n];
		Arrays.fill(dp, MAX);
		for(int i = n - 1; i >= 0; i--) {
			if(i == n - 1) {
				dp[i] = 0;
				continue;
			}
			for(int j = i + 1; j <= i + k; j++) {
				if(j < n) {
					dp[i] = Math.min(dp[i], dp[j] + (int) Math.abs(ar[j] - ar[i]));
				}
			}
		}
		System.out.println(dp[0]);
	}
}


Measured memory_bytes: 34860
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v) reverse(v.begin(),v.end())
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const ll MOD =1000000007;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m); 
}

int main(void){
	int N,p[20];
	cin>>N;
	REP(i,N) cin>>p[i];

	int result=0;
	FOR(i,1,N-1){
		if(p[i-1]<p[i] && p[i]<p[i+1]) result++;
		else if(p[i-1]>p[i] && p[i]>p[i+1]) result++;
	}

	print(result);
	return 0;
}


Measured memory_bytes: 256
from collections import deque
s = deque(input())
q = int(input())
li = [list(map(str, input().split())) for _ in range(q)]

flag = True
for i in range(q):
    que = li[i]
    if que[0] == '1':
        if flag:
            flag = False
        else:
            flag = True
    else:
        f = que[1]
        c = que[2]
        if flag:
            if f == '1':
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if f == '1':
                s.append(c)
            else:
                s.appendleft(c)

if flag:
    print("".join(s))
else:
    s.reverse()
    print("".join(s))




Measured memory_bytes: 119512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mo=1000000007;
int main(){
  ll a,b;
  cin>>a>>b;
  if(a<b) swap(a,b);
  if(a-b>1) cout<<0;
  else if(a==b){
    ll c=1;
    for(ll i=a;i>0;i--){
      c*=i;
      c%=mo;
    }
    for(ll i=a;i>0;i--){
      c*=i;
      c%=mo;
    }
    cout<<c*2%mo;
  }else{
    ll c=1;
    for(ll i=a;i>0;i--){
      c*=i;
      c%=mo;
    }
    for(ll i=b;i>0;i--){
      c*=i;
      c%=mo;
    }
    cout<<c;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<int> v;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		v.push_back(n);
	}
	sort(v.begin(), v.end());

	int ans = 0;
	int i = 0;
	while (i < v.size()) {
		int p = v.at(i);
		int c = 0;
		while ((i < v.size()) && (v.at(i) == p)) {
			c++;
			i++;
		}
		ans += c % 2;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3892
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>

int main(int argc, char* argv[])
{
  int a, b, c, k;
  std::vector< int > vi;
  std::vector< int >::iterator it;
  std::vector< int >::iterator max_it;

  std::cin >> a >> b >> c >> k;
  vi.push_back(a);
  vi.push_back(b);
  vi.push_back(c);

  int sum = 0;
  max_it = std::max_element(vi.begin(), vi.end());
  for (it = vi.begin(); it != vi.end(); it++) {
    int tmp = *it;
    if (max_it == it) {
      tmp *= std::pow(2, k);
    }
    sum += tmp;
  }

  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  int a[N]; rep(i,N) cin >> a[i];
  sort(a,a+N);
  ll b[N];
  bool c[N];
  rep(i,N){
    if (i==0) b[i] = a[i];
    else b[i] = b[i-1] + a[i];
    if (i<N-1 && 2*b[i]<a[i+1]) c[i] = false;
    else c[i] = true;
  }
  int cnt = 0;
  rep(i,N){
    cnt++;
    if (c[i]==false) cnt = 0;
  }
  cout << cnt << endl;




  // cout << fixed << setprecision(10);
  
  return 0;
}


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

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  vector<vector<int>> X(N + 1);
  vector<vector<int>> Y(N + 1);
  int loop = 1;
  rep(i, N) {
    cin >> A[i];
    rep(j, A[i]) {
      int x, y;
      cin >> x >> y;
      x--;
      X[i].push_back(x);
      Y[i].push_back(y);
    }
    loop *= 2;
  }
  int ans = 0;
  for (int i = 1; i < loop; i++) {
    vector<int> TrueFalse(N, -1);
    bool flag = true;
    rep(j, N) {
      bool Honest = (i & (1 << j)) ? true : false;
      // cout << "j=" << j << " Honest=" << Honest << endl;
      // rep(k, N) { cout << "TrueFalse=" << TrueFalse[k] << endl; }
      if (Honest) {
        rep(k, A[j]) {
          if (TrueFalse[X[j][k]] != -1 && TrueFalse[X[j][k]] != Y[j][k]) {
            flag = false;
            break;
          }
          TrueFalse[X[j][k]] = Y[j][k];
        }
      } else {
        // need to do something??
        rep(k, A[j]) {
          if (TrueFalse[X[j][k]] != -1 && TrueFalse[X[j][k]] == Y[j][k]) {
            // flag = false;
            // break;
          }
          // TrueFalse[X[j][k]] = (Y[j][k]) ? 0 : 1;
        }
      }
      if (!flag) break;
    }
    rep(j, N) {
      bool Honest = (i & (1 << j)) ? true : false;
      if (TrueFalse[j] != -1) {
        if (TrueFalse[j] == 0 && Honest) {
          flag = false;
          break;
        } else if (TrueFalse[j] == 1 && !Honest) {
          flag = false;
          break;
        }
      }
    }

    if (flag) {
      int tmp = 0;
      rep(j, N) {
        if (i & (1 << j)) tmp++;
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
n = N
while N != 0:
    N = N / 10
    n = n % 10

if n == 2 or n == 4 or n == 5 or n == 7 or  n == 9:
    print('hon')
elif n == 0 or n == 1 or n == 6 or n == 8:
    print('pon')
else:
    print('bon')

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

int main(){
  int a,b,c,k,count=0;
  cin >> a >> b >> c >> k;
  
  while(a>=b){
    b += b;
    count++;
  }
  while(b>=c){
    c += c;
    count++;
  }
  
  if(count <= k){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3572
//
//  main.cpp
//  L
//
//  Created by LucienShui on 2017/4/20.
//  Copyright ? 2017年 LucienShui. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>

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

using namespace std;

long long a[1005];

bool panduan(long long a) {
    while(a/10) {
        long long t = a%10;
        a /= 10;
        if(a%10!=t-1) return false;
    }
    return true;
}
int main() {
    long long n,cnt=0,result=-1,t;
    scanf("%lld",&n);
    for(long long i=0 ; i<n ; i++) scanf("%lld",a+i);
    for(long long i=0 ; i<n ; i++) {
        for(long long j=i+1 ; j<n ; j++) {
            t = a[i] * a[j];
            if(panduan(t)) result = max(t,result);
        }
    }
    printf("%lld\n",result);
    return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
const int tam = 100005;
int dp[tam];
vector< list<int> > G;

int DFS(int idx) {
    int &ans = dp[idx];
    if(ans != -1) 
        return ans;
    ans = 0;
    for(int &i: G[idx]) {
        ans = max(ans, DFS(i)+1);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, m, a, b;
    cin >> n >> m;
    G.assign(n+1, list<int>());
    memset(dp, -1, sizeof dp);
    for(int i = 1; i<=m; i++) {
        cin >> a >> b;
        G[a].push_back(b);
    }
    int ans = 0;
    for(int i=1; i<=n; i++) {
        if(dp[i] == -1) {
            ans = max(ans, DFS(i));
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6656
import operator
from collections import deque
N, d = map(int, input().split())
P = [list(map(int, input().split())) for i in range(N)]
P.sort(key=operator.itemgetter(2))
xd_min = deque()
xd_max = deque()
yd_min = deque()
yd_max = deque()
s = -1; t = 0
ans = 0
while t < N:
    t0 = t
    while t < N-1 and P[t][2] == P[t+1][2]:
        t += 1
    b = P[t][2]
    while b - P[s+1][2] > d:
        s += 1

    while xd_min and xd_min[0][0] <= s:
        xd_min.popleft()
    while xd_max and xd_max[0][0] <= s:
        xd_max.popleft()
    while yd_min and yd_min[0][0] <= s:
        yd_min.popleft()
    while yd_max and yd_max[0][0] <= s:
        yd_max.popleft()

    for i in range(t0, t+1):
        x, y, b = P[i]
        while xd_min and x <= xd_min[-1][1]:
            xd_min.pop()
        xd_min.append((i, x))
        while xd_max and xd_max[-1][1] <= x:
            xd_max.pop()
        xd_max.append((i, x))
        while yd_min and y <= yd_min[-1][1]:
            yd_min.pop()
        yd_min.append((i, y))
        while yd_max and yd_max[-1][1] <= y:
            yd_max.pop()
        yd_max.append((i, y))

    r = (xd_max[0][1] - xd_min[0][1]) * (yd_max[0][1] - yd_min[0][1])
    ans = max(ans, r)

    t += 1
print(ans)


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

#define int             long long
#define	ll				long long

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";
long long prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}

int lcm(int a, int b)
{
	return (a / gcd(a, b)) * b;
}

int fastExponentiation(int n, int x, int modulo)
{
	int res = 1;
	while(x > 0)
       {
          if(x & 1)
          res = (res*n) % modulo;
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res;
}

int power(int n , int p )
{
	if(p==0)
	   return 1;

	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;

	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i);
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;

   	else if(x>=n || y>=m)
       return false;

   	else
   		return true;
}

int sod(int n)
{
	int sum=0;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	return sum;
}



void solve()
{
	int n,a=0,b=0,c=0,d=0;
	cin>>n;
	for(int i=0;i<n;i++){
		string h;cin>>h;
		if(h=="AC")
		a++;
		else if(h=="WA")
		b++;
		else if(h=="TLE")
		c++;
		else
		d++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
				
}

int32_t main()
{

	//int t; cin>>t; while(t--)
	solve();

	return 0;
}


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

using namespace std;

int main()
{
    long long n,i,j,x,y,k;
    cin >> n >> k;
    long long dp[100001]={0};
    vector<long long> v;
    for(i=0;i<n;i++){
        cin >> x; v.push_back(x);
    }
    dp[1]=abs(v[1]-v[0]);
    for(i=2;i<n;i++){
        dp[i]=dp[i-1]+abs(v[i]-v[i-1]);
        for(j=2;j<=min(k,i);j++){
            dp[i]=min(dp[i], dp[i-j]+abs(v[i]-v[i-j]));
        }
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 2168
#include <iostream>

int main()
{
    int a, b, c;
    int ans = 0;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    while (a <= b) {
        if (c % a == 0) {
            ans++;
        }
        a++;
    }
    std::cout << ans << std::endl;
    return 0;
}

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

int main() {
  string a;
  cin >> a;
  int digits = 0;
  for(int i = 0; i < a.size(); i++){
    int d = a[i]-'0';
    digits += d;
  }
  if(digits % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    char S[4]; cin >> S;
 
    for(int i=0; i<3; i++){
        if(S[i]==S[i+1]){
            cout<< "Bad" << endl;
            return 0;
        }
    }
 
    cout << "Good" << endl;
 
}

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

vector<int> norm(vector<int> C) {
  vector<int> res = C;
  for (int i = 0; i < 4; ++i) {
    bool f = false;
    for (int j = 0; j < 4; ++j) {
      if (res[j] > C[j]) f = true;
      if (res[j] < C[j]) break;
    }

    if (f) res = C;
    rotate(C.begin(), C.begin() + 1, C.end());
  }

  return res;
}

int equ(vector<int> C) {
  if (C[0] == C[2] && C[1] == C[3]) {
    if (C[0] == C[1])
      return 4;
    else
      return 2;
  }
  return 1;
}

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

  vector<vector<int>> C;
  map<vector<int>, int64_t> cnt;
  for (int i = 0; i < N; ++i) {
    vector<int> c(4);
    for (auto &j : c) cin >> j;
    c = norm(c);
    cnt[c]++;
    C.push_back(c);
  }

  int64_t ans = 0;
  for (int i = 0; i < N; ++i) {
    cnt[C[i]]--;

    for (int j = 0; j < i; ++j) {
      cnt[C[j]]--;

      for (int k = 0; k < 4; ++k) {
        vector<vector<int>> hp(4);
        hp[0] = norm({C[i][1], C[i][0], C[j][1], C[j][0]});
        hp[1] = norm({C[i][2], C[i][1], C[j][0], C[j][3]});
        hp[2] = norm({C[i][3], C[i][2], C[j][3], C[j][2]});
        hp[3] = norm({C[i][0], C[i][3], C[j][2], C[j][1]});

        int64_t add = 1;
        if (cnt.count(hp[0]) && cnt.count(hp[1]) && cnt.count(hp[2]) && cnt.count(hp[3])) {
          for (int l = 0; l < 4; ++l) {
            add *= equ(hp[l]) * cnt[hp[l]];
            cnt[hp[l]]--;
          }

          ans += add;

          for (int l = 0; l < 4; ++l) {
            cnt[hp[l]]++;
          }
        }

        rotate(C[j].begin(), C[j].begin() + 1, C[j].end());
      }

      cnt[C[j]]++;
    }

    cnt[C[i]]++;
  }

  cout << ans / 3 << endl;
}


Measured memory_bytes: 256
def solve()

end

n, m = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
x.sort!

d = [m-1]
for i in 0...(m-1)
    d[i] = x[i+1] - x[i]
end
d.sort!

if m <= n
    puts 0
else
    ans = x[m-1] - x[0]
    for i in 0...(n-1)
        ans -= d[m-2-i]
    end
    puts ans
end



Measured memory_bytes: 9848
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79428
class Graph(object):

    class Edge:
        def __init__(self, to: int, cost: int):
            self.to = to
            self.cost = cost

        def __str__(self):
            return "Edge: (to " + str(self.to) + ", cost " + str(self.cost) + ")"

        def __repr__(self):
            return self.__str__()

    INF = 10e10

    def __init__(self, node_n: int):
        self.node_n = node_n
        self.edges = [{} for _ in range(self.node_n)]
        self.dist = [self.INF for _ in range(self.node_n)]

    def set_edge(self, from_pos: int, to_pos: int, cost: int, reversible: bool) -> None:
        self.edges[from_pos][to_pos] = self.Edge(to_pos, cost)
        if reversible:
            self.edges[to_pos][from_pos] = self.Edge(from_pos, cost)

    def solve(self) -> list:
        raise NotImplementedError


class WarshallFloyd(Graph):
    def solve(self) -> None:
        for via_p in range(self.node_n):
            for from_p in range(self.node_n):
                for to_p in range(self.node_n):
                    if via_p in self.edges[from_p].keys() and to_p in self.edges[via_p].keys():
                        alt = self.edges[from_p][via_p].cost + self.edges[via_p][to_p].cost
                        if to_p not in self.edges[from_p]:
                            self.edges[from_p][to_p].cost = alt
                        else:
                            self.edges[from_p][to_p].cost = min(self.edges[from_p][to_p].cost, alt)


if __name__ == '__main__':
    H, W = map(int, input().split())
    graph = WarshallFloyd(10)

    for i in range(10):
        buff = [int(i) for i in input().split()]
        for j in range(10):
            graph.set_edge(i, j, buff[j], False)

    graph.solve()

    A = [[int(j) for j in input().split()] for _ in range(H)]
    ans = sum(map(lambda l:
                  sum(map(lambda e:
                          0 if e == -1 else graph.edges[e][1].cost
                          , l))
                  , A))
    print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N - 1) cin >> v[i];
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(i == 0) {
            ans += v[i];
        } else if(i == N - 1) {
            ans += v[i - 1];
        } else if(v[i - 1] > v[i]) {
            ans += v[i];
        } else if(v[i - 1] <= v[i]) {
            ans += v[i - 1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256