akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            int year = int.Parse(S.Substring(0,4));
            int month = int.Parse(S.Substring(5,2));
            int day = int.Parse(S.Substring(8,2));
            var datetime1 = new DateTime(2019,4,30,0,0,0);
            var datetime2 = new DateTime(year,month,day,0,0,0);
            Console.WriteLine(datetime1>=datetime2?"Heisei":"TBD");


        }
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 27572
def checkACGT(s):
    for i in range(len(s)):
        if s[i] == "A" or s[i] == "G" or s[i] == "C" or s[i] == "T":
            continue
        else:
            return False
    return True
  
s=input()
n = len(s)
check = []
check.append(s)
while True:
    if not check:
        print(0)
        break
    if checkACGT(check[0]):
        print(len(check[0]))
        break
    else:
        if len(check[0]) == 1:
            check.pop(0)
            continue
        check.append(check[0][1:])
        check.append(check[0][:len(check[0])-1])
        check.pop(0)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
static unsigned int inf = 1e9+7;
static int bn = 1e5;
void swap(int *a, int *b)
{
    int tmp = *a;
    *a = *b;
    *b = tmp;
}
void quicksort(int *data, int n, int low, int high)
{
    if(low < high){
        int mid = (low + high) / 2;
        int x = data[mid];
        int i = low;
        int j = high;
        while(i <= j){
            while(data[i] < x) i++;
            while(data[j] > x) j--;
            if(i <= j) swap(&data[i++], &data[j--]);
        }
        quicksort(data, n, low, j);
        quicksort(data, n, i, high);
    }
}
int main(){
    int n = 0;
    cin >> n;
    int d[bn];
    for(int i = 0;i < n;i++){
        cin >> d[i];
    }
    quicksort(d, n, 0, n-1);
    int low = d[n/2-1];
    int high = d[n/2];
    cout << high-low << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;



long long i,j,k,X,Y,A,B,C,ans,a,b,c,u,v,w;

vector<long long> p,q,r;

int main()
{
  cin>>X>>Y>>A>>B>>C;
  for(i=0;i<A;i++)
  {
    cin>>j;
    p.push_back(j);
  }
  for(i=0;i<B;i++)
  {
    cin>>j;
    q.push_back(j);
  }
  for(i=0;i<C;i++)
  {
    cin>>j;
    r.push_back(j);
  }
  
  sort(p.begin(),p.end(),greater<long long>());
  sort(q.begin(),q.end(),greater<long long>());
  sort(r.begin(),r.end(),greater<long long>());
  
  
  ans=0;
  for(i=0;i<X;i++)
  {
    ans+=p[i];
  }
  for(i=0;i<Y;i++)
  {
    ans+=q[i];
  }
  
  a=X-1;
  b=Y-1;
  for(c=0;c<C;c++)
  {
    if(a<0)
    {
      if(b<0)
      {
        break;
      }
      else if(r[c]>q[b])
      {
        ans+=r[c]-q[b];
        b--;
      
      }
      else
      {
        break;
      }
    }
    else if(b<0)
    {
      if(r[c]>p[a])
      {
        ans+=r[c]-p[a];
        a--;
      
      }
      else
      {
        break;
      }
    }
    else if(p[a]>q[b])
    {
      if(r[c]>q[b])
      {
        ans+=r[c]-q[b];
        b--;
      
      }
      else
      {
        break;
      }
    }
    else
    {
      if(r[c]>p[a])
      {
        ans+=r[c]-p[a];
        a--;
      
      }
      else
      {
        break;
      }
    }
    
    
  }
  
  
  cout <<ans;
}

Measured memory_bytes: 3316
import numpy as np
if __name__ == "__main__":
    N = int(input())
    line = input().rstrip().split(' ')
    line = np.array(line).astype("int")
    ans = 0
    while not (line <= 0).any():
        #print((line % 2).sum())
        if (line % 2).sum() == 0:
            ans += 1
            line = line / 2
        else:
            break
    print(ans)

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

int main() {
    int N;
    long long sum=0;
    cin >> N;
    for (int i=0; i<N+1; i++){
        if ( i%3 == 0 ){
            continue;
        }
        if ( i%5 == 0 ){
            continue;
        }
        sum = sum+i;
    }
    cout << sum;
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pll;
const int LOG = 60;

ll l, r;

ll hi_bit(ll x) {
	for (int i = LOG; ~i; i--)
		if (x >> i & 1)
			return i;
}

ll f(ll l, ll r) { // []
	if (l == r)
		return 1;
	for (int i = LOG; ~i; i--)
		if ((l ^ r) >> i & 1)
			break;
		else if (l >> i & 1) {
			l ^= 1LL << i;
			r ^= 1LL << i;
		}
	
	
	ll a = hi_bit(l), b = hi_bit(r);
	ll c = (__builtin_popcountll(r) == 1? 0: 1 + hi_bit(r ^ (1LL << b)));
	//cerr << a << ' ' << b << ' ' << c << '\n';
	return (((1LL << b) - l) + (1LL << c) + ((1LL << b) - max((1LL << c), l)));
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> l >> r;
	cout << f(l, r) << '\n';
}


Measured memory_bytes: 256
import sys
import numpy as np
from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    T = M - 2 * N
    if T < 0:
        scc_num = int(M/2)
    else:
        scc_num = N + int(T/4)

    print scc_num

if __name__ == '__main__':
    main()


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  int ans = 0;
  vector<bool> exists(1'000'000'000 + 5, false);
  rep(i, n) {
    int a; std::cin >> a;
    if (exists[a] == false) ans++, exists[a] = true;
    else ans--, exists[a] = false;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 122368
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int d[] = new int[N];
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for(int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
			map.put(d[i], 1);
		}
		System.out.println(map.size());
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h> 
using namespace std;
int main()
{
	long long n,d,dt,ans=1;
	cin>>n>>d;
	dt=d*2+1;
	while (dt<n)
	{
		dt+=d*2+1;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

void input(vector<int>& rvnMonstr, vector<int>& rvnBrave)
{
  int nMonstrSiz;
  cin >> nMonstrSiz;
  rvnMonstr.resize(nMonstrSiz + 1);
  rvnBrave.resize(nMonstrSiz);

  for (int& rnMonstr : rvnMonstr)
    cin >> rnMonstr;

  for (int& rnBrave : rvnBrave)
    cin >> rnBrave;
}
  
llong calcStrikMonstr(vector<int>& rvnMonstr, vector<int>& rvnBrave)
{
  llong nSumStrikMon = 0;

  for (int nBgn = 0; nBgn < rvnBrave.size(); ++nBgn)
    for (int nFwd = nBgn; nFwd < nBgn + 2; ++nFwd)
    {
      int nStrikMonstr = min(rvnBrave[nBgn], rvnMonstr[nFwd]);

      rvnMonstr[nFwd] -= nStrikMonstr;
      rvnBrave[nBgn]  -= nStrikMonstr;
      nSumStrikMon += nStrikMonstr;
    }

  return nSumStrikMon;
}
  
int main()
{
  vector<int> vnMonstr, vnBrave;

  input(vnMonstr, vnBrave);
  cout << calcStrikMonstr(vnMonstr, vnBrave) << endl;

  return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////





int main() {

	ll N, ma, mb;
	cin >> N >> ma >> mb;

	ll dp[41][500][500];
	rep(i, 41)rep(j, 500)rep(k, 500) { dp[i][j][k] = INF; }

	dp[0][0][0] = 0;

	repn(i, N) {

		ll a, b, c;
		cin >> a >> b >> c;
		rep(j, 500)rep(k, 500) {
			if (j >= a && k >= b) {
				dp[i][j][k] = min(dp[i - 1][j][k], dp[i - 1][j - a][k - b] + c);
			}

			else { dp[i][j][k] = dp[i - 1][j][k]; }
		}
	}

	ll ans = INF;
	for (int i = 1; i*ma < 500 && i*mb < 500; i++) {
		ans = min(ans, dp[N][i*ma][i*mb]);
	}

	if (ans == INF) { cout << -1; }
	else { cout << ans; }


	system("PAUSE");
}

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

int main(){
	int n,a;
  	cin >> n;
  	int count=0;
  	for(int i = 0; i <n; i++) {
      	cin >> a;
      	if(a%2!=0)
          	count++;
	}
  	
  	cout << (count%2==0?"YES":"NO") <<endl;
}


Measured memory_bytes: 384
from collections import deque

if __name__ == '__main__':
    l = deque()
    n = int(input())
    for _ in range(n):
        m = input().split()
        if m[0] == 'insert':
            l.appendleft(m[1])
        elif m[0] == 'delete':
            try:
                l.remove(m[1])
            except:
                pass
        elif m[0] == 'deleteFirst':
            l.popleft()
        elif m[0] == 'deleteLast':
            l.pop()
    print(' '.join(map(str, l)))



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

int main() {
	string S;
	cin >> S;
	int ans = 700;
	for (int i = 0; i < S.size(); i++) {

		if (S[i] == 'o') {
			ans += 100;
		}
	}
	cout << ans << endl;
}

// または [デバッグ] > [デバ

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <vector>

#define PI (3.14159265358979323846)
#define INF (1e+9)
#define DV_NUM (100000007)

using namespace std;
 
int main()
{
    int K,S;
    cin >> K >> S;

    int count=0;

for(int x = 0; x<=K; x++){
    for(int y = 0; y<=K; y++){

    int z = S - x - y;

       if ( z >= 0 && z <= K ) {
        count++;
       }
    }
}

    cout << count << endl;
 
    return 0;
 
}

Measured memory_bytes: 256
mod=1000000007
def kai(n):
    a=1
    for i in range(1,n+1):
        a*=i
        a%=mod
    return a%mod
n,m=map(int,input().split())
if abs(n-m)==1:
    print(kai(n)*kai(m)%mod)
elif abs(n-m)==0:
    print(2*kai(n)*kai(m)%mod)
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const int sz=2e5+100;
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    int t,cs;
    cin>>a>>b;
    if(a<=b*2)  cout<<"0"<<endl;
    else cout<<a-(b*2)<<endl;


}


Measured memory_bytes: 256
//
// Created by 倉澤　一詩 on 2020/04/03.
//
#include <iostream>
#include <string>


int main(){

    std::string s;
    std::getline(std::cin, s);

//    uint64_t index = s.length();

    uint64_t i = 0;
    while (0 < s.length()) {

        if (s.substr(s.length()-5) == "dream"){
            for (int j = 0; j < 5; ++j) {
                s.pop_back();
            }
            i += 5;

        } else if (s.substr(s.length()-5) == "erase"){
            for (int j = 0; j < 5; ++j) {
                s.pop_back();
            }
            i += 5;

        } else if (s.substr(s.length()-6) == "eraser"){
            for (int j = 0; j < 6; ++j) {
                s.pop_back();
            }
            i += 6;

        } else if (s.substr(s.length()-7) == "dreamer"){
            for (int j = 0; j < 7; ++j) {
                s.pop_back();
            }
            i += 7;

        } else {

            std::cout << "NO";
            return 0;
        }

    }

    std::cout << "YES";

    return 0;
}


Measured memory_bytes: 512
# ABC79 D - Wall
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

def f_warshall(C):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

f_warshall(C)

cost = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == -1:
            continue
        else:
            cost += C[A[i][j]][1]

print(int(cost))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int main()
{
    string a,b,c;
    int n,ans=0;
    scanf("%d",&n);
    cin>>a>>b>>c;
    for(int i=0;i<n;i++)
    {
        if(a[i]!=b[i]&&b[i]!=c[i]&&a[i]!=c[i]) ans+=2;
        else if(a[i]==b[i]&&b[i]==c[i]) ans+=0;
        else ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
typedef  long long ll;
using namespace std;

int main(void) {
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i < H; i++)
	{
		cin >> S.at(i);
	}

	//相対位置
	const int dx[8] = {1, 0 ,-1 ,0, 1 , -1 , -1, 1};
	const int dy[8] = {0, 1 ,0 ,-1 , 1 , 1 , -1, -1};

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (S.at(i)[j] == '#') continue;
			
			int num = 0;
			for (int k = 0; k < 8; k++)
			{
				int xi = j + dx[k];
				int yi = i + dy[k];

				if (yi < 0 || H <= yi) continue; 
				if (xi < 0 || W <= xi) continue;
				if (S.at(yi)[xi] == '#') num++;
			}
			S.at(i)[j] = char(num + '0');
		}
	}

	for (int i = 0; i < H; i++)
	{
		cout << S.at(i) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int num,tNum,digit=2,cnt;
    int rem;
    scanf("%d",&num);


    cnt=0;
    tNum=num;

    while(tNum>0)
    {
        rem=tNum%10;
        if(rem==digit)
            cnt++;
        tNum/=10;
    }

    printf("%d",cnt);

    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	char a;
	cin >> a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
	{
		cout << "vowel" <<endl;
	}
	else
	{
		cout << "consonant" <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	scanf("%d", &a);
    d = a % 10;
    c = ((a - d) % 100) / 10;
    b = ((a - d - c * 10) % 1000) / 100;
    a = (a - d - c * 10 - b * 100) / 1000;

	if(a+b+c+d == 7) 
		printf("%d+%d+%d+%d=7", a, b, c, d);	
	else if(a+b+c-d == 7)
		printf("%d+%d+%d-%d=7", a, b, c, d);
	else if(a+b-c+d == 7)
		printf("%d+%d-%d+%d=7", a, b, c, d);
	else if(a-b+c+d == 7)
		printf("%d-%d+%d+%d=7", a, b, c, d);
	else if(a-b-c-d == 7)
		printf("%d-%d-%d-%d=7", a, b, c, d);
	else if(a+b-c-d == 7)
		printf("%d+%d-%d-%d=7", a, b, c, d);
	else if(a-b+c-d == 7)
		printf("%d-%d+%d-%d=7", a, b, c, d);
	else if(a-b-c+d == 7)
		printf("%d-%d-%d+%d=7", a, b, c, d);

	return 0;
}

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

using namespace std;

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

    vector <int> v;
    vector <int>::iterator it;

    double n;
    cin>>n;

    for(int i=1;i<=n;i++)
    {
        v.push_back(i);
    }

    double c=0;

    for(it=v.begin();it!=v.end();it++)
    {
        if((*it)%2!=0)
        {
            c++;
        }
    }

    double x;
    x=c/n;

    cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<string>vec(N);
	map<string, ll>mp;
	rep(i, 0, N) {
		cin >> vec[i];
		sort(all(vec[i]));
		mp[vec[i]]++;
	}
	ll ans = 0;
	for (auto p : mp) {
		ans += (p.second * (p.second - 1)) / 2;
	}
	cout << ans << "\n";

	return 0;
}

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

int main()
{
  int K;cin>>K;
  int odd,even;
  
  if (K%2 == 0)
  {
    odd = K/2;
    even = K/2; 
  }
  else 
  {
    odd = K/2 +1;
    even = K/2;
  }
  cout<< odd * even <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
Mau chot là, neu ban ue oai, luoi nhác hôm nay, ban se không bat chat tro nên tràn day nang luong vào tuân sau,
tháng sau, nam sau hay sau nua, tru phi ban bat tay làm gì dó
*/
using namespace std;

typedef long long ll ;

const ll ts = 100005;

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

int n , a[ts] , b[ts]  , ans = 1e9   ,ansa = 1e9 , ansb = 1e9 , A , B  , M ;

void init() {
    cin >> A >> B >> M ; 
    for(int i = 1;i <= A; i++) {
    	cin >> a[i];
    	ansa = min(ansa , a[i]);
	}
	for(int i = 1; i <= B; i++) {
		cin >> b[i]; 
		ansb = min(ansb , b[i]);
	}
	for(int i = 1; i <= M ; i++) {
		int x  , y , c; 
		cin >> x >> y >> c; 
		ans = min(ans  , a[x] + b[y] - c);
	}
	ans = min(ans , ansa + ansb);
}
signed main() {
	IOS;
	init();
    cout << ans; 

}










Measured memory_bytes: 1024
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;



 class Main {

   public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

   static class FastReader {

     BufferedReader br;
     StringTokenizer st;

     public FastReader() {
       br = new BufferedReader(new
           InputStreamReader(System.in));
     }

     String next() {
       while (st == null || !st.hasMoreElements()) {
         try {
           st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
       return st.nextToken();
     }

     int nextInt() {
       return Integer.parseInt(next());
     }

     long nextLong() {
       return Long.parseLong(next());
     }

     double nextDouble() {
       return Double.parseDouble(next());
     }

     String[] nextSArray() {
       String sr[] = null;
       try {
         sr = br.readLine().trim().split(" ");
       } catch (IOException e) {
         e.printStackTrace();
       }
       return sr;
     }

     String nextLine() {
       String str = "";
       try {
         str = br.readLine();
       } catch (IOException e) {
         e.printStackTrace();
       }

       return str;
     }
   }

   //  static int MOD=1000000000+7;
//  public static void sortbyCol(int arr[][],int col)
//  {
//    Arrays.sort(arr,new Comparator<int[]>(){
//      @Override
//      public int compare(int[] o1, int[] o2) {
//        // To sort in descending order revert
//        // the '>' Operator
//        if(o1[col]>o2[col])
//          return 1;
//        else
//          return -1;
//      }
//    });
//  }
   static int countbits(int a) {
     if (a == 0)
       return 0;
     return (int) (Math.log(a) / Math.log(2) + 1);
   }

   static int reversebits(int n, int pos) {
     while (pos > 0) {
       if ((n & pos) > 0) {
         n -= pos;
       } else
         n += pos;
       pos = pos >> 1;
     }
     return n;
   }

   public static void main(String[] args) throws java.lang.Exception {
     FastReader sc = new FastReader();
//   int t1=sc.nextInt();
//
//   for(int t=0;t<t1;++t)
//   {
//
//   }
      int n=sc.nextInt();
      long total=0;
      long arr[]=new long[n];
      for(int i=0;i<n;++i)
      {
        arr[i]=sc.nextLong();
        total=total^arr[i];
      }
     for(int i=0;i<n;++i)
     {
       out.print((total^arr[i])+" ");
     }
     out.flush();
     out.close();


   }
 }



// out.println(al.toString().replaceAll("[\\[|\\]|,]",""));


Measured memory_bytes: 57452
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int a, b, m;
    cin >> a >> b >> m;

    vector<int> c(a), d(b);
    for (int i = 0; i < a; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> d[i];
    }
    
    int r = 1 << 30;
    for (int i = 0; i < m; i++) {
        int x, y, e;
        cin >> x >> y >> e;
        x--; y--;

        r = min(r, c[x] + d[y] - e);
    }

    sort(c.begin(), c.end());
    sort(d.begin(), d.end());

    r = min(r, c[0] + d[0]);

    cout << r << endl;

    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Vertex {
    vector<pll> node;
};
ll N, M;
Vertex V[100005];
bool U[100005];

bool solve() {
    ll mx = 0;
    REP(i, N) {
        if (V[i].node.size() % 2 == 1)
            return false;
        mx = std::max(static_cast<ll>(V[i].node.size()), mx);
    }

    if (mx == 2)
        return false;
    if (mx >= 6)
        return true;

    vector<ll> v;
    REP(i, N) {
        if (V[i].node.size() == 4)
            v.push_back(i);
    }

    if (v.size() > 2)
        return true;
    if (v.size() == 1)
        return false;

    REP(i, V[v[0]].node.size()) {
        if (V[v[0]].node[i].first == v[0])
            return true;

        queue<ll> q;
        memset(U, 0, sizeof(U));
        q.push(V[v[0]].node[i].first);
        U[V[v[0]].node[i].second] = true;
        while (!q.empty()) {
            ll t = q.front();
            q.pop();
            for (auto &n : V[t].node) {
                if (U[n.second])
                    continue;
                if (n.first == v[1])
                    continue;
                if (n.first == v[0])
                    return true;
                U[n.second] = true;
                q.push(n.first);
            }
        }
    }

    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.emplace_back(pll(b, i));
        V[b].node.emplace_back(pll(a, i));
    }

    if (solve())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

Measured memory_bytes: 1156
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N;
	string S;
	cin >> N >> S;
	int mx = -1;
	for (int i = 1; i <= N - 1; i++) {
		string X, Y;
		int cnt = 0;
		for (int j = 0; j < i; j++)X.push_back(S[j]);
		for (int j = i; j < N; j++)Y.push_back(S[j]);
		for (int j = 0; j < 26; j++) {
			bool can_X = false;
			bool can_Y = false;
			char ch = 'a' + j;
			for (int k = 0; k < X.size(); k++)if (X[k] == ch)can_X = true;
			for (int k = 0; k < Y.size(); k++)if (Y[k] == ch)can_Y = true;
			if (can_X && can_Y)cnt++;
		}
		mx = max(mx, cnt);
	}
	cout << mx;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;
const double EPS = 1e-8;

int n, m;
map<int, int> mp[200010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        mp[a][b] = 1;
        mp[b][a] = 1;
    }
    rep(i, 1, n - 1){
        if(mp[0][i] && mp[i][n - 1]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

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

int main(void) {
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

ll dp[256];
int n;
char buf[25];

int main() {
	scanf("%d\n", &n);
	while(n--) {
		scanf("%s", buf);
		dp[buf[0]]++;
	}
	ll ret = 0;
	ret += dp['A']*dp['C']*dp['H'];
	ret += dp['A']*dp['C']*dp['M'];
	ret += dp['A']*dp['C']*dp['R'];
	ret += dp['A']*dp['H']*dp['M'];
	ret += dp['A']*dp['H']*dp['R'];
	ret += dp['A']*dp['M']*dp['R'];
	ret += dp['C']*dp['H']*dp['M'];
	ret += dp['C']*dp['H']*dp['R'];
	ret += dp['C']*dp['M']*dp['R'];
	ret += dp['H']*dp['M']*dp['R'];
	printf("%lld\n", ret);
}

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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

int add(int i, int j) {
    if((i += j) >= mod) i -= mod;
    return i;
}

int A[2000];
int B[2000];
int dp[2000][2000];
int rp[2000][2000];
int n, m;

int f(int, int);
int d(int i, int j) {
    if(i >= n || j >= m) return 0;
    if(rp[i][j] > -1) return rp[i][j];
    return rp[i][j] = add(d(i, j + 1), (A[i] == B[j] ? f(i + 1, j + 1) : 0));
}

int f(int i, int j) {
    if(i >= n || j >= m) return 1;
    if(dp[i][j] > -1) return dp[i][j];
    int mx = f(i + 1, j);
    mx = add(mx, d(i, j));
    return dp[i][j] = mx;
}

int main() {
    cin >> n >> m;
    for(int i = 0; i < n; ++i)
        cin >> A[i];
    for(int i = 0; i < m; ++i)
        cin >> B[i];
    
    memset(rp, -1, sizeof rp);
    memset(dp, -1, sizeof dp);
    cout << f(0, 0);
    
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

struct sliding_minimum {
	vector<ll> solve(const vector<ll>& values, int k) {
		deque<int> d;
		vector<ll> r;
		int n = values.size();
		rep(i, n) {
			while (!d.empty() && values[d.back()] >= values[i]) {
				d.pop_back();
			}
			d.push_back(i);
			if (i - k + 1 >= 0) {
				r.push_back(values[d.front()]);
				if (d.front() == i - k + 1) d.pop_front();
			}
		}
		return r;
	}
};


int main(void)
{
	ll n,l;
	cin >> n >> l;
	vector<ll> vs(n);
	rep(i, n) {
		cin >> vs[i];
	}
	sliding_minimum s;
	auto r = s.solve(vs, l);
	for (int i = 0; i < r.size();i++) {
		cout << r[i];
		if (i != r.size() - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	return 0;
}




Measured memory_bytes: 19032
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  int s;
  int m[1000000];
  int count=1;

  cin >> s;

  int a = s;
  m[a]++;
  while (true)
  {
    count++;
    if (a%2==0)
    {
      a=a/2;
    }else
    {
      a=3*a+1;
    }
    if (m[a]==0)
    {
      m[a]++;
    }else
    {
      break;
    }
  }
  cout << count << "\n";

  return 0;
}

Measured memory_bytes: 2304
ABCD = input()

for i in range(2 ** 3):
    s = ABCD[0]
    for j in range(3):
        s += ['-', '+'][(i >> j) & 1] + ABCD[j+1]
    x = eval(s)
    if x == 7:
        print(s+'=7')
        break
    continue

Measured memory_bytes: 3060
import math

N = int(input())
P = []
for n in range(N):
  x,y = map(int,input().split())
  P.append((x,y))
  
ans = 0

for xs,ys in P:
  for x,y in P:
    ans += math.sqrt((xs-x)**2+(ys-y)**2)
  
print(ans/N)

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

int main(){
  cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;++i){
        cin >> vec.at(i);
    }
    
    int a=vec.at(0);
    int b=vec.at(0);
    long long c=vec.at(0);
    
    for(int i=1;i<n;++i){
        a=min(a,vec.at(i));
        b=max(b,vec.at(i));
        c += vec.at(i);
    }
    cout << a << " " << b << " " << c << endl;

}



Measured memory_bytes: 3124
#include<stdio.h>
#include<stdlib.h>


int cntnumID(int* l, int* r, int n, int m){
    int count = 0;
    int maxl = 0;
    for(int i=0; i<m; i++){
        if(l[i]>maxl){
            maxl = l[i];
        }
    }
    int minr = n;
    for(int i=0; i<m; i++){
        if(r[i]<minr){
            minr = r[i];
        }
    }
    if((minr-maxl)<0){
        //
    }else{
        count = minr - maxl + 1;
    }
    return count;
}

int main(){
    int n, m, ans;
    
    scanf("%d %d", &n, &m);
    int* l;
    int* r;
    l = (int*)malloc(sizeof(int)*m);
    r = (int*)malloc(sizeof(int)*m);

    for(int i=0; i<m; i++){
        scanf("%d %d", &l[i], &r[i]);
    }
    ans = cntnumID(l, r, n, m);
    printf("%d\n", ans);
    return 0;
}
        



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

using namespace std;
typedef long long ll;

#define ZERO_IQ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x, y) cerr<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define debug2(x, y, z) cerr<<(#x)<<" " <<(#y)<<" " <<(#z)<<" is " << (x) <<" "<< (y) <<" "<<(z) << endl
#define watch(x) cerr<<(#x)<<" is " << (x) << endl

const int N = 2e5 + 10;
typedef long long ll;

ll dp[N];

int main() {
    ll n;
    cin >> n;
    vector<ll> v;
    vector<ll> summ(n + 1);
    for (int i = 1; i <= n; i++) {
        ll q;
        cin >> q;
        v.push_back(q);
        if (i % 2 == 1) {
            if (i == 1)summ[i] = q;
            else
                summ[i] = summ[i - 2] + q;
        }
    }
    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (i % 2 == 1) {
            dp[i] = max(dp[i - 2] + v[i - 1], dp[i - 1]);
        } else
            dp[i] = max(dp[i - 2] + v[i - 1], summ[i-1]);
    }
    cout << dp[n];
    return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int n;
    cin >> n;

    string a, b, c;
    cin >> a >> b >> c;

    int cnt = 0;
    for(int i = 0; i < n; ++i){
        set<char> st;
        st.insert(a[i]);
        st.insert(b[i]);
        st.insert(c[i]);
        cnt += st.size()-1;
    }

    ppp(cnt);



    return 0;
}


Measured memory_bytes: 256
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int dp[3][100001] = {};
	int score[256] = {};
	int n, k, r, s, p, ans = 0;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	score['r'] = p;
	score['s'] = r;
	score['p'] = s;
	for (int i = 0; i < n; ++i) {
		if (i >= k && t[i] == t[i - k]) {
			t[i] = 0;
		} else {
			ans += score[t[i]];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll l,r,ans;cin>>l>>r;
  if(r-l>=2018) ans=0;
  else {
    ans=1e9;
    for(ll i=l;i<r;++i)for(ll j=i+1;j<=r;++j) ans=min(ans,(i*j)%2019);
  }
  print(ans);
  return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, k)
    {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <ctype.h>

int main(void) {
	char sikibetushi[200];
	char kisoku[2];
	char* sbp;
	while(1) {
		scanf("%s%s",sikibetushi,kisoku);
		if(kisoku[0]=='X')break;
		if(kisoku[0]=='U') {
			putchar(toupper(sikibetushi[0]));
		} else {
			putchar(tolower(sikibetushi[0]));
		}
		for(sbp=sikibetushi+1;*sbp!=0;sbp++) {
			if(isupper(*sbp)) {
				if(kisoku[0]=='D') {
					putchar('_');
					putchar(tolower(*sbp));
				} else putchar(toupper(*sbp));
			} else if(*sbp=='_') {
				*sbp++;
				if(*sbp==0)break;
				if(kisoku[0]=='D') {
					putchar('_');
					putchar(tolower(*sbp));
				} else putchar(toupper(*sbp));
			} else putchar(*sbp);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 0
package main

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

func main() {
	s, t := readS(), readS()
	a, b := readI(), readI()
	u := readS()
	if s == u {
		fmt.Println(a-1, b)
	} else {
		fmt.Println(a, b-1)
	}
	t = t + t
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

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


Measured memory_bytes: 1780
import java.util.*;
public class Main{

public static void main(String[] args){
Scanner obj=new Scanner(System.in);
int a=obj.nextInt();
int b=obj.nextInt();
int out=1;
int ans=0;

while(out<b){
out--;
out=out+a;
ans++;

}

System.out.println(ans);


}



}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
const ll max_n = 2e5+5;

int main() {
    // your code goes here
    ll n, d, a, x[max_n], h[max_n];
    ll j, l[max_n], sum[max_n], ans = 0;
    vector<pair<ll, ll> > vp;
    vector<ll> v;
    cin >> n >> d >> a;
    rep(i,0,n-1) {
        cin >> x[i] >> h[i];
        h[i] = (h[i] - 1) / a + 1;
        vp.push_back({x[i], h[i]});
        v.push_back(x[i]);
    }
    sort(vp.begin(), vp.end());
    sort(v.begin(), v.end());
    rep(i,0,n-1) {
        x[i+1] = vp[i].first;
        h[i+1] = vp[i].second;
    }
    rep(i,1,n) {
        auto it = upper_bound(v.begin(), v.end(), x[i] + 2*d);
        ll memo = it - v.begin();
        for(;j<=memo;j++) l[j] = i;
    }
    sum[0] = 0;
    rep(i,1,n) {
        ll attack = h[i] - min(sum[i-1] - sum[l[i]-1], h[i]);
      	sum[i] = sum[i-1] + attack;
        ans += attack;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13932
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    s='E'+s+'E';
    int N=s.size(),l=1,r=N-2,sumx=0;
    while(l<r){
        int lx=0,rx=0;
        while(s[l]=='x'){lx++,l++;}
        while(s[r]=='x'){rx++,r--;}
        if(s[l]!=s[r]){cout1(-1);return 0;}
        if(l<=r) sumx+=abs(lx-rx);
        l++,r--;
    }
    cout1(sumx);
}

Measured memory_bytes: 512
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [Usize1; n],
        b: [Usize1; n],
    }

    let mut cnt_a = vec![0; n];
    let mut cnt_b = vec![0; n];

    for &x in &a {
        cnt_a[x] += 1;
    }

    for &x in &b {
        cnt_b[x] += 1;
    }

    for i in 0..n {
        if cnt_a[i] + cnt_b[i] > n {
            println!("No");
            return;
        }
    }

    let mut a_r = vec![None; n];
    let mut b_l = vec![None; n];

    for (index, &x) in a.iter().enumerate() {
        a_r[x] = Some(index);
    }

    for (index, &x) in b.iter().enumerate() {
        if b_l[x].is_none() {
            b_l[x] = Some(index);
        }
    }

    let rot = a_r
        .iter()
        .zip(b_l.iter())
        .map(|(&a, &b)| {
            if let Some(r) = a {
                if let Some(l) = b {
                    if r >= l {
                        return r - l + 1;
                    }
                }
            }
            0
        })
        .max()
        .unwrap();

    
    println!("Yes");

    for i in 0..n {
        let d = if i == n - 1 {
            "\n"
        } else {
            " "
        };
        print!("{}{}", b[(i + n - rot) % n] + 1, d);
    }
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, m;
bool now[100000];
int cnt[100000];

int main() {
    cin >> n >> m;
    now[0] = true;
    rep(i,n) cnt[i] = 1;
    rep(i,m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cnt[x]--;
        cnt[y]++;
        if (now[x]) {
            if (cnt[x] == 0) now[x] = false;
            now[y] = true;
        }
    }
    ll out = 0;
    rep(i,n) out += now[i];
    cout << out << endl;
}
































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

 using namespace std;
 int main() {
   string s1, s2, s3;
   cin >> s1 >> s2 >> s3;
   cout << (char)toupper(s1.at(0)) << (char)toupper(s2.at(0)) << (char)toupper(s3.at(0)) << endl;
 }


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

int main(){
  int N;cin>> N;
  double sum=0;
  for(int i=0;i<N;i++){
  int a; cin>>a;
    sum += 1.0/a;
  }
  double ans = 1/sum;
  printf("%.10f\n",ans);
  return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
const int MAX_N = 40;
const int MAX_A = 10 * MAX_N;
const int MAX_B = 10 * MAX_N;
int dp[MAX_N + 1][MAX_A + 1][MAX_B + 1];

signed main() {
    // dp[i+1][a][b] : i番目までのitemでaグラム/bグラムになるための最小コスト
    // i番目のitemを選ばない場合 dp[i+1][a][b] = min(dp[i+1][a][b], dp[i][a][b])
    // i番目のitemを選ぶ場合 dp[i+1][a][b] = min(dp[i+1][a][b], dp[i][a - cost[i]][b - cost[i]])

    int N, ma, mb;
    cin >> N >> ma >> mb;

    int A[N];
    int B[N];
    int C[N];
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i] >> C[i];

    for (int i = 0; i < MAX_N + 1; i++) {
        for (int a = 0; a < MAX_A + 1; a++) {
            for (int b = 0; b < MAX_B + 1; b++) {
                dp[i][a][b] = INF;
            }
        }
    }
    dp[0][0][0] = 0;

    for (int i = 0; i < N; i++) {
        for (int a = 0; a < MAX_A + 1; a++) {
            for (int b = 0; b < MAX_B + 1; b++) {
                dp[i+1][a][b] = min(dp[i+1][a][b], dp[i][a][b]);
                if (a - A[i] >= 0 && b - B[i] >= 0) {
                    dp[i+1][a][b] = min(dp[i+1][a][b], dp[i][a - A[i]][b - B[i]] + C[i]);
                }
            }
        }
    }

    int ret = INF;
    for (int a = 1; a < MAX_A + 1; a++) {
        for (int b = 1; b < MAX_B + 1; b++) {
            if (ma * b == mb * a) {
                ret = min(ret, dp[N][a][b]);
            }
        }
    }

    if (ret == INF) ret = -1;

    cout << ret << endl;
}

Measured memory_bytes: 51712
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

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

    ll res = lcm(A, B);

    cout << res << endl;
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int len = s.size(), cnt = 0;
    for(int i = 0; i < (len+1)/2; i++){
        if(s[i] == 'i' && s[len-1-i] != 'i') cnt++;
        if(s[i] == 'w' && s[len-1-i] != 'w') cnt++;
        if(s[i] == '(' && s[len-1-i] != ')') cnt++;
        if(s[i] == ')' && s[len-1-i] != '(') cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1184