akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 998244353;
template <bool P = 0> struct SegmentTree {
  #define lson L, R, N[u].l
  #define rson L, R, N[u].r
  #define OUT R <= N[u].L || N[u].R <= L
  #define IN  L <= N[u].L && N[u].R <= R
  struct Node { int L, R, l, r;
    LL rev, ans, sum;
  };
  vector<Node> N; int p, n; vector<int> rt;
  inline void init(int _n) { N.resize(_n * (P ? 40:4));
    n = _n; p = 1; rt.assign(1, build(0, n));
  }
  inline int copy(Node u) { return N[p] = u, p++; }
  int build(int L, int R) {
    int u = copy({L, R}), M = (L + R) >> 1;
    if (R - L == 1) return u;
    return pull(u, build(L, M), build(M, R));
  }
  inline int push(int u) {
    if (N[u].rev) {
        N[u].sum = N[u].R - N[u].L - N[u].sum;
        N[u].ans = 1ll * (N[u].R - N[u].L) * (N[u].R - N[u].L - 1) / 2 - N[u].ans - 1ll * N[u].sum * (N[u].sum - 1) / 2 - 1ll * (N[u].R - N[u].L - N[u].sum) * (N[u].R - N[u].L - N[u].sum - 1) / 2;
        if (N[u].l)
            N[N[u].l].rev ^= 1;
        if (N[u].r)
            N[N[u].r].rev ^= 1;
        N[u].rev = 0;
    }
    return u;
  }
  inline int pull(int u, int l, int r) {
    if (!l || !r) return l ? l : r;
    N[u].L = N[l].L; N[u].R = N[r].R;
    push(N[u].l = l); push(N[u].r = r);
    N[u].sum = N[l].sum + N[r].sum;
    N[u].ans = N[l].ans + N[r].ans + 1ll * N[l].sum * (N[r].R - N[r].L - N[r].sum);
    return u;
  }
  int m(int L, int R, int u, LL v) {
    if (OUT) return u; push(u);
    if (P) u = copy(N[u]);
    if (IN) return N[u].rev ^= 1, u;
    return pull(u, m(lson, v), m(rson, v));
  }
  int q(int L, int R, int u) {
    if (OUT) return 0; push(u); if (IN) return u;
    return pull(copy(N[u]), q(lson), q(rson));
  }
  inline void modify(int L, int R, int ver, LL v) {
    rt[ver] = m(L, R, rt[ver], v);
  }
  inline Node& query(int L, int R, int ver) {
    if (!P) p = 2 * n; return N[q(L, R, rt[ver])];
  }
  void print(int u) {
      if (!u) return ;
      push(u);
      cout << N[u].L << ' ' << N[u].R << ' ' << N[u].sum << ' ' << N[u].ans << '\n';
      print (N[u].l);
      print (N[u].r);
  }
};
SegmentTree solver;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, q; cin >> n >> q;
    solver.init(n);
    for (int i = 0 ; i < n ; i++) {
        LL v; cin >> v;
        if (v) solver.modify(i, i + 1, 0, v);
    }
    while (q--) {
        int op; cin >> op;
        int l, r; cin >> l >> r; l--;
        if (op == 1) {
            solver.modify(l, r, 0, 0);
        } else {
            cout << solver.query(l, r, 0).ans << '\n';
        }
//        solver.print (solver.rt[0]); cout << '\n';
    }
}

Measured memory_bytes: 34612
from collections import defaultdict
n = int(input())

counter = defaultdict(int)
for x in map(str, range(1, n+1)):
    head = x[0]
    tail = x[-1]
    counter[(head, tail)] += 1

ans = 0
items = list(counter.items())
for (head,tail), cnt in items:
    ans += cnt * counter[(tail,head)]
print(ans)

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d) cout << "Yes" << endl;
    else if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(void) {
    int N,M;
    cin>>N>>M;
    vector<int> vc;
    for (int i = 0; i < M; i++) {
        int a,b;
        cin>>a>>b;
        vc.push_back(a);
        vc.push_back(b);
    }

    // 結果出力
    for (int i = 1; i <= N; i++) cout << count(vc.begin(), vc.end(), i) << endl;
    return 0;
}

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

int main(){
    int n, q;
    cin >> n >> q;
    vector<pair<int, string> > v;
    v.push_back(make_pair(0, "kogakubu10gokan"));
    for(int i=0; i < n; i++){
        int m; string s;
        cin >> m >> s;
        v.push_back(make_pair(m, s));
    }
    sort(v.begin(), v.end());
    for(int i=0; i < v.size(); i++){
        if(q < v[i].first){cout << v[i-1].second << endl; return 0;}
        if(i == v.size()-1){cout << v[i].second << endl; return 0;}
    }
}

Measured memory_bytes: 1216
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll a, b, n;
    cin >> a >> b >> n;
    cout << ll(a * double(min(b - 1, n)) / b);
}

Measured memory_bytes: 3636
#include <string>
#include <iostream>
#include <vector>
#include <algorithm> 
using namespace std;
int main()
{
  int n;
  cin>>n;
  int* a1 = new int[n];
  vector <int> a2(n,0);
  
  for(int i=0;i<n;i++)
  	cin>>*(a1+i);
  	
  	
  for(int i=0;i<n;i++)
  	a2[a1[i]-1]=i+1;

	
  for(int i=0;i<n;i++)
  	cout<<a2[i]<<" ";
  	
  	
  return 0;
}

  	

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

  int main() {

    string S;
    cin >> S;
    
    int month = (S[5] - '0') * 10 + S[6] - '0';

    string answer = "";

    if (4 < month) {
      answer = "TBD";
    } else {
      answer = "Heisei";
    }

    cout << answer << endl;

  }

Measured memory_bytes: 256
N = int(input())
X = input()
B = X.count('1')
#print(B, 'B')

base_mod_1 = [1 for i in range(N)] # 2^i mod B+1
if B > 1:
  base_mod_2 = [1 for i in range(N)] # 2^i mod B-1

for i in range(1, N):
  base_mod_1[i] = (base_mod_1[i-1] * 2) % (B+1)
  if B > 1:
    base_mod_2[i] = (base_mod_2[i-1] * 2) % (B-1)

def num(A):
  b = 1
  r = 0
  for i in range(len(A)):
    r += b * int(A[-i-1])
    b *= 2
  return r

def f(n):
  global call
  call += 1
  bit = 0
  m = n
  while m > 0:
    if m % 2 == 1:
      bit += 1
    m //= 2
  next_n = n % bit
  if next_n > 0:
    f(next_n)

x = num(X)
x1 = x % (B+1)
if B > 1:
  x2 = x % (B-1)
#print('x', len(X))

for i in range(N):
  call = 0
  if X[i] == '0':
    y = (x1 + base_mod_1[-i-1]) % (B+1)
    R = B + 1
    call = 1
  else:
    if B > 1:
      y = (x2 - base_mod_2[-i-1]) % (B-1)
      R = B - 1
      call = 1
    else:
      y = 0
#  print(y, '+', call)
  if y > 0:
    f(y)
  print(call)

Measured memory_bytes: 100828
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String A,B,C;
        int num=0;
        A=sc.next();
        B=sc.next();
        C=sc.next();
        if(A.charAt(A.length()-1)==B.charAt(0))  num++;
        if (B.charAt(B.length()-1)==C.charAt(0)) num++;
        if(num==2) System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void){
  char a[12];
  scanf("%c%c%c%c%c%c%c%c%c%c%c%c\n",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&a[10],&a[11]);
  printf("%c%c%c%c %c%c%c%c%c%c%c%c\n",a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11]);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(void){
    int n,a = 0;
    bool yn = false;
    cin >> n >> a;
    while (n > 0)
    {
        n -= 500;
    }
    if(n == 0){
        yn = true;
        cout << "Yes";
    }else{
        n+= 500;
    }
    if(!yn){
    for (int i = 0; i < a; i++)
    {
        n -= 1;
        if(n == 0){
            cout << "Yes";
            yn = true;
            break;
        }
    }
    }
    if(!yn){
        cout << "No";
    }
}

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

int main(){

    ll a,b,x;
    cin >> a >> b >> x;

    ll ans=b/x+1;
    ll t;
    if(a==0){
        t=0;
    }else{
        t=(a-1L)/x+1;
    }
    ans-=t;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();
		int m = stdIn.nextInt();

		int[] a = new int[n];
		int cnt = 0;

		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
			cnt += a[i];
		}

		boolean flag = true;
		Arrays.sort(a);
		for(int i = a.length-1; i>a.length-1-m; i--) {
			if(a[i]< cnt/(4.0*m)) {
				flag = false;
			}
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll d = c - a - b;

    if(d > 0 && d * d > 4 * a * b){
        println("Yes");
    }else{
        println("No");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

bool asc(P a,P b){
    return a.first>b.first;
}

int n;

int main() {
    cin >> n;
    vector<int> v(n);
    //vector<int> a(100001,0);
    //vector<int> b(100001,0);
    vector<P> c(100001);
    vector<P> d(100001);
    REP(i,100001){
        c[i].second = i;
        d[i].second = i;
    }
    REP(i,n){
        cin >> v[i];
    }
    REP(i,n){
        if(i%2==0){
            //a[v[i]]++;
            c[v[i]].first++;
        }else{
            //b[v[i]]++;
            d[v[i]].first++;
        }
    }
    sort(all(c),asc);
    sort(all(d),asc);
    int res;
    if(c[0].second!=d[0].second){
        res = n - c[0].first - d[0].first;
    }else if((c[0].first + d[1].first) > (c[1].first + d[0].first)){
        res = n - c[0].first - d[1].first;
    }else{
        res = n - c[1].first - d[0].first;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
LL q[5020101],A[202020];
int n,K;
bool vis[5001010];
int main(){
	scanf("%d %d",&n,&K);
	for (int i=1;i<=n;i++) 
		cin>>A[i];
	int m=0;
	for (int l=1;l<=n;l++){
		LL sum=0;
		for (int r=l;r<=n;r++)
			sum+=A[r],q[++m]=sum;
	}
	LL ans=0;
	for (LL i=60;i>=0;i--){
		int sum=0;
		for (int j=1;j<=m;j++) if (!vis[j])
			if (q[j]&(1ll<<i)) sum++;
		if (sum<K) continue;
		for (int j=1;j<=m;j++) 
			if ((q[j]&(1ll<<i))==0) vis[j]=1;
		ans+=(1ll<<i);
	}
	cout<<ans;
}

Measured memory_bytes: 8960
def gcd(x,y):
    if x >= y:
        r = x % y
        if r == 0:
            return y
        return gcd(y,r)
    else:
        r = y % x
        if r == 0:
            return x
        return gcd(x,r)

a = list(map(int,input().split()))

print(str(gcd(a[0],a[1])))


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

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

    ll a[n],b[n],c[n-1];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=0;i<n;i++)
        cin>>b[i];
    for(ll i=0;i<n-1;i++)
        cin>>c[i];

    ll ans = 0,prev = 5000;
    for(ll i=0;i<n;i++){
        ll dish = a[i];
        ans = ans + b[dish-1];

        if(dish == prev+1)
            ans = ans + c[prev-1];
        prev = dish;
    }
    cout<<ans;

}



Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int partition(int *a,int r,int p) {
    int x,i,j,t;
    x=a[r];
    i=p-1;
    for(int j=p;j<r;j++) {
        if(a[j]<=x) {
            i++;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return i+1;

}

int n;
int a[100005];
int main() {
    cin>>n;
    rep(i,n) cin>>a[i];
    int q = partition(a,n-1,0);
    rep(i,n) {
        if(i) cout<<" ";
        if(i==q) cout<<"[";
        cout<<a[i];
        if(i==q) cout<<"]";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1548
#include<stdio.h>

int main(void)
{
    int n = 0;
    int i = 0;
    int j = 0;
    int qq[9][9];
    int cnt = 0;

    scanf("%d",&n);

    for(i=0;i<9;i++){
        for(j=0;j<9;j++){
            //printf("hairetu[%d][%d]  %d * %d \n",i,j,i+1,j+1);
            qq[i][j] =(i+1)*(j+1);
            //printf("%d\n",qq[i][j]);
        }
    }
    for(i=0;i<9;i++){
        for(j=0;j<9;j++){
            if(qq[i][j] == n){
              printf("Yes");
              cnt++;
              return 0;
            }
        }
    }
    if(cnt != 1 || cnt != 2) printf("No");


    return 0;
}


Measured memory_bytes: 128
from heapq import *

N = int(input())

A = list(map(int, input().split()))
A_indexed = [(a, i) for i, a in enumerate(A)]

def scores():
  # initial N:2N
  selected_left = A[:N] # min heap
  heapify(selected_left)
  l_score = sum(selected_left)

  temp = sorted(A_indexed[N:])
  selected_right_set = set(temp[:N])
  unselected_right = temp[N:] # min heap
  del temp
  r_score = sum(map(lambda x: x[0], selected_right_set))

  yield l_score,r_score

  for i in range(N, 2*N):
    a = A[i]
    # left 使うものを減らす, right 使うものを増やす
    if selected_left[0] < a:
      l_score -= heapreplace(selected_left, a)
      l_score += a
      
    if (a,i) in selected_right_set:
      r_score -= a
      selected_right_set.remove((a,i))

      n_element = heappop(unselected_right)
      while n_element[1] <= i:
        n_element = heappop(unselected_right)
      selected_right_set.add(n_element)
      r_score += n_element[0]

    yield l_score,r_score

# print(list(scores()))
print(max(map(lambda x: x[0]-x[1],scores())))

Measured memory_bytes: 59052
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <deque>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    int count = 0;
    for(int i = 0; i < 3; ++i)
    {
        if(s[i] == t[i])
        {
            ++count;
        }
    }
    cout << count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    
    ll a,b;
    cin >> a >> b;
    double min_a = a/0.08,max_a = (a+1)/0.08;
    double min_b = b/0.1,max_b = (b+1)/0.1;
    if(max_a <= min_b || max_b <= min_a) cout << -1 << endl;
    else cout << max(ceil(min_a),ceil(min_b)) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	k, x := nextInt(), nextInt()
	for i := x - k + 1; i < x+k; i++ {
		if i < x+k-1 {
			fmt.Printf("%d ", i)
		} else {
			fmt.Printf("%d\n", i)
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MAX 100001 // edit accordingly
#define nil 0
#define inf INT_MAX

using namespace std;

 
using namespace std;
 
struct MCBM{
       vector<int> adjlist[MAX];
       int n, m, match[MAX], dist[MAX];
       // n: number of nodes on left side, nodes are numbered 1 to n
       // m: number of nodes on right side, nodes are numbered n+1 to n+m
       // G = nil[0] _ G1[G[1---n]] _ G2[G[n+1---n+m]] // important!!
 
       MCBM(int nn, int mm){
              n = nn;
              m = mm;
       }
 
       bool bfs() {
              int i, u, v, len;
              queue< int > Q;
              for(i=1; i<=n; i++) {
                  if(match[i]==nil) {
                      dist[i] = 0;
                      Q.push(i);
                  }
                  else dist[i] = inf;
              }
              dist[nil] = inf;
              while(!Q.empty()) {
                  u = Q.front(); Q.pop();
                  if(u!=nil) {
                      for(auto v : adjlist[u]){
                          if(dist[match[v]]==inf) {
                              dist[match[v]] = dist[u] + 1;
                              Q.push(match[v]);
                          }
                      }
                  }
              }
              return (dist[nil]!=inf);
       }
       
       bool dfs(int u) {
              int i, v, len;
              if(u!=nil) {
                  len = adjlist[u].size();
                  for(i=0; i<len; i++) {
                      v = adjlist[u][i];
                      if(dist[match[v]]==dist[u]+1) {
                          if(dfs(match[v])) {
                              match[v] = u;
                              match[u] = v;
                              return true;
                          }
                      }
                  }
                  dist[u] = inf;
                  return false;
              }
              return true;
       }
       
       int hopcroft_karp() {
              int matching = 0, i;
              // match[] is assumed nil for all vertex in adjlist
              while(bfs())
                  for(i=1; i<=n; i++)
                      if(match[i]==nil && dfs(i))
                          matching++;
              return matching;
       }
       void addEdge(int u, int v){ // left to right
              assert(v>n);
              adjlist[u].push_back(v);
       }
}; //usage MCBM g(n,m); g.addEdge(a,b);


int N;
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
pii A[205];
int main(){
	//freopen("input.txt", "r", stdin);
	cin >> N;
	for(int i = 0; i<N; i++){
		cin >> A[i].first.first >> A[i].first.second;
		A[i].second = 0;
	}
	for(int i = N; i<2*N; i++){
		cin >> A[i].first.first >> A[i].first.second;
		A[i].second = 1;
	}
	MCBM *g = new MCBM(N, N);
	for(int i = 0; i<N; i++){
		for(int j = N; j<2*N; j++){
			if(A[i].first.first < A[j].first.first and A[i].first.second < A[j].first.second){
					// add edge
				g->addEdge(i+1,j+1);
			}
		}
	}
	int ans = g->hopcroft_karp();
	cout << ans;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          163577857
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

 typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   
    #endif
}



void solve()
{
 // int n;
 // cin >> n ;
 // int a[n+1];

 // forf(i,1,n+1) cin >> a[i];

 // map<int,int>mp;
 
 // int an =0;
 // for(int i=1;i<=n;i++)
 // {
 //   an += mp[i-a[i]];
 //   mp[a[i]+i]++;
 // }

 // cout<<an<<endl;
 
 string s;
 cin >> s;
 if(s=="ABC") cout<<"ARC\n";
 else cout<<"ABC\n";


}

int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }

Measured memory_bytes: 3608
#include <stdio.h>
int main(void){
   int n,i,temp;
   scanf("%d",&n);
   int num[n];
   for(i=0;i<=n-1;i++){
       scanf("%d",&num[i]);
   }
   for(i=0;i<n/2;i++){
        temp=num[i];
        num[i]=num[n-1-i];
        num[n-1-i]=temp;
   }
   
    for(i=0;i<=n-1;i++){
        if(i) printf(" ");
        printf("%d",num[i]);
    }
   printf("\n");
   
   return 0;
   }


Measured memory_bytes: 2044
s=int(input())
if 1==s or 2==s or 4==s:
  print(4)
  exit()
x=0
for i in range(1,10**9):
  if 1==i:
    x=s
  if 1<i:
    if x%2!=0:
      x=3*x+1
    else:
      x/=2
  if 4==x:
    print(i+3)
    exit()


Measured memory_bytes: 9040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
    int s, w; std::cin >> s >> w;
    if (w >= s) std::cout << "unsafe" << std::endl;
    else std::cout << "safe" << std::endl;
    return 0;
}

Measured memory_bytes: 3636
/**
 *  Hi, I'm Arpan.
 *  Hardwork beats talent if talents doesn't work hard, friend me if you want to. ✌.|•͡˘‿•͡˘|.✌
 *
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007

void solve()
{
    int x,n;
    cin >> x >> n;
    vi a(n);
    inv(a);

    if(n == 0){
		cout << x << endl;
    }
    else{
			set<int> s;
        for(int i=0;i<n;i++){
			s.insert(a[i]);
        }
		int ok = 1;
		int c = 0;
		while(ok != 0){
			auto x1 = s.find(x-c);
			if(x1 == s.end()){
				cout << x-c;
				return;
			}
			auto x2 = s.find(x+c);
			if(x2 == s.end()){
				cout << x+c;
				return;
			}
			c++;
		}

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

        solve();
    return 0;
}


Measured memory_bytes: 3648
n, k = map(int, input().split())

s = 0
for i in range(1, n+1):
    j = 0
    if i >= k:
        s += 1 / n
    else:
        while True:
            if i * 2 ** j >= k:
                s += (1 / n) * 0.5 ** j
                break
            j += 1

print(s)


Measured memory_bytes: 2940
N = int(input())
ans_list = []
# p_list = list(range(1,N+1))
if N%2 ==0:
    M = int(N*(N-2)/2)
    for i in range(1,N+1):
        pair = N+1-i
        for j in range(i+1,N+1):
            if j != pair:
                ans_list.append([i,j])
#         add_list = [[i,j] for j in range(i+1,N+1) if j != pair]
#         ans_list.extend(add_list)
else:
    M = int((N-1)*(N-1)/2)
    for i in range(1,N):
        pair = N-i
        for j in range(i+1,N):
            if j != pair:
                ans_list.append([i,j])
        ans_list.append([i,N])
        
print(M)
for ans in ans_list:
    print(ans[0],ans[1])

# print(ans_list)

Measured memory_bytes: 4124
import itertools
#h,w=map(int,input().split())
#S=[list(map(int,input().split())) for _ in range(h)]
n=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
num=0
numlist=[i for i in range(1,n+1)]
pall=list(itertools.permutations(numlist))
for pp in pall:
    if P==list(pp):
        pnum=num
    if Q==list(pp):
        qnum=num
    num+=1
print(abs(pnum-qnum))

Measured memory_bytes: 13892
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long int64;
const int64 MOD = (int64)( 1e9 + 7 );

const int MAX_N = int(1e5);
const int MAX_K = int(1e3);

struct WarpHole {
	int sy, sx, gy, gx;

	WarpHole(){}
	WarpHole(int sy, int sx, int gy, int gx):
		sy(sy), sx(sx), gy(gy), gx(gx)
	{}
};

bool operator< (const WarpHole& lhs, const WarpHole& rhs) {
	return make_pair(lhs.sy, lhs.sx) != make_pair(rhs.sy, rhs.sx) ?
			make_pair(lhs.sy, lhs.sx) < make_pair(rhs.sy, rhs.sx) :
			make_pair(lhs.gy, lhs.gx) != make_pair(rhs.gy, rhs.gx);
}

int N, M, K;
int64 fact[2*MAX_N + 1], invFact[2*MAX_N + 1];
WarpHole warps[MAX_K + 1];
bool visited[MAX_K + 1][MAX_K + 1];
int64 memo[MAX_K + 1][MAX_K + 1];

int64 calcPow(int64 x, int64 n, int64 mod = MOD) {
	int64 ret = 1;
	for (; n; n >>= 1, x = x * x % mod) if (n&1) {
		ret = ret * x % mod;
	}
	return ret;
}


int64 getComb(int n, int k) {
	return fact[n] * invFact[n-k] % MOD * invFact[k] % MOD;
}

int64 getWay(int y, int x) {
	if (y < 0 || x < 0) {
		return 0;
	}
	return getComb(y + x, x);
}

void prepare() {
	fact[0] = invFact[0] = 1;
	for (int i = 0; i < 2*MAX_N; ++i) {
		fact[i+1] = (i + 1) * fact[i] % MOD;
		invFact[i+1] = calcPow(fact[i+1], MOD - 2, MOD);
	}
}

bool init() {
	scanf("%d%d%d", &N, &M, &K);
	for (int i = 0; i < K; ++i) {
		int sy, sx, gy, gx;
		scanf("%d%d%d%d", &sy, &sx, &gy, &gx);
		warps[i] = WarpHole(sy,sx,gy,gx);
	}

	memset(visited, false, sizeof(visited));
	return N > 0;
}

//[0,k)までのワープホールが機能しているときの、
//(1,1)からt番目のワープホールの入り口までの経路の個数を返す
int64 rec(const int k, const int t) {
	//memorize
	if (visited[k][t]) {
		return memo[k][t];
	}
	visited[k][t] = true;

	int64& ret = memo[k][t];

	//base
	if ( k == 0 ) {
		return ret = getWay(warps[t].sy - 1, warps[t].sx - 1);
	}

	//calc
	const int64 inOut = getWay(warps[t].sy - warps[k-1].sy, warps[t].sx - warps[k-1].sx),
			outOut = getWay(warps[t].sy - warps[k-1].gy, warps[t].sx - warps[k-1].gx);
	ret = (rec(k-1, t) - rec(k-1,k-1) * (inOut - outOut) % MOD + MOD) % MOD;

	return ret;
}

int solve() {
	
	for (int i = 0; i < K - 1; ++i) {
		swap(warps[i], *min_element(warps + i, warps + K));
	}
	warps[K] = WarpHole(N, M, N, M);

	return int(rec(K, K));
}

int main() {
	prepare();
	for (;init();) {
		printf("%d\n", solve());
	}
	return 0;
}

Measured memory_bytes: 13060
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>

using namespace std;

int main(void) {
    int a,b,ret = 0;
    cin >> a >> b;
    ret = a - 1;
    if(a <= b)
        ret++;
    cout << ret << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc=new Scanner(System.in);
        int max1=0,max2=0,max3=0;
        for (int i=1;i<=10;i++){
            int h=sc.nextInt();
            if (h>max1){
                max3=max2;
                max2=max1;
                max1=h;
            }
            else if (h>max2){
                max3=max2;
                max2=h;
            }
            else if (h>max3)
                max3=h;
        }
        System.out.println(max1);
        System.out.println(max2);
        System.out.println(max3);
    }
}

Measured memory_bytes: 26360
#include"bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<vector<int>> x(N, vector<int>(M + 1));
	Rep(i, N) {
		Rep(j, M + 1) {
			cin >> x[i][j];
		}
	}
	int ans = 0;
	BitRep(i, N) {
		bitset<12> bit(i);
		vector<int> sum(M, 0);
		int cost = 0;
		Rep(j, N) {
			if (bit.test(j)) {
				Rep(k, M) {
					sum[k] += x[j][k + 1];
				}
				cost += x[j][0];
			}
		}
		bool judge = true;
		Rep(j, M) {
			if (sum[j] < X) {
				judge = false;
				break;
			}
		}
		if (judge) {
			if (ans == 0) {
				ans = cost;
			}
			else {
				ans = min(ans, cost);
			}
		}
	}
	if (ans > 0) {
		cout << ans << endl;
	}
	else {
		puts("-1");
	}
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
ll a[200050];
ll b[200050];
int ans;
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>b[i];
        b[i]+=b[i-1];
    }
    for(int i=0,j=m;i<=n;i++)
    {
        if(a[i]<=k)
        {
            while(a[i]+b[j]>k)j--;
            ans=max(ans,i+j);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6688
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int v[] = new int[n];
    int c[] = new int[n];
    int ans = 0;
    for(int i=0;i<n;i++){
      v[i] = sc.nextInt();
    }
    for(int j=0;j<n;j++){
      c[j] = sc.nextInt();
    }
    for(int k=0;k<n;k++){
      if(v[k] - c[k] >= 0){
        ans += v[k] - c[k];
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
import java.util.*;


class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    
    int sum=0;
    for(int i=0;i<m;i++){
      sum += sc.nextInt();
    }
    int ans = n - sum;
    if(ans < 0)
      ans = -1;
    
    System.out.println(ans);

  }
}

Measured memory_bytes: 46312
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long A=gl();
	    long B=Math.round(gd()*100);
	    long ab=A*B;
	    String s= String.valueOf(ab);

	    if (s.length()<=2) {
	    	System.out.print("0");
	    	return;
	    }
	    for (int i=0; i<s.length()-2;i++) {
            System.out.print(s.charAt(i));
	    }
//        if (flg) {
//        	System.out.print("YES");
//        }else {
//        	System.out.print("NO");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

void print() {
  cout << endl;
}

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
}

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
}

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

  string s;
  cin >> s;
  for (char ch: s) {
    if (ch == '1') cout << '9';
    if (ch == '9') cout << '1';
  }
  cout << endl;

  return 0;
};


Measured memory_bytes: 256
import itertools
 
H,W,K=map(int, input().split())
S=[]
for _ in range(H):
  S.append([int(s) for s in input()])
 
ans=2000
for t in itertools.product([0,1],repeat=H-1):
  cnt=t.count(1)
  lst=[[s for s in S[0]]]
  for h in range(H - 1):
    if t[h]==1:
      lst.append(S[h+1])
    else:
      lst[-1]=[lst[-1][i]+S[h+1][i] for i in range(W)]
  L=len(lst)
  R=[0]*L
  for w in range(W):
    if max(lst[i][w] for i in range(L))>K:
      break
    tmp=[R[i]+lst[i][w] for i in range(L)]
    if max(tmp)>K:
      cnt+=1
      R=[lst[i][w] for i in range(L)]
    else:
      R=tmp
  else:
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 3188
H = []
W = []
while(True):
    x,y = map(int,input().split())
    if x == 0 and y == 0:
        break
    else:
        H.append(x)
        W.append(y)
for i in range(len(H)):
    char = "#."
    for j in range(H[i]):#行数
        print(char*(W[i]//2)+char[0]*(W[i]%2))
        char = char[1]+char[0]
    print("")


Measured memory_bytes: 5624
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  double m[2][2],x[2],y[2],det,i[2][2];
  while(cin >>m[0][0]>>m[0][1]>>y[0]>>m[1][0]>>m[1][1]>>y[1]){
    det = m[0][0]*m[1][1]-m[1][0]*m[0][1];
    i[0][0] = m[1][1]/det;
    i[0][1] = -m[0][1]/det;
    i[1][0] = -m[1][0]/det;
    i[1][1] = m[0][0]/det;
    x[0] = i[0][0]*y[0]+i[0][1]*y[1];
    x[1] = i[1][0]*y[0]+i[1][1]*y[1];
    printf("%.3lf %.3lf\n",x[0],x[1]);
  }
  return 0;
}

Measured memory_bytes: 1236
import copy
n = int(input())
inp = []
inp = input().split()

class card:
    def __init__(self, suitin, numin):
        self.suit = suitin
        self.num = numin

a = []
for i in range(n):
    a.append(card(inp[i][0], inp[i][1]))

bubble = copy.deepcopy(a)

for i in range(n):
    for j in range(n-1, i, -1):
        if bubble[j].num < bubble[j - 1].num:
            bubble[j], bubble[j-1] = bubble[j-1], bubble[j]
            

print(bubble[0].suit, end="")
print(bubble[0].num, end="")

for i in range(1, len(bubble)):
    print(" ", end="")
    print(bubble[i].suit, end="")
    print(bubble[i].num, end="")
print("\n", end="")
print("Stable")

select = copy.deepcopy(a)

for i in range(n):
    minj = i
    for j in range(i, n):
        if select[j].num < select[minj].num:
            minj = j
   # if i != minj:
    select[i], select[minj] = select[minj], select[i]


print(select[0].suit, end="")
print(select[0].num, end="")

for i in range(1, len(select)):
    print(" ", end="")
    print(select[i].suit, end="")
    print(select[i].num, end="")
print("\n", end="")

flag = 1
for i in range(n):
    if bubble[i].suit != select[i].suit:
        flag = 0

if flag == 1:
    print("Stable")
else:
    print("Not stable")




Measured memory_bytes: 6356
program main
  implicit none
  character(len=100000) :: S
  character,allocatable:: S2(:)
  integer :: N,Q
  integer :: N2
  integer,allocatable :: l(:),r(:)
  integer :: i,ii
  integer,allocatable :: out(:),out2(:)
  read(*,*) N,Q
  read(*,*) S(1:N)
  allocate(l(Q),r(Q))
  do i=1,Q
     read(*,*) l(i),r(i)
  end do
  allocate(out(N))
  allocate(out2(N))
  ! set datas 
  out=0
  do i = 1,N-1
     if ( S( i:i+1 ) == 'AC' ) then
        out(1:i)=out(1:i)+1
     end if
  end do
  out2=-out
!@  do i = N-1,1,-1
!@     if ( S( i:i+1 ) == 'AC' ) then
!@        out2(1:i) = out2(1:i)-1
!@     end if
!@  end do
  ! output
  do i = 1,Q
     write(*,'(i0)')  out( l(i) )+out2( r(i) )
  end do
end program main


Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500050;
char s[MAXN];
int ans, l, r, n, a[MAXN];
inline bool chk(int x)
{
	int len = n, sum = 0;
	for( int i = 1 ; i <= n ; i++ ) a[ i ] = ( s[ i ] - '0' ) * 9;
	a[ 1 ] += 9 * x;
	for( int i = 1 ; i <= len ; i++ )
		if( a[ i ] > 9 )
		{
			if( i == len ) a[ ++len ] = 0;
			a[ i + 1 ] += a[ i ] / 10;
			a[ i ] %= 10;
		}
	for( int i = 1 ; i <= len ; i++ ) sum += a[ i ];
	return sum <= 9 * x;
}
int main()
{
    #ifdef wxh010910
    #endif
	scanf( "%s", s + 1 );
	l = 1, r = n = strlen( s + 1 );
	reverse( s + 1, s + n + 1 );
	while( l <= r )
	{
		int mid = l + r >> 1;
		if( chk( mid ) ) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2688
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };


int main()
{
	int N;
	int A[9] = { 0 };
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		if (a >= 3200)a = 3200;
		A[a / 400]++;
	}
	int min = 0;
	for (int i = 0; i < 8; i++)
	{
		if (A[i] > 0)min++;
	}
	if (min == 0)
	{
		cout << 1 << " " << A[8] << endl;
	}
	else
	{
		cout << min << " " << (min + A[8]) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[111100];
vector<int>i;
vector<int>y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=1,e;
  cin >>a;
  for(int n=0;n<a;n++){
    cin >>u[n];
  }
  b=u[0];
  for(int n=1;n<a;n++){
    if(b<=u[n]) d++,b=u[n];
  }
  cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 256
def count(data):
    dic = {}
    for d in data:
        if d in dic:
            dic[d] += 1
        else:
            dic[d] = 1
    return dic

n = int(input())
counts = {}
for _ in range(n):
    s = ''.join(sorted(input()))
    if s in counts:
        counts[s] += 1
    else:
        counts[s] = 1

ans = 0
for v in counts.values():
    ans += (v*(v-1))//2
print(ans)



Measured memory_bytes: 17848
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long maxim=a*c;
  maxim=max(maxim,a*d);
  maxim=max(maxim,b*c);
  maxim=max(maxim,b*d);
  cout<<maxim<<endl;
  return(0);
}

Measured memory_bytes: 3668
package main

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

const INF float64 = 1.e12

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n := input.NextInt()
  xbb := NewBoundingBox()
  ybb := NewBoundingBox()
  for i:=0;i<n;i++ {
    x,y,d := input.NextInput()
    switch (d) {
      case "R": xbb.Add(x,2);ybb.Add(y,1)
      case "L": xbb.Add(x,0);ybb.Add(y,1)
      case "U": xbb.Add(x,1);ybb.Add(y,2)
      case "D": xbb.Add(x,1);ybb.Add(y,0)
    }
  }
  t := []float64{0,INF}
  t = append(t,xbb.Event()...)
  t = append(t,ybb.Event()...)
  ans := INF*INF*INF
  for _,v := range t {
    ans = math.Min(ans,xbb.Get(v)*ybb.Get(v))
  }
  fmt.Printf("%.12f\n",ans)
}

type BoundingBox struct { l,r []float64 }
func NewBoundingBox() BoundingBox {
  return BoundingBox{[]float64{INF,INF,INF},[]float64{-INF,-INF,-INF}}
}
func(bb BoundingBox) Add(z float64,i int) {
  bb.l[i] = math.Min(bb.l[i],z)
  bb.r[i] = math.Max(bb.r[i],z)
}
func(bb BoundingBox) Get(t float64) float64 {
  l,r := INF,-INF
  for i:=0;i<3;i++ {
    l = math.Min(l,bb.l[i]+float64(i)*t)
    r = math.Max(r,bb.r[i]+float64(i)*t)
  }
  return r-l
}
func(bb BoundingBox) Event() []float64 {
  e := []float64{}
  for i:=0;i<3;i++ {
    for j:=0;j<i;j++ {
      tl := (bb.l[j]-bb.l[i])/float64(i-j)
      if tl > 0 { e = append(e,tl) }
      tr := (bb.r[j]-bb.r[i])/float64(i-j)
      if tr > 0 { e = append(e,tr) }
    }
  }
  return e
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInt() int {
  n,_ := strconv.Atoi(i.NextLine())
  return n
}
func(i *Input) NextInput() (float64,float64,string) {
  s := strings.Split(i.NextLine()," ")
  x,_ := strconv.ParseFloat(s[0],64)
  y,_ := strconv.ParseFloat(s[1],64)
  return x,y,s[2]
}

Measured memory_bytes: 5504
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200010];

int main ()
{
	int n, i;
	cin >> n;
	for(i = 0; i < n; i++)
		scanf("%d", &a[i]);
    int maxn = -1000000001;
	int minv = a[0];
	for(i = 1; i < n; i++)
	{
		maxn = max(a[i] - minv, maxn);
		minv = min(a[i], minv);
	}
	cout << maxn << endl;
	return 0;
} 


Measured memory_bytes: 3932
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
MOD = sum(XY[0]) % 2

for x, y in XY:
    if MOD != (x + y) % 2:
        print(-1)
        exit()

m = 33 - MOD
print(m)
D = [2 ** i for i in range(31, -1, -1)]
if MOD == 0:
    D.append(1)

print(" ".join(map(str, D)))
for x, y in XY:
    w = ""
    for d in D:
        if x + y >= 0 and x - y >= 0:
            w += "R"
            x -= d
        elif x + y < 0 and x - y >= 0:
            w += "D"
            y += d
        elif x + y >= 0 and x - y < 0:
            w += "U"
            y -= d
        else:
            w += "L"
            x += d

    print(w)


Measured memory_bytes: 3316
#include<algorithm>
#include<cassert>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<stack>
#include<sstream>
#include<complex>

#define pb push_back
#define clr clear()
#define sz size()
#define fs first
#define sc second

#define rep(i,a) for(int i=0;i<(int)(a);i++)
#define rrep(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define INIT(a) memset(a,0,sizeof(a))

using namespace std;
typedef double D;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const D EPS = 1e-8;
const int INF = 1e8;
const D PI = acos(-1);

struct edge{
  int from,to,cost,cap,rev;
  bool operator<(const edge x)const{return cost<x.cost;}
};

const int V = 210;

vector<edge> G[V];  //グラフの隣接リスト
//辺の追加。２つ目の辺の追加はフローアルゴリズムの残余グラフ用。
void AddEdge(int s,int g,int c,int p){
  G[s].pb((edge){s,g,c,p,G[g].sz});
  G[g].pb((edge){g,s,-c,0,G[s].sz-1});  //for Max-Flow
}

int v; //グラフの頂点数
int d[V];
int pv[V],pe[V];  //直前の頂点と辺

int primal_dual(int s,int t, int f){
  int res = 0;
  while(f>0){
    fill(d,d+v,INF);
    d[s] = 0;
    bool update = true;
    while(update){
      update = false;
      rep(u,v){
        if(d[u]==INF)continue;
        rep(i,G[u].sz){
          edge &e = G[u][i];
          if(e.cap > 0 && d[e.to] > d[u] + e.cost){
            d[e.to] = d[u] + e.cost;
            pv[e.to] = u; pe[e.to] = i;
            update = true;
          }
        }
      }
    }
    
    if(d[t] ==INF)return -1;
    
    int x = f;
    for(int u=t;u!=s;u=pv[u]){
      x = min(x,G[pv[u]][pe[u]].cap);
    }
    f -= x;
    res += x*d[t];
    for(int u=t;u!=s;u=pv[u]){
      edge &e = G[pv[u]][pe[u]];
      e.cap -= x;
      G[u][e.rev].cap += x;
    }
  }
  return res;
}

int main(){
  int n;
  int w[110][110], e[110][110];
  string f[110];

  cin >> n;
  rep(i,n)rep(j,n)cin >> w[i][j];
  rep(i,n)rep(j,n)cin >> e[i][j];
  rep(i,n)cin >> f[i];

  v = 2*n + 2;

  int base = 0;
  rep(i,n){
    AddEdge(v-2,i,0,1);
    AddEdge(i+n,v-1,0,1);

    rep(j,n){
      if(f[i][j] == 'o')AddEdge(i,n+j,-e[i][j],1), base += e[i][j];
      else AddEdge(i,n+j,w[i][j],1);
    }
  }

  cout << primal_dual(v-2,v-1,n) + base << endl;

  int op = 0;
  rep(i,n){
    rep(j,G[i].sz){
      int from = G[i][j].from, to = G[i][j].to - n, cap = G[i][j].cap;
      if(f[from][to] == 'o' && cap)op++;
      if(f[from][to] == '.' && !cap)op++;
    }
  }
  cout << op << endl;

  rep(i,n){
    rep(j,G[i].sz){
      int from = G[i][j].from, to = G[i][j].to - n, cap = G[i][j].cap;
      if(f[from][to] == 'o' && cap){
	cout << from+1 << " " << to+1 << " erase" << endl;
      }
      if(f[from][to] == '.' && !cap){
	cout << from+1 << " " << to+1 << " write" << endl;
      }

    }
  }
}

Measured memory_bytes: 1864
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h> 
#include<queue>
#include<string.h>
#include<stack>


using namespace std;

#define INF 2147483647


int n=1;
int A[300000];
bool flag[300000];
int lazy[300000];

void init(int size){

	while(n<size){
		n*=2;
	}
	for(int i=0;i<2*n-1;i++){
		A[i]=INF;
		flag[i]=false;
	}
}

void eval(int k,int l,int r){
	if(flag[k]){
		A[k]=lazy[k];
		if(l+1<r){
			lazy[2*k+1]=lazy[2*k+2]=lazy[k];
			flag[2*k+1]=flag[2*k+2]=true;
		}
		flag[k]=false;
	}
}


void update(int x,int y,int a,int k=0,int l=0,int r=n){
	eval(k,l,r);
	if(r<=x||y<=l){
		return;
	}
	if(x<=l&&r<=y){
		flag[k]=true;
		lazy[k]=a;
		eval(k,l,r);
	}
	else{
		update(x,y,a,2*k+1,l,(l+r)/2);
		update(x,y,a,2*k+2,(l+r)/2,r);
        A[k]=min(A[2*k+1],A[2*k+2]);
	}
}


int query2(int x,int y,int k=0,int l=0,int r=n){
	eval(k,l,r);
	if(r<=x||y<=l){
		return INF;
	}
    if(x<=l&&r<=y){
    	return A[k];
    }
    int vl=query2(x,y,2*k+1,l,(l+r)/2);
    int vr=query2(x,y,2*k+2,(l+r)/2,r);
    return min(vl,vr);
}

int main(){
	int k;
	int q;
	cin>>k>>q;
	init(k);
	int qu;
	int x,y,s,t;
	for(int i=0;i<q;i++){
		cin>>qu;
		if(qu==0){
			cin>>s>>t>>x;
			update(s,t+1,x);
		}
		else if(qu==1){
			cin>>x>>y;
			cout<<query2(x,y+1)<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int a, b, c, x, y;
   cin >> a >> b >> c >> x >> y;
   int ans = 1e9;
   rep(k, 1e5 + 1) {
      int cost = a * max(x - k, 0) + b * max(y - k, 0) + c * 2 * k;
      ans = min(ans, cost);
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256