akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

char f(char c){
	if( c == ')' )
		return '(';
	if( c == '(')
		return ')';
	return c;
}

int main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i=0 ; i < s.size()/2 ; i++ ){
		if( f(s[i]) != s[s.size()-i-1] ) ans++;
	}
	if( s.size() % 2 == 1 ){
		if( s[ s.size()/2 ] == '(' || s[ s.size()/2 ] == ')' ){
			ans++;
		}
	}
	cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,n){
        if(a[i] == a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1024
n = int(input())
A = []
for i in range(n):
    A.append(list(map(int, input().split())))
s = 0
for i in range(n):
    for j in range(n):
        s += ((A[i][0]-A[j][0])**2 + (A[i][1]-A[j][1])**2)**0.5
print(s/n)

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

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

	int x = (A < B) ? A : B;
	int y = (C < D) ? C : D;
	int ans = x + y;

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


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

typedef long long ll;

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

  int n;
  cin >> n;

  vector<int> d(n);
  for (int i = 0; i < n; i++){
    cin >> d.at(i);
  }

  int sum = 0;
  for (int i = 0; i < n - 1; i++){
    for (int j = i + 1; j < n; j++){
      sum += d.at(i) * d.at(j);
    }
  }

  cout << sum << endl;

  return 0;
}

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

N = int(input())

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

cnt = {}

for a in As:
    cnt.setdefault(a, 0)
    cnt[a] += 1

ans = 0
for k, v in cnt.items():
    #print(k, v)
    if v - k < 0:
        ans += v
    else:
        ans += v - k

print(ans)


Measured memory_bytes: 17780
using System;


namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true) {
                String[] s = Console.ReadLine().Split(' ');
                int H = int.Parse(s[0]);
                int W = int.Parse(s[1]);

                if (H == 0 && W == 0) break;
            
                int i = 0;
                while (true)
                {
                    if (i == H) break;
                    if (i%2==0)
                    {
                        for (int x = 0; x < W; x++)
                        {
                            if (x % 2 == 1)
                            {
                                Console.Write(".");

                            }
                            else if (x % 2 == 0)
                            {
                                Console.Write("#");

                            }

                        }
                    }
                    else
                    {
                        for (int x = 0; x < W; x++)
                        {
                            if (x % 2 == 1)
                            {
                                Console.Write("#");

                            }
                            else if (x % 2 == 0)
                            {
                                Console.Write(".");

                            }

                        }
                    }
                    
                    Console.WriteLine();

                    i++;
                }
                Console.WriteLine();


            }

        }
    }
}

Measured memory_bytes: 8920
from bisect import insort_left, bisect_left
n = int(input())
s = list(input())
Q = int(input())
query = [input() for _ in range(Q)]
dic = {chr(i+ord('a')):[] for i in range(26)}
for ind, c in enumerate(s):
    dic[c].append(ind)

for q in query:
    t, a, b = q.split()
    a = int(a)-1
    if t=='1':
        if s[a]==b:
            continue
        ind = bisect_left(dic[s[a]], a)
        dic[s[a]].pop(ind)
        insort_left(dic[b], a)
        s[a] = b
    else:
        b = int(b)-1
        tmp = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                tmp += 1
        print(tmp)


Measured memory_bytes: 98148
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();

        long ans = 0;

        for (int i = 1; i <= N; i++) {
            if(i % 5 == 0 && i % 3 == 0) continue;
            if(i % 5 == 0 || i % 3 == 0) continue;
            ans+= i;
        }

        out.println(ans);
        out.close();


    }
}


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

int bubbleSort(int A[],int N) {
	int sw = 0; 
	bool flag = 1;
	for(int i=0; flag; i++) {
		flag = 0;
		for(int j=N-1;j>=i+1;j--) {
			if(A[j]<A[j-1]) {
				swap(A[j],A[j-1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main(void) {
	int A[100], N, sw;
	cin >> N;
	for(int i=0;i<N; i++) cin >> A[i];
	
	sw = bubbleSort(A,N);
	
	for(int i=0;i<N;i++) {
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}

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

int main()
{
    int ax, ay, bx, by;
    cin >> ax >> ay >> bx >> by;
    int x = bx - ax;
    int y = by - ay;
    for(int i = 0; i < y; i++)
    {
        cout << "U";
    }
    for(int i = 0; i < x; i++)
    {
        cout << "R";
    }
    for(int i = 0; i < y; i++)
    {
        cout << "D";
    }
    for(int i = 0; i < x; i++)
    {
        cout << "L";
    }
    cout << "L" << "U";
    for(int i = 0; i < y; i++)
    {
        cout << "U";
    }
    cout << "R";
    for(int i = 0; i < x; i++)
    {
        cout << "R";
    }
    cout << "D" << "R" << "D";
    for(int i = 0; i < y; i++)
    {
        cout << "D";
    }
    cout << "L";
    for(int i = 0; i < x; i++)
    {
        cout << "L";
    }
    cout << "U" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, ll B, ll C) {
  cout << (A==B ? C : B==C ? A : B) << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll C;
  cin >> C;
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


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

    cout << (A - 1) * (B - 1) << endl;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int N;
  cin >> N;
 
  map<string, int> mp;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
 
    if (mp.count(s) == 0) {
      mp.insert(make_pair(s, 1));
    } else {
      mp[s]++;
    }
  }
 
  int M;
  cin >> M;
 
  for (int i = 0; i < M; i++) {
    string s;
    cin >> s;
 
    if (mp.count(s) == 0) {
      mp.insert(make_pair(s, -1));
    } else {
      mp[s]--;
    }
  }
 
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    int n = itr->second;
    if (n > ans) {
      ans = n;
    }
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
  int n;
  cin >> n;
  int x = 0, y = 0, z = 0;
  int t[n], a[n], b[n];
  rep(i, n) cin >> t[i] >> a[i] >> b[i];
  string s = "Yes";
  rep(i, n){
    int d = abs(x - a[i]) + abs(y - b[i]);
    if((t[i] - z) >= d && (t[i] - z + d) % 2 == 0){
      x = a[i];
      y = b[i];
      z = t[i];
    }
    else {
      s = "No";
      break;
    }
  }
  cout << s << endl;
       

  return 0;
}

Measured memory_bytes: 4784
import sys

n, we = map(int, input().split())

cf=[(0, 0)]*n

cf = sorted(tuple( int(x) for x in sys.stdin.readline().split()) for _ in range(n))

dp=[0]*(we+1)

best=0
cnt=1
lim=0

for w,c in cf:
    cnt=cnt+w
    lim=min(cnt, we-w)
    for j in range(lim, -1, -1):
        if dp[j+w]<(dp[j] + c) : dp[j+w]=dp[j] + c

print(max(dp))

Measured memory_bytes: 7736
#include <iostream>
#include <vector>
#include <iomanip>

int main(int argc, char const *argv[])
{
	double r;
	std::cin >> r;
	std::cout << std::fixed << std::setprecision(10) <<r*r*(double)3.14159265358979 <<" ";
	std::cout << std::fixed << std::setprecision(10) <<(double)2*r*(double)3.14159265358979 <<std::endl;
	return 0;
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int a,b,c;
  cin>>a>>b>>c;

  b/a>c? cout<<c<<endl : cout<<b/a<<endl;


return 0;}


Measured memory_bytes: 256
S = input()

a = S[0]
a0 = 1

b = ''

if a != S[1]:
    b = S[1]
    b0 = 1
elif S[0] == S[1]:
    a0 += 1

if a == S[2]:
    a0 += 1
elif b == '':
    b = S[2]
    b0 = 1
elif b == S[2]:
    b0 += 1

if a == S[3]:
    a0 += 1
elif b == S[3]:
    b0 += 1

if a0 == 2 and b0 == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main() {
	int N, Q, l[100000] = {}, r[100000] = {}, count[100001] = {},ans=0;
	char s[100001];
	cin >> N >> Q;
	cin >> s;
	for (int i = 0; i<Q; i++)
	{
		cin >> l[i] >> r[i];
	//	cout << l[i] << " " << r[i] << endl;
	}
	for (int i = 1; i<N+1; i++)
	{
		count[i] = count[i-1];
		if (s[i-1] == 'A'&&s[i] == 'C')count[i] += 1;
	//cout << count[i];
	}
	//cout << count[N];
	//cout << endl;
	for (int i = 0; i<Q; i++)
	{
		if (true)
		{
			cout << count[r[i]-1] - count[l[i]-1] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 2048
/*************************************************************************
  > File Name: 1.cpp
  > Author: PumpkinYing
  > Created Time: 2017年11月08日 星期三 00时18分08秒
 ************************************************************************/


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
#define pii pair<int,int>
#define F first 
#define S second

int main()
{
	int q,h,s,d;
	ll n;
	scanf("%d%d%d%d",&q,&h,&s,&d);
	scanf("%lld",&n);
	int c1 = min(min(q*4,h*2),min(q*2+h,s));
	int c2 = min(c1*2,d);
	ll ans = n/2*c2;
	if(n%2) ans += c1;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int n, m, d, buc[N];
Pair a[N];

int main() {
    cin >> n >> m >> d;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            int x;
            scanf("%d", &x);
            a[x] = mp(i, j);
        }
    }
    for (int start = 1; start <= d; start++) {
        int tmp = 0;
        for (int i = start; i <= n * m; i += d) {
            int j = i + d;
            buc[i] = tmp;
            if (j <= n * m) tmp += std::abs(a[i].fi - a[j].fi) + std::abs(a[i].se - a[j].se);
        }
    }
    int q;
    scanf("%d", &q);
    while (q--) {
        int l, r;
        scanf("%d %d", &l, &r);
        printf("%d\n", buc[r] - buc[l]);;
    }
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <list> //???????????????????????????
#include <vector>//????????¢??????????????????
#include <climits>
using namespace std;



int merge(vector <int>&A, int left, int mid, int right){
	
	
  int n1 = mid - left;
  int n2 = right - mid;
	vector <int> L(n1+1);
	vector <int> R(n2+1);
	for(int i=0 ; i < n1 ; i++){
		L[i] = A[left + i];
	}
	for(int i=0 ; i < n2 ; i++){
		 R[i] = A[mid + i];
	}
	
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	int i = 0;
	int j = 0;
	
	int sum = 0;
	for(int k = left ; k < right ; k++){
		if(L[i] <= R[j]){
			A[k] = L[i];
			i = i+1;
			
		}else{
			A[k] = R[j];
			j = j + 1;
		}

	}
		sum += i;
		sum += j;
	return sum;
}


int mergeSort(vector <int>&A, int left, int right){
	int sum=0;
	if(left+1 < right){
	    int mid = (left + right)/2;
	    sum += mergeSort(A, left, mid);
	    sum += mergeSort(A, mid, right);
	    sum += merge(A, left, mid, right);
		
	}
	return sum;
	
}
int main(void){
	int n;
	cin >> n;
	vector <int> S(n);
	
	int s;
	for (int i=0 ; i < n; i++){
		
	cin >> s;
		S[i]=s;
	}
	
	int sum = mergeSort(S,0,S.size());
	
	for(int i=0; i < S.size() ; i++){
		
		cout << S[i];
		if(i < S.size()-1){
		cout << " ";
		}
	}
	cout << endl;
	cout << sum << endl;

}

Measured memory_bytes: 5064
N = int(input())
L_list = list(map(int,input().split()))
count = 0
a = 1

for j, b in enumerate(L_list):
    if b == 1:
        continue
    for k, c in enumerate(L_list):
        if c == 1 or c == b:
            continue
        elif (a+b) > c and (b+c) > a and (c+a) > b and a < b < c:
            count += 1


for i, a in enumerate(L_list):
    if a == 1:
        continue
    for j, b in enumerate(L_list):
        if b == 1 or b == a:
            continue
        for k, c in enumerate(L_list):
            if c == 1 or c == b or c == a:
                continue
            elif (a+b) > c and (b+c) > a and (c+a) > b and a < b < c:
                count += 1

print(count)

Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
    string s,t;
    for(int i=0;i<a;i++)
    {
    	s += ( b+'0');
	}
	for(int i=0;i<b;i++)
    {
    	t += ( a+'0');
	}
	cout<<min(s,t)<<endl;
	
}

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

int main() {
  int s1,  s2,  s3, a;
  cin >> a;
  s1 = a/100;
  s2 = (a-s1*100)/10;
  s3 = a-(s1*100+s2*10);
  cout << s1+s2+s3 << endl; 
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= putStrLn . ( "2018" ++ ) . drop 4


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int A;
  int B;
  
  cin >> A >> B;
  
  string S;
  cin >> S;
  
  int num = 0;
  
  if(S[A] == '-'){
    for(int i = 0;i < S.size();++i){
      if(S[i] == '-'){
        num++;
      }
    }
    if(num == 1){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    count = max(a[0]*2-1,a[1]*2-1 ,a[0]+a[1])
    print(count)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,y;
    cin>>n>>y;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n-i;j++)
            if(i*10000+j*5000+(n-i-j)*1000==y) cout<<i<<' '<<j<<' '<<n-i-j<<endl,exit(0);
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
    public static void main(String args[]){
        String e;
        Scanner s=new Scanner(System.in);
        e=s.nextLine();
        if(e.contains("A")&&e.contains("B"))
                System.out.println("Yes");
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int K, X, Y;

struct V {
  int x, y;

  V(int _x, int _y) {
    x = _x, y = _y;
  }
};

void finish(int x, int y, vector<V> & res) {
  assert(x >= 0 && y >= 0 && x <= y && x + y <= 2*K);
  if(x == 0 && y == 0) return;
  if(x + y == K) {
    res.emplace_back(x, y);
    return;
  }
  if((x + y) % 2) {
    int dx, dy;
    if(x + y >= K) {
      dx = x, dy = K - x;
    } else {
      dx = -(K-1)/2, dy = -(K+1)/2;
    }
    res.emplace_back(dx, dy);
    x -= dx, y -= dy;
  }
  int u = (x+y)/2, v = (x-y)/2;
  res.emplace_back(K+v, -v);
  res.emplace_back(-K+u, u);
}

auto flip(int &X, int &Y) {
  bool flipX = false, flipY = false, flipXY = false;
  if(X < 0) {
    X = -X;
    flipX = true;
  }
  if(Y < 0) {
    Y = -Y;
    flipY = true;
  }
  if(X > Y) {
    swap(X, Y);
    flipXY = true;
  }
  assert(X >= 0 && Y >= 0 && X <= Y);
  auto reverse = [=](V &v) {
    if(flipXY) swap(v.x, v.y);
    if(flipY) v.y = -v.y;
    if(flipX) v.x = -v.x;

  };
  return reverse;
}

int main () {
  cin >> K >> X >> Y;

  if(K % 2 == 0 && (X + Y) % 2) {
    cout << -1 << endl;
    return 0;
  }

  auto reverseFlip = flip(X, Y);
  vector<V> moves;
  while(X > K) {
    X -= K;
    moves.emplace_back(K, 0);
  }
  while(Y > 2*K) {
    Y -= K;
    moves.emplace_back(0, K);
  }
  if(X + Y > 2*K) {
    moves.emplace_back(X, K-X);
    Y -= K - X;
    X = 0;
  }
  finish(X, Y, moves);

  cout << moves.size() << endl;

  int x = 0, y = 0;
  for(V &v: moves) {
    reverseFlip(v);
    x += v.x, y += v.y;
    printf("%d %d\n", x, y);
  }

  return 0;
}


Measured memory_bytes: 3824
#include<stdio.h>
#define N 200000
main(){
  int i,min,max,n,r[N];
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&r[i]);
  }
  max = r[1] - r[0];
  min = r[0];
  for(i = 1; i < n; i++){
    if(max > r[i]-min)max = max;
    else max = r[i]-min;
    if(min < r[i])min = min;
    else min = r[i];
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1376
#include<bits/stdc++.h>
using namespace std;
bool check(string s)
{
    if(s.size()==6)
    {
        if(s[2]==s[3] && s[4]==s[5])
            return true;
    }
    return false;
}
int main()
{
    string s;
    cin>>s;
    if(check(s))
       cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
	ll n; cin >> n;
	int bit[100] = {};
	int p = 0;
	while (n) {
		bit[p++] = (--n) % 26;
		n /= 26;
	}
	for (int i = p - 1; i >= 0; i--)
		cout << char(bit[i] + 'a');
}

Measured memory_bytes: 3584
S = input()
hi = "hi"

if len(S) % 2 != 0:
    print("No")
else:
    flag = 0
    n = len(S)//2
    for i in range(n):
        if S[2*i:2*i+2] != "hi":
            flag = 1
            break
    if flag == 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int a,b,x;
	while(scanf("%d %d",&a,&b)!=EOF) {
		x=a+b;
		if(1<=x&&x<=9) {
			printf("%d\n",1);
		}
		else if(10<=x&&x<=99) {
			printf("%d\n",2);
		}
		else if(100<=x&&x<=999) {
			printf("%d\n",3);
		}
		else if(1000<=x&&x<=9999) {
			printf("%d\n",4);
		}
		else if(10000<=x&&x<=99999) {
			printf("%d\n",5);
		}
		else if(100000<=x&&x<=999999) {
			printf("%d\n",6);
		}
		else if(1000000<=x&&x<=9999999) {
			printf("%d\n",7);
		}
		
	}
	return 0;
}


Measured memory_bytes: 2056
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>
#include <math.h>

using namespace std;
using namespace boost::multiprecision;

cpp_int N;
void solve() {
	cin >> N;
	cpp_int ans = 0;
	for (cpp_int i = 1;i*i < N; i++) {
		if (N%i == 0) {
			cpp_int m = (N / i) - 1;
			if (m + 1 <= N && N < m*(m + 1))
				ans += m;
		}
	}
	cout << ans << endl;
	return;
}

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

int main()
{
  int n,k;
  cin >> n;
  vector<vector<int> > v(n,vector<int>(3));
  
  for(int i = 0;i<n;i++)
  {
    cin >> v[i][0] >> v[i][1] >> v[i][2];
  }
  
  int a = v[0][0],b= v[0][1],c = v[0][2];
  for(int i = 1;i<n;i++)
  {
    int prev_a = a,prev_b = b,prev_c = c;
    a = v[i][0] + max(prev_b,prev_c);
    b = v[i][1] + max(prev_a,prev_c);
    c = v[i][2] + max(prev_a,prev_b);
  }
  cout << max(a,max(b,c)) << endl;
  return 0;
}


Measured memory_bytes: 8772
#include "bits/stdc++.h"
using namespace std;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    vector< int> v(n + 1);
    int b;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
        if (v[i] == 1) b = i;
    }
    int res = n;
    for (int i = max(1, b - k + 1); i <= b and i + k - 1 <= n; ++i) {
        int j = i + k - 1;
        res = min(res, 1 + (i + k - 3) / (k - 1) + (n - j + k - 2) / (k - 1));
    }
    printf("%d\n", res);
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

char a[105][105];

int cnt[105][105];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=1 ; i<=n ; i++) {
		scanf("%s", &a[i][1]);
	}
	for (int i=0 ; i<105 ; i++) {
		cnt[0][i] = 105;
		cnt[i][0] = 105;
	}
	cnt[1][1] = (a[1][1] == '#');
//	cout <<cnt[1][1]<<" ";
	for (int i=1 ; i<=n ; i++) {
		for (int j=1 ; j<=m ; j++) {
			if (i == 1 and j == 1) continue;
			cnt[i][j] = min(
				cnt[i][j-1] + (a[i][j-1] != a[i][j]),
				cnt[i-1][j] + (a[i-1][j] != a[i][j])
			);
	//		cout <<cnt[i][j]<<" ";
		}
	//	cout <<endl;
	}
	printf("%d\n", (cnt[n][m]+1)/2);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 #include <math.h>

 #define PI 3.14159265358979323846264338327950L
 int main(void) {
 int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));

 return 0;
}


Measured memory_bytes: 2492
#include<stdio.h>

int kai(int a){
	int ke[5];
	ke[0]=a%10;a=(a-ke[0])/10;
	ke[1]=a%10;a=(a-ke[1])/10;
	ke[2]=a%10;a=(a-ke[2])/10;
	ke[3]=a%10;a=(a-ke[3])/10;
	ke[4]=a%10;a=(a-ke[4])/10;
	if(ke[0]==ke[4]&&ke[1]==ke[3])return 1;
	else return 0;
}

int main(){
	int a,b,i,ans=0;
	scanf("%d%d",&a,&b);
	for(i=a;i<=b;i++){
		if(kai(i)==1)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
/* Shuffle */
#include <stdio.h>

int main()
{
    char n[201];
    int m, h, i, j, k, num, temp;

    while(1){
        scanf("%s", &n);
        if(n[0] == '-' ){ break; }
        for(num=0; num<201 ; num++){
            if(n[num] == '\0'){ break; }
        }
        scanf("%d", &m);
        for(i=0; i<m; i++){
            scanf("%d", &h);
            for(j=0; j<h; j++){
                temp = n[0];
                for(k=0; k<num; k++){
                    n[k] = n[k+1];
                }
                n[num-1] = temp;
            }
        }
        printf("%s\n",&n);
    }
    return 0;
}


Measured memory_bytes: 2036
def ABC088B():    
    n = int(input())
    ai = list(map(int,input().split()))

    # リストを降順にソートする
    ai.sort(reverse=True)
    ans = sum(ai[0::2]) - sum(ai[1::2])

    print(ans)

if __name__ == '__main__' :
    ABC088B()

Measured memory_bytes: 3060
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] x = new long[N];
        long[] y = new long[N];
        for(int i=0; i<N; i++) {
            x[i] = Long.parseLong(sc.next());
            y[i] = x[i];
        }
        Arrays.sort(y);
        
        if(y[N/2] == y[(N/2)-1]) {
            for(int i=0; i<N; i++) {
                System.out.println(y[N/2]);
            }
        }else {
            for(int i=0; i<N; i++) {
                if(x[i] < y[N/2]) {
                    System.out.println(y[N/2]);
                }else if(x[i] >= y[N/2]) {
                    System.out.println(y[(N/2)-1]);
                }
            }
        }
    }  
}

Measured memory_bytes: 89780
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	for (int C = 1; C <= 3; C++) {
		if (A * B * C % 2 == 1) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

}






Measured memory_bytes: 3636
import sys

while True:
	line = sys.stdin.readline()
	if line is '':
		break
	
	(a, b, e, c, d, f) = map(float, line.split())
	
	D = a * d - b * c
	x = (d * e - b * f) / D
	y = (a * f - c * e) / D
	
	if abs(x) < 1e-4:
		x = 0.0
	if abs(y) < 1e-4:
		y = 0.0
	
	print("{0:.3f} {1:.3f}".format(x, y))

Measured memory_bytes: 6756
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>

using namespace std;
#define INF 1e9
#define MAX 100005
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

void base(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}


int main(){
	base();
	int a,b;
	cin>>a>>b;
	if (abs(a-b)>1) {
		cout<<0<<endl;
		return 0;
	}
	int c;
	if (abs(a-b)==0){
		c=2;
	}else {
		c=1;
	}
	ll x = c;
	for(int i=1;i<=a;i++){
		x*=1LL*i;
		x%=MOD;
	}
	for(int i=1;i<=b;i++){
		x*=1LL*i;
		x%=MOD;
	}
	cout<<x<<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 10000000;

int N;

ll f[MAX_N + 1];

bool is_prime[MAX_N + 1];
vector<ll> primes;

void enum_prime() {
    REP(i, MAX_N + 1) is_prime[i] = true;
    is_prime[0] = false;
    is_prime[1] = false;
    REP2(i, 2, MAX_N + 1) {
        if (!is_prime[i]) continue;
        primes.PB((ll)i);
        for (int j = 2 * i; j < MAX_N + 1; j += i) is_prime[j] = false;
    }
    return;
}

int main() {
    enum_prime();

    REP(i, MAX_N+1) f[i] = 1;

    REP(i, primes.size()) {
        for (ll p = primes[i]; p <= MAX_N; p += primes[i]) {
            int cnt = 1;
            ll q = primes[i];
            while (p % q == 0) {
                q *= primes[i];
                cnt++;
            }
            f[p] *= cnt;
        }
    }

    // REP(i, 4) PRINT(f[i]);

    cin >> N;
    ll ans = 0;
    REP2(K, 1, N+1) ans += K * f[K];
    PRINT(ans);
    return 0;
}

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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string str;
    cin >> str;

    int orig_hapiness = 0;
    int r_clusters = 0;
    int l_clusters = 0;

    char c = str[0];
    for(int i=1;i<n;++i)
    {
        if(str[i] == c)
        {
            orig_hapiness++;
        }
        else
        {
            if(c == 'R')
            {
                r_clusters++;
            }
            else
            {
                l_clusters++;
            }
            c = str[i];
        }
    }
    if(c == 'R')
    {
        r_clusters++;
    }
    else
    {
        l_clusters++;
    }
    // cerr << orig_hapiness << endl;
    // cerr << r_clusters << endl;
    // cerr << l_clusters << endl;

    if (r_clusters == 0 || l_clusters == 0)
    {
        cout << orig_hapiness << endl;
    }
    else if(r_clusters == 1 || l_clusters == 1)
    {
        cout << n - 1 << endl;
    }
    else
    {
        cout << min(n-1, orig_hapiness + 2 * k) << endl;
    }
    
}

Measured memory_bytes: 512
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <utility>
#include <vector>

#define MAX_N (1000)
#define INF (1E18)

using namespace std;

void dijkstra(const vector<vector<pair<int, double>>> &adj_lists, int s,
              vector<double> &ds) {
  const int N = adj_lists.size();
  priority_queue<pair<double, int>, vector<pair<double, int>>,
                 greater<pair<double, int>>>
      que;
  for (int i = 0; i < N; i++) {
    ds[i] = INF;
  }
  que.push(make_pair(0.0, s));
  while (!que.empty()) {
    const int i = que.top().second;
    const double d = que.top().first;
    que.pop();
    if (d < ds[i]) {
      ds[i] = d;
      for (pair<int, double> p : adj_lists[i]) {
        const int j = p.first;
        const double w = p.second;
        que.push(make_pair(d + w, j));
      }
    }
  }
}

int main(int argc, char *argv[]) {
  // read inputs
  int N;
  double xs[MAX_N + 2], ys[MAX_N + 2], rs[MAX_N + 2], x0, y0, x1, y1;
  scanf("%lf %lf %lf %lf", &x0, &y0, &x1, &y1);
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%lf %lf %lf", &xs[i], &ys[i], &rs[i]);
  }

  // add start and finish
  xs[N] = x0;
  ys[N] = y0;
  xs[N + 1] = x1;
  ys[N + 1] = y1;
  rs[N] = rs[N + 1] = 0.0;

  // create graph
  vector<vector<pair<int, double>>> adj_lists(N + 2,
                                              vector<pair<int, double>>());
  for (int i = 0; i < N + 2; i++) {
    const double xi = xs[i], yi = ys[i], ri = rs[i];
    for (int j = i + 1; j < N + 2; j++) {
      const double xj = xs[j], yj = ys[j], rj = rs[j];
      const double d = sqrt((xj - xi) * (xj - xi) + (yj - yi) * (yj - yi)),
                   w = max(d - (ri + rj), 0.0);
      // printf("i = %d, j = %d, xi = %lf, yi = %lf, xj = %lf, yj = %lf\n", i, j,
      //        xi, yi, xj, yj);
      adj_lists[i].push_back(make_pair(j, w));
      adj_lists[j].push_back(make_pair(i, w));
    }
  }
  // for (int i = 0; i < N + 2; i++) {
  //   printf("i = %d:", i);
  //   for (pair<int, double> p : adj_lists[i]) {
  //     const int j = p.first;
  //     const double w = p.second;
  //     printf(" (%d, %lf)", j, w);
  //   }
  //   printf("\n");
  // }

  // calculate shortest path from node N
  vector<double> ds(N + 2, 0.0);
  dijkstra(adj_lists, N, ds);
  printf("%.12lf\n", ds[N + 1]);

  return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    string c;
    cin >> c;
    ll l = 0;
    ll r = n-1;
    ll ans = 0;
    while(l < r){
        if(c.at(l) == 'W' && c.at(r) == 'R'){
            c.at(l) = 'R';
            c.at(r) = 'W';
            ++ans;
            ++l;    --r;
        }else if(c.at(l) == 'W' && c.at(r) == 'W'){
            --r;
        }else if(c.at(l) == 'R' && c.at(r) == 'W'){
            ++l;    --r;
        }else if(c.at(l) == 'R' && c.at(r) == 'R'){
            ++l;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3756
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(long long int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  long long int n,x;
  cin>>n>>x;
  vector<long long int> v(n),w(n);
  
  rep(i,n){
    cin>>v[i];
    w[i]=abs(x-v[i]);
  }
  long long int ans=w[0];
  rep(i,n){
    ans=GCD(ans,w[i]);
  }
  cout<<ans<<endl;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N; cin >> N;
	vll arr (N);
	F0R(i, N) cin >> arr[i];

	ll ans = arr[0] - 1;
	ll min = 1;
	FOR(i, 1, N) {
		if (arr[i] <= min) continue;
		if (arr[i] == min + 1) {
			min++;
		} else {
			ans += (arr[i] - 1) / (min + 1);
		}
	}
	print(ans);
}

Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    int n, a;
    vector<int> v;
    int avg = 0;
    int sum = 0;
    
    
    int i;
    cin >> n;
    
    for(i = 0; i < n; i++){
        cin >> a;
        avg += a;
        v.push_back(a);
    }
    
    if(avg%n == 0){
        avg /= n;
        for(i = 0; i < n; i++){
            sum += (avg - v[i]) * (avg - v[i]);
        }
        cout << sum << endl;
    }else{
        int sum2 = 0;
        avg /= n;
        for(i = 0; i < n; i++){
            sum += (avg - v[i]) * (avg - v[i]);
        }
        for(i = 0; i < n; i++){
            sum2 += (avg + 1 - v[i]) * (avg + 1 - v[i]);
        }
        
        cout << min(sum, sum2) << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> h(n), opt(n);
    cin >> h;
    for(int i = n - 1; i >= 0; i--) {
        if(i == n - 1) {
            opt[i] = 0;
        } else {
            opt[i] = lim<int>::max();
            for(int j = 1; j <= k and i + j < n; j++) {
                opt[i] = min(opt[i], opt[i + j] + abs(h[i] - h[i + j]));
            }
        }
    }
    cout << opt[0] << endl;
    return 0;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;

    int ans=0;


    vector <string> s(n);
    map <string,int> mp;
    loop(i,0,n)
    cin>>s[i];

    loop(i,0,n)
    {
        sort(all(s[i]));
        mp[s[i]]++;
    }

    for(auto p:mp)
    {
        ans+=((p.se*(p.se-1))/2);
    }

    cout<<ans;


    return 0;
}


Measured memory_bytes: 14264
h,w=map(int,input().split())
list1=[[0 for i in range(w)]for j in range(h)]
list2=[[0 for i in range(w)]for j in range(h)]
dx=[-1,1,0,0]
dy=[0,0,-1,1]
a=0
for j in range(h):
 s=input()
 for i in range(w):
  list1[j][i]=s[i]
for j in range(h):
  for i in range(w):
   if list1[j][i]=="#":
    for k in range(4):
     xk=i+dx[k]
     yk=j+dy[k]
     if xk>=0 and xk<w and yk>=0 and yk<h:
      list2[yk][xk]+=1
for j in range(h):
  for i in range(w):
    if list1[j][i]=="#" and list2[j][i]==0:
     None
    else:
     a+=1
if a==h*w:
 print("Yes")
else:
 print("No")

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CCleaning {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    vector<vector<int>> G;
    vector<int> A;

    int dfs(int v, int p) {
        if (G[v].size() == 1 && p != -1) {
            return A[v];
        }

        int edges = 0;
        int maxe = -1;
        REP(i, G[v].size()) {
            int c = G[v][i];
            if (c == p) continue;
            int e = dfs(c, v);
            if (e == -1)
                return -1;
            edges += e;
            maxe = max(maxe, e);
        }

        int r = 2 * A[v] - edges;
        if (r < 0) {
            return -1;
        }

        maxe = max(maxe, r);
        if (maxe > A[v]) {
            return -1;
        }

        return r;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        A.resize(N);
        G.resize(N);
        REP(i, N) cin >> A[i];
        REP(i, N - 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }

        if (N == 2) {
            if (A[0] == A[1]) {
                cout << "YES" << endl;
            } else {
                cout << "NO" << endl;
            }
            return;
        }

        int root = 0;
        while (G[root].size() == 1) root++;

        int res = dfs(root, -1);
        if (res == 0) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CCleaning solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 10496
// Can U hack it?

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1e5+10,inf=2e9;

pii a[maxn],b[maxn];
bitset<maxn>is1,is2;
vector<pii>canda,canb;
vector<pii>MX1,MX2,MN1,MN2;

int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++)
	cin>>a[i].F>>b[i].F,a[i].S=i,b[i].S=i;
    sort(a,a+n);
    sort(b,b+n);
    int pos=-1;
    ll ans=0;
    for(int i=0;i<n;i++){
	if(a[i].F<=b[n-1-i].F){
	    is1[a[i].S]=1;
	    is2[b[n-1-i].S]=1;
	    pos=i;
	    ans+=a[i].F;
	    MX1.PB(a[i]);
	    MN2.PB(b[n-1-i]);
	}
	else{
	    MX2.PB(b[n-1-i]);
	    MN1.PB(a[i]);
	    ans+=b[n-1-i].F;
	}
    }
    sort(MX1.begin(),MX1.end(),greater<pii>());
    sort(MX2.begin(),MX2.end(),greater<pii>());
    sort(MN1.begin(),MN1.end());
    sort(MN2.begin(),MN2.end());
    while(sz(MX1)>3) MX1.pop_back();
    while(sz(MX2)>3) MX2.pop_back();
    while(sz(MN1)>3) MN1.pop_back();
    while(sz(MN2)>3) MN2.pop_back();
    if(is1==is2 && pos!=-1 && pos!=n-1){
	int delta=inf;
	if(pos==0 || pos==n-2)
	    delta=min(MN1[0].F,MN2[0].F)-max(MX1[0].F,MX2[0].F);
	else
	    for(auto x:MX1)
		for(auto y:MX2)
		    for(auto z:MN1)
			for(auto w:MN2)
			    if(x.S!=w.S && y.S!=z.S)
				delta=min(delta,-max(x.F,y.F)+min(z.F,w.F));
	ans+=delta;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3828
#include<stdio.h>
#include<math.h>
int main()
{
	double h,i,j;
	double w;
	scanf("%lf%lf",&h,&w);
	if(h==1||w==1)
	{
		printf("1");
		return 0;
	}
	i=floor((h+1)/2);
	j=floor(h/2);
	if(w/2!=floor(w/2))
	printf("%.0lf",floor(w/2)*(i+j)+i);
	else
	printf("%.0lf",w/2*(i+j));
	return 0;
}

Measured memory_bytes: 128
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

ll n, m;

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> n >> m;
	ll r = min(n * 2, m);
	m -= r;
	n = min(n, r / 2);
//	cout << m << " " << r << endl;
	n += m / 4;

	cout << n;
}


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

using namespace std;
 
int main(){
	int N, K;
	char chara;
    cin >> N >> K;
	for(int i = 0;i < N;i++){
		cin >> chara;
		if(i != K - 1){
			cout << chara;
		}else{
			if(chara == 'A'){
				cout << 'a';
			}else if(chara == 'B'){
				cout << 'b';
			}else{
				cout << 'c';
			}
		}
	}
}

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

int main(){
int N,A[100];
cin >> N;
for (int i = 0;i<N;i++){
  cin >> A[i];
}
int memo = 0;
for(int i = 0;i<N;i++) {
  for(int j = 0;j<N;j++) {
    if (A[i] < A[j]){
      memo = A[i];
      A[i] = A[j];
      A[j] = memo;
    }
  }
}
cout << A[N-1] - A[0] << endl;

}


Measured memory_bytes: 256