akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

// #define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;

signed main() {
    int A, B, C;

    cin >> A >> B >> C;
    int ans = 0;

    int tmpA, tmpB, tmpC;

    T tuple = make_tuple(A, B, C);
    map<T, bool> mp;
    mp[tuple] = true;

    while((A % 2 == 0) && (B % 2 == 0) && (C % 2 == 0)) {
        tmpA = (B + C) / 2;
        tmpB = (A + C) / 2;
        tmpC = (A + B) / 2;

        ans += 1;
        debug(ans);
        debug(A);
        debug(B);
        debug(C);
        hyphen();

        A = tmpA;
        B = tmpB;
        C = tmpC;

        tuple = make_tuple(A, B, C);
        if (mp.count(tuple) == 1) {
            cout << "-1" << endl;
            return 0;
        } else {
            mp[tuple] = true;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
module ABC126

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_C
  private :: calculate_probability_win

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_C

    ! variables for this <subroutine>
    integer(INT32) :: num_sides_dice
    integer(INT32) :: val_limit_win

    ! STEP.01
    ! read out ...
    ! 1. the number of sides of the given dice
    ! 2. the minimum points to win
    read(unit=INPUT_UNIT, fmt=*), num_sides_dice, val_limit_win

    ! STEP.02
    ! calculate and output the probability of winning this game under given conditions
    write(unit=OUTPUT_UNIT, fmt='(ES23.15e3)', advance='yes') calculate_probability_win (num_sides_dice, val_limit_win)

    ! STEP.END
    return

  end subroutine task_C

  pure function calculate_probability_win (num_sides_dice, val_limit_win) result(prbl_win)

    ! arguments for this <function>
    integer(INT32), intent(in) :: num_sides_dice
    integer(INT32), intent(in) :: val_limit_win

    ! return value of this <function>
    real(REAL64) :: prbl_win

    ! variables for this <function>
    integer(INT32)  :: points
    real   (REAL64) :: prbl_dice_simple_event
    real   (REAL64) :: prbl_coin_simple_event
    real   (REAL64) :: prbl_unit

    ! support variables for this <function>
    integer(INT32) :: itr_side

    ! STEP.01
    ! calculate & store the probability of simple event
    prbl_coin_simple_event = 5.0e-001_REAL64
    prbl_dice_simple_event = 1.0e+000_REAL64 / num_sides_dice

    ! STEP.02
    ! initialize the variable to store the total probability that points will reach the winning condition
    prbl_win = 0.0e+000_REAL64

    ! STEP.03
    ! calculate the total probability that points will reach the winning condition
    do itr_side = 1_INT32, num_sides_dice, 1_INT32

      ! STEP.03.01
      ! initialize the variable to store ...
      ! 1. the current points
      ! 2. the probability that points will reach the winning condition under a side of dice
      points    = itr_side
      prbl_unit = prbl_dice_simple_event

      ! STEP.03.02
      ! calculate the probability that points will reach the winning condition under a side of dice
      do while (points .lt. val_limit_win)
        points    = points    * 2_INT32
        prbl_unit = prbl_unit * prbl_coin_simple_event
      end do

      ! STEP.03
      ! update the total probability that points will reach the winning condition
      prbl_win = prbl_win + prbl_unit

    end do

    ! STEP.END
    return

  end function

end module ABC126


program main

  ! <module>s to import
  use, non_intrinsic :: ABC126

  ! require all variables to be explicitly declared
  implicit none

  call task_C

end program main

Measured memory_bytes: 512
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0];
    
    let cnt     = 0;
    let before  = "";
    let current = "";
    let debug   = [];
    
    for(let i=0; i<S.length; i++) {
        current += S[i];
        
        if(current === before) {
            continue;
        }
        
        before = current;
        debug.push(current);
        
        current = "";
        
        cnt++;
    }
    
    console.log(debug.length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 18636
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[n];
		long ans=Long.MAX_VALUE;
		for(int i=0; i<n; i++){
			x[i]=sc.nextInt();
		}
		for(int i=1; i<101; i++){
			long min=0;
			for(int j=0; j<n; j++){
				min+=(x[j]-i)*(x[j]-i);
			}
			ans=Math.min(ans,min);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin>>x;
	ll ans = 0, j= 0;
	ll a[int(1e5)];
	memset(a,0x3f,sizeof(a));
	a[0] = x;
	int i = 0;
	for(i = 1;i<x;i++)
	{
		ans = i*(i+1)/2;
		a[i] = i+(x-ans);
		if(ans>x)
		{
			a[i] = i;
			break;
		}
	}
	cout<<*min_element(a,a+int(1e5))<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
int C[201000], S[201000], n, m, w[201000], r;
void Add(int a) {
	int t = max(a - C[a], 1);
	r -= abs(S[t] - 1);
	S[t]++;
	r += abs(S[t] - 1);
	C[a]++;
}
void Del(int a) {
	C[a]--;
	int t = max(a - C[a], 1);
	r -= abs(S[t] - 1);
	S[t]--;
	r += abs(S[t] - 1);
}
int main() {
	int i, a, b;
	scanf("%d%d", &n, &m);
	r = n;
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
		Add(w[i]);
	}
	for (i = 1; i <= m; i++) {
		scanf("%d%d", &a, &b);
		Del(w[a]);
		w[a] = b;
		Add(w[a]);
		printf("%d\n", r / 2);
	}
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int limit=36;
  for(int i=n;i>0;i--){
    int a;
    cin>>a;
    int j=0;
    bool frag=true;
    while(frag==true){
      if(a%2==0){
        a=a/2;
        j=j+1;
      }
      else{
        frag=false;
      }
    }
    if(j<limit){
      limit=j;
    }
    else{
    }
  }
  cout<<limit<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int >P;

ll N, H;

P ab[200000];

int main() {
	cin >> N >> H;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		ab[i] = P(a, 0);
		ab[i + N] = P(b, 1);
	}

	sort(ab, ab + 2 * N);

	int ans = 0;
	int i = N * 2 - 1;
	while (H > 0) {
		if (ab[i].second == 1) {
			H -= ab[i].first;
			ans++;
		}
		else {
			ll c = (H + ab[i].first - 1) / ab[i].first;
			ans += c;
			H -= ab[i].first * c;
		}
		i--;
	}
	cout << ans << endl;
	return 0;
}

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


void solve(long long H,
           long long W,
           long long D,
           std::vector<std::vector<long long>> A,
           long long Q,
           std::vector<long long> L,
           std::vector<long long> R){
  vector<long long> x(H*W);
  vector<long long> y(H*W);
  Rep(i,H)Rep(j,W){
    x[A[i][j]-1]=i;
    y[A[i][j]-1]=j;
  }

  vector<long long> acc(H*W);
  Rep(i, H*W){
    if(i<D)acc[i]=x[i]+y[i];
    else acc[i]=acc[i-D]+abs(x[i-D]-x[i])+abs(y[i-D]-y[i]);
  }

  Rep(i, Q)cout << acc[R[i]-1]-acc[L[i]-1] << endl;
}

int main(){
  long long H;
  scanf("%lld",&H);
  long long W;
  scanf("%lld",&W);
  long long D;
  scanf("%lld",&D);
  std::vector<std::vector<long long>> A(H, std::vector<long long>(W));
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      scanf("%lld",&A[i][j]);
    }
  }
  long long Q;
  scanf("%lld",&Q);
  std::vector<long long> L(Q);
  std::vector<long long> R(Q);
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&L[i]);
    scanf("%lld",&R[i]);
  }
  solve(H, W, D, std::move(A), Q, std::move(L), std::move(R));
  return 0;
}


Measured memory_bytes: 5504
import std.string,
           std.stdio,
           std.conv;
 
void main() {
  int N = readln.chomp.to!int;
  int[] input = readln.chomp.split.to!(int[]);
  int max , min = int.max;
 
  foreach (e; input) {
    if (max < e) {
      max = e;
    }
    if (min > e) {
      min = e;
    }
  }
 
  writeln(max - min);
}


Measured memory_bytes: 256
import heapq
from collections import deque

# input
N, M = map(int, input().split())
A = []
for x in input().split():
    heapq.heappush(A, (int(x), int(x)))

A_num = []
num = 0
cnt = 0
while len(A) > 0:
    a, _ = heapq.heappop(A)
    if num == a:
        cnt += 1
    else:
        heapq.heappush(A_num, (num, cnt))
        num = a
        cnt = 1
heapq.heappush(A_num, (num, cnt))


# 2nd input
input_act = []
for _ in range(M):
    B, C = map(int, input().split())
    heapq.heappush(input_act, (-C, B))

act = deque()
cnt = 0
while len(input_act) > 0:
    c, b = heapq.heappop(input_act)
    if cnt > N:
        break
    else:
        act.appendleft((-c, b))
        cnt += b

# print("A_num:", A_num)
# print("act:", act)

# exec
for c, b in act:
    # print("A_num:", A_num)
    cont_cnt = 0
    while b>0:
        num, cnt = heapq.heappop(A_num)
        # print(num, cnt)
        if num * cnt == 0:
            pass
        elif num < c:
            if cnt < b:
                cont_cnt += cnt
                b -= cnt
            else:
                cont_cnt += b
                heapq.heappush(A_num, (num, cnt-b))
                b = 0
        else:
            heapq.heappush(A_num, (num, cnt))
            break
    heapq.heappush(A_num, (c, cont_cnt))

ret = 0
for num, cnt in A_num:
    ret += num * cnt

# print("A_num:", A_num)

print(ret)


Measured memory_bytes: 27748
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    X, Y = LI()
    ans = 0
    if X == 1:
        ans += 300000
    elif X == 2:
        ans += 200000
    elif X == 3:
        ans += 100000

    if Y == 1:
        ans += 300000
    elif Y == 2:
        ans += 200000
    elif Y == 3:
        ans += 100000

    if X == 1 and Y == 1:
        ans += 400000

    print(ans)
    return


# B
def B():
    N = I()
    A = LI()
    A_sum = sum(A)
    cnt = 0
    ans = sum(A)
    for i in range(N):
        cnt += A[i]
        sa = abs(A_sum - cnt - cnt)
        ans = min(ans, sa)
    print(ans)
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    B()
    return


# Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 80764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<int,int> a;
  for(int i=0;i<n;i++){
    int p;
    cin>>p;
    a[p]++;
  }
  bool ok=true;
  for(auto x:a){
    if(x.second>=2)ok=false;
  }
  if(ok){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

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

#define MOD (1.0e9 + 7)

using namespace std;

int HW[100*100+1];

int main(void)
{
    int h,w;
    int n;
    int counter = 0;

    cin>>h;
    cin>>w;
    cin>>n;


    for(int i = 1;i <= n;i++)
    {
	int temp;
	cin >> temp;
	for(int j = temp;j > 0;j--)
	    HW[counter++] = i;
    }

    for(int offset = 0;offset < h*w;offset += w) {
	for(int i = offset;i < w+offset;i++)
	{
	    cout<<HW[i]<<" ";
	}
	cout<<endl;
	offset += w;
	if(offset >= h*w)
	    break;
	for(int i = 0;i < w;i++)
	{
	    cout<<HW[offset+w-1-i]<<" ";
	}
	cout<<endl;
    }

    return 0;
}



Measured memory_bytes: 384
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1149&lang=jp
#include<iostream>
#include<fstream>
#include<array>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define fin cin



bool cmp(pair<int, int> _p1, pair<int, int> _p2)
{
    return _p1.first * _p1.second < _p2.first * _p2.second;
}



int main()
{
    //ifstream fin("in.txt");

    int n{0}, w{0}, d{0};

    while(true)
    {
        fin >> n >> w >> d;

        if( !(n | w | d) )break;

        vector< pair<int, int> > cake{pair<int, int> (w, d)};

        vector<int> p(n);
        vector<int> s(n);


        for(int i = 0; i < n; i++)
        {
            fin >> p[i] >> s[i];
        }




        for(int i = 0; i < n; i++)
        {
            //cake[p[i]]???s[i]??§??????
            //cake[p[i]].first = w
            //cake[p[i]].second = d

            int w = cake[p[i] - 1].first;
            int d = cake[p[i] - 1].second;
            

            int mod = s[i] % (d + w);


            //????????????
            if(mod < w)
            {
                pair<int, int> cake1{mod, d};
                pair<int, int> cake2{w - mod, d};

//                if(mod < w / 2)
                if(cake1.first * cake1.second < cake2.first * cake2.second)
                {
                    cake.push_back(cake1);
                    cake.push_back(cake2);
                }
                else
                {
                    cake.push_back(cake2);
                    cake.push_back(cake1);                    
                }

            }
            //?¨??????????
            else
            {
                mod -= w;
                pair<int, int> cake1{w, mod};
                pair<int, int> cake2{w, d - mod};

//                if(mod < d / 2)
                if(cake1.first * cake1.second < cake2.first * cake2.second)
                {
                    cake.push_back(cake1);
                    cake.push_back(cake2);
                }
                else
                {
                    cake.push_back(cake2);
                    cake.push_back(cake1);              
                }
            }

            auto itr = cake.begin();
            itr += (p[i] - 1);
            cake.erase(itr);
            
            for_each(cake.begin(), cake.end(), 
            [](auto p){
      //          cout << p.first << " : " << p.second << endl;
                });
            
           // cout << endl;
        
        }

        vector<int> area{};
        for_each(cake.begin(), cake.end(), 
        [&](auto p){
            area.push_back(p.first * p.second);
        });

        sort(area.begin(), area.end());

        for_each(area.begin(), --area.end(), 
        [](auto p){
            cout << p << " ";
        });

        cout << area[area.size() - 1] << endl;

    }
    


    return 0;
}

Measured memory_bytes: 3088
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
		
N = INT()
a = LIST()

odd = 0
even_2 = 0
even_4 = 0
for x in a:
	if x%4 == 0:
		even_4 += 1
	elif x%2 == 0:
		even_2 += 1
	else:
		odd += 1

if even_4+1 == odd and even_2 == 0:
	print("Yes")
elif odd > even_4:
	print("No")
else:
	print("Yes")


Measured memory_bytes: 16324
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
struct Fstring{
	vector<pair<pii,int> > cc;
	bool fli;
	int L;
	Fstring(){
		cc.clear();
		fli=false;
		L=0;
	}
	void getfrom(int A,int B){
		L=A+B;
		cc.clear();
		if(A<B){
			fli=true;
			swap(A,B);
		}else fli=false;
		int mw=(A-1)/(B+1)+1;
		if(mw==1){
			cc.push_back(MP(MP(1,1),B));
			if(A>B)cc.push_back(MP(MP(1,0),1));
		}else{
			ll md=(ll(A)*mw-B)%(ll(mw)*mw-1);
			int c1=(md-1)/mw+1;
			int c2=ll(c1)*mw-md;
			cc.push_back(MP(MP(mw,1),(ll(mw)*A-B-2*c1+c2)/(ll(mw)*mw-1)));
			cc.push_back(MP(MP(c1,c2),1));
			cc.push_back(MP(MP(1,mw),(ll(mw)*B-A-2*c2+c1)/(ll(mw)*mw-1)));
		}
	}
	char getkth(int id){
		if(fli)id=L-id-1;
		rep(k,cc.size())
		if(id<(cc[k].first.first+cc[k].first.second)*cc[k].second){
			id%=(cc[k].first.first+cc[k].first.second);
			if(id<cc[k].first.first)return fli?'B':'A';
			else return fli?'A':'B';
		}else id-=(cc[k].first.first+cc[k].first.second)*cc[k].second;
	}
}dat;
int main(){
	int q,a,b,l,r;
	scanf("%d",&q);
	while(q--){
		scanf("%d%d%d%d",&a,&b,&l,&r);
		dat.getfrom(a,b);
		l--;r--;
		for(int k=l;k<=r;k++)putchar(dat.getkth(k));
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
  int n,k;

  scanf("%d%d", &n, &k);

  int d[k], a[k][n];

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

  int b[n], ans=0;

  for (int i = 0; i < n; i++)
    b[i] = 0;

  for (int i = 0; i < k; i++) {
    for (int j = 0; j < d[i]; j++) {
      b[(a[i][j]-1)]++;
    }
  }

  for (int i = 0; i < n; i++){
    if (b[i] == 0)
      ans++;
  }

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

  return 0;
}


Measured memory_bytes: 1760
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
 
int main()
{
    int n;
    while(cin>>n){
	if(n==0) return 0;
         int a[11][11]={0};
	 int sum=0;
         for(int i=0;i<n;i++){
             for(int j=0;j<n;j++){
		cin>>a[i][j]; 
                sum+= a[i][j]; 
             }
          }

          for(int i=0;i<n;i++){
             for(int j=0;j<n;j++){
               a[i][n]+=a[i][j];                
             }
          }
          for(int j=0;j<n;j++){
             for(int i=0;i<n;i++){
                a[n][j]+=a[i][j];               
             }
          }
          a[n][n]=sum;
          for(int i=0;i<n+1;i++){
             for(int j=0;j<n+1;j++){
		cout<<setw(5)<<a[i][j];
             }
             cout<<endl;
           }
    }
}

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

int main() {
    string s;
    int i;

    getline(cin, s);

    for(i=0;i<s.size();i++){
        if(isupper(s[i])){
            s[i]=tolower(s[i]);
        }else{
            s[i]=toupper(s[i]);
        }
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3164
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Replacing
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_A = 100000;

/* typedef */

typedef long long ll;

/* global variables */

int ts[MAX_A + 1];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  ll sum = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);

    sum += ai;
    ts[ai]++;
  }

  int q;
  scanf("%d", &q);

  while (q--) {
    int bi, ci;
    scanf("%d%d", &bi, &ci);

    sum += (ll)(ci - bi) * ts[bi];
    ts[ci] += ts[bi];
    ts[bi] = 0;

    printf("%lld\n", sum);
  }
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  string str{}; cin >> str;
  vector<int> A(4);
  for (int i = 0; i < 4; ++i) {
    A[i] = str[i] - '0';
  }

  vector<vector<int>> table = {
    {A[0], A[1], A[2], A[3]},
    {A[0], A[1], A[2], -A[3]},
    {A[0], A[1], -A[2], A[3]},
    {A[0], A[1], -A[2], -A[3]},
    {A[0], -A[1], A[2], A[3]},
    {A[0], -A[1], A[2], -A[3]},
    {A[0], -A[1], -A[2], A[3]},
    {A[0], -A[1], -A[2], -A[3]},
  };
  for (const auto& row : table) {
    auto sum = std::accumulate(row.begin(), row.end(), 0);
    if (sum == 7) {
      for (const auto& c : row) { cout << c << std::showpos; }
      cout << "=7" << CRLF;
      return;
    }
  }

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;
const int INF = 1e18;
const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};
#define WHITE 0
#define GRAY 1
#define BLACK 2
int H, W;
vector<string> maze;

int bfs(int sh, int sw, int gh, int gw)
{
    int seen[22][22];
    int dist[22][22];
    memset(seen, 0, sizeof(seen));
    memset(dist, 0, sizeof(dist));

    queue<pair<int, int>> q;

    //set start point
    seen[sh][sw] = true;
    dist[sh][sw] = 0;
    q.push(make_pair(sh, sw));

    //calc
    while (!q.empty())
    {
        auto now = q.front();
        q.pop();
        int h = now.first;
        int w = now.second;

        for (int i = 0; i < 4; i++)
        {
            int nh = h + dh[i];
            int nw = w + dw[i];

            //座標がOKかどうか
            bool isHok = (0 <= nh && nh < H);
            bool isWok = (0 <= nw && nw < W);

            if (!(isHok && isWok))
                continue;

            if (maze[nh][nw] == '#')
                continue;

            if (seen[nh][nw])
                continue;

            dist[nh][nw] = dist[h][w] + 1;
            seen[nh][nw] = true;
            q.push(make_pair(nh, nw));
        }
    }

    return dist[gh][gw];
}

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    cin >> H >> W;
    maze.resize(H);
    rep(h, H) cin >> maze[h];

    int ans = 0;
    for (int sh = 0; sh < H; sh++)
    {
        for (int sw = 0; sw < W; sw++)
        {
            for (int gh = 0; gh < H; gh++)
            {
                for (int gw = 0; gw < W; gw++)
                {
                    if (maze[sh][sw] == '#')
                        continue;
                    if (maze[gh][gw] == '#')
                        continue;

                    ans = max(ans, bfs(sh, sw, gh, gw));
                }
            }
        }
    }

    cout << ans << endl;
}

signed main()
{
    solve();
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
const int INF = 0x3f3f3f3f;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length(); ++i) {
        for (int j = 0; j < s.length(); ++j) {
            bool flag = true;
            string t = s.substr(i, j - i + 1);
            for (char &c : t) {
                if (c != 'A' && c != 'C' && c != 'G' && c != 'T') {
                    flag = false;
                    break;
                }
            }
            if (flag)
                ans = max(ans, (int)t.length());
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

while True:
    h, w = map(int, input().split())
    if h + w == 0:
        exit(0)

    for i in range(h):
        for j in range(w):
            if i == 0 or i == h-1 or j == 0 or j == w-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 8300
N, H, W = map(int, input().split())
lst = []
for i in range(N):
    Ai, Bi = map(int, input().split())
    lst.append((Ai, Bi))

cnt = 0
for i in range(N):
    if lst[i][0] >= H and lst[i][1] >= W:
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
S = list(input())

a0 = 0
a1 = 0
b0 = 0
b1 = 0

f = True
for s in S:
    if f:
        if s == '0':
            a0 += 1
        else:
            a1 += 1
        f = False
    else:
        if s == '0':
            b0 += 1
        else:
            b1 += 1
        f = True

ans = min(a0 + b1, a1 + b0)
print(ans)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N,K;
    cin>>N>>K;
    vll A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N-K;i++){
        if(A[i]<A[i+K]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 4840
#include <stdio.h>
int main(void) {
  int i, sc, fir = 0, sec = 0, thr = 0, co=2;
  while(co) {
    co--;
    i = 10;
    while(i) {
      i--;
      scanf("%d",&sc);
      if(sc > fir) {
	thr = sec; sec = fir; fir = sc;
      } else if(sc > sec) {
	thr = sec; sec = sc;
      } else if(sc > thr) {
	thr = sc;
      }
    } printf("%d",fir+sec+thr);
    if(co) printf(" ");
    fir=0;sec=0;thr=0;
  }
  puts("");
  return(0);
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vll A(n); for(auto& e : A) cin >> e;
    sort(_all(A));

    vi tbl;
    rep(i, n - 1){
        if(A[i] == A[i+1]){
            tbl.emplace_back(A[i]);
            i++;
        }
    }

    ll res = 0LL;
    int m = tbl.size();
    if(m >= 2){
        res = 1LL * tbl[m-1] * tbl[m-2];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  char a, b;
  cin >> a >> b;
  if(a > b) cout << ">\n";
  else if(a < b) cout << "<\n";
  else cout << "=\n";
}


Measured memory_bytes: 3596
n = gets.to_i
cmds = n.times.map{ gets.chomp.split }

dict = {}
cmds.each do | cmd, key |
  if cmd == 'insert'
    dict[key] = true
  else    # 'find'
    if dict[key]
      puts 'yes'
    else
      puts 'no'
    end
  end
end


Measured memory_bytes: 216452
#include<iostream>
#include<algorithm>
using namespace std;
int a[3];
int main()
{
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
int ans=2*a[2]-a[1]-a[0];
if(ans%2)
ans+=3;
ans/=2;
cout<<ans<<endl;
system ("pause"); 
return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <climits>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/home/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
  register char c = getchar();x = 0;
  int neg = 0;
  for(; ((c<48 || c>57) && c != '-'); c = getchar());
  if(c=='-'){neg = 1;c = getchar();}
  for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
  if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
  long long ret = 1;
  for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 50;
LL mod = 1e9+7;

void sum(LL &a, LL b) {
  a = (a + b) % mod;
}

struct mat{
  LL m[N][N];
  int d;
  mat(int d): d(d) { memset(m,0,sizeof m);}
  mat operator * (const mat& rhs) const {
    mat z(d);
    for(int i=0;i<d;i++){
      for(int j=0;j<d;j++){
        for(int k=0;k<d;k++){
          sum(z.m[i][j], m[i][k] * rhs.m[k][j]);
        }
      }
    }
    return z;
  }
};

mat exp(mat A, LL p) {
  if(p == 1) return A;
  if(p%2 == 0) {
    mat r = exp(A,p/2);
    return r*r;
  }
  return A * exp(A, p - 1);
}

int main()
{
  int n;
  LL K;
  in2(n,K);
  mat A(n);
  for(int i = 0; i < n; i ++) {
    for(int j = 0; j < n; j ++) {
      in(A.m[i][j]);
    }
  }
  A = exp(A,K);
  LL ans = 0;
  for(int i = 0; i < n; i ++) {
    for(int j = 0; j < n; j ++) {
      sum(ans, A.m[i][j]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main ()
{
    string s, t, u;
    cin >> s >> t >> u;
    cout << s[0] << t[1] << u[2] << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  cout << n*n*n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3,typename T4> inline void print4(T1 a, T2 b, T3 c, T4 d){
	cout << a << " " << b << " " << c << " " << d << endl;
}
constexpr int mod = 1e9 + 7;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(ll i=2; i<MAX; i++){
		fac[i] = fac[i-1]*i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}


ll com(ll n, ll k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

vl dp(202020,-1);
vl siz(202020,0);
vvl G(202020);
vl ans(202020,-1);
ll n;

P cp(ll u, ll p){
	if(dp[u] != -1) return P(dp[u],siz[u]);
	ll res = 1;
	vl sz;
	for(auto v : G[u]){
		if(v == p) continue;
		if(res == 0) res = 1;
		P p = cp(v,u);
		res *= p.first;
		res %= mod;
		siz[u] += p.second + 1;
		sz.push_back(p.second + 1);
	}
	res *= fac[siz[u]];
	res %= mod;
	for(auto i : sz){
		res *= finv[i];
		res %= mod;
	}
	dp[u] = res;
	return P(dp[u],siz[u]);
}

ll modpow(ll x, ll n, ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}


void dfs(ll u, ll p){
	ans[u] = dp[u];
	if(p != -1){
		ans[u] *= siz[u] + 1;
		ans[u] %= mod;
		ans[u] *= ans[p] * modpow(dp[u],mod-2,mod) % mod;
		ans[u] %= mod;
		ans[u] *= inv[n-1-siz[u]];
		ans[u] %= mod;
	}
	for(auto v : G[u]){
		if(v != p) dfs(v,u);
	}
}

int main(){
	cin >> n;
	rep(i,n-1){
		ll a,b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	comInit();
	cp(0,-1);
	dfs(0,-1);
	rep(i,n) cout << ans[i] << "\n";
}

Measured memory_bytes: 32624
#include<bits/stdc++.h>
using namespace std;
stack<int>s;
int a[105];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int t=n;
    while(t--)
    {
        int flag=-1;
        for(int i=n;i>=1;i--)
            if(a[i]==i)
        {
            s.push(i);
            flag=i;
            break;
        }
        if(flag==-1)
        {
            printf("-1\n");
            return 0;
        }
        int cot=0;
        for(int i=1;i<=n;i++)
            if(i!=flag)
            a[++cot]=a[i];
        n--;
    }
    while(!s.empty())
    {
        printf("%d\n",s.top());s.pop();
    }
}


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

int main(){
 int N;
 cin >> N;
 int ans = 0;
 for(int i = 1; i <= N; i += 2){
   int cnt = 0;
   for(int j = 1; j <= i; j++){
     if(i % j == 0){
       cnt++;
     }
   }
   if(cnt == 8){
     ans++;
   }
 }
cout << ans << endl;
}

Measured memory_bytes: 256
import sys

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

b = [sys.maxsize for i in range(a)]

c = list(map(int,input().split()))
b[0] = 0
for i in range(1,a):
	k = min(i,aa)
	for j in range(1,k+1):
		ma = min(b[i],b[i-j] + abs(c[i]-c[i-j]))
		b[i] = ma
print(b[-1])


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

use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        mut s: [chars; n],
    }

    let mut map = HashMap::<String, isize>::new();
    for i in 0..n {
        s[i].sort();
        let t = s[i].iter().map(|&s| s as char).collect::<String>();
        //println!("{}", t);
        if map.contains_key(&t) {
            let tmp = map[&t] + 1; 
            map.insert(t.clone(), tmp);
        } else {
            map.insert(t, 1);
        }
    }

    let mut ans = 0;
    for (_, v) in map {
        ans = ans + v * (v-1) / 2;
    }

    println!("{}", ans);
}


Measured memory_bytes: 25720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
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; }
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main()
{
    ll x;cin >>x;++x;
    ll ans = 0;
    rep2(i,1, x)rep2(j,1, x)rep2(k, 1,x)
    {
        ll z = GCD(GCD(i, j), k);
        ans += z;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#define rep(i, n) for (int i = 0; i < (n); i ++)
using namespace std;

int main()
{
  string s;
  cin >> s;
  
  int n = s.size();
  int b = -1;
  int e = -1;
  
  rep(i, n)
  {
    if (s.at(i) == 'A' && b == -1) b = i;
    if (s.at(i) == 'Z') e = i;
  }
  
  cout << e - b + 1;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int a;
	float b,c,bmi;
	while(scanf("%d,%f,%f",&a,&b,&c)!=EOF) {
		bmi=b/(c*c);
		if(bmi>=25) {
			printf("%d\n",a);
		}
	}
	return 0;
}

Measured memory_bytes: 624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	char c;
	cin >> c;
	c = char(c + 1);
	cout << c;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0, tail=0, n=0;

void enqueue(P x){
  Q[tail]=x;
  tail=tail+1;
  tail=tail%(LEN+1);
}


P dequeue(){
  int l;
  l=head;
  head=head+1;
  head=head%(LEN+1);
  return Q[l];
}


int main(){
  int elaps=0, c=0;
  int i, q;
  P u;

  head=1;
 

  scanf("%d %d", &n, &q);
  tail=1+n;

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  while(1){
    //printf("%d %d\n", head, tail);
    if(head==tail) break;
    u=dequeue();
    if(u.t>q){
      c=c+q;
      u.t=u.t-q;
      enqueue(u);
    } else{
      c=c+u.t;
      printf("%s %d\n",u.name,c);
    }
  }  
  return 0;
}

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

int main(){
    int H,W;
    cin >> H >> W;
    for(int i = 0; i < W+2; i++) {
        cout << '#';
    }
    cout << endl;
    for(int i = 0; i < H; i++) {
        string a;
        cin >> a;
        cout <<'#'<< a << '#' << endl;
    }
    for(int i = 0; i < W+2; i++) {
        cout << '#';
    }
    cout << endl;
}

Measured memory_bytes: 256
L, R = map(int, input().split())
X = []
N = R - L
n = N % 2019
l = L % 2019
r = R % 2019
if l >= r or N // 2019 > 0:
  print(0)
else:
  for i in range(l,r):
    for j in range(i+1,r+1):
      X.append((i*j)%2019)
  print(min(X))

Measured memory_bytes: 75416
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  double a,b,v;
  cin>>a>>b>>v;
  double ans=atan(a*b*b/2/v)*(180.0/M_PI);
  double ANS=atan(2*(a*a*b-v)/a/a/a)*(180.0/M_PI);
  if(a*a*b>=v*2) printf("%.14f\n",ans);
  else printf("%.14f\n",ANS);
}

Measured memory_bytes: 256
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-variable"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
// }}}

int main() {
    int n;
    LL h,w;
    cin >> n >> h >> w;
    int ans=0;
    for ( int i=0; i<n; i++ ) {
        LL a,b;
        cin >> a >> b;
        if ( a>=h&&b>=w ) ans++; 
    }
    cout << ans << '\n';
    return 0;
}






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

int gcd(unsigned int x, unsigned int y){
  int tmp;
  // must x >= y
  if(x < y){
    tmp = x; x = y;y = tmp;
  }

  while (y != 0){
    tmp = y;
    y = x % y;
    x = tmp;
  }
  return x;
}

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

  unsigned long long int x, y, d;
  cin >> x;
  cin >> y;

  d = gcd(x, y);

  cout << d << "\n";
}



Measured memory_bytes: 3172