akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int maxn=5e5+10;
typedef long long LL;
typedef pair<double,double> P;
struct Dam{
	double t,v;
}d[maxn];
LL n;
double l;
deque<P> deq;
int main(){
	scanf("%lld%lf",&n,&l);
	for (int i=0;i<n;i++) scanf("%lf%lf",&d[i].t,&d[i].v);
	deq.push_back(P(d[0].t,d[0].v));
	printf("%.10f\n",d[0].t);
	double sum=d[0].t*d[0].v,val=d[0].v;
	for (int i=1;i<n;i++){
		deq.push_back(P(d[i].t,d[i].v));
		sum+=d[i].t*d[i].v;
		val+=d[i].v;
		while (val>l){
			double detl=val-l;
			if (deq.front().se<detl){
				sum-=deq.front().fi*deq.front().se;
				val-=deq.front().se;
				deq.pop_front();
			}
			else{
				sum-=deq.front().fi*detl;
				deq.front().se-=detl;
				val=l;
			}
		}
		while (deq.size()>=2&&deq[deq.size()-2].fi>deq[deq.size()-1].fi){
			P p1=deq.back(); deq.pop_back();
			P p2=deq.back(); deq.pop_back();
			deq.push_back(make_pair((p1.fi*p1.se+p2.fi*p2.se)/(p1.se+p2.se),p1.se+p2.se));
		}
		printf("%.10f\n", sum/l);
	}
	return 0;
}
/*
3 10
10 10
20 5
4 3
*/

Measured memory_bytes: 26512
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/

int main() {
	string n;
	cin >> n;
	int a[1];
	ll ans = 0;
	for (int i = 0;i < n.size();i++) {
		a[0] = n[i] -'0';
		ans += a[0];
	}
	;
	if (stoi(n)%ans== 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main() {
    int n, i;
    cin >> n;
    int a[n];
    
    for ( i = 0; i < n; i++ ) {
        cin >> a[i];
    }
    for ( i = n - 1; i >= 0; i-- ) {
        cout << a[i];
        if ( i != 0 ) cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>
#include <cassert>

using namespace std;

using i64 = long long int;
using u64 = std::uint_fast64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
constexpr i64 MOD = 1000000007;
constexpr i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    i64 n, m;
    cin >> n >> m;
    vector<P> d;
    for (int i = 0; i < n; ++i) {
        i64 a, b;
        cin >> a >> b;
        d.push_back(P(a, b));
    }
    sort(d.begin(), d.end());
    i64 idx = 0, ans = 0;
    priority_queue<i64> pq;
    for (int i = 0; i < m; ++i) {
        while (idx < n && d[idx].first <= i + 1) {
            pq.push(d[idx].second);
            ++idx;
        }
        if (!pq.empty()) {
            ans += pq.top(); pq.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3696
#include <iostream>
#include <algorithm>

#define MOD 1000000007
#define N_MAX 200002

using namespace std;

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

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
ll pow2[N_MAX];

int W, B, N;

void init(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    pow2[0] = 1;
    pow2[1] = 2;
    for(int i=2;i<N_MAX;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll) i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
        pow2[i] = (pow2[i-1]*2)%MOD;
    }
}

ll inv_(ll n){
    if(n == 1) return 1;
    else return MOD-inv_(MOD%n)*(MOD/n)%MOD;
}

ll comb(ll n, ll r){
  ll ans;
  if(n < r){
      ans = 0;
  }else{
      ans = (fac[n]*finv[r])%MOD;
      ans = (ans*finv[n-r])%MOD;
      ans = (ans+MOD)%MOD;
  }
  return ans;
}

P add(P a, P b){
    P ans;
    ans.first = (a.first*b.second+a.second*b.first)%MOD;
    ans.second = (a.second*b.second)%MOD;
    return ans;
}

P sub(P a, P b){
    P ans;
    ans.first = ((a.first*b.second-a.second*b.first)%MOD+MOD)%MOD;
    ans.second = (a.second*b.second)%MOD;
    return ans;
}

P mul(P a, P b){
    P ans;
    ans.first = (a.first*b.first)%MOD;
    ans.second = (a.second*b.second)%MOD;
    return ans;
}

int main(){
    cin >> W >> B;
    N = W+B;
    init();
    P pw = P(0, 1);
    P pb = P(0, 1);
    P p = P(1, 1); 
    for(int i = 1; i <= N; i++){
        P ans = add(mul(P(1, 2), p), pb);
        ll y = ans.first;
        ll x = ans.second;
        ll z = (y*inv_(x))%MOD;
        cout << z << endl;
        pw = add(pw, P(comb(i-1, W-1), pow2[i]));
        pb = add(pb, P(comb(i-1, B-1), pow2[i]));
        p = sub(p, P(comb(i-1, W-1), pow2[i]));
        p = sub(p, P(comb(i-1, B-1), pow2[i]));
    }
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

ll rec(map<ll,ll>& mp,ll s) {
    if (mp[s] > 0) return mp[s];
    return mp[s] = rec(mp,s/2)*2+1;
}

int main() {
    ll h;
    cin >> h;
    map<ll,ll> mp;
    mp[1] = 1;
    rec(mp,h);
    cout << mp[h] << endl;
}

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

int top,S[1000000];

void push(int a){
  S[++top] = a;
}

int pop(){
  top--;
  return S[top+1];

  
}

int main(){
  
  int x, y, z;
  top = 0;
  char array[100];
  
  while(1)
    {
    if( scanf("%s", &array[0]) == EOF ) break;
    
    if ( array[0] == '+' ){
      x = pop();
      y = pop();
      push(x + y);
    } 
    else if ( array[0] == '-' ){
      y = pop();
      x = pop();
      push(x - y);
    }
    else if ( array[0] == '*' ){
      x = pop();
      y = pop();
      push(x * y);
    }
    else {
      z = atoi(array);
      push(z);
    }
    }
  
  printf("%d\n", pop());
  
  return 0;
}

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

string s;

int main() {
	cin >> s;
	rep(i,s.length()) {
		s[i] -= 3;
		if (s[i]<'A') s[i] += 26;
	}
	cout << s << '\n';
}


Measured memory_bytes: 3076
#include<stdio.h>


int main(void)
{	int x,y,i;
	for(i = 1; 1 ; i++){
		scanf("%d %d\n",&x,&y);
		if(x == 0 && y == 0)break;
		if(x < y){printf("%d %d\n",x,y);}
		else if(x > y){printf("%d %d\n",y,x);}
		else if(x = y){printf("%d %d\n",x,y);}
}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long int a,b,c,d,i,j,k,l;
    cin>>a;

    string s;
    int cnt=0;
    cin>>s;
    for(i=0;i<s.length();i++)
    {
        if(s[i]!=s[i+1])
        cnt++;


    }
    cout<<cnt;

}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int plus_tax(int v, int p){
  return v * (100 + p) / 100;
}

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

  int x, y, s;
  while (cin >> x >> y >> s && x + y + s > 0) {
    int res = 0;
    REP2(i, 1, s){
      REP2(j, 1, s){
        if (plus_tax(i, x) + plus_tax(j, x) == s){
          res = max(res, plus_tax(i, y) + plus_tax(j, y) );
        }
      }
    }
    cout << res << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define pb  					push_back
#define mp 						make_pair
#define all(v) 					((v).begin()) ,((v).end())
#define let(o,v)				memset(o,v,sizeof (o))
typedef long long 				ll;
typedef vector<int>				vi;
typedef vector<vi>				vvi;
typedef vector<string>			vs;

const int MOD = (int)1e9 + 7;
const int oo = (int)1e9;
const ll OO = (ll)1e18;
const double PI = acos(-1.0);
const int N = (int)1e6 + 9;

bool isprime(int n) {
	if (n <= 1)
		return 0;
	for (int i = 2; i*i <= n; i++)
		if (n%i == 0)
			return false;
}
ll intlog(ll base, ll x) {
	return (log(x) / log(base));
}
bool prime[N];
void primee()
{

	for (int p = 2; p*p <= N; p++)
	{

		if (prime[p] == true)
		{
			for (int i = p * 2; i < N; i += p)
				prime[i] = false;
		}
	}

}
string decToBinary(ll n)
{
	string z = "";
	int i = 0;
	while (n > 0) {

		z += (n % 2) + 48;
		n = n / 2;
		i++;
	}
	reverse(all(z));
	return z;
}

int main()
{
	int k, ans = 0;
	scanf("%d", &k);
	for (int i = 1; i <= k; i++)
	{
		for (int j = i; j <= k; j++)
		{
			if ((i % 2 == 0 && j % 2 == 1) || (i % 2 == 1 && j % 2 == 0)) ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)
#define INF 100000000000 // long only


int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int ans[n];
  F(i,0,n)ans[i]=1;
  F(i,0,k){
    int d;
    scanf("%d",&d);
    F(j,0,d){
      int tmp;
      scanf("%d",&tmp);
      ans[tmp-1]=0;
    }
  }
  int sum=0;
  F(i,0,n){
    if(ans[i]==1) sum++;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int main() {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    if (a < b) {
        printf("a < b\n");
    } else if (a == b) {
        printf("a == b\n");
    } else {
        printf("a > b\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
       ll a,b,c; cin >> a >> b >> c;
       swap(a,b);
       swap(a,c);
       cout << a << " " << b << " " << c << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
using cd = complex <double>;

const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 998244353;//786433;//998244353;
const double Pi = acos(-1);

 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, l;
int a[100005], id = 0;

signed main()
{
	Fastio();
	cin >> n >> l;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for(int i = 1; i <= n - 1; i++)
	{
		if(a[i] + a[i + 1] >= l)
		{
			id = i;
			break;
		}
	}
	if(id == 0)
	{
		cout << "Impossible";
		return 0;
	}
	cout << "Possible\n";
	for(int i = 1; i < id; i++)
	{
		cout << i << '\n';
	}
	for(int i = n - 1; i > id; i--)
	{
		cout << i << '\n';
	}
	cout << id;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  string s;cin>>s;
  ll ans = 0;
  int b=0,e=0;
  ll memo = 0;
  while(e < s.size()){
    while(e < s.size() && s[e] == '<'){
      memo++;
      e++;
      ans += memo;
    }
    b = e;
    while(e < s.size() && s[e] == '>'){
      e++;
    }
    if(e-b <= memo){
      memo = 0;
      REP(i,e-b){
        ans += i;
      }
    }else{
      ans += e-b - memo;
      REP(i,e-b){
        ans += i;
      }
      memo = 0;
    }
    b = e;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if(a >= 13) cout << b << endl;
    else if(a < 6) cout << 0 << endl;
    else cout << b / 2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    #print(L)
    ans = 0

    for i in range(N-2):
        #jの探索
        j = i + 1
        while True:
            if L[i] != L[j]:
                break
            else:
                j += 1
                if j == N-1:
                    return ans

        while (j < N-1):
            #hの探索
            h = j+1
            while True:
                if L[j] != L[h]:
                    break
                else:
                    h += 1
                    if h == N:
                        break
            if h == N:
                break

            while (h < N):
                if (L[i] + L[j]) > L[h]:
                    #print(i,j,h)
                    ans += 1
                    h += 1
                else:
                    break
            j += 1

    return ans

print(main())


Measured memory_bytes: 9212
/*
ID: Aditya Srivastava[yashsri2]
LANG: C++
TASK: test
*/
#include <bits/stdc++.h>
const double PI=acos(-1);
using namespace std;
#define ll long long
#define ull unsigned long long
#define ul unsigned long
#define FD(N,M) (cout<<fixed<<setprecision(M)<<(N))
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define rep(i,n) for(ll i=0;i<(n);i++)
#define templ template<typename T>
ll findmin(ll a,ll b) {
    return a<b?a:b;
}
ll findmax(ll a,ll b) {
    return a>b?a:b;
}
int log2_fl(ll num) {
	int count=0;
	while(num>>=1) {
		count++;
	}
	return count;
}
// debugging
void printArr(ll *arr, ll n) {
	for(ll i=0;i<n;i++) {
		cout<<arr[i]<<" ";
	}
	cout<<"\n";
}
templ void printVect(vector<T>& arr) {
	for(T i:arr) {
		cout<<i<<" ";
	}
	cout<<"\n";
}
templ void printVect2d(vector<vector<T>>& arr) {
	for(auto i:arr) {
		for(T j:i) {
			cout<<j<<" ";
		}
		cout<<"\n";
	}
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n;
    cin>>n;
    long t[n];
    ll tt=0;
    for(int i=0;i<n;i++) {
		cin>>t[i];
		tt+=t[i];
	}
	cin>>m;
	int p;long x;
	while(m--) {
		cin>>p>>x;
		cout<<(tt-t[p-1]+x)<<"\n";
	}
    cout.flush();
	return 0;
}


Measured memory_bytes: 3660
from collections import defaultdict

N = int(input())

d = defaultdict(int)

for x in range(1,100):
    for y in range(x,100):
        for z in range(y,100):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if x == y == z:
                d[n] += 1
            elif x == y or y == z or z == x:
                d[n] += 3
            else:
                d[n] += 6
            
            if n > N:
                break

for i in range(1,N+1):
    print(d[i])



Measured memory_bytes: 76376
N = int(input())
H = list(map(int, input().split()))

flag = False
sum = 1

for i in range(1, N):
    for j in range(0, i):
        if H[j] > H[i]:
            flag = False
            break
        flag = True
    if flag == True:
        sum = sum + 1
        flag = False

print(sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N,M; cin >> N >> M;
    cout << N*(N-1)/2 + (M-1)*M/2 << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    if(x / d >= k){
        // K * d の最大は10e30//

        cout << x - k * d << endl;
    }else{
        // x / d < k
        // k - x / d > 0
        long t = k - x / d;
        if(t % 2 == 0){
            cout << x % d << endl;
        }else{
            cout << abs(x % d - d) << endl;
        }
    }
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    char x, y;
    cin >> x >> y;

    cout << (x == y ? '=' : x < y ? '<' : '>') << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n;
  cin >> n;
  vi h(n);
  rep(i,n) cin >> h[i];
  vi dp(n+5,INF);
  dp[0] = 0;
  rep(i,n) {
    if (dp[i] == INF) continue;
    chmin(dp[i+1], dp[i] + abs(h[i]-h[i+1]));
    chmin(dp[i+2], dp[i] + abs(h[i]-h[i+2]));
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
 
    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]
 
    def count(self, x):
        return -self.table[self._root(x)]
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

N, M, K = map(int, input().split())
ins_friend = UnionFind(N)
friends = [0 for i in range(N)]
blocks = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    ins_friend.union(a-1, b-1)
    friends[a-1] += 1
    friends[b-1] += 1
for _ in range(K):
    c, d = map(int, input().split())
    blocks[c-1].add(d-1)
    blocks[d-1].add(c-1)
ans = [0 for i in range(N)]
for i in range(N):
    ans[i] = ins_friend.count(i) - 1 - friends[i]
    for x in blocks[i]:
        if ins_friend.find(i, x) == True:
            ans[i] -= 1
print(*ans)


Measured memory_bytes: 111612
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
A = np.array(readline().split(),np.int32)
B = np.array(readline().split(),np.int32)

# B を昇順にしておく
I = B.argsort(); B = B[I]; A = A[I]

Asorted = np.msort(A)

if (Asorted > B).any():
    print('No')
    exit()

# N-1回あればできるやつ
# 目標位置をswapできる場所があれば、達成可能

if any(Asorted[1:] <= B[:-1]):
    print('Yes')
    exit()

# この時点で、Aは相異なり、目標インデックスも1つに決まる

perm = A.argsort().tolist()

x = 0
period = 0
while True:
    period += 1
    x = perm[x]
    if x == 0:
        break

print('Yes' if period != N else 'No')

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

int main() {
  
  string S;
  cin >> S;
  vector<char> L(S.size());
  
  for(int i = 0; i < S.size(); i++){
    L.at(i) = S.at(i);
  }
  
  sort(L.begin(), L.end());
  
  //for(int i = 0; i < S.size(); i++){
    //cout << L.at(i) << endl;
  //}
  
  for(int i = 1; i < L.size(); i++){
    if(L.at(i - 1) == L.at(i)){
      cout << "no" << endl;
      break;
    }
    else{
      if(i == L.size() - 1){
        cout << "yes" << endl;
      }  
      continue;
    }
  }
}


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

int a[12][12];
const int INF = 1001001001;

int main() {
	int ans = INF;
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	rep(i, n) {
		cin >> c[i];
		rep(j, m)cin >> a[i][j];
	}

	rep(s, 1 << n) {
		int cost = 0;
		vector<int> d(m);
		rep(i, n) {
			if (s >> i & 1) {
				cost += c[i];
				rep(j, m)d[j] += a[i][j];
			}
		}
		bool ok = true;
		rep(j, m)if (d[j] < x)ok = false;
		if(ok)ans = min(ans, cost);
	}

	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;

	return 0;
}






Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#define INF (1<<30)
using namespace std;

int main()
{
	int b[101][2],dp[100][2],N;
	while(cin >> N, N)
	{
		for(int i=0; i<2; i++)
		for(int j=0; j<N; j++)
		{
			cin >> b[j][i];
			dp[j][i]=INF;
		}

		b[N][0]=b[N][1]=-1;
		dp[0][0]=dp[0][1]=0;

		while(1)
		{
			bool flag=false;
			for(int i=0; i<2; i++)
			for(int j=0; j<N; j++)
			{
				if(dp[j][i]==INF) continue;

				if(b[j][i]==1 && b[j+1][i]==1)
				{
					int p=j;
					while(b[p+1][i]==1) p++;
					if(dp[p][i] <= dp[j][i]) continue;
					flag = true;
					dp[p][i] = dp[j][i];
				}
				else if(b[j][i]==2)
				{
					int p=j;
					while(b[p][i]==2) p--;
					if(dp[p][i] <= dp[j][i]) continue;
					flag = true;
					dp[p][i] = dp[j][i];
				}
				else
				{
					for(int k=0; k<=2; k++)
					{
						if(j+k>=N) break;
						if(dp[j+k][(i+1)%2] <= dp[j][i] +1 ) continue;
						flag=true;
						dp[j+k][(i+1)%2] = dp[j][i] +1;
					}

				}
			}

			if(!flag) break;
		}

		if(b[N-1][0]==2) dp[N-1][0]=INF;
		if(b[N-1][1]==2) dp[N-1][1]=INF;

		int ret=min(dp[N-1][0], dp[N-1][1]);

		if(ret==INF) cout << "NA" << endl;
		else cout << ret << endl;
	}
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int r;
    cin >> r;
    cout << r*r << endl;
}

Measured memory_bytes: 888
use num::integer::gcd;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        x: usize,
        a: [usize; n]
    }
    let mut res = 0;
    for i in a.iter() {
        res = gcd(res, (x as isize - *i as isize).abs() as usize);
    }
    println!("{}", res);
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}


int main() {
    long long a , b, c, ans = 1;
    cin >> a >> b;
    c = __gcd(a, b);
 //   cout << c << endl;
    for (long long i = 2; i * i <= c; i++){
        if (c % i == 0){
            ans++;
        }
        while (c % i == 0){
            c /= i;
        }
    }
    if (c != 1){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
r = {l[i]:0 for i in range(n)}
for i in range(n):
    r[l[i]] += 1
t = list(r.items())
ans = 0
for i in range(len(t)-2):
    for j in range(i+1, len(t)-1):
        for k in range(j+1, len(t)):
            y = sum([t[i][0], t[j][0], t[k][0]])
            x = max([t[i][0], t[j][0], t[k][0]])
            if 2*x < y:
                ans += t[i][1] * t[j][1] * t[k][1]
print(ans)

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

int main() {
  int h , w;
  cin >> h >> w;
  vector<string> vec(h+2);
  vec.at(0) = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
  vec.at(h+1) = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
  for(int i=0;i<h;i++){
    cin >> vec.at(i+1);
  }
  if(w==1){
    for(int i=1;i<=h;i++){
      if(vec.at(i).at(0)=='.'){
        int s=0;
        if(vec.at(i-1).at(0)=='#') s++;
        if(vec.at(i+1).at(0)=='#') s++;
        cout <<s <<endl;
      }
      else{
        cout <<"#"<<endl;
      }
    }
  }
  else{
    for(int i=1;i<=h;i++){
      if(vec.at(i).at(0)=='.'){
        int s=0;
        if(vec.at(i-1).at(0)=='#') s++;
        if(vec.at(i-1).at(1)=='#') s++;
        if(vec.at(i).at(1)=='#') s++;
        if(vec.at(i+1).at(0)=='#') s++;
        if(vec.at(i+1).at(1)=='#') s++;
        cout <<s;
      }
      else{
        cout <<"#";
      }
      for(int j=1;j<w-1;j++){
        if(vec.at(i).at(j)=='.'){
          int s=0;
          if(vec.at(i-1).at(j-1)=='#') s++;
          if(vec.at(i-1).at(j)=='#') s++;
          if(vec.at(i-1).at(j+1)=='#') s++;
          if(vec.at(i).at(j-1)=='#') s++;
          if(vec.at(i).at(j+1)=='#') s++;
          if(vec.at(i+1).at(j-1)=='#') s++;
          if(vec.at(i+1).at(j)=='#') s++;
          if(vec.at(i+1).at(j+1)=='#') s++;
          cout <<s;
        }
        else{
        cout <<"#";
        }
      }
      if(vec.at(i).at(w-1)=='.'){
        int s=0;
        if(vec.at(i-1).at(w-2)=='#') s++;
        if(vec.at(i-1).at(w-1)=='#') s++;
        if(vec.at(i).at(w-2)=='#') s++;
        if(vec.at(i+1).at(w-2)=='#') s++;
        if(vec.at(i+1).at(w-1)=='#') s++;
        cout << s << endl;
      }
      else{
        cout << "#" <<endl;
      }
    }
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;
public class C{
    public static void Main(){
        int n,k;
        string[] nk = Console.ReadLine().Split(' ').ToArray();
        n = int.Parse(nk[0]);k=int.Parse(nk[1]);
        
        int[] h = new int[n];
        for (int i= 0;i<n;i++){
            h[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(h);
        int ans = 1001001001;
        for (int i = 0;i<=n-k;i++){
            ans = Math.Min(ans,h[i+k-1]-h[i]);
        }
        Console.WriteLine(ans);
        
    }
}


Measured memory_bytes: 32976
// https://atcoder.jp/contests/abc160/tasks/abc160_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, X, Y;
  cin >> N >> X >> Y;

  VVL edge_list(N, VL(0));

  rep(i, N - 1) {
    edge_list[i].emplace_back(i + 1);
    edge_list[i + 1].emplace_back(i);
  }

  edge_list[X - 1].emplace_back(Y - 1);
  edge_list[Y - 1].emplace_back(X - 1);

  VVL dist(N, VL(N, INF));

  rep(i, N) {
    queue<PL> q;
    q.emplace(i, 0);
    dist[i][i] = 0;

    while (!q.empty()) {
      PL p = q.front();
      q.pop();
      ll n = p.fi;
      ll di = p.se;

      for (auto np : edge_list[n]) {
        if (chmin(dist[i][np], di + 1)) {
          q.emplace(np, di + 1);
        }
      }
    }
  }

  VL dist_ct(N + 1);

  rep(j, N) rep(i, j) { ++dist_ct[dist[i][j]]; }
  rep1(i, N - 1) { cout << dist_ct[i] << endl; }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 31744
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
	int a, b;
	char c;
	cin >> a >> c >> b;
	if (c == '+') cout << a+b << endl;
	else cout << a-b << endl;
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
const ll INF = LLONG_MAX / 10;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll A[N];
    ll sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    vector<ll> D;
    for(ll i = 1; i * i <= sum; i++) {
        if(sum % i == 0) {
            D.push_back(i);
            D.push_back(sum / i);
        }
    }
    sort(D.begin(), D.end());
    ll ans = 1;
    for(ll d : D) {
        ll a[N];
        for(int i = 0; i < N; i++) {
            a[i] = A[i] % d;
        }
        sort(a, a + N);
        ll cnt = 0;
        ll l = 0, r = N - 1;
        while(l < r) {
            ll dif = min(a[l], d - a[r]);
            cnt += dif;
            a[l] -= dif;
            a[r] += dif;
            if(a[l] == 0)
                l++;
            if(a[r] == d)
                r--;
        }
        if(cnt <= K)
            ans = d;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math

#N,A,=[int(x) for x in input().split()]
X=int(input())

def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    if n==3:
        return True
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m,2):
        if n % p == 0:
            return False
    return True

Is = isPrime(X)
while Is == False:
    X+=1
    Is =isPrime(X)

print(X)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
string st,st1;
int main()
{
	cin>>st>>st1;
	for(int i=0;i<3;i++)
		if(st[i]!=st1[2-i])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, x, y,z,w,h, sum= 1, ans = 0;
ll enum_div(ll n) {
    vector<int> ret;
    ll cnt = 0;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0 && n % (n / i - 1) == i) {
            cnt += n / i - 1;
        }
    }
    return cnt;
}
int main() {
    cin >> n;
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << enum_div(n) << endl;
}

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

int main() {
    int N;
    int a[110];  // 最大 100 個ですが余裕をもたせます
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
    
    sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) { // Alice のターン
            Alice += a[i];
        }
        else { // Bob のターン
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = int(s.size());
  // if(n % 2 == 0){
    for (int i = 0; i < n; i+=2) {
      cout << s[i];
    }
    cout << endl;
  // }
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
	int k;
	cin >> str;
	cin >> k;

	int key = 0;
	while(k != 0) {
		if(key == str.length() - 1) {
			k %= 26;
			if(k == 0) {
				break;
			} else if(str[key] == 'z') {
				str[key] = 'a';
			} else {
				str[key]++;
			}
			k--;
		} else if((str[key] != 'a')&&('z' < str[key] + k)) {
			k -= 'z' - str[key] + 1;
			str[key] = 'a';
			key++;
		} else {
			key++;
		}
	}

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE
const Int MAX_N = 301;
Int h, w;
vector<string> mp;
Int calcCost(Int I, Int a, Int b){
  static _int used[MAX_N][MAX_N][MAX_N];
  static _int mem[MAX_N][MAX_N][MAX_N];
  if(h - a - 1 < 0 || h - b - 1 < 0) return 0;
  if(used[I][a][b]++) return mem[I][a][b];
  return mem[I][a][b] = calcCost(I, a+1, b+1) + (mp[h-a-1][I] == mp[h-b-1][I+1]);
}

Int dfs(Int i, Int a, Int b){
  static _int used[MAX_N][MAX_N][MAX_N];
  static _int mem[MAX_N][MAX_N][MAX_N];
  if(a == h || b == h) return 0;
  if(used[i][a][b]++) return mem[i][a][b];
  Int cost = calcCost(i, a, b);
  Int x = dfs(i, a + 1, b) + cost;
  Int y = dfs(i, a, b + 1) + cost;
  Int res = min(x, y);
  return mem[i][a][b] = res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>h>>w;
  mp.resize(h);
  cin>>mp;

  Int ans = 0;
  for(Int i=0;i<w-1;i++){
    Int cost = dfs(i, 0, 0);
    ans += cost;
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 426368
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

LL dist[1005];
LL a[2005], b[2005], c[2005];
LL INF = 1LL << 60;

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i];
    }
    for (int i = 1; i <= n; i++) {
        dist[i] = INF; 
    }
    dist[1] = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < m; j++) {
            if (dist[a[j]] == INF) {
                continue;
            } 
            if (dist[b[j]] > dist[a[j]] + c[j]) {
                dist[b[j]] = dist[a[j]] + c[j];
            }
        }
    }
    LL ans = dist[n];
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < m; j++) {
            if (dist[a[j]] == INF) {
                continue;
            } 
            if (dist[b[j]] > dist[a[j]] + c[j]) {
                dist[b[j]] = dist[a[j]] + c[j];
            }
        }
    }
    if (ans != dist[n]) {
        cout << "inf" << endl;
    } else {
        cout << -ans << endl;
    }
}


Measured memory_bytes: 3640
import itertools
import math

n = int(input())
num = list(list(map(int, input().split())) for i in range(n))

num = list(itertools.permutations(num))

count = 0

for i in num:
  for j in range(len(i) - 1):
    count += math.sqrt(((i[j][0] - i[j + 1][0]) ** 2 + (i[j][1] - i[j + 1][1]) ** 2))

print(count/math.factorial(n)) 


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

int main(){
  vector<int> a;
  int s,d,f,g;
  cin >> s;
  for(int i=0;i<s;i++){
    cin >> d;
    a.push_back(d);
  }
  std::sort(a.begin(),a.end());
  f=0;
  g=-1;
  d=0;
  for(int i=0;i<s;i++){
   	f=a.at(i);
    if(f!=g)
      d +=1;
    g=f;
  }
  cout << d << endl;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = sc.nextInt()
    }

    var approved = true
    for (num <- a.filter(_ % 2 == 0)) {
      if (num % 3 != 0 && num % 5 != 0) {
        approved = false
      }
    }

    if (approved) println("APPROVED ")
    else println("DENIED ")
  }
}


Measured memory_bytes: 27320
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

int bit[1123456], bit_n;

int bit_sum(int i)
{
    int s = 0;
    while (i > 0)
    {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void bit_add(int i, int x)
{
    while (i <= bit_n)
    {
        bit[i] += x;
        i += i & -i;
    }
}

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

    string s;
    cin >> s;

    int cnt[30];
    fill(cnt, cnt + 26, 0);

    REP(i, s.size())
    cnt[s[i] - 'a']++;

    int one = 0;
    REP(i, 26)
    one += cnt[i] % 2;

    if (one > 1)
    {
        cout << -1 << endl;
        return 0;
    }

    ll res = 0;

    vector<char> l;
    vector<char> r;

    bool oneu = false;

    REP(i, s.size())
    {
        if (cnt[s[i] - 'a'] <= 0)
        {
            r.push_back(s[i]);
            if (one && !oneu)
                res++;
            continue;
        }

        if (cnt[s[i] - 'a'] == 1)
        {
            oneu = true;
            cnt[s[i] - 'a']--;
            continue;
        }

        res += i - l.size();
        cnt[s[i] - 'a'] -= 2;
        l.push_back(s[i]);
    }

    reverse(r.begin(), r.end());

    V num[30];

    REP(i, r.size())
    num[r[i] - 'a'].push_back(i);

    int acnt[30];
    fill(acnt, acnt + 26, 0);

    int dec = 0;

    bit_n = l.size();
    fill(bit, bit + bit_n, 0);

    REP(i, l.size())
    {
        int ind = l[i] - 'a';
        res += (num[ind][acnt[ind]] + (dec - bit_sum(num[ind][acnt[ind]] + 1))) - i;
        bit_add(num[ind][acnt[ind]] + 1, 1);
        dec++;
        acnt[ind]++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1812