akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;
using P = pair<int,int>;
template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i,T x=1){
        for(i++;i<=n;i += i&-i){
            d[i] += x;
        }
    }
    T sum(int i){
        T x = 0;
        for(i++;i;i-= i&-i) {
            x += d[i];
        }
        return x;
    }
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,d,a;
    cin >> n >> d >> a;
    d*= 2;
    vector<pair<int,int>> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;
    sort(ALL(p));
    ll ans = 0;
    BIT<ll> bit(n+1);
    rep(i,n){
        ll x = p[i].first;
        ll h = p[i].second;
        h -= bit.sum(i);
        if(h<=0)continue;
        ll num = (h+a-1)/a;
        ans += num;
        ll damage = num*a;
        bit.add(i,damage);
        ll rx = min(x+d,1001001001ll);
        ll j = upper_bound(ALL(p),P(rx+1,-1)) - p.begin();
        bit.add(j,-damage);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
main :: IO ()
main = do
    [n,_,x] <- map read . words <$> getLine :: IO [Int]
    a <- map read . words <$> getLine :: IO [Int]
    let a' = map (\i -> if i `elem` a then 1 else 0) [0..n]
        (l,r) = splitAt x a'
    print $ min (sum l) (sum r)

Measured memory_bytes: 892
import numpy as np

def luka(n):
    a,b=1,2
    if n==1:
        pass
    elif n>=1:
        for _ in range(n-1):
            a,b=a+b,a
    
    print(a)
    

def main():
    N=int(input())

    luka(N)

if __name__=="__main__":
    main()


Measured memory_bytes: 21664
#--import&define---------------------
import math

def yes():
    print("Yes")
def no():
    print("No")

def gusu(n):
    a = 0
    x = int(n/2)-1
    for i in range(x+1):
        if l[i]!=l[n-i-1]:
            a = a+1
    return a

def kisu(n):
    a=0
    x = int(n/2)-1
    for i in range(x+1):
        if l[i]!=l[n-i-1]:
            a = a+1
    return a
#--my_library--------------------------------
#mapを利用した入力
# x,y = map(int,input().split())

#forを利用した入力
#l = []
#for i in range():
#    l.append(int(input()))
#--以下解答---------------------------------
s = input()
l =list(s)
ans = 0

i=0
n=len(l)
flag = False

#偶数か奇数か見分ける
if n%2 == 0:
    flag = True

if flag == True:
    ans = gusu(n)
else:
    ans = kisu(n)

print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S; 
  rep(i, H) {
	string s;
	cin >> s;
	S.push_back(s);
  }

  rep(i, W + 2) cout << '#';
  cout << endl;

  rep(i, H) {
	cout << '#' << S[i] << '#' << endl;
  }

  rep(i, W + 2) cout << '#';
  cout << endl;
}



Measured memory_bytes: 1016
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
const int MOD = 1e9 + 7;
 
int main(){
  int N; cin >>N;
  map<int, int> M;
  for(int i = 0; i < N; ++i){
    int a; cin >>a; M[a]++;
  }
  int ans = 1;
  for(int i = N - 1; i >= 0; i -= 2) ans = (ans * M[i]) % MOD;
  for(int i = N - 1; i >= 2; i -= 2) ans = (ans * (M[i] - 1)) % MOD;
  cout <<ans <<endl;
}


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





int main(){
	string S;
	cin >> S;
	int len = S.length();
	vector<int> v(len);
	
	S = S + "X";
	
	for ( int i = 0; i < len; ){
		int i0 = i;
		
		int R = 0, L = 0;
		// RR...RLL...L の連続数を調べる
		while ( S[i] == 'R' ){
			R++;
			i++;
		}
		while ( S[i] == 'L' ){
			L++;
			i++;
		}
		
		// RLの境界に集まる
		v[i0+R-1]   = (R+1)/2 + L/2;
		v[i0+R] = R/2 + (L+1)/2;
	}
	
	for ( auto it : v )
		cout << it << " ";
	cout << endl;
	
	return 0;
}



Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;cin >> n >> x;
    vector<int> l(n),d(n+1);
    d[0]=0;
    REP(i,n){
        cin >> l[i];
        d[i+1]=d[i]+l[i];
    }
    int ans=0;
    REP(i,n+1){
        if(d[i]<=x) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W ==0)	break;
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					if(i == 0 || i == H - 1)	System.out.printf("#");
					else
						if(j == 0 || j == W - 1)	System.out.printf("#");
						else System.out.printf(".");
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
	}
}



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

int main() {
  int a;
  int b;
  cin >> a >> b;
  int c;
  c = a*b;
  if (c%2 == 1){
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
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 ALL(c) (c).begin(), (c).end()
 
typedef unsigned long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m = 4;
    cin >> n;
    VI p(m), t(m);
    REP(i,m) cin >> p[i];
    REP(i,m) cin >> t[i];

    VI dp(201, 1e9);
    dp[0] = 0;
    REP(i,201){
        REP(j,4) if (i + t[j] <= 200) chmin(dp[i + t[j]], dp[i] + p[j]);
    }
    int ans = 1e9;
    FOR(i,n,200) chmin(ans, dp[i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3088
a, b, n = map(int, input().split())
score = abs(a - b)
for x in range(1, n + 1):
  for y in range(1, n + 1):
    if b * x % y == 0:
      new_a = b * x // y
      score = min(score, abs(a - new_a))
print(score)


Measured memory_bytes: 5596
#include <iostream>
#include <cctype>
#include <string>

using namespace std;

int counts[26];

int
main(int argc, const char *argv[])
{
    string sentence;
    while (cin >> sentence) {
        for (auto &e : sentence) {
            if (islower(e)) counts[e-'a']++;
            else if (isupper(e)) counts[e-'A']++;
        }
    }
    for (int i = 0; i < 26; ++i) {
        printf("%c : %d\n", 'a'+i, counts[i]);
    }

    return 0;
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
 
using namespace std;
 
bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.first< right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.second < right.second;
}
 
void dfs(lli ed, lli num, vector<map<lli,lli>>& vec){
    lli n=1;
    for(auto e: vec[num]){
        if(n == ed)n++;
        if(e.second != -1)continue;
        vec[num][e.first] = n;
        vec[e.first][num] = n;   
        dfs(n, e.first, vec);
        n++;
    }
}
 
lli gcd(lli a, lli b){
    if(a < b)return gcd(b, a);
    lli temp;
    while((temp = a%b)){
        a=b;
        b=temp;
    }
    return b;
}

struct nCr{
  vector<lli> f, rf;
  lli count=0;
  nCr(lli num): f(num), rf(num){
      count = num;
      f[0] = 1;
      rep1(i, num) f[i] = (f[i - 1] * i) % MOD;
      rep0(i, num+1) rf[i] = inv(f[i]);
  }
    
  lli inv(lli x) {
      lli res = 1;
      lli k = MOD - 2;
      lli y = x;
      while (k) {
          if (k & 1) res = (res * y) % MOD;
          y = (y * y) % MOD;
          k /= 2;
      }
      return res;
  }
  lli C(lli n, lli k) {
      lli a = f[n];
      lli b = rf[n-k];
      lli c = rf[k];
   
      lli bc = (b * c) % MOD;
   
      return (a * bc) % MOD;
  }
};

struct UF{
    vector<int> par,size;

    UF(int N) : par(N), size(N, 1){
        rep0(i,N)par[i] = i;
    }

    int root(int x){
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        size[rx] += size[ry];
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int getSize(int x){
        return size[x];
    }
};
int main(){
  lli N;
  cin >> N;
  cout << N*(N+1)/2 - 3*(N/3*(N/3+1)/2) - 5*(N/5*(N/5+1)/2) + 15*(N/15*(N/15+1)/2);
}


Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e3+10;
int a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=2*n;i++)cin>>a[i];
    sort(a+1,a+2*n+1);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=a[2*i-1];
    }
    cout<<ans<<endl;
}

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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;

    int counter = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 2 == 1)
        {
            counter++;
        }
    }

    // double pi = 3.1415926535898;

    // cout << fixed << setprecision(10) << pi << endl;
    // printf("%.10lf\n", pi);
    // // result = 3.1415926536

    double ans = (double)counter / (double)N;
    cout << fixed << setprecision(10) << ans << endl;
    // printf("%.10lf\n", ans);
    return 0;
}


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

class MinSegmentTree {
	std::vector<std::vector<int>> mArray;
	static constexpr int maxValue = (1L << 31) - 1;
public:
	MinSegmentTree(int n) :mArray() {
		int size = 0;
		while ((n >> size) > 0) ++size;
		mArray = std::vector<std::vector<int>>(size + 1);
		for (auto i = 0; i < mArray.size(); ++i) {
			mArray[i] = std::vector<int>((n >> i) + 1, maxValue);
		}
	}
	int findMin(int from, int to) const {
		int res = maxValue;
		for (auto i = 0; from <= to; ++i) {
			if ((from >> i) % 2 == 1) {
				res = std::min(res, mArray[i][from >> i]);
				from = ((from >> i) + 1) << i;
			}
			if ((to >> i) % 2 == 0) {
				res = std::min(res, mArray[i][to >> i]);
				to = ((to >> i) - 1) << i;
			}
		}
		return res;
	}
	void set(int pos, int value) {
		mArray[0][pos] = value;
		for (auto i = 1; i < mArray.size(); ++i) {
			if ((mArray[i - 1].size() > ((pos >> i) << 1) + 1))
				mArray[i][pos >> i] = std::min(mArray[i - 1][(pos >> i) << 1], mArray[i - 1][((pos >> i) << 1) + 1]);
			else
				mArray[i][pos >> i] = mArray[i - 1][(pos >> i) << 1];
		}
	}
};
int main() {
	int n, l;
	std::cin >> n >> l;
	MinSegmentTree st(n);
	for (auto i = 0; i < n; ++i) {
		int a; std::cin >> a;
		st.set(i, a);
	}
	for (auto i = 0; i + l < n; ++i) {
		std::cout << st.findMin(i, i + l - 1) << ' ';
	}
	std::cout << st.findMin(n - l, n - 1) << std::endl;
}


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

template <class T>
inline void read(T &res)
{
	res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	if (bo) res = ~res + 1;
}

template <class T>
inline T Max(const T &a, const T &b) {return a > b ? a : b;}

typedef long long ll;

const int N = 1005, M = 2005, djq = 1e9 + 7;

int n, m, fa[N], cnt, ans = 1, d[N][N], ecnt, nxt[M], adj[N], go[M], val[M];
bool is[M];
ll MST, X;

void add_edge(int u, int v, int w)
{
	nxt[++ecnt] = adj[u]; adj[u] = ecnt; go[ecnt] = v; val[ecnt] = w;
	nxt[++ecnt] = adj[v]; adj[v] = ecnt; go[ecnt] = u; val[ecnt] = w;
}

struct edge
{
	int u, v, w;
} a[M];

inline bool comp(edge a, edge b)
{
	return a.w < b.w;
}

int cx(int x)
{
	if (fa[x] != x) fa[x] = cx(fa[x]);
	return fa[x];
}

bool zm(int x, int y)
{
	if ((x = cx(x)) != (y = cx(y))) return fa[y] = x, 1;
	return 0;
}

void dfs(int u, int fu, int rt)
{
	for (int e = adj[u], v; e; e = nxt[e])
		if ((v = go[e]) != fu) d[rt][v] = Max(d[rt][u], val[e]), dfs(v, u, rt);
}

int main()
{
	read(n); read(m); read(X);
	for (int i = 1; i <= m; i++) read(a[i].u), read(a[i].v), read(a[i].w);
	if (n <= 2) return puts("0"), 0;
	std::sort(a + 1, a + m + 1, comp);
	for (int i = 1; i <= n; i++) fa[i] = i;
	for (int i = 1; i <= m;)
	{
		int nxt = i;
		while (a[i].w == a[nxt].w) nxt++;
		for (int j = i; j < nxt; j++) cnt += (is[j] = cx(a[j].u) != cx(a[j].v));
		for (int j = i; j < nxt; j++) if (zm(a[j].u, a[j].v))
			MST += a[j].w, add_edge(a[j].u, a[j].v, a[j].w);
		i = nxt;
	}
	if (X == MST)
	{
		for (int i = 1; i <= cnt; i++) ans = (ans + ans) % djq;
		ans = (ans - 2 + djq) % djq;
		for (int i = 1; i <= m - cnt; i++) ans = (ans + ans) % djq;
		return std::cout << ans << std::endl, 0;
	}
	for (int u = 1; u <= n; u++) dfs(u, 0, u);
	for (int i = 1; i <= m; i++) if (!is[i] && MST - d[a[i].u][a[i].v] + a[i].w
		== X) ans = (ans + ans) % djq;
	ans = (ans - 1 + djq) % djq;
	for (int i = 1; i <= m; i++) if (!is[i] && MST - d[a[i].u][a[i].v] + a[i].w
		> X) ans = (ans + ans) % djq;
	return std::cout << (ans << 1) % djq << std::endl, 0;
}

Measured memory_bytes: 7676
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(std::string S) {
  map<char, bool> mp;

  for (char c : S) {
    if (!mp.count(c)) {
      mp[c] = true;
    }
  }
  char m;
  bool found = false;
  for (char c = 'a'; c <= 'z'; c++) {
    if (!mp.count(c)) {
      m = c;
      found = true;
      break;
    }
  }

  if (found) {
    cout << m << endl;
  } else {
    cout << "None" << endl;
  }
}

int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<set<int>>v(26);
	for (int i = 0; i < n; i++) {
		v[s[i] - 'a'].insert(i);
	}
	int ans = 0;
	int q;
	cin >> q;
	for (int i = 0; i < q; i++ ) {
		int type;
		cin >> type;
		if (type == 1) {
			int idx;
			char ch;
			cin >> idx >> ch;
			--idx;
			v[s[idx] - 'a'].erase(idx);
			v[ch - 'a'].insert(idx);
			s[idx] = ch;
		}
		else {
			int l, r;
			cin >> l >> r;
			--l, --r;
			ans = 0;
			for (int j = 0; j < 26; j++) {
				auto lower = v[j].lower_bound(l);
				if (*lower > r ||  lower == v[j].end())continue;
				ans++;
			}
			cout << ans << endl;

		}
	}
}

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

int main() {
  string s;
  long long n;
  cin>> n>> s;
  
  vector<long long> v(26);
  for(long long i=0;i<n;i++){
       v.at(s.at(i)-'a')++;
  }
  long long  r=1;
  long long m=1000000007 ;
  for(long long i=0;i<26;i++){
     if(v.at(i)!=0) r*=(v.at(i)+1);
     r = r%m;
  }
  
  long long z=(r-1)%m;
  cout <<z<< endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[4];
    for(int i=0;i<4;i++)cin>>a[i];
    sort(a,a+4);
    if(a[0]==a[1]&&a[2]==a[3])cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}

Measured memory_bytes: 3136
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

long long gcd(long long a, long long b)
{
	long long tmp, r;
	if (a < b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	int sirokuro = 0;
	int kurosiro = 0;
	rep(i, s.size())
	{
		if (i % 2)
		{
			if (s[i] == '0')
			{
				kurosiro++;
			}
			else
			{
				sirokuro++;
			}

		}
		else
		{
			if (s[i] == '0')
			{
				sirokuro++;
			}
			else
			{
				kurosiro++;
			}
		}
	}
	cout << min(kurosiro, sirokuro) << endl;
	debug;
	return 0;
}

Measured memory_bytes: 712
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

const int INF = 1001001001;
int main() {
    int dp[1000001],odddp[1000001];
    rep(i,1000001) {
        dp[i] = INF;
        odddp[i] = INF;
    }      
    dp[0] = 0;
    odddp[0] = 0;
    for(int i = 1;;i++) {
        int num = i*(i+1)*(i+2)/6;
        if(num>1000000) break;
        for(int j = num;j<=1000000;j++) {
            dp[j] = min(dp[j],dp[j-num] + 1);
            if(num%2==1) {
                odddp[j] = min(odddp[j],odddp[j-num] + 1);
            }
        }
    }
    while(true) {
        int n;
        cin >> n;
        if(n==0) break;
        cout << dp[n] << " " << odddp[n] << endl;
    }

}


Measured memory_bytes: 10824
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int A;
    cin >> A;
int B;
    cin >> B;
    int dig1, dig2, dig4, dig5, counter;
    counter=0;
   while (A<=B) {
    dig5=A/10000;
    dig4=(A%10000)/1000;
    dig2=(A%100)/10;
    dig1=A%10;

if (dig1==dig5 && dig2==dig4){
   counter++;
}
else{
}
A++;
}

    // 出力
    cout << counter;
    return 0;
}
    


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

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

int n, x;

int main() {
    fastio();

    cin >> n >> x;
    int y;
    cin >> y;
    int g = abs(x - y);
    forn(i, n) {
        cin >> y;
        g = gcd(g, abs(x - y));
    }

    cout << g << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

vector<int> f(int n) {
	ll p = 0;

	vector<int> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;

	for (int i = 2; i <= n; i++) {
		if (!isPrime[i]) {
			continue;
		}

		for (int j = 2 * i; j <= n; j += i) {
			isPrime[j] = false;
		}
	}

	vector<int> a(n);
	for (int i = 3; i < n; i++) {
		a[i] = isPrime[i] && isPrime[(i + 1) / 2];
	}

	vector<int> memo(n + 1);
	for (int i = 1; i <= n; i++) {
		memo[i] += memo[i - 1] + a[i - 1];
	}

	return memo;
}

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


	const int N_MAX = (int)1e5 + 30;
	vector<int> memo = f(N_MAX);

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;

		cout << memo[r + 1] - memo[l] << endl;
	}
	return 0;
}


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

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scanner.nextInt();
		}
		Arrays.sort(a);
		int s=n-1;
		int tmp[]=new int[n];
		for(int i=0;i<n;i++) {
			tmp[i]=s;
			if(i%2==1) {
				s-=2;
			}
		}
		Arrays.sort(tmp);
		for(int i=0;i<n;i++) {
			if(a[i]!=tmp[i]) {
				System.out.println(0);
				return;
			}
		}
		long ans=1;
		for(int i=0;i<n/2;i++) {
			ans=(ans*2)%1000000007;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 51180
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int x = i;
		int cnt = 0;
		while (x) {
			cnt += x % 10;
			x /= 10;
		}
		if (cnt >= a && cnt <= b) ans += i;
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 256
import sys
_ = sys.stdin.readline()
x=sys.stdin.readline()

arr=x.split()

arrInt=list()
#print(arr, type(arr))
for i in arr:
   # print(i)
    arrInt.append(int(i))

#print(arrInt,type(arrInt))
print(min(arrInt),max(arrInt),sum(arrInt))




Measured memory_bytes: 6512
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int[][] alp = new int[n][26];
		String str = "abcdefghijklmnopqrstuvwxyz";
		for(int i = 0; i < n; i++){
			String S = in.next();
			for(int j = 0; j < S.length(); j++){
				alp[i][(S.charAt(j) - 'a')]++;
			}
		}
		
		for(int i = 0; i < 26; i++){
			int min = Integer.MAX_VALUE;
			for(int j = 0; j < n; j++) min = Math.min(min, alp[j][i]);
			for(int j = 0; j < min; j++) System.out.print(str.charAt(i));
		}
	}
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

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

   set<string> st;
   rep(i,n){
      string s;
      cin>>s;
      st.insert(s);
   }
   cout<<st.size()<<endl;
return 0;
}



Measured memory_bytes: 19224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

struct pt{
  int x, y;
};

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

  int n;
  cin >> n;
  vector <pt> v(n);
  vi perm(n);
  ld fac = 1;
  for(int i = 0; i < n; i++){
    cin >> v[i].x >> v[i].y;
    perm[i] = i;
    fac *= (i + 1);
  }
  ld sum = 0;
  do{
    for(int i = 0; i < n - 1; i++){
      ld dx = (v[perm[i]].x - v[perm[i + 1]].x);
      ld dy = (v[perm[i]].y - v[perm[i + 1]].y);
      sum += sqrt((ld) dx * dx + dy * dy);
    }
  } while(next_permutation(all(perm)));
  cout << fixed << setprecision(10) << sum / fac;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  int a[n];
  rep(i,0,n) a[i]=0;
  bool used[n];
  rep(i,0,n) used[i]=false;
  bool p=true;
  rep(i,0,m){
    int s,c;
    cin>>s>>c;
    s--;
    if(used[s]){
      if(a[s]!=c){
        p=false;
        break;
      }
    }
    else{
      used[s]=true;
      a[s]=c;
    }
  }
  if(p){
    if(a[0]==0){
      if(n==1) cout<<a[0]<<endl;
      else if(used[0]) cout<<-1<<endl;
      else{
        a[0]=1;
        rep(i,0,n) cout<<a[i];
        cout<<endl;
      }
    }
    else{
      rep(i,0,n){
        cout<<a[i];
      }
      cout<<endl;
    }
  }
  else cout<<-1<<endl;
}


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

int n,a,mx,ans;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    while(n--){
        cin>>a;
        if(a>=mx){
            ans++;
            mx=a;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  long long k,n;
  cin>>k>>n;
  long long a[n],b[n];
  long long ans=0,maxb=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n-1;i++){
    b[i]=a[i+1]-a[i];
  }
  b[n-1]=k-a[n-1]+a[0];
  for(int i=0;i<n;i++){
  	ans+=b[i];
    maxb=max(maxb,b[i]);
  }
  cout<<ans-maxb<<endl;
}

Measured memory_bytes: 3328
import java.util.*;
import java.io.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                PrintWriter ou = new PrintWriter(System.out);
                int n = Integer.parseInt(sc.next());
                if(n == 1){
                        ou.print("Hello World\n");
                }else{
                        ou.print(Integer.parseInt(sc.next()) + Integer.parseInt(sc.next()) + "\n");
                }
                ou.flush();
        }
}

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



int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

 string n;
  cin>>n;
  long long int res=0;
  long long int res1=0;
cout<<fixed<<setprecision(15);
  for(int i=0;i<n.length();i++){
      res = n[i] - '0';
		res1 += res;
      
  }
  if(res1%9==0 ){
      cout<<"Yes\n";
  }
  else{
      cout<<"No\n";
  }
    return 0;
}


Measured memory_bytes: 3740
program main;
var
	n, m, i, free, total : int64;
	a : array[1..100000] of int64;
begin
	read(n, m);
    total := 0;
    for i := 1 to m do begin
    	read(a[i]);
        total := total + a[i];
    end;
	free := n - total;
    if free >= 0
    	then writeln(free)
        	else writeln('-1');
end.
    
    

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

#define ios ios_base::sync_with_stdio(0); cout.tie(0);cin.tie(0);
#define endl "\n"
#define f first
#define s second

using namespace std;

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

const int N = (int)(6e5), A = (int)(1e7 + 2);

int main() {
    ios
    string s, t;
    cin >> s >> t;
    int c = 0;
    for (int i = 0; i < s.size(); ++ i) {
        if (s[i] != t[i]) ++ c;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 3836
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;


int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    cout << fixed << setprecision(6) << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) << "\n";
    
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x,t;cin>>n>>x>>t;
  ll d=(n+x-1)/x;
  print(t*d);
  return 0;
}

Measured memory_bytes: 3608
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
p = na()
p.sort()


print(sum(p[:k]))

Measured memory_bytes: 9184
import java.io.*;
import java.util.*;
public class Main{
	static void main() throws Exception{
		int maxn=(int)1e5;
		int[]occ=new int[maxn+1];
		int n=sc.nextInt();
		long sum=0;
		for(int i=0;i<n;i++) {
			int x=sc.nextInt();
			sum+=x;
			occ[x]++;
		}
		int q=sc.nextInt();
		while(q-->0) {
			int b=sc.nextInt(),c=sc.nextInt();
			int cnt=occ[b];
			occ[c]+=cnt;
			occ[b]=0;
			sum+=(1l*cnt*c);
			sum-=(1l*cnt*b);
			pw.println(sum);
		}
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 54880
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main(void)
{
	double x, h, s, a;
	
	
	while(cin >> x >> h && x && h){
		double r = x / 2;
		a = sqrt(h * h + r * r);
		s = x * x + 4 * (x * a / 2);
		
		printf("%.6f\n", s);
	}
	return 0;
}

Measured memory_bytes: 1236
#pragma comment(linker, "/STACK:102400000,102400000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 100010
#define M 2000100
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define FJ(i,a,b) for(int i=a;i<b;++i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define FD T&q=fd[rt],&ql=fd[rt<<1],&qr=fd[rt<<1|1]
#define MID int mid=((l+r)>>1)
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define zero(x) (((x)>0?(x):-(x))<EPS)
#define PB push_back
#define SZ size
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define MP make_pair
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;
const int MOD=1000000007;
const double PI=acos(-1.0);
const double EPS=1e-8;
inline int II(){int n=0,ch=getchar();bool t=0;if(ch==-1)return 0;
for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')t=1;
for(;ch>='0'&&ch<='9';n=n*10+ch-'0',ch=getchar());if(t)return -n;return n;}
int n;
char s[N];
int a[N];
int main(){
 //   IN;
    SC(n);
    scanf("%s",s+1);
    int len=strlen(s+1);
    bool ok=0;
    FF(u,0,1){
    FF(v,0,1){
        a[1]=u;
        a[2]=v;
        FF(i,3,len){
            if(a[i-1]==0){
                if(s[i-1]=='o')a[i]=a[i-2];
                else a[i]=1-a[i-2];
            }
            else {
                if(s[i-1]=='o')a[i]=1-a[i-2];
                else a[i]=a[i-2];
            }
        }
        bool ok1=0,ok2=0;
        if(a[len]==0){
            if(s[len]=='o'&&a[1]==a[len-1])ok1=1;
            if(s[len]=='x'&&a[1]!=a[len-1])ok1=1;
        }
        else {
            if(s[len]=='o'&&a[1]!=a[len-1])ok1=1;
            if(s[len]=='x'&&a[1]==a[len-1])ok1=1;
        }
        if(a[1]==0){
            if(s[1]=='o'&&a[2]==a[len])ok2=1;
            if(s[1]=='x'&&a[2]!=a[len])ok2=1;
        }
        else {
            if(s[1]=='o'&&a[2]!=a[len])ok2=1;
            if(s[1]=='x'&&a[2]==a[len])ok2=1;
        }
        if(ok1&&ok2)ok=1;
        if(ok==1)break;
    }
    if(ok==1)break;
    }
    if(ok){
        FF(i,1,len)putchar(a[i]==0?'S':'W');
        puts("");
    }
    else puts("-1");
    return 0;
}


Measured memory_bytes: 768
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [2*a];
        for(int i=0;i<2*a;i++){
                             in[i] = sc.nextInt();
                            }
        Arrays.sort(in);
        int b = 0;
        for(int i=0;i<a;i++){
                             b+=in[2*i];
                            }
		System.out.println(b);
	}
}


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

using namespace std;
int main() {
  string s;
  cin >> s;
  int total = 0;
  for (int i = 0; i < s.length(); i++) {
    total += s[i] - '0';
  }
  cout << (stoi(s) % total == 0 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <typeinfo>
using namespace std;


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    int Digit(int N); //桁和
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }

    int Digit(int N){
        if(N<10){
            return N;
        }
        int r = 0;
        while (N>=10)
        {
            r += (N%10);
            N /= 10;
        }
        r += N;
        return r;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define strcin(s) string (s); cin >> (s);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    #define back_sort(a) sort(all((a)),[](const int &p,const int &q){return p > q;})
    using intv = vector<int>;
    using douv = vector<double>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
    void YN (bool b){
        if(b){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin(n);
    intv a(n);
    input(n,a);
    back_sort(a);

    int A=0,B=0;
    rap(n,i){
        if(i%2==0){
            A += a[i];
        }else{
            B += a[i];
        }
    }
    cout<<A-B<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
static const int N = 100;

int main(){
  int M[N][N];
  int i,j,n,u,k,v;

  scanf("%d",&n);

  for(i =0; i<n; i++){
    for(j = 0; j < n; j++) M[i][j] = 0;
  }

  for(i = 0; i<n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j) printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main(){
  string S;
  cin >> S;
  string set = "abcdefghijklmnopqrstuvwxyz";
  int i = 0;
  int tmp1, tmp2, tmp3, key;

  if(S == "zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl;
  }else if(S.size() < 26){
    for(i = 0; i < 26; i++){
      if(S.find(set[i]) == -1){
        tmp1 = i;
        break;
      }
    }
    cout << S + set.substr(tmp1, 1);
  }else{
    for(int j = 25; j >= 1; j--){
      if(S[j - 1] < S[j]){
        tmp2 = j;
        break;
      }
    }
    for(int k = 0; k < 26; k++){
      if(S[tmp2 - 1] == set[k]){
        tmp3 = k;
        break;
      }
    }
    for(key = tmp3; key < 26; key++){
      if((S.substr(tmp2, 26 - tmp2)).find(set[key]) != -1) break;
    }
    string ans = S.substr(0, tmp2 - 1) + set[key];
    cout << ans << endl;
  }
}


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

int main(void)
{
  double kg;
  
  while(cin >> kg)
    {
      if(kg <= 48.00) cout << "light fly" << endl;
      else if(kg > 48.00 && kg <= 51.00) cout << "fly" << endl;
      else if(kg > 51.00 && kg <= 54.00) cout << "bantam" << endl;
      else if(kg > 54.00 && kg <= 57.00) cout << "feather" << endl;
      else if(kg > 57.00 && kg <= 60.00) cout << "light" << endl;
      else if(kg > 60.00 && kg <= 64.00) cout << "light welter" << endl;
      else if(kg > 64.00 && kg <= 69.00) cout << "welter" << endl;
      else if(kg > 69.00 && kg <= 75.00) cout << "light middle" << endl;
      else if(kg > 75.00 && kg <= 81.00) cout << "middle" << endl;     
      else if(kg > 81.00 && kg <= 91.00) cout << "light heavy" << endl;
      else if(kg > 91.00) cout << "heavy" << endl;
    }
  return 0;
}

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

const int N = 105;

int n, k, cnt;
bool vis[N];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= k; i++) {
		int d, a; scanf("%d", &d);
		while (d--) {
			scanf("%d", &a);
			vis[a] = true;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) ++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;


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

  string s; cin >> s;
  int ssize = s.size();
  int cnt = 0;
  int now = 0;
  rep(i, ssize) {
    if (s[i] == 'S') {
      now++;
    } else if (now > 0) {
      now--;
      cnt++;
    }
  }

  cout << ssize - cnt*2 << endl;
}

Measured memory_bytes: 720
N,Q = map(int,input().split())
BIT = [0]*(N+1)

def BIT_query(idx):
    res_sum = 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

def BIT_update(idx,x):
    while idx <= N:
        BIT[idx] += x
        idx += idx&(-idx)
    return

a = list(map(int,input().split()))
for i in range(N):
    BIT_update(i+1,a[i])

for i in range(Q):
    a,b,c = map(int,input().split())
    if a == 0:
        BIT_update(b+1,c)
    else:
        print(BIT_query(c)-BIT_query(b))


Measured memory_bytes: 132404
#include <bits/stdc++.h>
using namespace std;
//Position this line where user code will be pasted.


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

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

    int c = 0;

    sort(a, a+n);

    int num = a[n/2];

    int ans = num - a[n/2  - 1];

    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//virtual participate
int main() {
    ll n;
    cin >> n;
    unordered_map<string,ll> um;
    rep(i,n){
        string s;cin >> s;
        um[s]++;
    }
    cout << "AC x " << um["AC"] << endl;
    cout << "WA x " << um["WA"] << endl;
    cout << "TLE x " << um["TLE"] << endl;
    cout << "RE x " << um["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main() {
    int N,L;
    cin >> N >> L;

    string s[100], ans;

    REP(i, N) cin >> s[i];
    sort(s, s + N);

    REP(i, N) ans += s[i];
    cout << ans << endl;
}

Measured memory_bytes: 3640
void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], m = tmp[1];

    long scc = min(n, m/2);
    scc += (m - 2 * scc) / 4;

    scc.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main(){
    int n,m;
    cin >> n >> m;
   char ndata[50][50];
    char mdata[50][50];
    string result;

    for (int y = 0; y< n; y++){
        for (int x = 0; x < n; x++)
        {
            cin >> ndata[y][x];
        }        
    }

     for (int y = 0; y< m; y++){
        for (int x = 0; x < m; x++)
        {
            cin >>mdata[y][x];
        }        
    }

    bool exist = false;
    for (int ly = 0; ly < n; ly++){
     for (int lx = 0; lx < n; lx++){
            if (ly + m-1 >= n or lx + m-1 > n)continue;

         bool match = true;

        for (int y = 0; y < m; y++){
            for (int x = 0; x < m; x++) {
                if (ndata[ly+y][lx+x] != mdata[y][x])match = false;
            }
        }

        if (match)exist = true;    
      }    
    }

    result = (exist)? "Yes" : "No";
    cout << result <<endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define boostup ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;
vector <ll> adj[1000000+5];
map<ll,ll> mp;
int main()
{
    ll n,m;
    cin>>n;
    ll i,j;
    ll h[n+1];
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        cin>>h[i];
        ans+=mp[i-h[i]];
        mp[i+h[i]]++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 51316