akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

int main(void) {
  int n, k;
  int right, left;
  int sum = 0;
  int right_end;
  vector<int> v;

  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }

  if (v[0] >= 0) {
    std::cout << abs(v[0]) + abs(v[k - 1] - v[0]) << std::endl;
    return 0;
  } else if (v[n - 1] <= 0) {
    std::cout << abs(v[n - 1]) + abs(v[(n - 1) - (k - 1)] - v[n - 1])
              << std::endl;
    return 0;
  } else {
    for (int i = 0; i < n; i++) {
      if (v[i] == 0) {
        right = i;
        right_end = min(i + (k - 1), n);
        break;
      } else if (v[i] > 0) {
        right = i - 1;
        right_end = min(i + (k - 1), n);
        break;
      }
    }
  }
  left = max(0, right - (k - 1));
  right = min(left + (k - 1), n - 1);
  sum = min(abs(v[left]), abs(v[right])) + abs(v[right] - v[left]);
  for (; right < right_end; left++, right++) {
    sum = min(sum, min(abs(v[left]), abs(v[right])) + abs(v[right] - v[left]));
  }
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 892
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};


int main(void){
    int A[3];
    rep(i,3) cin >> A[i];
    sort(A,A+3);
    if(A[0]==A[1] && A[1]!=A[2]) cout << "Yes" << endl;
    else if(A[0]!=A[1] && A[1]==A[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s, t;
int ls, lt;

int main() {
	cin >> s >> t;
	ls = (int)s.length(), lt = (int)t.length();
	
	if (ls<lt) {
		cout << "UNRESTORABLE" << ln;
		return 0;
	}
	// 後ろから見ていかないと辞書順最小って条件を破るかもしれないから注意
	repr(i,ls-lt) {
		rep(j,lt) {
			// ?じゃなくて文字が違ったらだめ
			if (s[i+j]!='?' && s[i+j]!=t[j]) goto dame;
		}
		// 条件をクリアしたらsの[i, i+lt)をtに書き換えて、他の?を全部aに書き換えて出力
		rep(j,lt) s[i+j] = t[j];
		rep(i,ls) if (s[i]=='?') s[i] = 'a';
		cout << s << ln;
		return 0;
		dame:;
	}
	cout << "UNRESTORABLE" << ln;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    LL H, W;
    cin >> H >> W;

    if(H == 1 || W == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    if(W % 2 == 0)
    {
        cout << H * W / 2 << endl;
    }
    else
    {
        LL temp = H * (W-1) / 2;
        temp = temp + (H+1) / 2;
        cout << temp << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#dfs renshuu
from collections import defaultdict

def dfs(x):
  if f[x] == 1: return
  f[x]=1
  for nex in dd[x]:
    if x==a and nex==b: continue
    dfs(nex)

n,m=map(int,input().split())
dd=defaultdict(list)
lst=[]
ans=0
for i in range(m):
  a,b=map(int,input().split())
  lst.append((a,b,))
  dd[a].append(b)
  dd[b].append(a)
for a,b in lst:
  f=[0]*(n+1)
  dfs(a)
  if f[b]!=1:
    ans+=1
print(ans)


Measured memory_bytes: 9476
s = input()
tmp = "0"
A = 0
B = 0

for ss in s:
    if tmp != ss:
        A += 1
    if tmp == "1":
        tmp = "0"
    elif tmp == "0":
        tmp = "1"

tmp = "1"
for ss in s:
    if tmp != ss:
        B += 1
    if tmp == "1":
        tmp = "0"
    elif tmp == "0":
        tmp = "1"
if A < B:
    print(A)
else:
    print(B)

Measured memory_bytes: 3188
//atcoder clange
#include <stdio.h>

#include <stdlib.h>

int main(void){
  int N;
  scanf("%d", &N);
  int i=0;
  int W[N];
  for(i=0;i<N;i++){
    scanf("%d", &W[i]);
  }
  
  int min = 1000;
  int j=0;
  int s1,s2;
  for(i=0;i<N;i++){
    s1 = 0;
    s2 = 0;
	for(j=0;j<N;j++){
		if(j <= i){
			s1 = s1 + W[j];
          }else{
          s2 = s2 + W[j];
        }
    }
    if(min > abs(s1-s2)){
     min = abs(s1-s2); 
    }
  }
  
  
  
    printf("%d",min);

    //int max = max(a, N);
    return 0;     
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn = 2e3+100;
const ll mod=998244353;
pll a[maxn];
ll c[maxn];
ll f[maxn];
ll dp[maxn][maxn];
map<ll,ll> mp;
ll val[maxn];
ll mx=0;


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("test.txt", "r", stdin);
    if (fopen("pump.in","r"))
    {
        freopen("pump.in","r", stdin);
        freopen("pump.out", "w",stdout);
    }
  ll x;
   cin>>x;
   cout <<!x;








}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  //vector<unsigned int> h(n);
  unsigned int h[200005];
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  sort(h, h+n );
  reverse(h, h+n);
  for (int i = 0; i < k; i++){
    h[i] = 0;
  }
  unsigned long long int ans = 0;
  for (int i = 0; i < n; i++)
  {
    ans += h[i];
  }
  cout << ans << "\n";
  return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		string s; cin>>s;
		cout<<(count(all(s),'R')>count(all(s),'B')?"Yes":"No")<<endl;
	}
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: chars,
    }
    let n = S.len();
    let mut ans:Vec<i64> = vec!(-1,-1);
    for i in 0..n-1{
        if S[i]==S[i+1]{
            ans = vec!(i as i64 +1,i as i64 +2);
            break;
        }
    }
    for i in 0..n-2{
        if S[i]==S[i+2] && S[i]!=S[i+1]{
            ans = vec!(i as i64 +1,i as i64 +3);
            break;
        }
    }
    println!("{} {}",ans[0],ans[1]);
}

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

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

	#define ll   long long
	#define ld long double
	#define all(v) v.begin(),v.end()
	#define pb push_back
	#define S second
	#define F first
	#define die() return 0;


	#define md          1000000007
	#define fmd         998244353 
	#define M           200011
	#define N            18
	ll exp(ll a,ll b){if(b<0)return 0;ll r=1;while(b){if(b&1)r=r*a%md,r%=md;a=a*a%md;b/=2;}return r;}
	ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}

	int solve(){
	    ll n,i,j,k,m,x,y,z;
	    cin>>n;
	    vector<ll> a(n+1),d(n+1);
	    for(i=1;i<=n;++i){
	    	cin>>a[i];d[i]=d[i-1]+a[i];
	    }
	    ll ans=1e18;
		for(i=1;i<=n;++i){
			ll sum=d[i];
			x=0;ll p=i;
			vector<pair<ll,ll> > p1;
			for(;p>=1;p/=2){
				while(x+p<i&&d[x+p]<=sum-d[x+p])x+=p;
			}
			if(x!=0)
				p1.pb({d[x],sum-d[x]});
			if(x+1!=i)
				p1.pb({d[x+1],sum-d[x+1]});
			if(!p1.size())continue;
			vector<pair<ll,ll> > p2;
			x=i;p=n;
			for(;p>=1;p/=2){
				while(x+p<=n&&d[x+p]-d[i]<=d[n]-d[x+p])x+=p;
			}
			if(x!=i)
				p2.pb({d[x]-d[i],d[n]-d[x]});
			if(x+1!=n)
				p2.pb({d[x+1]-d[i],d[n]-d[x+1]});
			if(!p2.size())continue;
			for(auto x1:p1){
				for(auto x2:p2){
					vector<ll> pp;
					// trace(x1.F,x1.S,x2.F,x2.S,i);
					pp.pb(x1.F);pp.pb(x1.S);pp.pb(x2.S);pp.pb(x2.F);

					sort(all(pp));
					ans=min(ans,pp.back()-pp[0]);
				}
			}
		}
			cout<<ans<<"\n";










	    // trace(f(2,2));



		die();

	}
	 
	 
	int main(){
	 
	 
	#ifndef ONLINE_JUDGE
	    double _tBeg=clock();
	#endif

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

	    int t;
	    t=1;;
	    // prec();
	    // cin>>t;
	 
	    while(t--){

	        solve();
	    }
	 
	 
	 
	 


	#ifndef ONLINE_JUDGE
	    double _tEnd=clock();
	    // printf("\ntotal time %.6f\n",(_tEnd-_tBeg)/CLOCKS_PER_SEC);
	#endif
	 
	    die();
	}


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

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

  int64_t R=0;
  int64_t G=0;
  int64_t B=0;

  for(int i=0;i<N;i++){
    if(S.at(i) == 'R'){
      R++;
    }else if(S.at(i) == 'G'){
      G++;
    }else if(S.at(i) == 'B'){
      B++;
    }
  }

  int64_t ans = R*G*B;
  for(int i=0;i<N;i++){
    for(int d=1;d<=min(i,N-i-1);d++){
      if(S.at(i)!=S.at(i+d)
      && S.at(i)!=S.at(i-d)
      && S.at(i+d)!=S.at(i-d)){
        ans--;
      }
    }
  }/*
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      if(2*j-i<N
      && S.at(i)!=S.at(j)
      && S.at(i)!=S.at(2*j-i)
      && S.at(j)!=S.at(2*j-i)){
        ans--;
      }
    }
  }*/
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,k;
    cin >> n >> k;
    if(k == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << n-(k-1)-1 << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	switch s {
	case "AKIHABARA", "KIHABARA", "AKIHBARA", "AKIHABRA", "AKIHABAR", "KIHBARA", "KIHABRA", "KIHABAR", "AKIHBRA", "AKIHBAR", "AKIHABR", "KIHBRA", "KIHBAR", "KIHABR", "AKIHBR", "KIHBR":
		fmt.Println("YES")
	default:
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

double funcT(double v){
	return v / 9.8;
}

double funcY(double t){
	return 4.9 * t * t;
}

const int oneFloor = 5;

int main(){
    int minFloor;
	for(double minSpeed; cin >>minSpeed; cout << minFloor << endl){ 
		double minY = funcY(funcT(minSpeed));

		minFloor = 1 + (int)minY / oneFloor + ((minY/(double)oneFloor == (int)minY / oneFloor) ? 0 : 1);
	}

	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <cmath>
using namespace std;
int main() {
	int D[4] = { 0, 9, 909, 90909 };
	int E[3] = { 1, 100, 10000 };
	int N;
	cin >> N;
	int digit = (int)log10(N)+1;
	if (digit % 2 == 0) cout << D[digit / 2] << endl;
	else cout << D[digit / 2] + N - E[digit / 2] + 1 << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;



int n,a,b;


void check(vector<int> a) {
    assert((int)a.size() == n);
    for (int i=0; i<n; i++) {
	assert(a[i]>=1 && a[i]<=n);
    }
}

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

    cin>>n>>a>>b;

    // a islands of at most size b

    ll lb = b + (a-1);
    if (lb > n) out(-1);

    ll ub = 1ll*a*b;
    if (ub < n) out(-1);

    vector<int> ans;
    int x=1;
    
    for (int i=a; i>=1; i--) {
	int rem = n-x+1; // remaining elements
	int rest = i-1; // groups remaining
	int siz = min(b, rem-rest); // save at least 1 elem for the remaining groups
	assert(siz>0);
	
	vector<int> v;
	for (int j=0; j<siz; j++) {
	    v.push_back(x++);
	}
	while (v.size()) {
	    ans.push_back(v.back());
	    v.pop_back();
	}
    }

    check(ans);
    
    for (int x: ans) cout<<x<<" ";
    cout<<"\n";
    
    
    return 0;
}


Measured memory_bytes: 5840
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n,a=0;
    cin>>n;
    for(int i = 1;i <= n; ){
        int k = i,cont = 0;
        for(int j = 1;j <= sqrt(k);j++){
            if(k % j == 0){
                cont = cont + 2;
            }
        }
        if(cont == 8){
            a++;
        }
        i = i + 2;
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())

if L % 2019 == 0 or L + 2019 - (L % 2019) <= R:
    print(0)
else:
    print(min(i * j % 2019 for i in range(L, R)
                           for j in range(i + 1, R + 1)))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long q,h,s,d,n;
    cin>>q>>h>>s>>d;
    cin>>n;
    if(min(q*8,min(h*4,min(s*2,d)))==d)
    {
        if(n%2==0) cout<<d*(n/2);
        else cout<<(d*(n/2))+((min(q*8,min(h*4,s*2)))/2);
    }
    else cout<<((min(q*8,min(h*4,s*2)))/2)*n;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int main() {
  int a,b;
  cin >> a >> b;
  cout << (b-a)*(b-a+1)/2-b;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, M;
    cin >> N >> M;
    vector<ll> cnt1(N, 0), cnt2(N, 0);
    REP(i, M){
    	ll p;
    	string S;
    	cin >> p >> S;
    	p--;
    	if(S == "AC"){
    		cnt1[p]++;
    	}else{
    		if(cnt1[p]==0){
    			cnt2[p]++;
    		}
    	}
    }
    ll a=0, b=0;
    //cout << cnt1 << endl;
    //cout << cnt2 << endl;
    REP(i, N) if(cnt1[i]>0) a++;
    REP(i, N) if(cnt1[i]>0 )b += cnt2[i];

    cout << a << " " << b << endl;
    return 0;
}

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

int main(){
  int N;
  double ans = 0;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
    ans += 1.000000 / A.at(i);
  }
  cout << 1 / ans << endl;
}

Measured memory_bytes: 256
import std.string;
import std.stdio;
import std.range;
import std.algorithm;
import std.array;
import std.conv;

void bfs(ref int[] table, int curr) {
  // 上下左右
  int[] directions = [1, 14, -1, -14];
  int[] que;
  que ~= curr;
  while(que != null) {
    auto point = que.front;
    que.popFront;    
    foreach(d; directions) {
      if (point + d < table.length && table[point + d] == 1) {
        que ~= point + d;
        table[point + d] = 0;
      }
    } 
  }
}

void main() {
  while(true) {
    int[] table;
    int count = 0;
    table ~= repeat(0).take(14).array;
    foreach(t; 0..12) {
      string line = readln.chomp;
      table ~= [0] ~ line.array.map!((x) => x.to!(int) - '0').array ~ [0];
    }
    table ~= repeat(0).take(14).array;
    foreach(i; 1..13) {
      foreach(j; 1..13) {
        int num = j + i * 14;
        if (table[num] == 1) {
          bfs(table, num);
          ++count;
        }
      }
    }
    writeln(count);
    readln;
    if (stdin.eof) goto end;
  }
 end:;
}

Measured memory_bytes: 1104
#include <stdio.h>
 int main(int argc, char *argv[])
 {
    int number[1001];
    int n,i,x=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&number[i]);
    for(i=0;i<n-2;i++)
    {
        if(number[i+1]>number[i]&&number[i+2]>number[i+1]) x++;
        else if(number[i+1]<number[i]&&number[i+2]<number[i+1])x++;
        else continue;
    }
    printf("%d\n",x);
    return 0;
 }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

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

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
LL n;
int main() {
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	cin>>n;
	int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
	VL fact(25,0);
	for(int i=2;i<=n;i++){
		int t = i;
		for(int j = 0;j<25;j++){
			while((t % primes[j]) == 0){
				t /= primes[j];
				fact[j]++;
			}
		}
	}
	LL ans = 0;
	
	int a = 0, b = 0, c = 0, d = 0, e=0;
	for(int i = 0;i<25;i++){
		if(fact[i] >= 2)
			a++;
		if(fact[i] >= 4)
			b++;
		if(fact[i] >= 14)
			c++;
		if(fact[i] >= 24)
			d++;
		if(fact[i] >= 74)
			e++;
	}
	// cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<"\n";
	// case 1 -> (2, 24)
	ans += d*(a-1);
	// + (d * (d-1))/2;
	
	// case 2 -> (4, 14)
	ans += c*(b-1);
	// + (c*(c-1))/2 ;
	
	// case 3 -> (2, 4, 4)
	// ans += ((b*(b-1))/2)*(a - b) + (b * (b-1) * (b-2))/6;
	ans += (b * (b-1) * (a-2))/2;

	ans += e;
	cout<<ans;
  	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=2e5;
typedef int fuko[yuzu|10];
int main() {
  int i,n=read(),u,v;
  ll lxy=1ll*n*(n+1)*(n+2)/6;
  for (i=1;i<n;++i) {
    read(u),read(v);
    if (u>v) swap(u,v);
    lxy-=1ll*u*(n-v+1);
  }
  printf("%lld\n",lxy);
}

Measured memory_bytes: 3760
# coding: utf-8
# Your code here!
from collections import deque

N = int(input())
v = deque(sorted(list(map(int, input().split()))))

a = 0
b = 0
tmp = 0

for i in range(N - 1):
    a = v.popleft()
    b = v.popleft()
    tmp = (a + b) / 2.0
    v.appendleft(tmp)
print(v[0])

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long ans1=max(a,b)*max(c,d);
    long long ans2=min(a,b)*min(c,d);
    long long ans3=max(a,b)*min(c,d);
    long long ans4=min(a,b)*max(c,d);
    cout<<max(ans1,max(ans2,max(ans3,ans4)))<<endl;
    return 0;
}


Measured memory_bytes: 3640
a, b = map(int, input().split())
m,n=max(a,b),min(a,b)
if m%n==0:
    print(m)
else:
    while m%n!=0 and n!=1:
        m%=n
        m,n=max(m,n),min(m,n)
    print(int(a*b/n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s; cin>>s;
    vector<bool> al(26,true);
    for(int i=0; i<s.size(); i++){
        al.at(s.at(i)-'a')=false;
    }
    for(int i=0; i<26; i++){
        if(al.at(i)){cout<<char(i+'a')<<endl; return 0;}
    }
    cout<<"None"<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct l{int s,d,t;}l;
int N,M,i,j,I[20001],R;
l L[20001];
int c(const void *a,const void *b)
{
	return (*(l*)a).t-(*(l*)b).t;
}

int main()
{
	for(;scanf("%d%d",&N,&M),N;)
	{
		memset(I,0,sizeof(I));
		I[1]=1;
		for(i=0;i<M;i++)
			scanf("%d%d%d",&L[i].t,&L[i].s,&L[i].d);
		qsort(L,M,sizeof(l),c);
		for(i=0;i<M;i++)
			I[L[i].d]|=I[L[i].s];
		for(i=R=0;i<=N;i++)
			if(I[i])
				R++;
		printf("%d\n",R);
	}
	return 0;
}

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

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

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)(x).size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

vector<ll> ft;

ll query(int i) {
    ll ret = 0;
    for (; ~i; i = (i & (i + 1)) - 1) ret += ft[i];
    return ret;
}

void update(int i, ll d) {
    for (; i < sz(ft); i |= i + 1) ft[i] += d;
}

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

    int n, d, a;
    cin >> n >> d >> a;
    map<int, ii> mon;
    rep(i, n) {
        int x, h;
        cin >> x >> h;
        mon[x].fi = h;
    }

    ft.resize(n + 1);

    int idx = 0;
    for (auto& i : mon) i.se.se = idx++;

    idx = -1;
    ll cnt = 0;
    for (auto& i : mon) {
        idx++;

        ll cdmg = query(idx), hp = i.se.fi - cdmg;
        if (hp <= 0) continue;

        int x = min(1ll << 30, i.fi + 2ll * d);
        int idxReach = (--mon.upper_bound(x))->se.se;
        int atk = (hp + a - 1) / a;
        cnt += atk;

        int dmg = min(1ll << 30, (ll)atk * a);
        update(0, dmg);
        update(idxReach + 1, -dmg);
    }
    cout << cnt;

    return 0;
}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;

  int num = r * 100 + g * 10 + b;
  cout << ((num % 4 == 0) ? "YES" : "NO") << endl;
  return 0;
}

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

string field[101];
int h, w;

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

void sol(int x, int y, char c);

int main()
{
  while (cin >> h >> w){
    if (h == 0 && w == 0) break;
    long ct = 0;
    for (int i = 0; i < h; i++){
      field[i][0] = ' ';
    }
    for (int i = 0; i < h; i++){
      cin >> field[i];
    }
    for (int i = 0; i < w; i++){
      for (int j = 0; j < h; j++){
        char c = field[j][i];
        if (c != '0'){
          field[j][i] = '0';
          sol(i, j, c);
          ct++;
        }
      }
    }
    cout << ct << endl;
  }
}

void sol(int x, int y, char c)
{
  for (int i = 0; i < 4; i++){
    int a = x + dx[i], b = y + dy[i];
    if (!(0 <= a && a < w && 0 <= b && b < h)) continue;
    if (field[b][a] == c){
      field[b][a] = '0';
      sol(a, b, c);
    }
  }
}

Measured memory_bytes: 4248
// AOJ 2804 Minimum Enclosing Rectangle
// 2018.5.5 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct { int x, y; } PP;

#define INF  1e18
#define PI   3.1415926535897932384626433832795
#define H_PI 1.5707963267948966192313216916398
#define EPS  1e-7
#define EQ(a,b)  (fabs((a)-(b))<EPS)

#define MAX_N 100002
int xpos[MAX_N], ypos[MAX_N];
PP  pi[MAX_N<<2], po[MAX_N<<2]; int sz;

int cmp(PP *a, PP *b) {
	if (a->y - b->y) return a->y - b->y;
	return a->x - b->x;
}

PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
int cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
int convex_hull(int n, PP *ps, PP *po)
{
	int i, k, j = 0;

	qsort(ps, n, sizeof(PP), cmp);
	for (i = 0; i < n; i++) {
		while (j > 1 && cross(vsub(po[j-1], po[j-2]), vsub(ps[i], po[j-1])) <= 0) j--;
		po[j++] = ps[i];
	}
	k = j;
	for (i = n - 2; i >= 0; i--) {
		while (j > k && cross(vsub(po[j-1], po[j-2]), vsub(ps[i], po[j-1])) <= 0) j--;
		po[j++] = ps[i];
	}
	return j-1;
}

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void xypos(int id, int x, int y)
{
	xpos[id] = x, ypos[id] = y;
	pi[sz].x = x  , pi[sz].y = y,   sz++;
	pi[sz].x = x+1, pi[sz].y = y,   sz++;
	pi[sz].x = x,   pi[sz].y = y+1, sz++;
	pi[sz].x = x+1, pi[sz].y = y+1, sz++;
}

double area(int n)
{
	int j, x, y;
	int xmin, xmax, ymin, ymax;
	
	xmin = xmax = po[0].x, ymin = ymax = po[0].y;
	for (j = 1; j < n; j++) {
		x = po[j].x, y = po[j].y;
		if      (x < xmin) xmin = x;
		else if (x > xmax) xmax = x;
		if      (y < ymin) ymin = y;
		else if (y > ymax) ymax = y;
	}
	return (double)(xmax-xmin) * (double)(ymax-ymin);
}

int main()
{
	int N, n, i, j, d, x, y;
	double delta, ans;
	double t, fx, fy, xmin, xmax, ymin, ymax, cosv, sinv;


	sz = 0;
	xypos(0, 0, 0);
	N = in();
	for (i = 1; i < N; i++) {
		n = in(), d = gc() & 0xf, gc();
		x = xpos[n], y = ypos[n];
		if      (d == 0) xypos(i, x-1, y);	// 左
		else if (d == 1) xypos(i, x, y+1);  // 下
		else if (d == 2) xypos(i, x+1, y);  // 右
		else             xypos(i, x, y-1);  // 上
	}

	n = convex_hull(sz, pi, po);
	po[n] = po[0];

	ans = area(n);
	for (i = 0; i < n; i++) {
		delta = -atan2(po[i+1].y-po[i].y, po[i+1].x-po[i].x);

		t = delta; if (t < 0) t = -t;
		if (EQ(t, 0) || EQ(t, H_PI) || EQ(t, PI)) continue;

		cosv = cos(delta), sinv = sin(delta);
		x = po[i].x, y = po[i].y;
		xmin = xmax = (po[0].x-x) * cosv - (po[0].y-y) * sinv;
		ymin = ymax = (po[0].x-x) * sinv + (po[0].y-y) * cosv;
		for (j = 1; j < n; j++) {

			fx = (po[j].x-x) * cosv - (po[j].y-y) * sinv;
			fy = (po[j].x-x) * sinv + (po[j].y-y) * cosv;

			if      (fx < xmin) xmin = fx;
			else if (fx > xmax) xmax = fx;
			if      (fy < ymin) ymin = fy;
			else if (fy > ymax) ymax = fy;
		}
		t = (xmax-xmin)*(ymax-ymin);
		if (t < ans) ans = t;
	}
	printf("%.10lf\n", ans);
	return 0;
}



Measured memory_bytes: 8492
def input
n, init_x =  gets.strip.split(/\s/).map(&:to_i)
xs = gets.strip.split(/\s/).map(&:to_i)
return [n, init_x, xs]
end

def gcp(a,b)
   return a if(b == 0)
   gcp(b, a%b)
end

def calc_d(n, init_x, ws)
  t = ws
  t << init_x
  t.sort.each_cons(2).map{|a, b| (a-b).abs }.reduce{|memo, x| gcp(memo, x)}
end


puts calc_d(*input())

Measured memory_bytes: 16616
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
W=[]
w,l=0,0
chg=0
for i in range(n):
  a,b=A[i],B[i]
  if a>=b:
    W.append((a,b,a-b))
    w+=a-b
  else:
    l+=b-a
    chg+=1
W.sort(key=lambda x:x[2])
if l>w:
  print(-1)
else:
  while l>0:
    a,b,c=W.pop()
    l-=c
    chg+=1
  print(chg)



Measured memory_bytes: 19044
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

//????????¢?´¢??¨?????§????????????????????????????????§??????????????????????????????????°??????????

using namespace std;

typedef struct s {
    int Key;
    s *Parent;
    s *Left;
    s *Right;
} Node;

Node *root,*NIL;

void insert(int Key){
    Node *x = root;//?§????????????¢?????¬???
    Node *y = NIL;//??¢?????¬???????????????????????¨????????????NIL??§?????????
    Node *z;//??¬???
    
    z = (Node *)malloc(sizeof(Node));
    z -> Key = Key;
    z -> Left = NIL;
    z -> Right = NIL;
    
    //x???NIL????????????
    while (x != NIL) {
        y = x;
        if (z -> Key < x -> Key) {
            x = x -> Left;
        }else{
            x = x -> Right;
        }
    }
    
    z -> Parent = y;
    //root??????NIL??????????????£?????´???
    //
    if (y == NIL) {
        root = z;
    }else{
        if (z -> Key < y -> Key) {
            y -> Left = z;
        }else{
            y -> Right = z;
        }
    }
}

bool find(int Key){
    Node *f = root;
    
    while (f != NIL) {
        if(f -> Key > Key) f = f -> Left;
        else if (f -> Key < Key) f = f -> Right;
        else return true;
    }
    return false;
}

void inoder(Node *n){
    if (n == NIL) return;
    inoder(n -> Left);
    cout << " " << n -> Key;
    inoder(n -> Right);
}

void preoder(Node *n){
    if (n == NIL) return;
    cout << " " << n -> Key;
    preoder(n -> Left);
    preoder(n -> Right);
}

int main(){
    root = NIL;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string com;
        cin >> com;
        if (com == "insert") {
            int num;
            scanf("%d",&num);
            insert(num);
        }else if (com == "find"){
            int num;
            scanf("%d",&num);
            if(find(num)) cout << "yes" << endl;
            else cout << "no" << endl;
        }else{
            inoder(root);
            cout << endl;
            preoder(root);
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 20016
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

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

    ans = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
    printf("%lf\n", ans);
}


Measured memory_bytes: 3188
time = 2
list = [list(map(int,input().split())) for i in range(time)] #list[0]にnとxが,list[1]にL1~Lnが入る
n, x = [i for i in list[0]]

y = [0]
n = 1
for i in range(len(list[1])):
    y.append(y[i] + list[1][i])
    if (y[i+1] > x):
        break
    n += 1


print(n)

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

int main(){
  int N,K,a,b;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    cin >> b;
    if(b >= K){
      a++;
    }
  }
  cout << a << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (){
	int a, b;
	cin >> a >> b;
	if (a<b)
		cout << "a < b" <<endl;
	else if (a==b)
		cout << "a == b"<<endl;
	else 
		cout << "a > b"<<endl;
	return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n){
        string s;
        cin >> s;
        sort(all(s));
        mp[s]++;
    }
    ll sum=0;
    for(auto p : mp){
        int k = p.second;
        sum+=1LL*k*(k-1)/2;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 11264
N, M = map(int, input().split())

p_dict = {}

for i in range(M):
  p, y = map(int, input().split())
  if p not in p_dict.keys():
    p_dict[p] = [[y, p, i]]
  else:
    p_dict[p].append([y, p, i])
  
ans = []
for p in p_dict.keys():
  p_dict[p].sort()
  for i in range(len(p_dict[p])):
    p_dict[p][i].append(i + 1)
    ans.append(p_dict[p][i])
    
ans.sort(key=lambda x: x[2])
for y, p, oi, si in ans:
  print("{:06d}{:06d}".format(p, si))

Measured memory_bytes: 49412
#include <stdio.h>

int main(){
  int i,j;
  int n,a;

  scanf("%d",&n);
  int data[n];
  for(i = 0;i < n;i++){
    scanf("%d",&a);
    data[i] = a;
  }

  for(j = 0;j < n;j++){
    int key = data[j];
    i = j -1;
    while(i>=0 && data[i] > key){
      data[i+1] = data[i];
      data[i] = key;
      i = i-1;
    }
    for(i = 0;i < n;i++){
    printf("%d",data[i]);
    if(i==n-1) break;
    printf(" ");
    }
  printf("\n");
  }
   
  return 0;
}



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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 1000000007
int main() {
	int n = ri();
	int k = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	int dp[n + 1][k + 1];
	memset(dp, 0, sizeof(dp));
	dp[0][k] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= k; j++) {
			if (j) {
				dp[i][j] += dp[i][j - 1];
				if (dp[i][j] >= MOD) dp[i][j] -= MOD;
			}
			int min = std::max(0, j - a[i]);
			dp[i + 1][min] += dp[i][j];
			if (dp[i + 1][min] >= MOD) dp[i + 1][min] -= MOD;
			if (j + 1 <= k) {
				dp[i + 1][j + 1] -= dp[i][j];
				if (dp[i + 1][j + 1] < 0) dp[i + 1][j + 1] += MOD;
			}
		}
	}
	std::cout << dp[n][0] << std::endl;
	return 0;
}


Measured memory_bytes: 39680
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;

int main() {
	int n;
	cin >> n;
	for(int i=0; i<n; i++) {
		string input;
		cin >> input;
		int btn[9] = {};
		for(int j=0; j<input.size(); j++) {
			if(input[j] != '0') {
				btn[(int)input[j] - '0' - 1]++;
			}
			else {
				for(int k=0; k<9; k++) {
					if(btn[k] > 0) {
						if(k == 0) {
							if(btn[k]%5 == 1) cout << '.';
							if(btn[k]%5 == 2) cout << ',';
							if(btn[k]%5 == 3) cout << '!';
							if(btn[k]%5 == 4) cout << '?';
							if(btn[k]%5 == 0) cout << ' ';
						}
						else if(k == 1) {
							if(btn[k]%3 == 1) cout << 'a';
							if(btn[k]%3 == 2) cout << 'b';
							if(btn[k]%3 == 0) cout << 'c';
						}
						else if(k == 2) {
							if(btn[k]%3 == 1) cout << 'd';
							if(btn[k]%3 == 2) cout << 'e';
							if(btn[k]%3 == 0) cout << 'f';
						}
						else if(k == 3) {
							if(btn[k]%3 == 1) cout << 'g';
							if(btn[k]%3 == 2) cout << 'h';
							if(btn[k]%3 == 0) cout << 'i';
						}
						else if(k == 4) {
							if(btn[k]%3 == 1) cout << 'j';
							if(btn[k]%3 == 2) cout << 'k';
							if(btn[k]%3 == 0) cout << 'l';
						}
						else if(k == 5) {
							if(btn[k]%3 == 1) cout << 'm';
							if(btn[k]%3 == 2) cout << 'n';
							if(btn[k]%3 == 0) cout << 'o';
						}
						else if(k == 6) {
							if(btn[k]%4 == 1) cout << 'p';
							if(btn[k]%4 == 2) cout << 'q';
							if(btn[k]%4 == 3) cout << 'r';
							if(btn[k]%4 == 0) cout << 's';
						}
						else if(k == 7) {
							if(btn[k]%3 == 1) cout << 't';
							if(btn[k]%3 == 2) cout << 'u';
							if(btn[k]%3 == 0) cout << 'v';
						}
						else if(k == 8) {
							if(btn[k]%4 == 1) cout << 'w';
							if(btn[k]%4 == 2) cout << 'x';
							if(btn[k]%4 == 3) cout << 'y';
							if(btn[k]%4 == 0) cout << 'z';
						}
						for(int l=0; l<9; l++) btn[l] = 0;
						break;
					}
				}
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s=="SUN") cout << 7 << endl;
    else if(s=="MON") cout << 6 << endl;
    else if(s=="TUE") cout << 5 << endl;
    else if(s=="WED") cout << 4 << endl;
    else if(s=="THU") cout << 3 << endl;
    else if(s=="FRI") cout << 2 << endl;
    else if(s=="SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define all(n)      (n).begin(), (n).end()
#define ll long long 
#define PI 3.14159265358979323846

void solve(){
	int r; cin >> r; 
	long double ans;
	ans = (2 * PI * r);
	cout << setprecision(40) << ans << endl;
	

}


int main (){
	#ifndef ONLINE_JUDGE
		freopen ("input.txt","r",stdin);
		freopen ("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	
		solve();
	
	return 0;
}

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

int main()
{
  int a, b, k;
  cin >> a >> b >> k;

  if(b - a < k*2){
    for(int i = a; i <= b; i++) cout << i << endl;
  }

  else{
    for(int i = 0; i < k; i++) cout << a + i << endl;
    for(int i = k - 1; i >= 0; i--) cout << b - i << endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const int N=10000010;
ll f[N];
int main(){
    ll n,ans=0;
    scanf("%lld",&n);
    for(ll i=1;i<=N-10;i++){
        for(ll j=i;j<=N-10;j+=i){
            f[j]++;
        }
    }
    for(ll i=1;i<=n;i++) ans+=i*f[i];
    printf("%lld",ans);
}


Measured memory_bytes: 81944
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]); lines.shift();
    var CSF = lines.map(i => i.split(" ").map(i => Number(i)));

    for (var i = 0; i < N - 1; i++) {
        var time = 0;

        for (var j = i; j < N - 1; j++) {
            var C = CSF[j][0], S = CSF[j][1], F = CSF[j][2];

            // 始発が動いていない時間に駅に到着した場合，始発まで待つ
            if (time < S) { time = S; }

            // 始発が動いているなら，次出発する電車に乗る
            else {
                var x = (time - S) % F; time -= x
                if (x !== 0) time += F;
            }

            // 次の駅までC秒かかる
            time += C;
        }
        console.log(time);
    }
    console.log(0);
});

Measured memory_bytes: 9564
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var C = new int[3, 3];
        for(var i = 0; i < 3; i++)
        {
            var input = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
            for (var j = 0; j < 3; j++)
            {
                C[i, j] = input[j];
            }
        }

        var isExist = false;
        for (var a1 = 0; a1 <= C[0, 0]; a1++)
        {
            var b1 = C[0, 0] - a1;
            var b2 = C[0, 1] - a1;
            var b3 = C[0, 2] - a1;
            var a2 = C[1, 0] - b1;
            var a3 = C[2, 0] - b1;

            if (C[1, 1] == a2 + b2 && C[1, 2] == a2 + b3 &&
                C[2, 1] == a3 + b2 && C[2, 2] == a3 + b3)
            {
                isExist = true;
            }
        }

        Console.WriteLine(isExist ? "Yes" : "No");
    }
}


Measured memory_bytes: 28184
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i(0);i<n;i++)

using namespace std;
int main(){
    int n;
    cin >> n;
    bool ans = false;
    for(int i(2);i<=9;i++){if(n%i==0 && n/i<10) ans = true;}
    if(n==1)ans =true;
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        System.out.println(Math.max(c - a + b, 0));
    }
}


Measured memory_bytes: 21844
void main()
{
    int n = readln.chomp.to!int;
    int[] a = new int[n];
    foreach (i; 0 .. n)
    {
        a[i] = readln.chomp.to!int;
    }

    a.sort!"a < b";
    auto g = a.group.array;
    int cnt;
    foreach (x; g)
    {
        if (x[1] & 1) ++cnt;
    }

    cnt.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: 2428