akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

#include <iostream>
#include <vector>

class union_find
{
  std::vector<size_t> parent;
  std::vector<size_t> rank;

public:
  // 初期化
  union_find(size_t size)
  {
    parent.resize(size);
    rank.resize(size);
    for(size_t i=0;i<size;i++)
      {
        parent[i]=i;
        rank[i]=1;
      }
  }

  // aとbをグルーピング
  void unite(size_t a,size_t b)
  {
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(rank[a]<rank[b])
      parent[a]=b;
    else
      parent[b]=a;
    if(rank[a]==rank[b])
      rank[a]++;
  }

  size_t find(size_t node)
  {
    if(parent[node]==node)
      return node;
    else
      return parent[node]=find(parent[node]);
  }

  bool same(size_t a, size_t b)
  {
    return find(a)==find(b);
  }
};

signed main(void)
{
  in(int,n,q);
  union_find uf(n);
  int i;
  rep(i,q)
    {
      in(int,c,x,y);
      if(c==0)
        uf.unite(x,y);
      else
        putv(uf.same(x,y));
    }
}



Measured memory_bytes: 3252
n = int(input())
a=list(input())
b=list(input())
c=list(input())
res = 0
for i in range(n):
    d = len(list(set([a[i],b[i],c[i]])))
    if d == 3:
        res += 2
    elif d == 2:
        res += 1
print(res)

Measured memory_bytes: 3316
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
ab = [None] * (N - 1)
for i in range(N - 1):
    ab[i] = list(map(int, input().split()))
ab = sorted(ab, key=lambda x: (x[0], x[1]))

px_n = [0] * N
for i in range(Q):
    p, x = list(map(int, input().split()))
    px_n[p-1] += x

ans = [0] * N
ans[0] = px_n[0]
for (a, b) in ab:
    ans[b-1] += ans[a-1] + px_n[b-1]

print(*ans)


Measured memory_bytes: 92764
package main

import "fmt"

func main() {
	var (
		n, a, b int
	)

	fmt.Scan(&n)

	if n == 1 {
		fmt.Printf("Hello World")
	} else if n == 2 {
		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Print(a + b)
	}
}


Measured memory_bytes: 1828
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	if( n % 111 == 0 ) cout << n << endl;
	else cout << (n / 111 + 1) * 111 << endl;
	
	return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main(){
char a[100010][5],s;
int n,m,i,j;
while(1){
scanf("%d\n",&n);
if(n==0){
break;
}
for(i=0;i<n;i++){
scanf("%c %c\n",&a[i][0],&a[i][1]);
}
scanf("%d\n",&m);
for(i=0;i<m;i++){
scanf("%c\n",&s);
for(j=0;j<n;j++){
if(a[j][0]==s){
printf("%c",a[j][1]);
break;
}
}
if(j==n){
printf("%c",s);
}
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2028
N,x = list(map(int,input().split(" ")))
a=list(map(int,input().split(" ")))

def solve(N,x,a):
	a.insert(0,0)
	count=0
	for i in range(len(a)-1):
		if a[i]+a[i+1]>x:
			eat=a[i+1]+a[i]-x
			count+=eat
			a[i+1]-=eat
	return(count)


print(solve(N, x, a))


Measured memory_bytes: 14252
S = input()
N = len(S)

if N == 2 and S[0] == S[1]:
  print(1, 2)
  quit()

for i in range(N-2):
  if len(set(S[i:i+3])) <= 2:
    print(i+1, i+3)
    quit()

print(-1, -1)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

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

using namespace std;

/*thief??????*/

int main(void){
    
    int input[120] = {0};
    int c  = 1;
    int check[101] = {0};
    int asnwer[101] = {0};
    int max = 0;
    while(cin >> input[c])
    {
        int temp = input[c];
        check[temp]++;
        c++;
    }
    REP(i, 101)
        if(max <= check[i])
            max = check[i];
    
    REP(i,101) if(check[i] == max) cout << i << endl;
    return 0;
        }

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,sh=1,cnt=0,flag=0;
  vector<int> a(100010);
  cin>>n;
  for(int i=0; i<n; i++)
    cin>>a.at(i);
  
  for(int i=0; i<n; i++){
    sh=a.at(sh-1);
    cnt++;
    if(sh==2 && flag==0){
      cout<<cnt<<endl;
      flag=1;
    }
  }
  if(flag==0)
    cout<<"-1"<<endl;
}

Measured memory_bytes: 640
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    n,A,B,C = map(int, readline().split())
    N = A + B + C
    S = [readline().strip() for _ in range(n)]

    ans = []
    possible = True
    for i, s in enumerate(S):
        if s == "AB":
            if A + B == 0:
                print("No")
                possible = False
                break
            
            if i < n - 1 and N == 2 and A == B == 1:
                if S[i+1] == "AC":
                    A += 1
                    B -= 1
                    ans.append("A")
                elif S[i+1] == "BC":
                    A -= 1
                    B += 1
                    ans.append("B")
                else:
                    A += 1
                    B -= 1
                    ans.append("A")
            else:
                if A < B:
                    A += 1
                    B -= 1
                    ans.append("A")
                else:
                    A -= 1
                    B += 1
                    ans.append("B")

        elif s == "AC":
            if A + C == 0:
                print("No")
                possible = False
                break
            
            if i < n - 1 and N == 2 and A == C == 1:
                if S[i+1] == "AB":
                    A += 1
                    C -= 1
                    ans.append("A")
                elif S[i+1] == "BC":
                    A -= 1
                    C += 1
                    ans.append("C")
                else:
                    A += 1
                    C -= 1
                    ans.append("A")
            else:
                if A < C:
                    A += 1
                    C -= 1
                    ans.append("A")
                else:
                    A -= 1
                    C += 1
                    ans.append("C")

        else:
            if B + C == 0:
                print("No")
                possible = False
                break
            
            if i < n - 1 and N == 2 and B == C == 1:
                if S[i+1] == "AB":
                    B += 1
                    C -= 1
                    ans.append("B")
                elif S[i+1] == "AC":
                    B -= 1
                    C += 1
                    ans.append("C")
                else:
                    B += 1
                    C -= 1
                    ans.append("B")
            else:
                if B < C:
                    B += 1
                    C -= 1
                    ans.append("B")
                else:
                    B -= 1
                    C += 1
                    ans.append("C")

    if possible:
        print("Yes")
        print("\n".join(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 17312
l,r = map(int,input().split())
ans = 1000000000000000000000000
if r-l >= 2019:
    print(0)
    exit()
else:
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            ans = min(ans, i*j%2019)
print(ans)

Measured memory_bytes: 40812
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FOR(i,a,b) for(i=a;i<=b;i++)

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll n;
ll a[200010],b[200010],A;


int main()
{
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	A = a[n - 1];
	for (ll i = 0; i < n; i++) {
		b[i] = a[i];
	}

	for (ll i = 0; i < n; i++) {
		if (a[i] > A - a[i]) {
			a[i] = A - a[i];
		}
	}
	sort(a, a + n);
	cout << A << " ";

	for (ll i = 0; i < n; i++) {
		if (b[i] == a[n - 1]) {
			cout << b[i];
			return 0;
		}
	}

	cout << (A - a[n - 1]);


    return 0;
}



Measured memory_bytes: 1920
n = int(input())
A = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    A[i].append(i)

B = [[j for j in i] for i in A]

A.sort()
B.sort(key=lambda x:x[1])

M = []
for i in range(n-1):
    M.append([A[i][2], A[i+1][2], A[i+1][0]-A[i][0]])
    M.append([B[i][2], B[i+1][2], B[i+1][1]-B[i][1]])

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def size(self, x):
        if self.parents[x] < 0:
            return -self.parents[x]
        else:
            self.parents[x] = self.size(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
# print(M)

M.sort(key=lambda x:x[2])
ans = 0
U = UnionFind(n+1)
for i in range(len(M)):
    if U.find(M[i][0]) != U.find(M[i][1]):
        U.union(M[i][0], M[i][1])
        ans += M[i][2]
        # print(M[i])

print(ans)

Measured memory_bytes: 126296
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int op(int a, int b) { return max(a, b); }
int e() { return 0LL; }
int main() {
	int n, k;
	cin >> n >> k;
	Vi a(n);
	cin >> a;
	segtree<int, op, e> seg(300010);
	rep(i, n) {
		seg.set(a[i], 1 + seg.prod(max(0, a[i] - k), min(300010, a[i]  +1+k)));
	}
//	rep(i, 100) {
//		clog << i << " " << seg.get(i) << endl;
//		
//	}
//	clog << endl;
	cout << seg.all_prod() << endl;
}

Measured memory_bytes: 9584
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    vector <int> a = igets(3);
    cout << min(a[2],a[0]*a[1]) << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    ev = [(num + 1) / 2 for num in p]

    cumsum = []
    c = 0
    for num in ev:
        c += num
        cumsum.append(c)
    cumsum.append(0)  # let cumsum[-1] be 0
    
    ans = 0
    for i in range(n):
        if i + k - 1 > n - 1:
            break
        nominee = cumsum[i+k-1] - cumsum[i-1]
        if nominee > ans:
            ans = nominee

    print(ans)

main()


Measured memory_bytes: 24804
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        HashSet<String> passwords = new HashSet<>();
        for (int i = 1; i <= n; i++) {
            String password = Integer.toString(i);
            for (int j = 1; j <= n; j++) {
                password += j;
                for (int k = 1; k <= n; k++) {
                    passwords.add(password += k);
                }
            }
        }

        System.out.println(passwords.size());
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld\n",x)
#define print2(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 333333


int main(void) {
  cin >> n;
  if (n == 1)cout << "Hello World" << endl;
  else {
	ll a, b;
	cin >> a >> b;
	cout << a + b << endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() 
{
	long i,j,n,ans=0;
	long m=0,a=0,r=0,c=0,h=0;
	string s[100001];
  	cin >> n;

	for(i=0;i<n;i++){
		cin >> s[i];
	} 
	for(i=0;i<n;i++){
		if(s[i][0]=='M'){
			m++;
		}
		if(s[i][0]=='A'){
			a++;
		}
		if(s[i][0]=='R'){
			r++;
		}
		if(s[i][0]=='C'){
			c++;
		}
		if(s[i][0]=='H'){
			h++;
		}
	} 
	ans=(m*a*r)+(m*a*c)+(m*a*h)+(m*r*c)+(m*r*h)+(m*c*h)+(a*r*c)+(a*r*h)+(a*c*h)+(r*c*h);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6144
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    for(int i=0; i<n; ++i)
        cin >> s[i];
    for(int i=0; i<m; ++i)
        cin >> t[i];

    vector<vector<vector<int> > > dp(2, vector<vector<int> >(n+1, vector<int>(m+1, 0)));
    dp[0][0][0] = 1;
    for(int i=0; i<=n; ++i){
        for(int j=0; j<=m; ++j){
            for(int k=0; k<2; ++k){
                if(i < n && j < m && s[i] == t[j]){
                    dp[0][i+1][j+1] += dp[k][i][j];
                    dp[0][i+1][j+1] %= MOD;
                }
                if(i < n && k == 0){
                    dp[0][i+1][j] += dp[k][i][j];
                    dp[0][i+1][j] %= MOD;
                }
                if(j < m){
                    dp[1][i][j+1] += dp[k][i][j];
                    dp[1][i][j+1] %= MOD;
                }
            }
        }
    }
    int ans = (dp[0][n][m] + dp[1][n][m]) % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 47360
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta, n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define RRep(i,sta, n) for(int i=sta;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())S
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;

    vector<int> v(n+1,0);
    REP(i, n){
        v[i+1]=v[i]+((s[i] == 'A' && s[i+1] == 'C')?1:0);
    }

    vector<int> ans(q,0);
    REP(i, q){
        int l,r;
        cin >> l >> r;
        ans[i]=v[r-1]-v[l-1];
    }
    REP(i, q){
        pr(ans[i]);
    }
}

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

int main()
{
	vector<int> Vec(100);
	int n;
	while(cin>>n){
		Vec[n]++;
	}
	int max_r = 0, ans=0;
	for(int i=0;i<Vec.size();i++){
		max_r = max( max_r, Vec[i]);
	}
	for(int i=0;i<Vec.size();i++){
		if(max_r == Vec[i]){
			cout<<i<<endl;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 1192
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll a, b;
  cin >> a >> b;
  cout << (a/b) << " " << (a%b) << " " << (1.0*a/b) << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3244
#include <stdio.h>

int main(void)
{
	int S,h,m,s;
	scanf ("%d",&S);
	h=S/3600;
	S=S%3600;
	m=S/60;
	s=S%60;
	printf ("%d:%d:%d\n",h,m,s);
		
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;

string s;
ll ans;
set<string> se;

string create(int n) {
	string t;
	ll f = 0;
	if (n == 0) {
		return s;
	}
	while (n > 0) {
		t += s[f++];

		if (n % 2 == 1) {
			t += '+';
		}
		n /= 2;
	}
	rep(i, f, s.size()) {
		t += s[i];
	}

	return t;
}
ll convertV(string s) {
	ll ans = 0;
	ll t = 1;

	for (int i = s.size() - 1; i >= 0; i--) {
		rep(k, 0, i) {
			t *= 10;
		}
		ans += (ll)((s[s.size() - 1 - i] - '0') * t);
		t = 1;
	}

	return ans;
}

ll calc(string s) {
	string p;
	map<string, ll> value;
	rep(i, 0, s.size()) {
		if (s[i] == '+') {
			value[p]++;
			p = "";
		}
		else if (s[i] == '0' && i >= 1 && s[i - 1] == '+') {
		}
		else {
			p += s[i];
		}
		if (i == s.size() - 1) {
			value[p]++;
		}
	}

	ll cnt = 0;
	for (map<string, ll>::iterator it = value.begin(); it != value.end(); it++) {
		rep(i, 0, it->second) {
			cnt += convertV(it->first);
		}
	}
	return cnt;
}

int main() {
	cin >> s;
	ll dig = s.size();

	for (int i = 0; i < 1 << (dig - 1); i++) {
		string t = create(i);
		se.insert(t);
	}

	for (set<string>::iterator it = se.begin(); it != se.end(); it++) {
		//cout << *it << endl;
		ans += calc(*it);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
  ll n;
  cin>>n;
  vector<pair<string,ll>>v;
  map<pair<string,ll>,ll>m;
  rep(i,0,n){
    string s;
    ll x;
    cin>>s>>x;
    v.pb(mp(s,x));
    m[mp(s,x)]=i+1;
  }
  sort(v.begin(),v.end(),comp);
  for(int i=0;i<v.size();i++){
    cout<<m[v[i]]<<endl;
  }

  }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define ll unsigned long long
using namespace std;

int main(){
    int A,B,C,K,ans=0;
    cin >> A >> B >> C >> K;
    if(A >= K){
        ans = K;
    }else{
        ans = A;
        K = K - A;
        // cout << K << endl;
        if(B >= K){
            
        }else{
            K = K-B;
            // cout << K << endl;
            ans = ans - K;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 1000005;
const int mod = 1e9 + 7;

int n, ans[N], fac[N], inv[N];

inline int F(int x, int y) {
  if (x < y) {
    return 0;
  }
  return 1LL * fac[x] * inv[x - y] % mod;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), fac[0] = fac[1] = inv[0] = inv[1] = 1;
  for (int i = 2; i <= n; ++i) {
    fac[i] = 1LL * fac[i - 1] * i % mod;
    inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
  }
  for (int i = 2; i <= n; ++i) {
    inv[i] = 1LL * inv[i - 1] * inv[i] % mod;
  }
  for (int i = 1; i < n; ++i) {
    ans[i] = 1LL * fac[i] * F(i - 1, n - i - 1) % mod;
  }
  int ret = 0;
  for (int i = n - 1; i; --i) {
    ans[i] = (ans[i] - ans[i - 1] + mod) % mod;
    ret = (1LL * ans[i] * i + ret) % mod;
  }
  printf("%d\n", ret);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


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

int main() {

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

  int n;
  cin >> n;
  int dp[20][20];
  memset(dp, 0, sizeof dp);

  for (int i = 1; i <= n; ++i) {
    string tmp = to_string(i);
    int f = tmp[0] - '0';
    int l = tmp.back() - '0';
    dp[f][l]++;
  } 

  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    string tmp = to_string(i);
    int f = tmp[0] - '0';
    int l =tmp.back() - '0';
    ans += dp[l][f];
  
    string r = tmp;
    reverse(r.begin(), r.end());
    // ans -= (tmp == r);    
  }

  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> P(M), Y(M);
    vector<vector<int>> data(N + 1);
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        data[P[i]].push_back(Y[i]);
    }
 
    for (int i = 0; i < N + 1; i++) {
        sort(all(data[i]));
    }
 
    for (int i = 0; i < M; i++) {
        vector<int> &d = data[P[i]];
        int k = lower_bound(all(d), Y[i]) - d.begin();
        
        printf("%06d%06d\n", P[i], k + 1);
    }
 
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 7808
#include<stdio.h>
int main(void) {
	int a, b, t;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &t);

	int ans = 0;

	int syou = 0;

	syou = t / a;

	ans = b * syou;

	printf("%d\n", ans);
	

	return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int H = scan.nextInt();
			if (H == 0) {
				scan.close();
				break;
			}
			int W = scan.nextInt();

			char[][] table = new char[H][];
			for (int i = 0; i < table.length; i++) {
				// 与えられるテーブルをしまっておく
				table[i] = scan.next().toCharArray();
			}

			String answer = "";// 解答
			int[] dir = { -1, 0, 1 };// 方向

			@SuppressWarnings("unchecked")
			ArrayList<String>[][] parts = new ArrayList[26][201];// [頭文字][長さ]の文字列を格納する
			for (int i = 0; i < parts.length; i++) {
				for (int j = 0; j < parts[i].length; j++) {
					parts[i][j] = new ArrayList<String>();
				}
			}

			for (int i = 0; i < table.length; i++) {
				for (int j = 0; j < table[i].length; j++) {
					for (int k = 0; k < dir.length; k++) {
						for (int l = 0; l < dir.length; l++) {
							if (dir[k] == dir[l] && dir[k] == 0) {
								continue;
							}

							int nowi = i;
							int nowj = j;
							StringBuilder sb = new StringBuilder();
							sb.append(table[nowi][nowj]);

							while (true) {
								nowi = (nowi + dir[k] + H) % H;
								nowj = (nowj + dir[l] + W) % W;

								if (nowi == i && nowj == j) {
									// 元の場所に戻ってきてたら終わる
									break;
								}

								sb.append(table[nowi][nowj]);// 文字を後ろに付け加える

								char init = (char) (table[i][j] - 'A');// 頭文字
								String seq = sb.toString();// 文字列
								int length = sb.length();// 文字列の長さ

								if (parts[init][length].contains(seq)) {
									if (length > answer.length()) {
										answer = seq;
									} else if (length == answer.length()) {
										// 文字列の長さが同じ時は辞書順で前のやつを採用する
										if (answer.compareTo(seq) > 0) {
											answer = seq;
										}
									}
								} else if (length >= 2) {
									// 2文字以上ならリストに加えておく
									parts[init][length].add(seq);
								}
							}
						}
					}

				}
			}
			if (answer.equals("")) {
				System.out.println(0);
			} else {
				System.out.println(answer);
			}
		}

	}
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m, k;
  cin >> m >> k;
  if (m == 1) {
    if (k == 0) {
      cout << "0 0 1 1\n";
    } else {
      cout << -1 << '\n';
    }
    return 0;
  } else if (m == 0) {
    if (k == 0) {
      cout << "0 0" << '\n';
    } else {
      cout << -1 << '\n';
    }
    return 0;
  }
  if (k >= (1 << m)) {
    cout << -1 << '\n';
    return 0;
  }
  for (int i = 0; i < (1 << m); i++) {
    if (i != k) {
      cout << i << ' ';
    }
  }
  cout << k << ' ';
  for (int i = (1 << m) - 1; i >= 0; i--) {
    if (i != k) {
      cout << i << " ";
    }
  }
  cout << k << '\n';
  return 0;
}

Measured memory_bytes: 1792
from math import factorial

N, A, B = map(int, input().split())
V = [int(i) for i in input().split()]
V.sort(reverse=True)

a = 0
for i in range(A):
    a += V[i]
a /= A
print(a)

c = 0

if V[0] != V[A-1]:
    r = 0
    while True:
        r += 1
        if V[A-1-r] != V[A-1]:
            break
    n = 0
    while True:
        if A+n > N-1:
            break
        if V[A+n] != V[A-1]:
            break
        n += 1
    n += r
    c = round(factorial(n) / factorial(r) / factorial(n-r))

else:
    n = 0
    while True:
        n += 1
        if n > N-1:
            break
        if V[n] != V[0]:
            break
    B = min(B, n)
    for i in range(B-A+1):
        c += round(factorial(n) / factorial(A+i) / factorial(n-A-i))

print(c)


Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
    int w,h,n;cin >> w >> h >> n;
    vector<vector<bool>> white(w,vector<bool>(h,true));
    rep(i,n){
        int x,y,a;cin >> x >> y >> a;
        if(a==1)rep(j,x)rep(k,h)white[j][k]=false;
        else if(a==2)rep2(j,x,w)rep(k,h)white[j][k]=false;
        else if(a==3)rep(j,w)rep(k,y)white[j][k]=false;
        else if(a==4)rep(k,w)rep2(j,y,w)white[k][j]=false;
    }
    int ans=0;
    rep(i,w)rep(j,h)if(white[i][j])ans++;
    printf("%d\n",ans);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = double.Parse(Console.ReadLine());
            Console.WriteLine(l * l * l / 27);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    ll dp[n+1][5];
    for(int i=0;i<5;i++)dp[0][i]=0;
    for(int i=0;i<n;i++){
    	dp[i+1][0]=dp[i+1][4]=dp[i][0]+a[i];
    	dp[i+1][1]=min(dp[i][1]+a[i]%2,dp[i][0]+a[i]%2)+(a[i]==0?2:0);
    	dp[i+1][2]=min(dp[i][2]+(a[i]+1)%2,min(dp[i][1]+(a[i]+1)%2,dp[i][0]+(a[i]+1)%2));
    	dp[i+1][3]=min(min(dp[i][3]+a[i]%2,dp[i][2]+a[i]%2),min(dp[i][1]+a[i]%2,dp[i][0]+a[i]%2))+(a[i]==0?2:0);
    	for(int j=1;j<5;j++)dp[i+1][4]=min(dp[i+1][4],dp[i][j]+a[i]);
    }
    ll ans=1e18;
    for(int i=0;i<5;i++)ans=min(ans,dp[n][i]);
    cout <<ans<<endl;
    return 0;
}


Measured memory_bytes: 9728
#include <stdio.h>

int main(void)
{
	int a;
	int b = 0;
	while(1){
		scanf("%d",&a);
		if(a != 0){
			b++;
			printf("Case %d: %d\n",b,a);
		}
		else{
			break;
		}
	}
	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> ans(N);
    rep (i, N) {
        ll A;
        cin >> A;
        ans[A-1] = i+1;
    }

    rep (i, N) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }

}


Measured memory_bytes: 256
n, c, k = map(int, input().split())
T = [int(input()) for _ in range(n)]
T.sort()
cnt = 0
ans = 1
t = T[0]
for i in range(n):
    cnt += 1
    if cnt > c or T[i] > t + k:
        ans += 1
        cnt = 1
        t = T[i]
print(ans)


Measured memory_bytes: 50648
let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m

let () = Scanf.scanf "%d" @@ fun n ->
  let dp = Array.make_matrix 63 3 0 in
  dp.(62).(2) <- 1;
  for i = 61 downto 0 do
    if n land (1 lsl i) <> 0 then begin
      dp.(i).(0) <- dp.(i + 1).(0) *^ 3 +^ 2 *^ dp.(i + 1).(1);
      dp.(i).(1) <- dp.(i + 1).(1) +^ dp.(i + 1).(2);
      dp.(i).(2) <- dp.(i + 1).(2)
    end else begin
      dp.(i).(0) <- dp.(i + 1).(0) *^ 3 +^ dp.(i + 1).(1);
      dp.(i).(1) <- dp.(i + 1).(1);
      dp.(i).(2) <- dp.(i + 1).(1) +^ dp.(i + 1).(2)
    end
  done;
  Printf.printf "%d\n" @@ Array.fold_left ( +^ ) 0 dp.(0)

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=50005;
int mod;
int n,x[N],y[N],a[N],b[N],c[N],ans[N];
int fastpow(int a,int x){
	int res=1;
	while(x){
		if(x&1){
			res=1LL*res*a%mod;
		}
		x>>=1;
		a=1LL*a*a%mod;
	}
	return res;
}
int main(){
	scanf("%d",&n);
	mod=n;
	n--;
	a[0]=1;
	for(int i=0;i<=n;i++){
		x[i]=i;
		scanf("%d",&y[i]);
		b[0]=0;
		for(int j=1;j<=i+1;j++){
			b[j]=a[j-1];
		}
		for(int j=0;j<=i;j++){
			b[j]=(b[j]-1LL*x[i]*a[j]%mod+mod)%mod;
		}
		for(int j=0;j<=i+1;j++){
			a[j]=b[j];
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n+1;j++){
			b[j]=a[j];
		}
		for(int j=n+1;j>=1;j--){
			c[j-1]=b[j];
			b[j-1]=(b[j-1]+1LL*b[j]*x[i]%mod+mod)%mod;
		}
		int tmp=1;
		for(int j=0;j<=n;j++){
			if(j!=i){
				tmp=1LL*tmp*(x[i]-x[j]+mod)%mod;
			}
		}
		tmp=1LL*y[i]*fastpow(tmp,mod-2)%mod;
		for(int j=0;j<=n;j++){
			c[j]=1LL*c[j]*tmp%mod;
			ans[j]=(ans[j]+c[j])%mod;
		}
	}
	for(int i=0;i<=n;i++){
		printf("%d ",ans[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
	#include<vector>
	#include<algorithm>
	#include<string>
	#include<cmath>
	#include<map>
	#include<cstdio>
	#include<stack>
	#include<queue>
	#include<fstream>
	#include<cstdio>
	#include<deque>
	#include<iomanip>
	#include <numeric>
	//#include<bits/stdc++.h>

	using namespace std;
	#define ok1 printf("ok1\n");
	#define ok2 printf("ok2\n");
	#define M 1000000000000000000LL
	#define rep(i,n) for(int i=0;i<n;i++)
	#define REP(i,s,n) for(int i=(s);i<(n);i++)
	#define repr(i,n) for(int i=n-1;i>=0;i--)
	#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
	#define all(a) (a).begin(),(a).end()
	#define reall(a) (a).rbegin(),(a).rend()
	#define pb push_back
	#define pf push_front
	#define MIN(a,b) a=min((a),(b))
	#define MAX(a,b) a=max((a),(b))
	#define SIZE(v) (int)v.size()
	const double pi = acos(-1.0);

	typedef vector<int> vi;
	typedef vector<string> vs;
	typedef long long ll;
	typedef vector<ll> vll;
	typedef vector<vi> vvi;
	typedef vector<vll> vvll;
	typedef deque<ll> dll;
	typedef pair<ll, ll> P;
	const ll mod = 1e9 + 7;
	ll dx[4] = {1,0,-1,0};
	ll dy[4] = {0,1,0,-1};


	int main() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		
		/*ll n,a,b;
		cin >> n >> a >> b;
		ll x=0;
		if (min(a, b) - (n - max(a, b)) > 0) x = min(a, b) - (n - max(a, b));
		cout << min(a, b) << " " << x << endl;*/
		ll n, ans = 0;
		cin >> n;
		vll a(n), b(n);
		vector<P> v(n);
		ll maxa = 0, maxb = 0;
		rep(i, n) {
			cin >> a[i] >> b[i];
			v[i] = P(a[i]+b[i], i);
			//s[i] = P(a[i] - b[i], i);
		}

		sort(reall(v));

		rep(i, n) {
			if (i % 2 == 1) ans -= b[v[i].second];
			else ans += a[v[i].second];
		}

		cout << ans << endl;
		//sort(reall(w));
		//sort(all(s));
		//rep(i, n) cout << w[i].first << " " << w[i].second << endl;
		/*ll x = 0, y = 0;
		map<ll, bool> m,l;
		rep(i, n) {
			if (i % 2 == 1) {
				while (m[v[x].second]) x++;
				ans -= b[v[x].second];
				m[v[x].second] = true;
				x++;
			}
			else {
				//cout << m[w[y].second] << endl;
				while (m[w[y].second]) y++;
				ans += a[w[y].second];
				m[w[y].second] = true;
				y++;
			}
			//cout << ans << endl;
		}
		ll ret = 0;
		x = 0, y = 0;
		rep(i, n) {
			if (i % 2 == 0) {
				while (l[v[x].second]) x++;
				ret += a[v[x].second];
				l[v[x].second] = true;
				x++;
			}
			else {
				//cout << m[w[y].second] << endl;
				while (l[w[y].second]) y++;
				ret -= b[w[y].second];
				l[w[y].second] = true;
				y++;
			}
		}
		cout << min(ans,ret) << endl;*/
		return 0;
	}	
	

Measured memory_bytes: 3456
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define LL long long

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

LL ipow(LL base, LL exp) {
    LL result = 1;
    while(true) {
        if (exp & 1) result *= base;
        exp >>= 1;
        if (!exp) break;
        base *= base;
    }

    return result;
}

int nDividable(LL a, LL b) {
    if (b == 1) return 0;
    int divided = 0;
    while (a % b == 0) {
        //cout << b << endl;
        divided++;
        a /= b;
    }
    return divided;
}

int main() {
    LL n, p;
    cin >> n >> p;

    LL gcd = 1;
    for (LL i=1; i <= sqrt(p); i++){
        LL q = p;

        int d1 = 0, d2 = 0;
        if (isPrime(i)) d1 = nDividable(q, i);
        if (p % i == 0 && isPrime(p / i)) d2 = nDividable(q, p / i);
 
        if (d1 != 0) gcd *= ipow(i, d1 / n);
        if (d2 != 0) gcd *= ipow(p / i, d2 / n);

        //cout << i << endl;
    }

    cout << gcd << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		scan.close();

		int sum = A + B;
		int hiku = A - B;
		int kakeru = A * B;

		int max = sum;

		if (hiku > max) {
			max = hiku;
		}

		if (kakeru > max) {
			max = kakeru;
		}

		System.out.println(max);

	}

}


Measured memory_bytes: 22096
#include<stdio.h>
#include<cstring>
int main()
{
    long long n,a,judge,sum,k;
    long long s1[100010],dis[100010];
    while(scanf("%lld",&n)!=EOF)
    {
        sum=0;
        for(a=1; a<=n; a++)
        {
            scanf("%lld",&s1[a]);
            sum+=s1[a];
        }
        dis[1]=s1[1]-s1[n];
        for(a=2; a<=n; a++)
        {
            dis[a]=s1[a]-s1[a-1];
        }
        if(sum%((1+n)*n/2))
        {
            printf("NO\n");
        }
        else
        {
            judge=0;
            k=sum/((1+n)*n/2);
            sum=0;
            for(a=1; a<=n; a++)
            {
                if((k-dis[a])%n||k<dis[a])
                  {
                    judge=1;
                  }
                else
                    sum+=(k-dis[a])/n;
            }
            if(sum!=k)printf("NO\n");
            else
            {
                if(judge)printf("NO\n");
                else printf("YES\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

int main(void) {
    int n, a[100];
    scanf("%d", &n);

    for(int i= n-1; i>=0; i--) {
        scanf("%d", &a[i]);
    }
    for(int i=0; i<n-1;i++) {
        printf("%d ", a[i]);
    }
    printf("%d\n", a[n-1]);
    return 0;
}


Measured memory_bytes: 2044
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())


def solve():
    divs = set()
    r = 0
    cnt = 1
    while (r * 10 + 7) % N not in divs:
        r = (r * 10 + 7) % N
        divs.add(r)
        if r == 0:
            return cnt
        cnt += 1

    return -1


print(solve())

Measured memory_bytes: 78544
import std.stdio;
import core.stdc.stdio;
import std.array;
import std.conv;
import std.algorithm;
import std.range;

void main() {
    int n; scanf("%d",&n);
    int[] a; a.length=n;
    foreach(i; 0..n) scanf("%d", &a[i]);
    a.sort().reverse();
    int x, y;
    foreach(i, v; a) {
        if(i & 1) y += v;
        else x += v;
    }
    writeln(x - y);
}


Measured memory_bytes: 256