akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int f[110000],h[110000];
set<int> x[110000],y[110000];

int bcj(int now){
	if(now!=f[now])
		return f[now]=bcj(f[now]);
	return now;
}

int cmp2(piii x,piii y){
	if(x.se==y.se)
		return x.fi.fi<y.fi.fi;
	return x.fi.se<y.fi.se;
}

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	piii p[n+10];
	for(int i=1;i<=n;i++){
		cin>>p[i].fi.fi>>p[i].fi.se;
		p[i].se=i;
		f[i]=i;
		h[i]=1;
	}
	sort(p+1,p+n+1);
	int j=0;
	for(int i=1;i<=n;i=j)
		for(j=i+1;j<=n&&p[i].fi.fi==p[j].fi.fi;j++){
			int xx=p[j-1].se,yy=p[j].se;
			int xxx=bcj(xx),yyy=bcj(yy);
			if (xxx!=yyy){
				f[yyy]=xxx;
				h[xxx]+=h[yyy];
			}
		}
	sort(p+1,p+n+1,cmp2);
	
	for(int i=1;i<=n;i=j)
		for(j=i+1;j<=n&&p[i].fi.se==p[j].fi.se;j++){
			int xx=p[j-1].se,yy=p[j].se;
			int xxx=bcj(xx),yyy=bcj(yy);
			if (xxx!=yyy){
				f[yyy]=xxx;
				h[xxx]+=h[yyy];
			}
		}
	for(int i=1;i<=n;i++){
		bcj(p[i].se);
		h[p[i].se]=0;
	}
	for(int i=1;i<=n;i++){
		int mee=bcj(p[i].se);
//		cout<<mee<<endl;
		x[mee].insert(p[i].fi.fi);
		y[mee].insert(p[i].fi.se);
		h[mee]++;
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
		if(f[i]==i)
			ans+=ll(x[i].size()*y[i].size()-h[i]);
	cout<<ans;
	return 0;
}
/*
13
1 1
1 2
1 3
1 4
1 5
2 1
2 4
3 1
3 3
4 1
4 2
5 1
5 5
*/

Measured memory_bytes: 17280
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n, k, ans;
    string s;
    cin >> n >> k >> s;
    
    vector<int> l, r;
    
    int b = -1, c = -1;
    for(int i=0;i<n;i++){
        if(i == n-1){
            if(s[i] == 'L')l.push_back(-i+b);
            else r.push_back(-i+b);
        }else if(s[i] != s[i+1]){
            if(s[i] == 'L')l.push_back(c*(i-b));
            else r.push_back(c*(i-b));
            b = i;
            c = 1;
        }
    }
    
    sort(l.begin(), l.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
    
    if(l.size() <= k || r.size() <= k){
        ans = n-1;
    }else{
        int tmp = 0;
        for(int i=0;i<l.size();i++){
            tmp += abs(l[i])-1;
        }
        for(int i=0;i<k;i++){
            if(r[i]>0)tmp += r[i]+1;
            else tmp += -r[i];
        }
        for(int i=k;i<r.size();i++){
            tmp += abs(r[i])-1;
        }
        ans = tmp;
        tmp = 0;
        for(int i=0;i<r.size();i++){
            tmp += abs(r[i])-1;
        }
        for(int i=0;i<k;i++){
            if(l[i]>0)tmp += l[i]+1;
            else tmp += -l[i];
        }
        for(int i=k;i<l.size();i++){
            tmp += abs(l[i])-1;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int max2(int a,int b){
    int ans=a;
    if(a<b)ans=b;
    return ans;
}
struct Edge{
  int t;
  int c;
  int num;
};
struct Tree{
  vector<Edge> edge;
  vector<int> color;
  int buf_c;
  void push_edge(Edge in){
      edge.push_back(in);
  }
};
int main(){
  int n;
  cin>>n;
  vector<Tree> node(n+1);
  vector<Edge> edge(n);
  rep1(i,n-1){
    int a,b;cin>>a>>b;
    edge[i].num=i;
    edge[i].t=b;
    edge[i].c=0;
    node[a].push_edge(edge[i]);
    edge[i].t=a;
    node[b].push_edge(edge[i]);
  }
  int k=0;
  rep1(i,n){
    k=max2(k,node[i].edge.size());
  }
  cout<<k<<endl;
  queue<int> que;
  que.push(1);
  vector<bool> memo(n+1,true);
  memo[1]=false;
  node[1].buf_c=0;
  vector<int> memoc(k+1,0);
  while(!que.empty()){
      int buf=que.front();
      que.pop();
      memo[buf]=false;
      int tmp_i=1;
      int num=node[buf].edge.size();
      for(int i=0;i<num;i++){
          int tmp=node[buf].edge[i].t;
          if(memo[tmp])que.push(tmp);
          else continue;
          if(node[buf].buf_c!=tmp_i){
              edge[node[buf].edge[i].num].c=tmp_i;
              node[tmp].buf_c=tmp_i;
          }
          else{
              tmp_i++;
              edge[node[buf].edge[i].num].c=tmp_i;
              node[tmp].buf_c=tmp_i;
          }
          tmp_i++;
      }
  }
  rep1(i,n-1){
      cout<<edge[i].c<<endl;
  }
  return 0;
}


Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
struct rbtree: tree<T,null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>{};
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define mp make_pair
#define pb push_back
#define lowb lower_bound
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mem0(a) memset((a), 0, sizeof(a))
#define mem(a, b) memset((a), (b), sizeof(a))
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;


int main(){
    IOS;
    ll a; cin>>a;
    ll sum = 0;
    ll k = 5;
    if(a&1){
        cout<<0;
        return 0;
    }
    for(ll i = 1; i <= 30; i++){
        sum += (a/k)/2;
        k *= 5;
        if(k>=a)break;
    }
    cout<<sum;



    return 0;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,ans=0;
  string s;
  map<string,int> m;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    sort(s.begin(),s.end());
    ans+=m[s];
    m[s]++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 11264
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {

	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1')
			cout << '9';
		else
			cout << '1';
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int>> A(n, vector<int>(m, 0));
    vector<vector<int>> B(m, vector<int>(l, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> B[i][j];
        }
    }

    for (int i = 0; i < n; i++) {
        for  (int j = 0; j < l; j++) {
            int ans = 0;
            for (int k = 0; k < m; ++k) ans += A[i][k] * B[k][j];
            if (j != l - 1) cout << ans << " ";
            else cout << ans << endl;
        }
    }
}



Measured memory_bytes: 3284
#include<stdio.h>
int main()
{
	int a,b,c,d,n,h=7,flag=0;
	scanf("%d",&n);
	d=n%10;
	c=(n/10)%10;
	b=(n/100)%10;
	a=(n/1000)%10;
	if(a+b+c+d==7&&flag==0)
	{
		printf("%d+%d+%d+%d=7",a,b,c,d);
		flag=1;
	}
	else if(a-b+c-d==7&&flag==0)
	{
		printf("%d-%d+%d-%d=7",a,b,c,d);
		flag=1;
	}
	else if(a+b+c-d==7&&flag==0)
	{
	    printf("%d+%d+%d-%d=7",a,b,c,d);
		flag=1;
	}
	else if(a+b-c+d==7&&flag==0)
	{
		printf("%d+%d-%d+%d=7",a,b,c,d);
		flag=1;
	}
	else if(a+b-c-d==7&&flag==0)
	{
		printf("%d+%d-%d-%d=7",a,b,c,d);
		flag=1;
	}
	else if(a-b-c-d==7&&flag==0)
	{
		printf("%d-%d-%d-%d=7",a,b,c,d);
		flag=1;
	}
	else if(a-b-c+d==7&&flag==0)
	{
		printf("%d-%d-%d+%d=7",a,b,c,d);
		flag=1;
	}
	else if(a-b+c+d==7&&flag==0)
    {
        printf("%d-%d+%d+%d=7",a,b,c,d);
        flag=1;
    }
	return 0;
}


Measured memory_bytes: 128
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          int
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
	string s;
	cin>>s;
	map<char,ll>m;
	ll i,j;
	for(i=0;i<s.size();i++)
		m[s[i]]++;
	if(((m['N']>0&&m['S']>0)||(m['N']==0&&m['S']==0))&&((m['E']>0&&m['W']>0)||(m['E']==0&&m['W']==0)))
		cout<<"Yes";else cout<<"No";
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
 
input_dis = input()
distance = input_dis.split(" ")
 
minum_dis = 100000000
 
cal_dis1 = int(distance[0]) + int(distance[1])
cal_dis2 = int(distance[2]) + int(distance[0])
cal_dis3 = int(distance[2]) + int(distance[1])
 
if cal_dis1 < minum_dis:
    minum_dis = cal_dis1
if cal_dis2 < minum_dis:
    minum_dis = cal_dis2
if cal_dis3 < minum_dis:
    minum_dis = cal_dis3
    
print(minum_dis)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
int a[maxn];

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
    	scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	if(n == 2){
		printf("%d\n",a[2]);
		return 0;
	}
	for(int i = 1;i*2 <= n;i++){
		int t = a[i];
		a[i] = a[n-i+1];
		a[n-i+1] = t;
	}
	ll sum = 0;
	for(int i = 2;i <= n;i++){
		sum += a[(i+1)/2];
	}
	cout << sum << endl;	
}

Measured memory_bytes: 4544
S = input()

now_col = int(S[0])
ans = 0
if len(S)==1:
    print(ans)
if len(S)!=1:
    for i in range(1,len(S)):
        # print(now_col,int(S[i]),ans)
        if now_col != int(S[i]):
            # print("aa")
            now_col = int(S[i])
            continue
        else:
            ans += 1
            if now_col == 1:
                now_col = 0
            else:
                now_col = 1
    print(ans)

Measured memory_bytes: 3188
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = int(read())
v = 10 ** 9
x = (v - s % v) % v
print(0, 0, v, 1, x, (s + x) // v)


Measured memory_bytes: 2940
n,m = map(int,input().split())

class UnionFind:
	"""
	class UnionFind
	https://note.nkmk.me/python-union-find/
	
	order O(log(n))
	
	n = the number of elements
	parents = the list that contains "parents" of x. be careful that it doesn't contain "root" of x.
	"""
	def __init__(self, n):
		"""
		make UnionFind
		:param n: the number of elements
		"""
		self.n = n
		self.parents = [-1] * n
	
	def find(self, x):
		"""
		:param x: an element
		:return: the root containing x
		"""
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]
	
	def union(self, x, y):
		"""
		:param x, y: an element
		"""
		# root
		x = self.find(x)
		y = self.find(y)
		if x == y:
			# already same group so do nothing
			return
		if self.parents[x] > self.parents[y]:
			# the root should be min of group
			x, y = y, x
		# remind that x, y is the root, x < y, then, y unions to x.
		self.parents[x] += self.parents[y]
		# and then y's parent is x.
		self.parents[y] = x
	def size(self, x):
		# return the size of group
		return -self.parents[self.find(x)]
	
	def same(self, x, y):
		# return whether the x, y are in same group
		return self.find(x) == self.find(y)
	
	def members(self, x):
		# return members of group
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]
	
	def roots(self):
		# return all roots
		return [i for i, x in enumerate(self.parents) if x < 0]
	
	def group_count(self):
		# return how many groups
		return len(self.roots())
	
	def all_group_members(self):
		# return all members of all groups
		return {r: self.members(r) for r in self.roots()}

friends = UnionFind(n)

for i in range(m):
	a,b = map(int,input().split())
	friends.union(a-1, b-1)

ans = 0
for j in friends.roots():
	ans = max(ans, friends.size(j))

print(ans)

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    string S;
    cin >> S;

    string ans = "";
    REP(i, S.length()) { ans += 'x'; }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

//D	Restore the Tree
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.valueOf(sc.nextLine());
		List<Input> inList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			Input in = new Input();
			in.a = Integer.valueOf(sc.nextInt());
			in.b = Integer.valueOf(sc.nextInt());
			inList.add(in);
		}

		Collections.sort(inList, new Comparator<Input>() {

			@Override
			public int compare(Input o1, Input o2) {
				return Long.valueOf(o2.a + o2.b).compareTo(Long.valueOf(o1.a + o1.b));
			}
		});

		long p1 = 0;
		long p2 = 0;
		for (int i = 0; i < inList.size(); i++) {
			if (i % 2 == 0) {
				p1 += inList.get(i).a;
			} else {
				p2 += inList.get(i).b;
			}
		}
		System.out.println(p1 - p2);

		sc.close();
	}

	static class Input {
		long a;
		long b;
	}
}


Measured memory_bytes: 94196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  if(n%2==0){
    if(n/2>=k){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
  else{
    if(n/2+1>=k){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

// clang-format off
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int sum = 0;
    For(i, 1, n) {
        if (1 <= i and i <= 9) sum++;
        if (100 <= i and i <= 999) sum++;
        if (10000 <= i and i <= 99999) sum++;
    }
    print(sum);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,c=0;
  cin>>a;
  vector<int>b(a);
  rep(i,a){
    cin>>b[i];
    c+=b[i];
  }
  if(c%10!=0){
    cout<<c;
    return 0;
  }
  sort(b.begin(),b.end());
  rep(i,a){
    if(b[i]%10!=0){
      cout<<c-b[i];
      return 0;
    }
  }
  cout<<0;
}


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

/* 選択ソート(0オリジン) */
int selectionSort(vector<int> &A, int N) {
  int i, j, sw = 0, minj;
  for ( i = 0; i < N - 1; i++ ) {
    minj = i;
    for ( j = i; j < N; j++ ) {
      if ( A.at(j) < A.at(minj) ) minj = j;
    }
    swap(A.at(i), A.at(minj));
    if ( i != minj ) sw++;
  }
  return sw;
}

int main() {
  int N, i, sw;
  cin >> N;
  vector<int> A(N);
  for ( i = 0; i < N; i++ ) cin >> A.at(i);
  
  sw = selectionSort(A, N);
  
  for ( i = 0; i < N; i++ ) {
    if ( i > 0 ) cout << " ";
    cout << A.at(i);
  }
  cout << endl;
  cout << sw << endl;
  
  return 0;
}


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

typedef long long ll;

int main() {
    string S;
    int w;
    cin >> S >> w;
    for (int i = 0; i < S.size(); i += w) {
        cout << S[i];
    }
    cout << "\n";
}

Measured memory_bytes: 3576
#include <iostream>
#include<string.h>
using namespace std;

int main()
{
     int sum;
     cin>>sum;
    int ant=0;
    if(sum<=9)
        cout<<sum;
    else if(sum<=99)
        cout<<"9";
    else if(sum<=999)
    {
        ant=9+sum-99;
        cout<<ant;
    }
    else if(sum<=9999)
    {
        cout<<"909";
    }
    else if(sum<=99999)
    {
        ant=909+sum-9999;
        cout<<ant;
    }
    else
        cout<<"90909";
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n),c(1000010);
    rep(i,n)cin>>a[i],c[a[i]]++;
    SORT(a);
    vector<bool> f(1000010,true);
    int ans=0;
    rep(i,n){
        if(!f[a[i]])continue;
        if(c[a[i]]==1)ans++;
        for(int j=a[i];j<1000010;j+=a[i])f[j]=false;
    }
    cout<<ans<<endl;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    auto s = to_string(N);
    
    if(count(s.begin(), s.end(), '7') == 0){
        cout << NO << endl;
    }else{
        cout << YES << endl;
    }
}

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


Measured memory_bytes: 3748
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		// 整数の入力


int a= sc.nextInt();
int b= sc.nextInt();
int c= sc.nextInt();
int d= sc.nextInt();

int max=a;
int min=a;

if(max<b){
	max=b;
}
if(max<c){
	max=c;
}
if(min>b){
	min=b;
}
if(min>c){
	min=c;
}
int mid =a+b+c-(min+max);

if(max==b){
	if(mid-min<=d){
			System.out.println("Yes");
	}else{
			System.out.println("No");
	}
}else if(min==b){
	if(max-mid<=d){
			System.out.println("Yes");
	}else{
			System.out.println("No");
	}
}else{
	if(max-mid<=d && mid-min<=d){
		System.out.println("Yes");
	}else{
		System.out.println("No");
	}
}
}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

bool sorty(P l, P r){
    return l.second>=r.second;
}
int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll a;
    string sb,s;
    cin >> a >> sb;
    rep(i,4) if(sb.at(i)!='.') s+=sb.at(i);
    ll b = stoll(s);
    cout << (a*b)/100 << endl;
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		long w = saori.saori_hayami();
		long h = saori.saori_hayami();
		long x = saori.saori_hayami();
		long y = saori.saori_hayami();
		double ans1 = w*h/2.0;
        int ans2 = 0;
        if(x*2==w && y*2==h)ans2++;
		System.out.println(ans1 + " " + ans2);
	

		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21076
import scala.io.StdIn

object Main extends App {

  case class Dice(su1: Int, su2: Int, su3: Int, su4: Int, su5: Int, su6: Int){
    private val nums = Map(1 -> su1, 2 -> su2, 3 -> su3, 4 -> su4, 5 -> su5, 6 -> su6)
    def currentTop(): Int = nums(1)
    
    def roll(d: Char): Dice = d match {
        case 'N' => Dice(su2, su6, su3, su4, su1, su5)
        case 'S' => Dice(su5, su1, su3, su4, su6, su2)
        case 'W' => Dice(su3, su2, su6, su1, su5, su4)
        case 'E' => Dice(su4, su2, su1, su6, su5, su3)
    }
    
    def rollToNum(top: Int): Dice = {
      
      var cnt = 0
      var temp = this.copy()
      while(temp.su1 != top && cnt < 4){
        temp = temp.roll('N')
        cnt += 1
      }

      cnt = 0
      while(temp.su1 != top && cnt < 4){
        temp = temp.roll('W')
        cnt += 1
      }
      if(temp.su1 == top) temp else this
    }
    
  }
  
  val n = StdIn.readLine().toInt

  val dices = (0 until n).map { i =>
    val nums = StdIn.readLine().split(' ').map(_.toInt)
    val dice1 = Dice(nums(0), nums(1), nums(2), nums(3), nums(4), nums(5))
    // for duplicate numbers
    val numsGrouped = nums.groupBy(n => n)
    if(numsGrouped.keys.size == 2 && numsGrouped.count(p => p._2.length == 1) >= 1) {
      val t = numsGrouped.filter(p => p._2.length == 1).head
      val k = t._1
      dice1.rollToNum(k)
    } else {
      dice1
    }
  }


  var judge = false
  var i = 0
  while(!judge && i < n){
    var base = dices(i)
    var j = i+1
    while(!judge && j < n){
      var comp = dices(j)
      // search top
      var count = 0
      comp = comp.rollToNum(base.su1)
      if(base.su1 == comp.su1){
        // roll south
        base = base.roll('S')
        comp = comp.roll('S')

        count = 0
        // 2 is match / again search top, side 3 
        while(base.su1 != comp.su1 &&
          base.su3 != comp.su3 && count < 4){
          comp = comp.roll('W')
          count += 1
        }
        
        //println("base:" + base)
        //println("comp:" + comp)
        judge = base == comp
      }
      j += 1
    }
    i += 1
  }
  
  println(if(judge) "No" else "Yes")
  
}



Measured memory_bytes: 104528
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
//#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    v_int a;
    irep(i, n) {
        int tmp;
        cin >>  tmp;
        if(tmp % 2 == 0) {
            a.push_back(tmp);
        }
    }
    irep(i, a.size()){ 
        if(a[i] % 3 != 0 && a[i] % 5 != 0) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
N,M = map(int,input().split())
num =0
line_m=[]
line_s=[]
for k in range(M+1):
    line_m.append(0)
for i in range(N):
    line_s = list(map(int, input().split()))
    for n in range(int(line_s[0])):
        line_m[int(line_s[n+1])] = int(line_m[int(line_s[n+1])]) + 1

for s in range(M+1):
    if line_m[s] == N:
        num = num+1

# print(line_s)
# print(line_m)

print(num)
        
        

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int cnt = -1;
    REP(0, i, 101) {
        if (A <= i && i <= B) {
            if (C <= i && i <= D) {
                // cout << "i=" << i << endl;
                cnt++;
            }
        }
    }

    cout << (cnt > 0 ? cnt : 0) << endl;

    return 0;
}


Measured memory_bytes: 256
X = int(input())
ans = 1

for j in range(10, 1, -1):
    if int(pow(X, (1/j)) + 1)**j <= X:
        ans = max(int(pow(X, (1/j))+1)**j, ans)
    else:
        ans = max(int(pow(X, (1/j)))**j, ans)

print(ans)


Measured memory_bytes: 3060
n = int(input())
lst = list(map(int,input().split()))
lst = sorted(lst)

ans = lst[n-1] - lst[0]
for i in range(1,n-1):
    ans += abs(lst[i])

print(ans)

for i in range(1,n-1):
    if lst[i] >= 0:
        print("%s %d" % (lst[0],lst[i]))
        lst[0] = lst[0] - lst[i]
    else:
        print("%s %d" % (lst[n-1],lst[i]))
        lst[n-1] = lst[n-1] - lst[i]
        

print("%s %d" % (lst[n-1],lst[0]))


Measured memory_bytes: 14264
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define REP(i, n) for(int i=0;i<(n);++i)
#define MOD 1e9+7;
typedef long long ll;

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

	double t, x;
	cin >> t >> x;
	printf("%.10f\n", t/x);
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
int cnt = 0;
vector< vector<ll> > ans;
vector<vector<ll>> vac;
ll vacation(int N,int i){
  if(N==0){
      return vac[N][i];
  }
  if(ans[N][i]!=-1){
    return ans[N][i];
  }
  for(int j=0;j<3;j++){
    if(i!=j){
      cnt++;
      ans[N-1][j] = vacation(N-1,j);
    }
  }
  for(int j=0;j<3;j++){
    if(i!=j){
      ans[N][i] = max(vac[N][i]+ans[N-1][j],ans[N][i]);
    }
  }
  return ans[N][i];
}
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  ll N;
  cin>>N;
  ans.resize(N);
  vac.resize(N);

  for(int i=0;i<N;i++){
    ans[i].resize(3);
    vac[i].resize(3);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      ans[i][j] = -1;
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      cin>>vac[i][j];
      //cout<<vacation[i][j]<<" ";
    }
  }
  
  ll final_ans = vacation(N-1,0);

  final_ans = max(final_ans,vacation(N-1,1));
  final_ans = max(final_ans,vacation(N-1,2));

  cout<<final_ans<<endl;
  
  return 0;
  /*
  for(int i=0;i<1e5;i++){
    cout<<i+1<<endl;
  }*/

}


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

int main()
{
    int n,a,b;

    cin >> n;
    vector<int> m(n), p(n), q(n);
    rep(i, n) {
        int x;
        cin >> x;
        p[i] = --x;
        m[i] = i;
    }
    rep(i, n) {
        int x;
        cin >> x;
        q[i] = --x;
    }

    int cnt = 0;
    int flg1, flg2;
    a = b = -1;
    do {
        flg1 = flg2 = 0;
        rep(i, n) {
            if (p[i] != m[i]) {
                ++flg1;
            }
            if (q[i] != m[i]) {
                ++flg2;
            }
        }
        if (flg1 == 0)
            a = cnt;
        if (flg2 == 0)
            b = cnt;
        if (a > 0 && b > 0)
            break;
        ++cnt;
    } while (next_permutation(m.begin(), m.end()));

    cout << abs(a-b) << endl;
}


Measured memory_bytes: 3608
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, t = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort()
    dp = [0] * t
    mt = 0
    for a, b in ab:
        mt = max(mt, dp[-1] + b)
        for i in range(t - a - 1, -1, -1):
            dp[i+a] = max(dp[i+a], dp[i] + b)
    print(mt)


if __name__ == '__main__':
    solve()


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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  int N; cin >> N;
  vector<string> S(N); REP(i, N) cin >> S[i];

  map<string, int> m;

  REP(i, N) {
    m[S[i]]++;
  }

  int ans = 0;
  for(auto x : m) {
    if(x.second > 0) {
      ans++;
    }
  }

  cout << ans << endl;
}

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

const ll MOD = 1e9+7;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  vector<bool> ps(n);
  vector<int> wa(n);
  int accnt = 0;
  int wacnt = 0;
  
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    --p;
    if(ps[p] == true) continue;
    if(s == "AC") {
      ps[p] = true;
      ++accnt;
      wacnt += wa[p];
    }
    if(s == "WA") {
      ++wa[p];
    }
  }
  cout << accnt << " " << wacnt << endl;
  return 0;
}
      
    

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

typedef pair<ll,ll> P_ll;
struct edge {int to , cost;};
typedef vector<vector<edge>> wgraph; // cost, to


struct state {
    int node;
    ll cnt;
    ll nokori;
    bool operator<(const state& r) const{
        if(cnt != r.cnt) return cnt > r.cnt;
        else return nokori < r.nokori;
    }
};

P_ll ans[300][300];

int main(void) {
  int N, M;
  std::cin >> N >> M;

  ll L;
  std::cin >> L;

  wgraph g(N);
  REP(i, M){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    a--, b--;
    if(L >= c){
      g[a].push_back({b, c});
      g[b].push_back({a, c});
    }
  }

  priority_queue<state> que;
  REP(i, N) REP(j, N) {
    if(i == j) ans[i][j] = {0, L};
    else ans[i][j] = {longinf, -1};
  }

  REP(st, N){
    que.push({st, 0, L});

    while(que.size()){
      auto q = que.top();
      que.pop();

      ll s = q.node;
      ll c1 = q.cnt;
      ll zan = q.nokori;

      if(ans[st][s].first < c1) continue;
      if(ans[st][s].second > zan) continue;

      for(auto&& v : g[s]){
        ll z = zan;
        ll c = c1;
        if(z < v.cost) {
          z = L;
          c++;
        }
        z -= v.cost;
        if(ans[st][v.to].first > c || (ans[st][v.to].first == c && z > ans[st][v.to].second)){
          ans[st][v.to] = {c, z};
          que.push({v.to, c, z});
        }
      }
    }
  }

  int Q;
  cin >> Q;

  REP(i, Q){
    int s, t;
    scanf("%d %d", &s, &t);
    t--;s--;

    if(ans[s][t].first == longinf){
      cout << -1 << endl;
    } else {
      cout << ans[s][t].first << endl;
    }
  }

  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int x, y; cin >> x >> y;
  cout << (y-x) * (y-x-1) / 2 - x << endl;

  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

void SieveEratosthenes(long long n, vector<bool>& isPrime) {
    if (n+1 > isPrime.size()) isPrime.resize(n+1, true);
    isPrime[0] = isPrime[1] = false;

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

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

    Int Q; cin >> Q;
    const Int N = 100001;
    vector<bool> isPrime(N, true);
    vector<Int> subsum(N, 0);

    SieveEratosthenes(N, isPrime);

    rep(i, 1, N) {
        subsum[i] = subsum[i-1];
        if (i%2 == 1 and isPrime[i] and isPrime[(i+1)/2])
            subsum[i]++;
    }

    rep(i, 0, Q) {
        Int r, l; cin >> l >> r;
        cout << subsum[r] - subsum[l-1] << endl;
    }
}


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

void solve(long long N, std::vector<long long> h){

    h.push_back(0);

    ll ans=0;
    for (int k = 0; k < 101; k++)
    {        
        ll l = 0;
        for (int i = 0; i < h.size(); i++)
        {
            if(h[i] == 0){
                if( l != i ){
                    for (int j = l; j < i; j++)
                    {
                        h[j]--;
                    }
                    ans++;
                }
                l = i+1;
            }
        } 
    }
    cout << ans << endl;
    
    

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, std::move(h));
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int c[10]={0,2,5,5,4,5,6,3,7,6};
int n,m;
int a[9];
int cnt[9];
int ans[10];
int ansk;
int now[10];
void f(int i,int sum)
{
	if(i==m)
	{
		if(n<sum||(n-sum)%c[a[0]])return;
		cnt[0]=(n-sum)/c[a[0]];
		int nowk=0;
		for(int j=0;j<m;j++)
		{
			now[a[j]]=cnt[j];
			nowk+=cnt[j];
		}
		bool flag=0;
		if(nowk<ansk)return;
		else if(nowk>ansk)flag=1;
		else
		{
			for(int j=10;j--;)
			{
				if(now[j]!=ans[j])
				{
					flag=now[j]>ans[j];
					break;
				}
			}
		}
		if(flag)
		{
			ansk=nowk;
			for(int j=1;j<10;j++)ans[j]=now[j];
		}
	}
	else if(n<sum)return;
	else
	{
		for(cnt[i]=0;cnt[i]<7;cnt[i]++)
		{
			f(i+1,sum+cnt[i]*c[a[i]]);
		}
	}
}
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)cin>>a[i];
	for(int i=1;i<m;i++)
	{
		if(c[a[0]]>c[a[i]]||c[a[0]]==c[a[i]]&&a[0]<a[i])a[0]^=a[i]^=a[0]^=a[i];
	}
	f(1,0);
	for(int j=10;j--;)for(int k=0;k<ans[j];k++)cout<<(char)(j+'0');
	cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int main()
{
    ll x,k,d;
    cin>>x>>k>>d;
    if(x<0)
        x*=-1;
    ll m=x/d;  
    if(k>=m)  
    {ll nc=x-m*d;
    k-=m;
    if(k==0)
    {
        cout<<nc<<endl;
        return 0;
    }
    if(k%2==0)
        cout<<nc<<endl;
    else 
        cout<<abs(nc-d)<<endl;}
    else
    {
        cout<<x-k*d<<endl;
    }
    
}

   

Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
from collections import Counter

def solve(N: int, A: "List[int]"):
    s = [0]*(N+1)

    for i in range(N):
        s[i+1] = s[i] + A[i]

    # print(s[:10])

    c = Counter(s)

    ans = 0
    for k,v in c.items():
        ans += v*(v-1)//2

    print(ans)
    
    return



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

if __name__ == '__main__':
    main()


Measured memory_bytes: 55104
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
#include <functional>
#include <iomanip>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }

template<typename Ty>
inline Ty gcd(Ty a, Ty b)
{
	Ty r;
	if (a < b) swap(a, b);
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}




int main(int argc, char* argv[])
{
	cout << std::fixed << std::setprecision(10);

	for (;;) {
		ll A, B, C, D;

		cin >> A >> B >> C >> D;
		if (cin.fail()) break;
		A--;

		ll e = (C * D) / gcd(C, D);
		ll ac = A / C;
		ll bc = B / C;
		ll ad = A / D;
		ll bd = B / D;
		ll ae = A / e;
		ll be = B / e;
		ll x = (A - (ac + ad - ae));
		ll y = (B - (bc + bd - be));
		cout << y - x << endl;
	}

	return 0;
}


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

using namespace std;

int digit_sum(unsigned long long xx){
    int dd = 0;
    string xx_string = to_string(xx);
    int len = xx_string.length();
    for(int i=0; i<len; ++i){
        dd += xx_string[i] - '0';
    }
    return dd;
}

int main(){
    unsigned long long M;
    cin>>M;
    vector<unsigned long long> d(M), c(M);
    for(int i=0; i<M; ++i){
        cin>>d[i]>>c[i];
    }

    unsigned long long ans = 0;
    stack<int> a;
    for(int i=0; i<M; ++i){
        unsigned long long x = d[i] * c[i];
        ans += c[i] - 1;
        if(x>1){
            ans += (x - 1) / 9;
        }
        while(x>=10){
            x = digit_sum(x);
        }
        a.push(x);

        while(a.size()>1){
            int aa = a.top();
            a.pop();
            int bb = a.top();
            a.pop();

            int sum = aa + bb;
            if(sum < 10){
                a.push(sum);
            }else{
                a.push(1);
                a.push(sum-10);
            }
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3328
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], b[i] = scanInt(), scanInt()
	}

	ans := 0
	for i := n - 1; i >= 0; i-- {
		if r := (a[i] + ans) % b[i]; r > 0 {
			ans += b[i] - r
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4736
n = int(input())
m = int(input())
card = list(range(1, 2*n+1))

for _ in range(m):
    ope = int(input())
    if ope == 0:
        card1 = card[:n]
        card2 = card[n:]
        card = []
        for c1, c2 in zip(card1, card2):
            card.append(c1)
            card.append(c2)
    else:
        card1 = card[:ope]
        card2 = card[ope:]
        card = []
        card.extend(card2)
        card.extend(card1)

for c in card:
    print(c)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    if(A >=B && A >=C){
        for(int i=0; i<K; i++){
            A = A*2;
        }
    }else if(B>=A && B>=C){
        for(int i=0; i<K; i++){
            B = B*2;
        }
    }else if(C>=A && C>=B){
        for(int i=0; i<K; i++){
            C = C*2;
        }
    }
    cout << A+B+C;
}

Measured memory_bytes: 256