akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  ll M;
  IN(N,M);
  vll WA(N, 0);
  vll AC(N, 0);
  REP(i,M){
    ll p;
    string str;
    IN(p, str);
    p--;
    if(str=="WA"){
      if(AC[p]==0){
        WA[p]++;
      }
    }else{
      AC[p]++;
    }
  }

  ll ans1 = 0;
  REP(i,N){
    if(AC[i]>0) ans1++;
  }
  ll ans2 = 0;
  REP(i,N){
    if(AC[i]>0) ans2+=WA[i];
  }

  printf("%lld %lld\n", ans1, ans2);

  return 0;
}


Measured memory_bytes: 1792
#define N 105
#include <stdio.h>

void showArray(int a[], int n) {
    for (int i = 0; i < n; i++) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", a[i]);
    }
    printf("\n");
}

int SelectionSort(int a[], int n) {
    int sw = 0;
    for (int i = 0; i < n; i++) {
        int minj = i;  //这里记录的是最小值的下标
        for (int j = i + 1; j < n; j++) {
            if (a[j] < a[minj]) {
                minj = j;
            }
        }
        if (minj != i) {
            int tmp = a[i];
            a[i] = a[minj];
            a[minj] = tmp;
            sw++;
        }
    }
    return sw;
}

int main() {
    int a[N];
    int n = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    int sw = SelectionSort(a, n);
    showArray(a, n);
    printf("%d\n", sw);
    return 0;
}


Measured memory_bytes: 2760
n=input()
a=int(n[0])
b=int(n[1])
c=int(n[2])
d=int(n[3])
for i in [b,-b]:
  for j in [c,-c]:
    for k in [d,-d]:
      if a+i+j+k==7:
        ii='+'
        jj='+'
        kk='+'
        if i==-b:
          ii='-'
        if j==-c:
          jj='-'
        if k==-d:
          kk='-'
        print(str(a)+ii+str(b)+jj+str(c)+kk+str(d)+'=7')
        exit()

Measured memory_bytes: 3064
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

S = list(input())
N = len(S)
answer = (N+1)//2

if len(set(S)) == 1:
    print(N)
    exit()
right = N
left = answer

while right > left + 1:
    mid = (right + left) // 2
    S2 = S[-mid:mid]
    if len(set(S2)) == 1:
        left = mid
    else:
        right = mid

print(left)


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

using namespace std;

int main(){
	
	int n,k;
	
	cin>>n>>k;
	
	int h[n+1],dp[n+1];
	
	for(int i=1; i<=n; i+=1){
		
		cin>>h[i];
		
		dp[i] = -1;
	}
	
	dp[1] = 0;
	
	for(int i=1; i<=n; i+=1){
		
		for(int j=1; j<=k; j+=1){
			
			if(i+j <= n){
				
				if(dp[i+j] == -1){
					
					dp[i+j] = dp[i] + abs(h[i]-h[i+j]);
				}
				
				else{
					
					dp[i+j] = min(dp[i+j],dp[i] + abs(h[i]-h[i+j]));
				}
			}
		}
	}
	
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    switch(s[0]){
        case 'S' :  
            if(s[1] == 'U') cout << 7 << endl;
            else
            {
                cout << 1 << endl;
            }
            break;
        case 'M' :  cout << 6 << endl;
                    break;
        case 'T' :  if(s[1] == 'U') cout << 5 << endl;
                    else
                    {
                        cout << 3 << endl;
                    }
                break;    
        case 'W' :  cout << 4 << endl;  break;
        case 'F' :  cout << 2 << endl;  break;
    }
    return 0;
}

Measured memory_bytes: 256
s = input()

count = 0
bef = ""
maxC = 0
for i in range(len(s)):
    if bef == "" and s[i] == "R":
        count+=1
    else:
        if s[i] == "R" and bef == "R":
            count+=1
        elif s[i] == "R" and bef == "S":
            if count > maxC:
                maxC = count
            count = 1
        elif s[i] == "S" and bef == "R":
            if count > maxC:
                maxC = count
            count = 0
        else:
            count = 0
    bef = s[i]
if count > maxC:
    maxC = count
print(maxC)

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

const int MAX_N = 200005;

int N, cnt, u, v, L, R;
long long ans, w, A[MAX_N], SUM[MAX_N][2];
priority_queue<pair<long long, pair<int, int>>> pq;
set<int> unused;

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

	cin >> N;

	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
	}

	for (int i = 1; i <= N; i++)
	{
		pq.push({ A[i], {i, i + 1} });
	}

	for (int i = 0; i <= N + 2; i++)
	{
		unused.emplace(i);
	}

	for (int i = 1; i <= N + 2; i++)
	{
		SUM[i][0] = SUM[i - 1][0];
		SUM[i][1] = SUM[i - 1][1];
		SUM[i][i & 1] += A[i];
	}

	while (cnt < N / 2)
	{
		w = pq.top().first;
		u = pq.top().second.first;
		v = pq.top().second.second;
		pq.pop();

		if (unused.find(u) != unused.end() && unused.find(v) != unused.end())
		{
			unused.erase(u);
			unused.erase(v);
			cnt++;
			ans += w;
			L = *prev(unused.lower_bound(u));
			R = *unused.lower_bound(v);
			if (1 <= L && R <= N + 1)
			{
				pq.push({ (SUM[R - 1][L & 1] - SUM[L - 1][L & 1]) - (SUM[R - 1][(L & 1) ^ 1] - SUM[L - 1][(L & 1) ^ 1]), {L, R} });
			}
		}
	}

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

Measured memory_bytes: 20304
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    string S;
    cin >> N;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i]+N > 'Z') S[i] = (S[i]+N-26);
        else S[i] = (S[i]+N);
    }
    cout << S << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  int total = 0;
  for (int i = 0; i < N; i++) {
    int left, right;
    cin >> left >> right;
    total += right - left + 1;
  }
  
  cout << total << endl;
}

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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0


int main ()

{
    #define int ll
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int x;
    cin >> x;

    int remain = x%100;
    int aaa = x/100;
    if (5*aaa < remain) {
        cout << 0 << endl;
    }
    else cout << 1 << endl;

    return 0;
}

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

int main() {
  int N;
  int min = 10000000;
  vector<int>X(N);
  
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> X.at(i);
  }
  
  for(int P=1; P<=100; P++){
    int a= 0;
    for(int i=0; i<N; i++){
      a += (P-X.at(i))*(P-X.at(i));
    }
    if(min>a) min = a;
    
  }
  
  cout << min << endl;
}


Measured memory_bytes: 3716
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;




int main()
{
	int a,b;
	char S;
	cin >> a >> S >> b;
	if(S == '+')
		cout << a+b ;
	else
		cout << a-b;
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<int> P;
	std::cin >> N;
	P.resize(N);
	for (auto& p : P)
		std::cin >> p;
	
	auto highest = *std::max_element(P.begin(), P.end());
	auto sum = std::accumulate(P.begin(), P.end(), 0);
	std::cout << (sum - highest / 2) << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
pair<double, int> p1[8], p2[8], p3[8], p4[24];
int main() {
	for(int i = 0; i < 8; i++) scanf("%d %lf", &p1[i].second, &p1[i].first), p4[i] = p1[i]; sort(p1, p1 + 8);
	for(int i = 0; i < 8; i++) scanf("%d %lf", &p2[i].second, &p2[i].first), p4[i + 8] = p2[i]; sort(p2, p2 + 8);
	for(int i = 0; i < 8; i++) scanf("%d %lf", &p3[i].second, &p3[i].first), p4[i + 16] = p3[i]; sort(p3, p3 + 8);
	printf("%d %.2f\n%d %.2f\n", p1[0].second, p1[0].first, p1[1].second, p1[1].first);
	printf("%d %.2f\n%d %.2f\n", p2[0].second, p2[0].first, p2[1].second, p2[1].first);
	printf("%d %.2f\n%d %.2f\n", p3[0].second, p3[0].first, p3[1].second, p3[1].first);
	sort(p4, p4 + 24);
	for(int i = 0, c = 0; c < 2; i++) {
		int s = p4[i].second; bool flag = true;
		flag = flag && (s != p1[0].second && s != p2[0].second && s != p3[0].second);
		flag = flag && (s != p1[1].second && s != p2[1].second && s != p3[1].second);
		if(flag) printf("%d %.2f\n", p4[i].second, p4[i].first), c++;
	}
	return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W,A,B;
  cin >> H >> W >> A >> B;
  for (int i=1; i<=H; i++){
    for (int j=1; j<=W; j++){
      if (i<=B && j<=A || i>B && j>A){
        cout << 1;
      } else {
        cout << 0;
      }
    }
    cout << endl;
  }
}

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

using namespace std;
#define N 100005
#define ll long long
int primeFactorize(ll n)
{
    int res = 0;
    for(ll i = 2 ; i * i <= n ; i++)
    {
        if(n % i != 0)
            continue;
        res++;
        while(n % i == 0)
        {
            n /= i;
        }
    }
    if(n != 1)
        res++;
    return res;
}
int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<primeFactorize(__gcd(a,b)) + 1<<endl;

    return 0;
}
/*
2 3
10 1
1
15 1
2
30 2
1 2
*/


Measured memory_bytes: 3572
using System;

class ABC_130_B
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int X = int.Parse(input[1]);

        int ans = 1;
        int sum = 0;

        string[] input2 = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            sum += int.Parse(input2[i]);
            if (sum > X) break;

            ans++;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define Inf 100000000000ll
#define MAXN 100000
#define ll long long
using namespace std;

int N, A;

int X[55];

ll GetWays(int pos, int summ, int num_cards) {
    
    if (pos == N) {
        return (summ > 0 && summ == A * num_cards);
    }
    
    //if (dp[pos][summ][num_cards]!=-1)
     //   return dp[pos][summ][num_cards];
    
    ll answer = GetWays(pos+1, summ, num_cards) + GetWays(pos+1, summ + X[pos], num_cards+1);
    
    return answer;
    
}

ll dp[2][3000][55];

int main() {
    cin>>N>>A;
    int S[55];
    for(int i=0;i<N;i++) {
        cin>>X[i];
        S[i]=X[i]+(i>0?S[i-1]:0);
    }
    
    
    
    
    for(int pos = N;pos>=0;pos--) {
        for(int summ=0;summ<=2500;summ++)
            for(int num_cards=0;num_cards<=pos+1;num_cards++) {
                
                if (pos == N) {
                    dp[pos&1][summ][num_cards] = (summ > 0 && summ == A * num_cards);
                    continue;
                }
                
                
                ll answer = dp[(pos+1)&1][summ][num_cards];
                if (summ + X[pos] <= 2500) {
                    answer += dp[(pos+1)&1][summ+X[pos]][num_cards+1];
                }
                
                dp[pos&1][summ][num_cards]=answer;
            }
    }
    
    cout << dp[0][0][0] << endl;
    
}

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int cts[256][50];
int n;
string s;

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

	cin >> n;
	for (int i=0;i<n;i++) {
		cin >> s;
		for (char c:s) cts[c][i]++;
	}
	for (char c='a';c<='z';c++) cout << string(*min_element(cts[c],cts[c]+n),c);
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_163D(){
    ll n, k;
    cin >> n >> k;

    ll min = (k * (k-1)) / 2;
    ll max = (k * n) - min;

    ll ans = 0;
    for(ll i = k; i <= n+1; i++){
        ans = (ans + max - min + 1) % MOD;
        min += i;
        max = ((i+1) * n) - min;
    }

    cout << ans % MOD << endl;
}

int main(void){
    solve_163D();
    
    return 0;
}

Measured memory_bytes: 3580
import heapq

def main():
    N, M = map(int, input().split())
    n_list = map(int, input().split())
    n_dic = {}
    for n in n_list:
        n_dic.setdefault(n, 0)
        n_dic[n] += 1
    
    for i in range(M):
        b, c = map(int, input().split())
        n_dic.setdefault(c, 0)
        n_dic[c] += b
    
    com_list = []

    for score, num in n_dic.items():
        heapq.heappush(com_list, (-score, num))
    
    taken = 0
    result = 0

    while True:
        score, num = heapq.heappop(com_list)
        score = -score
        if N - taken > num:
            result += score * num
            taken += num
        else:
            result += score * (N - taken)
            break
    
    print(result)

main()


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main(){

	string s;
	cin>>s;

	if(s.at(s.size()-1)=='s'){
		cout<<s<<"es"<<endl;
	}
	else{
		cout<<s<<"s"<<endl;
	}




    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int W,H,x,y,i,j;
    cin>>W>>H>>x>>y;
    cout<<(double)W*H/2<<" ";
    if((double)x==(double)W/2&&(double)y==(double)H/2)cout<<1<<endl;
    else cout<<0<<endl;
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define Ms(s, n) memset(s, n, sizeof(s))
#define Rp(i,l,m) for(int i=l; i<m; ++i)
#define Rpd(i,l,m) for(int i=l; i>=m; --i)
#define Rpp(i,l,m) for(int i=l; i<=m; i++)
#define RpAll(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define All(a) (a).begin(), (a).end()
#define Fi first
#define Se second
#define Pb push_back
#define Pf push_front
#define Is insert
#define Sz(a) int((a).size())
#define ooi INT_MAX
#define ool LLONG_MAX
#define endl "\n"
#define maxx(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline ll gcd(ll a,ll b) {ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
inline ll fpow(ll n,ll k){ll r=1; for(;k;k>>=1){if(k&1)r=r*n%MOD;n=n*n%MOD;}return r;}
const int base = 311;
const int N = 1e5 + 5;

ll m, n, k, ans, a[N], g[N], pw[15] ;
string s;
map<string, ll> mp;
void Solve(){
    cin >> n;
    for(int  i = 1; i<= n; i++) {
        cin >> s;
        sort(All(s));
        mp[s]++;
    }
    for(auto it: mp){
        ll x = it.Se;
        ans += x * (x - 1) / 2;
    }
    cout << ans;

}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    Solve();
    return 0;
}


Measured memory_bytes: 11264
#include <iostream>
using namespace std;
int main(void){
    long long a, b, k;
    cin >> a >> b >> k;
    if(a >= k){
        a -= k;
    }else{
        b -= k-a;
        a = 0;
    }
    if(b < 0) b = 0;
    cout << a << " " << b << endl;
}


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


int main() {
  char N;
  cin >> N;
  
  string ans = "consonant";
  if (N == 'a' || N == 'i' || N == 'u' || N == 'e' || N == 'o') {
    ans = "vowel";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.read

N, *X = map(int, read().split())
X = np.array(X, np.int64)
n = np.arange(X.max() + 1)
answer = (X.reshape(-1, 1) - n) ** 2
answer = answer.sum(axis=0)
print(answer.min())


Measured memory_bytes: 21404
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
// #define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
ll getnum(ll a,ll c)
{
	ll ret = a / c;
	if(ret * c == a)
	{
		return ret;
	}
	return ret + 1;
}
ll getnum2(ll a,ll c)
{
	ll ret = a / c;
	return ret;
}
ll gcd(ll a,ll b)
{
	if(b == 0)
	{
		return a;
	}
	return gcd(b,a % b);
}
ll lcm(ll a,ll b)
{
	return a / gcd(a,b) * b;
}
int main(int argc, char const *argv[])
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll af = getnum(a,c);
	ll as = getnum(a,d);
	ll bf = getnum2(b,c);
	ll bs = getnum2(b,d);
	debug("af = %lld,as = %lld,bf = %lld,bs = %lld\n",af,as,bf,bs);
	ll ans1 = bf - af + 1 + bs - as + 1;
	ll p = lcm(c,d);
	debug("p = %lld\n",p);
	ll pf = getnum(a,p);
	ll ps = getnum2(b,p);
	ll ans2 = ps - pf + 1;
	debug("pf = %lld,ps = %lld,ans2 = %lld\n",pf,ps,ans2);
	ans1 -= ans2;
	printf("%lld\n",b - a + 1 - ans1);
	return 0;
}

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

template <typename T>
T ipow(T b, long long e) {
    if (e == 0) {
        return 1;
    } else if (e % 2 == 0) {
        return ipow(b * b, e / 2);
    } else {
        return ipow(b * b, e / 2) * b;
    }
}

int digit_number_10(long long n) {
    for (int i = 1;; i++) {
        if (n < ipow(10, i)) {
            return i;
        }
    }
}

int main() {
    long long N, ans = 0;
    cin >> N;
    int c[10][10];
    for (int l = 1; l <= 9; l++) {
        for (int r = 1; r <= 9; r++) {
            c[l][r] = 0;
            for (int X = 1; X <= N; X++) {
                if (X % 10 == r && X / ipow(10, digit_number_10(X) - 1) == l) {
                    c[l][r]++;
                }
            }
        }
    }
    for (int l = 1; l <= 9; l++) {
        for (int r = 1; r <= 9; r++) {
            ans += c[l][r] * c[r][l];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

ll memo[300][300];

int gcd(int x, int y) {
  if (memo[x][y] != 0) return memo[x][y];
  if (y == 0) {
    memo[x][y] = x;
    return x;
  }
  memo[x][y] = gcd(y, x % y);
  return memo[x][y];
}

int main() {
  int k;
  cin >> k;
  ll ans = 0;
  for (int i = k; i >= 1; i--) {
    for (int j = k; j >= 1; j--) {
      for (int l = k; l >= 1; l--) {
        ans += gcd(i, gcd(j, l));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4048
#python3

def f(array, ch):
    res = True
    for i in array:
        if i == ch:
            res = False
            break
    return res

def main():
    s = input()
    odd = [s[i] for i in range(len(s)) if i%2 == 0 ] 
    even = [s[i] for i in range(len(s)) if i%2 != 0]
    if f(odd, 'L') and f(even, 'R'):
        print('Yes')
    else:
        print('No')
main()

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

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

    int N, K; cin >> N >> K;
    int p = 1;
    while (p < K) p *= 2;
    double ans = 1;
    for (int i = 2; i <= N; i++) {
        int x = i;
        int res = 1;
        while (x < K) {
            x *= 2;
            res *= 2;
        }
        ans += p / res;
    }
    ans = ans / (1LL * N * p);
    cout << fixed << setprecision(10) << ans << "\n";
}

Measured memory_bytes: 256
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
ls = []
for i in range(5):
    ls.append(int(input()))
ls2 = [i%10 for i in ls]
if ls2 == [0,0,0,0,0]:
    print(sum(ls))
else:
    lasttime = 10
    for a in ls:
        b = a%10
        if b < lasttime and b != 0:
            lasttime = b
            ans =a

    ls.remove(ans)
    sum =0
    for i in ls:
        if i%10 ==0:
            sum +=i
        else:
            p = i//10
            sum += (p+1)*10

    print(int(sum + ans))



Measured memory_bytes: 3064
IDENTIFICATION DIVISION.
      PROGRAM-ID. 088A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 N PIC 9(5).
      01 A PIC 9(4).
      01 SHO PIC 9(3).
      01 AMA PIC 9(3).
      01 ANS PIC 9(3).
      
      PROCEDURE DIVISION.
      ACCEPT N.
      ACCEPT A.
      DIVIDE N BY 500 GIVING SHO REMAINDER AMA.
      IF A >= AMA
         DISPLAY "Yes"
      ELSE
         DISPLAY "No"
      END-IF.
      STOP RUN.

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, 
less<int>, rb_tree_tag, 
tree_order_statistics_node_update> indexed_set;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	int a[1000];
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a, a + n);
	int sum  = 0;
	for(int i = 0; i < k; ++i) {
		sum += a[i];
	}
	cout << sum << "\n";
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

//??¨?????????????????????i???????¢°????????¨??¶???(?????????0,????????£??????1,???????????????2)
int dp[100001][3];

int main()
{
    int n;
    cin >>n;
    vector<int> a(n);
    rep(i,n) scanf(" %d", &a[i]);

    rep(i,n)rep(j,3) dp[i][j]=1;

    //i????????????????????¨???
    for(int i=1; i<n; ++i)
    {
        if(a[i]!=a[i-1])
        {
            dp[i][0]=max(dp[i][0],dp[i-1][0]+1);
            dp[i][1]=max(dp[i][1],dp[i-1][1]+1);
            dp[i][2]=max(dp[i][2],dp[i-1][2]+1);
        }
        else
        {
            dp[i][1]=max(dp[i][1],dp[i-1][0]+1);
            dp[i][2]=max(dp[i][2],dp[i-1][1]+1);
        }
    }

    int ans=0;
    rep(i,n)rep(j,3) ans=max(ans,dp[i][j]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4408
#include<iostream>
#include<string>
using namespace std;
string a[10];
int p[10];
int main(){
	int n,b,z,c;
	bool first=true;
	while(true){
	cin>>n;
	if(n==0)break;
	if(!first)cout<<endl;
	first=false;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b>>z>>c;
		p[i]=b*3+c*1;
	}
	for(int i=0;i<n-1;i++){
		for(int j=n-1;j>i;j--){
			if(p[j]>p[j-1]){
				string tmps=a[j];
				a[j]=a[j-1];
				a[j-1]=tmps;
				int tmp=p[j];
				p[j]=p[j-1];
				p[j-1]=tmp;
			}
		}
	}
	for(int i=0;i<n;i++)
		cout<<a[i]<<","<<p[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

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


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


vector <int> g[MAXN];
int d[2222][2222];

void dfs(int v, int par, int root, int dist) {
	d[root][v] = dist;
	for (int i : g[v]) {
		if (par != i) {
			dfs(i, v, root, dist + 1);						
		}
	}
}

int u[MAXN];
int v[MAXN];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
   	int n = readInt(), k = readInt();
   	for (int i = 1; i < n; i++) {
   		u[i] = readInt(), v[i] = readInt();
		g[u[i]].pb(v[i]);
		g[v[i]].pb(u[i]);
   	}
   	for (int i = 1; i <= n; i++) {
   		dfs(i, 0, i, 0);	
   	}
   	int mx = 0;
   	for (int i = 1; i <= n; i++) {
   		int cnt = 0;
   		for (int j = 1; j <= n; j++) {
   			if (2 * d[i][j] <= k) {
   				cnt++;
   			}
   		}
   		mx = max(mx, cnt);	
   	}
   	for (int i = 1; i < n; i++) {
   		int cnt = 0;
   		int a = u[i];
   		int b = v[i];
   		for (int j = 1; j <= n; j++) {
			if (2 * min(d[j][a], d[j][b])+1 <= k) cnt++;   		
   		}
   		mx = max(mx, cnt);
   	}
   	cout << n - mx;
    return 0;
}

Measured memory_bytes: 46848
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  long long N,X,M;
  cin >> N >> X >> M;
  
  if (M == 1){
    cout << 0 << endl;
    return 0;
  }
  
  long long sum1 = 0;
  long long sum2 = 0;
  vector<long long>L(M);
  vector<long long>count(M,0);
  L.at(0) = X;
  count.at(X)++;
  long long A = -1;
  long long B = -1;
  long long Y = -1;
  
  if (N == 1){
    cout << X << endl;
    return 0;
  }
  
  for (int i = 1; i < M; i++) {
    L.at(i) = (L.at(i-1)*L.at(i-1)) % M;
    count.at(L.at(i))++;
    if (count.at(L.at(i)) > 1){
      A = i+1;
      Y = L.at(i);
      break;
    }
  }
  
  long long ans = 0;
  if (A == -1){
    for (int i = 0; i < N; i++) {
      ans += L.at(i);
    }
    cout << ans << endl;
    return 0;
  }
      
  
  long long judge = 0;
  for (int i = 0; i < A; i++) {
    if (L.at(i) == Y){
      judge++;
      if (judge == 1){
        B = i+1;
      }
    }
    if (judge == 0){
      sum1 += L.at(i);
    }
    else if (judge == 1){
      sum2 += L.at(i);
    }
  }
  
  if (N < A){
    for (int i = 0; i < N; i++) {
      ans += L.at(i);
    }
  }
  else {
    long long C = (N-B+1)/(A-B);
    long long D = (N-B+1)%(A-B);
    for (int i = B-1; i < B+D-1; i++) {
      ans += L.at(i);
    }
    ans += sum1 + C*sum2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  rep(i, n) {
    int a;
    cin >> a;
    if(a % 2 == 0 && a % 3 != 0 && a % 5 !=0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <ostream>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

template<typename T, typename U>
std::ostream& operator << (std::ostream& os, std::pair<T, U> p) {
  os << "(" << p.first << ", " << p.second << ")";

  return os;
}

template<typename T>
std::ostream& operator << (std::ostream& os, std::vector<T> v) {
  os << "[";
  for (int i = 0; i < int(v.size()); ++i) {
    os << v[i] << (i + 1 == int(v.size()) ? "" : " ");
  }
  os << "]";

  return os;
}

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

int main() {
  init();

  int a, b;

  cin >> a >> b;

  for (int i = 1; i < 999; ++i) {
    int A = i * (i + 1) / 2, B = (i + 1) * (i + 2) / 2;

    int l = 0, r = B + 1, m;
    while (r - l > 1) {
      m = (l + r) / 2;

      if (A - m == a && B - m == b) {
        cout << m << endl;
        return 0;
      }
      else if (A - m > a) {
        l = m;
      }
      else {
        r = m;
      }
    }
  }

  system("pause");
  return 0;
}


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

using task = pair<int64_t, int64_t>;

int main()
{
	int N;
	cin >> N;
	vector<task> v(N);
	for (int i = 0; i < N; ++i)
	{
		int64_t a, b;
		cin >> a >> b;
		v[i] = task(a, b);
	}

	sort(v.begin(), v.end(), [](task& A, task& B) { return A.second < B.second; });

	int count = 0;
	bool isComplete = true;
	for (auto e : v)
	{
		count += e.first;
		if (count > e.second)
		{
			isComplete = false;
			break;
		}
	}

	if (isComplete)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

int main() {
	int N;
	cin >> N;
	set<int> st;
	int d;
	for (int i = 0; i < N; i++) {
		cin >> d;
		st.insert(d);
	}
	

	cout << st.size() << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
  int r=sc.nextInt();
  int c=sc.nextInt();
  char grid[][]=new char[r][c];
  int dp[][]=new int[r][c];
  for(int i=0;i<r;i++){
      String a=sc.next();
  for(int j=0;j<c;j++){
  grid[i][j]=a.charAt(j);
    if(grid[i][j]=='#')
      dp[i][j]=-1;
  }
  }
  dp[0][0]=1;
  
  for(int i=0;i<r;i++){
  for(int j=0;j<c;j++){
    if(i==0&&j==0)
      continue;
    if(dp[i][j]==-1)
      continue;
    
    if(j-1>=0&&dp[i][j-1]!=-1){
    dp[i][j]+=dp[i][j-1]%1000000007;
    }
    if(i-1>=0&&dp[i-1][j]!=-1){
    dp[i][j]+=dp[i-1][j]%1000000007;
    }
    
  }  
  }
  System.out.println(dp[r-1][c-1]%1000000007);
}
}

Measured memory_bytes: 36688
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int n;
bool used[MAXN];
int main(){
	SF("%d",&n);
	if(n==3){
		PF("2 5 63");
		return 0;
	}
	used[2]=1,used[4]=1,used[3]=1,used[9]=1;
	n-=4;
	int x=8,y=10;
	while(n>1&&y<=30000){
		used[x]=1;
		used[y]=1;
		n-=2;
		x+=6;
		y+=6;
	}
	x=15,y=21;
	while(n>1&&y<=30000){
		used[x]=1;
		used[y]=1;
		n-=2;
		x+=12;
		y+=12;
	}
	x=6;
	while(n>0&&x<=30000){
		used[x]=1;
		x+=6;
		n--;
	}
	for(int i=2;i<=30000;i++)
		if(used[i]==1)
			PF("%d ",i);
} 

Measured memory_bytes: 256
####### 二項係数 C(n,k) mod pの計算 #######

MOD=10**9+7
FACT=[]
INV=[]

## a**b mod p by 繰り返し二乗法 ##
def pow(a,b)
  return 1 if b==0
  return a*pow(a,b-1)%MOD if b%2==1
  return pow(a**2%MOD,b/2)
end

## n! mod p ##
def fact(n)
  ret=1
  n.times do |i|
    ret=ret*(i+1)%MOD
  end
  ret
end

## a**(-1) mod p ##
def inv(n)
  pow(n,MOD-2)%MOD
end

## FACT[n],INV[n] mod p ##
def calc_fact(n)
  FACT[0]=1
  INV[0]=pow(FACT[0],MOD-2)
  for i in 1..n
    FACT[i]=FACT[i-1]*i%MOD
    INV[i]=pow(FACT[i],MOD-2)
  end
end

## C(n,k) mod p ##
def com(n,k)
  (fact(n)*inv(fact(k)))%MOD*inv(fact(n-k))%MOD
end

## C(n,k) mod p (10**5>>k version) ##
def frac(n,k)
  a=1
  b=1
  k.times do |i|
    b*=i+1
    b%=MOD
  end
  k.times do |i|
    j=i+1
    a*=n-i
    a%=MOD
  end
  a*inv(b)%MOD
end

## C(n,k) mod p (n,k>10**5 version) ##
def conv(n,k)
  (FACT[n]*INV[n-k]%MOD)*INV[k]%MOD
end

##########################################

N,K=gets.split.map(&:to_i)
K=N-1 if N<=K

calc_fact(N)
ans=0

for num in 1..K do
  ans+=conv(N,num)*conv(N-1,num)%MOD
end
 
puts (ans+1)%MOD

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

const int nmax = 40, abmax = 10, inf = 1000000;

int a[nmax], b[nmax], c[nmax];
int dp[nmax + 1][nmax * abmax + 1][nmax * abmax + 1];

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;

    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    for (int i = 0; i <= n; i++) {
        for (int ca = 0; ca <= nmax * abmax; ca++) {
            for (int cb = 0; cb <= nmax * abmax; cb++) {
                dp[i][ca][cb] = inf;
            }
        }
    }

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

    for (int i = 0; i < n; i++) {
        for (int ca = 0; ca <= nmax * abmax; ca++) {
            for (int cb = 0; cb <= nmax * abmax; cb++) {
                /*
                if (dp[i][ca][cb] == inf) continue;
                dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
                dp[i + 1][ca + a[i]][cb + b[i]] = min(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
                */
               dp[i + 1][ca][cb] = dp[i][ca][cb];
               if (a[i] <= ca && b[i] <= cb) {
                   dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca - a[i]][cb - b[i]] + c[i]);
               }
            }
        } 
    }

    int ans = inf;
    for (int ca = 1; ca <= nmax * abmax; ca++) {
        for (int cb = 1; cb <= nmax * abmax; cb++) {
            if (ca * mb == cb * ma) ans = min(ans, dp[n][ca][cb]);
        }
    }

    if (ans == inf) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  string s;
  cin >> n >> s;
  bool ans = true;
  if(n % 2)
    ans = false;
  else {
    string s1 = s.substr(0, n / 2);
    string s2 = s.substr(n / 2, n / 2);
    if(s1 != s2) ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a%b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int i, j, k, n, m, t, x, y, z, s=0, c=0, l;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    for(i=0; i<n-1; i++)
    {
        for(j=i+1; j<n; j++)
            s+=(a[i]*a[j]);
    }
    cout << s << endl;
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main()
{
    int n, x;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        }
        else if (x % 10 == 3) {
            cout << " " << i;
        }
        else{
            x /= 10;
            while (x) {
                if (x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
            
        }
    }
    cout << endl;
}

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

int main(void)
{
  int k,a[1000],b[1000],c;
  string s[1000];

  k=0;
  do{
    k=k+1;
    cin >> a[k] >> s[k] >> b[k];
  }while(s[k] != "\?");

  k=1;
  while(s[k]!="\?"){
    if(s[k]=="+") c=a[k]+b[k];
    if(s[k]=="-") c=a[k]-b[k];
    if(s[k]=="*") c=a[k]*b[k];
    if(s[k]=="/") c=a[k]/b[k];
    cout << c << endl;
    k=k+1;
  };

  return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  ll ans = 0;
  const ll mini = -1e17;
  if(N%2==0){
    vector<ll> dp00(N+1, 0), dp01(N+1, 0), dp10(N+1, 0), dp11(N+1, 0);
    rep(i,N){
      dp00[i+1] = i%2? dp01[i] : -mini;
      dp01[i+1] = i%2? -mini: dp00[i]+A[i];
      dp10[i+1] = max(dp00[i], dp11[i]);
      dp11[i+1] = i>0? dp10[i]+A[i]: -mini;
    }

    ans = max(dp00[N], dp11[N]);
  }
  else{
    vector<ll> dp00(N+1, 0), dp01(N+1, 0), dp10(N+1, 0), dp11(N+1, 0), dp20(N+1, 0), dp21(N+1, 0);

    rep(i,N){
      dp00[i+1] = i%2? dp01[i] : mini;
      dp01[i+1] = i%2? mini: dp00[i] + A[i];
      dp10[i+1] = max(dp00[i], dp11[i]);
      dp11[i+1] = i>0? dp10[i]+A[i]: mini;
      dp20[i+1] = max(dp10[i], dp21[i]);
      dp21[i+1] = i>1? dp20[i]+A[i]: mini;
    }
    /*
    rep(i,N+1) cout << dp00[i] << " ";
    cout << endl;
    rep(i,N+1) cout << dp01[i] << " ";
    cout << endl;
    rep(i,N+1) cout << dp10[i] << " ";
    cout << endl;
    rep(i,N+1) cout << dp11[i] << " ";
    cout << endl;
    rep(i,N+1) cout << dp20[i] << " ";
    cout << endl;
    rep(i,N+1) cout << dp21[i] << " ";
    cout << endl;
    */

    ans = max({dp21[N], dp10[N]});
  }
  cout << ans << endl;
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 064 B / Link: http://abc064.contest.atcoder.jp/tasks/abc064_b  ----- */


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

	LL N; 
	cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	SORT(a);
	
	LL ans = a.back()-a.front();
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    long long n,m,sum=0;
    cin>>n>>m;
    if(n==1||m==1)
        cout<<1;
    else
    {
        if(n%2==0)
            cout<<(n/2)*m;
        else
        {
            if(m%2==0)
                cout<<n*(m/2);
            else
                cout<<n*(m/2)+n/2+1;
        }
    }


}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#define PI 3.141592653589793
using namespace std;

int main() {
	
	double a, b, C, S, L, H, r;
	cin >> a >> b >> C;
	
	r = C * PI / 180;
	
	S = a * b * sin(r) / 2;
	L = a + b + sqrt((a * a) + (b * b) - (2 * a * b * cos(r)));
	H = b * sin(r);
	
	cout << fixed << setprecision(6) << S << "\n" << L << "\n" << H << "\n";
	
	return 0;
}


Measured memory_bytes: 3492
x1,y1,x2,y2 = map(int,input().split())
katamukix = x2 - x1
katamukiy = y2 - y1
x3 = x2 - katamukiy
y3 = y2 + katamukix
x4 = x3 - katamukix
y4 = y3 - katamukiy
print(x3,y3,x4,y4)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main() {
    #ifndef LOCAL
    fastIO;
    #endif
    double PI=acos(-1),rta,gA,gB,gradosReales;
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    gA=(30.0*h)+(m*1.0)/2;
    gB=6*m;
    gradosReales=min(abs(gA-gB),360-abs(gA-gB));
    rta=sqrt(a*a+b*b-2*a*b*cos(gradosReales*PI/180));
    cout << fixed << setprecision(10) << rta << endl;
    return 0;
}



Measured memory_bytes: 4200
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))), end((c)))
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

vector<int> G[101010];
int deg[101010], n;
set<int>st;

int dfs(int x, int lt) {
	if (G[x].size() > 2)return x;
	REP(i, G[x].size()) {
		int y = G[x][i];
		if (lt != y)return dfs(y, x);
	}
}

int main() {
	cin >> n;
	REP(i, n - 1) {
		int x, y;
		cin >> x >> y;
		G[x].emplace_back(y);
		G[y].emplace_back(x);
		deg[x]++;
		deg[y]++;
	}
	int maxl = 0;
	REP(i, n)maxl = max(maxl, deg[i]);
	if (maxl == 2) {
		cout << 1 << endl;
		return 0;
	}
	else {
		int ans = 0;
		REP(i, n) {
			if (deg[i] == 1) {
				st.insert(dfs(i, i));
				ans++;
			}
		}
		cout << ans - st.size() << endl;
	}
}

Measured memory_bytes: 7296
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
	string s,t;
	cin >> s;
	map<char,char> mp;
	mp['b'] = 'd';
	mp['d'] = 'b';
	mp['p'] = 'q';
	mp['q'] = 'p';
	FORR(i,s.length()-1,0){
		t += mp[s[i]];
	}
	cout << (s == t ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 640