akhauriyash/Code-Regression huggingface dataset:
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main()
{
	string A = "";
	string B = "";
	string C = "";
	string ret = "No";// No

	cin >> A >> B;
	C = A + B;
	double test = sqrt(atoi(C.c_str()));

	if( floor(test) == ceil(test) ){
		ret = "Yes";
	}
	cout << ret << endl;

	return 0;
}





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

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

vector<double> p;

int main() {
    int N;
    cin >> N;
    p.resize(N);
    for (int i = 0; i < N; i++) cin >> p[i];
    double dp[N+10][N+10] = {0.0};
    dp[0][0] = 1.0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i+1][j+1] += dp[i][j]*p[i];
            dp[i+1][j] += dp[i][j]*(1-p[i]);
        }
    }
    int thr = N/2 + 1;
    double ans = 0.0;
    for (int j = thr; j <= N; j++) {
        ans += dp[N][j];
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 71040
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  ll n; cin >> n;
  
  vl num(100001);
  
  rep(i,n){
    ll x; cin >> x;
    num[x]++;
  }
  
  ll ans = 0; ll cnt = 0;
  
  rep(i,100001){
    if(num[i] != 0){
      cnt++;
      ans += max(0LL,num[i] - 1);
    }
  }
  
  if(ans % 2 == 0) cout << cnt << endl;
  else cout << cnt-1 << endl;
  
  
}

Measured memory_bytes: 3976
#include <fstream>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, a;
lli arr [100001];
lli psum [100001] = {0};

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    F0R(i,N+1) cin >> arr[i];
    RF0(i,N) psum[i] = arr[i+1] + psum[i+1];
    
    lli t_nodes = 0;
    lli lvl = 1;
    F0R(i,N+1) {
        if (lvl-arr[i] < 0 || lvl-arr[i] > psum[i]) {cout << "-1\n"; return 0;}
        t_nodes += lvl;
        lvl = min(2*(lvl-arr[i]), psum[i]);
    }
    cout << t_nodes << '\n';
}

Measured memory_bytes: 5168
"use strict";

const main = (arg) => {
  const array = arg.trim().split(" ");
  for (let i = 0; i < array.length; i++) {
    let num = i + 1;
    if (num != array[i]) {
      console.log(num);
      break;
    }
  }
};
main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
    char ch;
    scanf("%c", &ch);
    if(ch == 'A')
        printf("T");
    else if(ch == 'T')
        printf("A");
    else if(ch == 'G')
        printf("C");
    else
        printf("G");
    return 0;
}


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

// ????????????????????§????°?????????°?????±?????????????°?????????±????§???????????????????

int Sort( int A[], int N){
	int s = 0;
	bool flag = 1; // bool???ture?????????false???????¨??????§??????
	for( int i=0; flag; i++ ){ // for (????????????; ?¶??¶??????¶???; ???????????????)??§???????????§???ture?????´????¶??¶?
		flag = 0;
		for(int j=N-1; j>=i+1; j--){
			if( A[j]<A[j-1] ){
				swap( A[j],A[j-1] ); // A[j]??¨A[j-1]???????????????
				flag = 1;
				s++;
			}
		}
	}
	return s;
}



int main(){
	int A[100],N,s;
	cin >> N;

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

	s = Sort(A,N);

	for( int i=0; i<N; i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << "\n";
	cout << s << "\n";


	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/

int main() {
    cin >> n;
    vi v(n);
    REP(i, n) {
        cin >> v[i];
    }
    if (v[0] != 0) {
        cout << -1 << endl;
        return 0;
    }
    REP(i, n - 1) {
        if (v[i + 1] > v[i] + 1) {
            cout << -1 << endl;
            return 0;
        }
    }

    FOR(i, 1, n ) {
        if (v[i] == v[i - 1] + 1) {
            ans++;
        } else {
            ans += v[i];
        }
    }
    cout << ans << endl;
}

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

int main(void){
    
    int N,D,i,j,k,X[10][10],result = 0;
    double dist = 0;

    scanf("%d %d",&N,&D);
    for(i = 0;i < N;i++){
        for(j = 0;j < D;j++){
            scanf("%d",&X[i][j]);
        }
    }

    for(i = 0;i < N;i++){
        for(k = i + 1;k < N;k++){
            dist = 0;
            for(j = 0;j < D;j++){
                dist += (X[k][j] - X[i][j])*(X[k][j] - X[i][j]); 
            }
            if(ceil(sqrt(dist)) == floor(sqrt(dist))){
                //printf("%d番目と%d番目 %lf %lf\n",i,k,ceil(sqrt(dist)),floor(sqrt(dist)));
                result++;
            }
        }
    }

    printf("%d",result);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>

int counter = 0;

void solve(std::vector<int>& data1, std::vector<int>& data2)
{
    for(int i = 0; i < data2.size(); i++) {
        for(int j = 0; j < data1.size(); j++) {
            if(data2[i] == data1[j]) {
                counter++;
                break;
            }
        }
    }
}

int main()
{
    int first_sequence_size, second_sequence_size;
    std::cin >> first_sequence_size;
    std::vector<int> first_sequence(first_sequence_size);
    for(int i = 0; i < first_sequence.size(); i++) {
        std::cin >> first_sequence[i];
    }
    std::cin >> second_sequence_size;
    std::vector<int> second_sequence(second_sequence_size);
    for(int i = 0; i < second_sequence.size(); i++) {
        std::cin >> second_sequence[i];
    }
    solve(first_sequence, second_sequence);

    printf("%d\n", counter);
}

Measured memory_bytes: 3204
#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let n = cin.next_usize();
    let m = cin.next_usize();
    let inf = 1<<29;
    let mut edges = vec![(0,0); m];
    for i in 0..m {
        let a = cin.next_usize() - 1;
        let b = cin.next_usize() - 1;
        edges[i] = (a,b);
    }
    let mut ans = 0;
    for e in 0..m {
        let mut dist = vec![vec![inf; n]; n];
        for i in 0..n { dist[i][i] = 0; }
        for i in 0..m {
            if i != e {
                let a = edges[i].0;
                let b = edges[i].1;
                dist[a][b] = 1;
                dist[b][a] = 1;
            }
        }
        for k in 0..n {
            for i in 0..n {
                for j in 0..n {
                    dist[i][j] = std::cmp::min(dist[i][j], dist[i][k] + dist[k][j])
                }
            }
        }
        let mut b = 0;
        for i in 0..n {
            for j in 0..n {
                if dist[i][j] == inf {
                    b = 1;
                }
            }
        }
        ans += b;
    }
    println!("{}", ans);
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }
    
    #[allow(dead_code)] fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)] fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)] fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)] fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)] fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}



Measured memory_bytes: 4352
a,b=map(int,input().split())
p=[list(map(int,input().split()))for i in range(a)]
q=[list(map(int,input().split()))for i in range(b)]
for i in range(a):
    r=[]
    for j in range(b):
        r.append([abs(p[i][0]-q[j][0])+abs(p[i][1]-q[j][1]),j+1])
    else:
        r.sort()
        print(r[0][1])

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

const int mod = 1000000007;

char s[100010];
int vis[26];

int main(){
	int n; scanf("%d", &n);
	scanf("%s", s);
	int l = 0, r = 0;
	for (int i = 0; i < n; i++){
		vis[s[i] - 'a']++;
	}
	long long ans = 1;
	for (int i = 0; i < 26; i++){
		ans = ans * (vis[i] + 1) % mod;
	}
	printf("%lld\n", (ans - 1 + mod) % mod);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<string> c(2);
  for(int i=0;i<2;i++)
    cin>>c.at(i);
  bool f=1;
  for(int i=0;i<2;i++)
    for(int j=0;j<3;j++)
      f=(c.at(i).at(j)!=c.at(1-i).at(2-j)?0:f);
  cout<<(f?"YES":"NO")<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
    int r;
    cin >> r;
    if(r<1200){
        cout << "ABC" << endl;
    }else if(r<2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cctype>

using namespace std;


void change(const char a[],const char b[],const char c[]){
	cout<<static_cast<char>(toupper(a[0]));
	cout<<static_cast<char>(toupper(b[0]));
	cout<<static_cast<char>(toupper(c[0]));
	cout<<endl;
}



int main(){
	
	char a[15]={};
	char b[15]={};
	char c[15]={};

	cin>>a>>b>>c;
	
	change(a,b,c);
	
	
	
	
	return 0;
	
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int maxn = 110;
int A[maxn], dp[maxn][maxn][maxn];

int dfs(const int i, const int j, const int k)
{
    if (i > j || !k)
        return 0;
    int& ans = dp[i][j][k];
    if (-1 == ans) {
        ans = -inf;
        const int a = A[i] + dfs(i+1,j,k-1);
        const int b = A[j] + dfs(i,j-1,k-1);
        ans = max(ans, max(a,b));
        if (k >= 2) {
            const int c = dfs(i+1,j,k-2);
            const int d = dfs(i,j-1,k-2);
            ans = max(ans, max(c,d));
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    int n,k;
    while (cin >> n >> k) {
        memset(dp,-1,sizeof(dp));
        FOR(i,0,n)
            cin >> A[i];
        int ans = 0;
        FOR(x,1,k+1) {
            ans = max(ans, dfs(0,n-1,x));
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <fstream>
#include <set>
#include <cmath>
#include <array>
#include <iomanip>


using namespace std;

struct Point {
    long double x;
    long double y;
    long double rad;
};

int main(void) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    std::vector<Point> points;

    auto go = [&]() {
        points.push_back({});
        cin >> points.back().x >> points.back().y;
        points.back().rad = 0;
    };
    go();
    go();
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        points.push_back({});
        cin >> points.back().x >> points.back().y >> points.back().rad;
    }
    auto calc = [&](int i, int j) {
        return std::max((long double)0.0, sqrt((points[i].x - points[j].x) * (points[i].x - points[j].x) + (points[i].y - points[j].y) * (points[i].y - points[j].y)) - points[i].rad - points[j].rad);
    };

    std::vector<long double> current_distance(n + 2);
    std::vector<bool> used(n + 2, false);
    for (auto& el : current_distance) {
        el = 1e18;
    }
    current_distance[0] = 0;

    for (int i = 0; i < n + 2; i++) {
        int cur_min = 1;
        for (int j = 0; j < n + 2; j++) {
            if (current_distance[j] < current_distance[cur_min] && !used[j]) {
                cur_min = j;
            }
        }
        used[cur_min] = true;
        if (cur_min == 1) {
           break;
        }
        for (int j = 0; j < n + 2; j++) {
            if (!used[j]) {
                current_distance[j] = min(current_distance[j], current_distance[cur_min] + calc(cur_min, j));
            }
        }
    }


    cout << std::setprecision(15) << current_distance[1] << std::endl;;

    return 0;
}


Measured memory_bytes: 512
a, b, c = [int(i) for i in input().split()]
if b >= c:
    count = c + (b-(b-c))
    c = 0
else:
    count = (c-(c-b))*2
    c -= b
b -= count//2
if c >= a and a > 0:
    count += c-(c-a)
    c -= c-(c-a)
    print(count + (1 if c else 0))
elif a > c and c > 0:
    print(count+(a-(a-c)))
else:
    print(count+b)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int N, L; cin >> N >> L;

  vi apple(N);
  rep(i,N) {
    apple.at(i) = L+i;
  }
  int eat;
  if(0<L) 
    eat = L;
  else if(0<L+N-1)
    eat = 0;
  else
    eat = L+N-1;
    
  int sum = accumulate(all(apple),0);
  cout << sum - eat << endl;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;cin>>a>>b;
    ll g = __gcd(a,b);
    ll g_org = g;
    ll ans = 1;
    for(ll d=2; d*d<=g_org; d++){
        if(g%d==0)ans++;
        while(g%d==0)g/=d;
    }
    if(g!=1) ans++;
    cout<<ans<<endl;
    return 0;
}

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

int mpow(ll a, int b) {
    int ans = 1;
    while (b) {
        if (b % 2 == 1)
            ans = (ans * a) % MOD;
        b /= 2;
        a = (a * a) % MOD;
    }
    return ans;
}

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

    cout << ((mpow(10, n) - mpow(9, n) - mpow(9, n) + mpow(8, n)) % MOD + MOD) % MOD << endl;

    return 0;
}

Measured memory_bytes: 3628
N = input()
An = map(int, raw_input().split())

avg = sum(An)*1.0/len(An)
avg = int(round(avg))

avg_cost = 0
for a in An:
    avg_cost += (a-avg)**2

while True:
    l_avg = avg
    g_avg = avg
    l_avg -= 1
    g_avg += 1
    l_cost = 0
    g_cost = 0

    for a in An:
        l_cost += (a-l_avg)**2
        g_cost += (a-g_avg)**2

    if min(l_cost, avg_cost, g_cost) == avg_cost:
        ans = avg_cost
        break
    else:
        avg_cost = l_cost
        avg = l_cost


print ans


Measured memory_bytes: 2692
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll x;
  scanf("%lld", &x);
  ll uOf500 = x / 500 * 1000;
  x -= x / 500 * 500;
  ll uOf5 = x / 5 * 5;
  printf("%lld\n", uOf500 + uOf5);
}


Measured memory_bytes: 128
//============================
// ABC137c Green Bin
//
// 2019/08/12
//============================

#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  int N;
  map<string, int> m;

  cin >> N;
  for(int i=0; i<N; i++)
  {
    string str;
    cin >> str;
    sort(str.begin(), str.end());
    m[str] += 1;
  }

  long cnt=0;
  for(auto i = m.begin(); i != m.end(); ++i)
  {
    long temp;
    temp = i->second;
    cnt += temp*(temp-1)/2;
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 11136
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    h = ii()
    ans = 0
    mons = 1
    while h > 0:
        ans+=mons
        h//=2
        mons*=2
    print(ans)


main()


Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007


int main()
{
   int arr[5];
   for(int i=0;i<5;i++)
      cin>>arr[i];
   int k;
   int flag = 0;
   cin>>k;
   for(int i=0;i<4;i++)
   {
      for(int j=i+1;j<5;j++)
      {
         if(arr[j] - arr[i]>k)
         {
            flag = 1;
            break;
         }

      }
   }
   if(flag == 0)
      cout<<"Yay!";
   else
      cout<<":(";
   return 0;
}


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

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

  A = N/1000;
  B = N%1000/100;
  C = N%1000%100/10;
  D = N%1000%100%10;
  
  if (A==B && B==C) {
    cout << "Yes" << endl;
  }
  
  else if (B==C && C==D) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

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

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


//////////////////////////////////////////////////////////////////////////////////////b,cl

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int count = 0;
    for (int i = 0;i < s.size();i++){
        if (s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T'){
            count++;
            ans = max(ans, count);
        }
        else {
            count = 0;
        }
    }

    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    
    ll sum = 0, sum2 = 0;
    
    rep(i,n){
        ll a; cin >> a;
        sum += a;
        sum %= MOD;
        sum2 += a*a;
        sum2 %= MOD;
    }
    sum *= sum;
    sum %= MOD;
    sum += MOD-sum2;
    sum %= MOD;
    
    if(sum%2)cout<<(sum+MOD)/2<<endl;
    else cout<<sum/2<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, M, K;
    cin >> N >> M >> K;
    if (N > M) swap(N,M);
    bool ans = false;
    REP(i,N+1) {
        int count = M*i;
        int md = N - i*2;
        int rest = K-count;
        if (md == 0) {if (count == K) ans = true;}
        else if (md > 0 && rest > 0) {if (rest % md == 0 && rest / md <= M) ans = true;}
        else if (md < 0 && rest < 0) {if (rest % md == 0 && rest / md <= M) ans = true;}
        if (ans) break;
    }
    ATYN(ans)

    return 0;
}

Measured memory_bytes: 3608
H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())

S = [0 for i in range(H+4)]
S[0] = "#"*(W+4)
S[1] = "#"*(W+4)
S[H+2] = "#"*(W+4)
S[H+3] = "#"*(W+4)
for i in range(2, H+2):
  S[i] = "##" + input() + "##"
  
B = [ [-1 for i in range(W+4)] for i in range(H+4)]

def search(i,j,c):
  global B
  B[i][j] = c
  L = [(-1,0), (1, 0), (0, -1), (0, 1)]
  for X in L:
    if S[i+X[0]][j+X[1]] == '.' and B[i+X[0]][j+X[1]] < 0:
        search(i+X[0],j+X[1],c)
        
#<01>[2--H+1]<H+2,3>#
c = 0
for i in range(2,H+2):
  for j in range(2,W+2):
    if S[i][j] == '.' and B[i][j] < 0:
      search(i, j, c)
      c += 1

Cc = B[Ch+1][Cw+1]
Dc = B[Dh+1][Dw+1]
dic = {i:set() for i in range(c)}

for i in range(2, H+2):
  for j in range(2, W+2):
    if B[i][j] >= 0:
      for x in range(-2, 3):
        for y in range(-2, 3):
          if S[i+x][j+y] == '.' and B[i][j] != B[i+x][j+y]:
            dic[B[i][j]].add(B[i+x][j+y])

ans = [-1 for i in range(c)]
ans[Cc] = 0
not_check = [1 for i in range(c)]
not_check[Cc] = 0
next_check = {Cc}
#
t = 0
while len( next_check ):
  t += 1
  tmp = set()
  for i in next_check:
    for j in dic[i]:
      if not_check[j]:
        not_check[j] = 0
        ans[j] = t
        tmp.add( j )
  next_check = {i for i in tmp}
#
print(ans[Dc])


Measured memory_bytes: 151424
#include<stdio.h>
int main()
{
    int a,b,c,count=0,i;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) cout<<(#x)<<":"<<x<<endl

// uf
int data[252];
void uf_init(int n){
  REP(i,n)data[i]=-1;
}
int uf_root(int x){
  return (data[x]<0?x:data[x]=uf_root(data[x]));
}
int uf_size(int x){
  return -data[uf_root(x)];
}
void uf_unite(int a,int b){
  a=uf_root(a);
  b=uf_root(b);
  if(a!=b){
    if(-data[a]<-data[b])swap(a,b);
    data[a]+=data[b];
    data[b]=a;
  }
}
bool uf_same(int a,int b){
  return uf_root(a)==uf_root(b);
}

int n,m;
pii h[252];
int mp[252][252];
const int INF = 830252521;

void solve(){
  REP(i,n){
    int x;
    scanf("%d",&x);
    h[i] = pii(x,i);
  }
  sort(h,h+n);
  reverse(h,h+n);
  REP(i,n)REP(j,n)mp[i][j]=INF;
  REP(i,m){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    --a;--b;
    mp[a][b] = min(mp[a][b],c);
    mp[b][a] = min(mp[b][a],c);
  }
  // REP(i,n){
  //   REP(j,n)printf("%10d",mp[i][j]);
  //   putchar('\n');
  // }
  uf_init(n);
  vi isl;
  ll ans = 0;
  int con[252];
  vector< pair<int,pii> > edges;
  // first : should connect or not
  REP(i,n){
    con[i] = 0;
    int x = h[i].second;
    REP(j,i){
      int y = h[j].second;
      if(mp[x][y]!=INF)
        edges.push_back(pair<int,pii>(mp[x][y],pii(x,y)));
    }
    if(i<n-1&&h[i].first==h[i+1].first){
      con[i] = -1;
      continue;
    }
    sort(ALL(edges));
    REP(j,edges.size()){
      int c = edges[j].first;
      int s = edges[j].second.first;
      int t = edges[j].second.second;
      if(!uf_same(s,t)){
        uf_unite(s,t);
      }
    }
    if(uf_size(x)==i+1){
      con[i]=1;
    }
    edges.clear();
  }
  int concon = 1;
  REP(_i,n){
    int i = n-1-_i;
    if(con[i]==-1)continue;
    if(con[i]==0)concon=0;
    con[i] = concon;
  }
  // second : let's connect
  uf_init(n);
  edges.clear();
  REP(i,n){
    int x = h[i].second;
    REP(j,i){
      int y = h[j].second;
      if(mp[x][y]!=INF)
        edges.push_back(pair<int,pii>(mp[x][y],pii(x,y)));
    }
    if(i<n-1&&h[i].first==h[i+1].first)continue;
    if(!con[i])continue;
    sort(ALL(edges));
    REP(j,edges.size()){
      int c = edges[j].first;
      int s = edges[j].second.first;
      int t = edges[j].second.second;
      if(!uf_same(s,t)){
        ans += c;
        uf_unite(s,t);
      }
    }
    edges.clear();
  }
  printf("%lld\n",ans);
}

int main(){
  while(true){
    scanf("%d%d",&n,&m);
    if(n==0 && m==0)break;
    solve();
  }
  return 0;
}

Measured memory_bytes: 1860
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()


int main() {
	
	ll N, Z, W;
	cin >> N >> Z >> W;
	vll a(N);	
	rep(i, N) cin >> a[i];

	if (N == 1) cout << abs(a[0] - W) << endl;
	else cout << max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1])) << endl;
}

Measured memory_bytes: 256
# C - XYZ Triplets
from collections import Counter


def main():
    N = int(input())
    calc = lambda x, y, z: x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    cnt = Counter(
        calc(i, j, k)
        for i in range(1, 101)
        for j in range(1, 101)
        for k in range(1, 101)
    )
    res = [cnt[i] for i in range(1, N + 1)]
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    main()


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

int main(int argc, char const *argv[]) {
  int n, rank;
  char suit;
  cin >> n;

  int card[4][13] = {};

  for (int i = 0; i < n; i++) {
    cin >> suit >> rank;
    switch (suit) {
      case 'S':
        card[0][rank - 1] = 1;
        break;
      case 'H':
        card[1][rank - 1] = 1;
        break;
      case 'C':
        card[2][rank - 1] = 1;
        break;
      case 'D':
        card[3][rank - 1] = 1;
        break;

      default:
        break;
    }
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (card[i][j] == 0) {
        switch (i) {
          case 0:
            cout << "S " << j + 1;
            break;
          case 1:
            cout << "H " << j + 1;
            break;
          case 2:
            cout << "C " << j + 1;
            break;
          case 3:
            cout << "D " << j + 1;
            break;

          default:
            break;
        }
        cout << endl;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3068
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 
 using namespace std;
 
 int arr[30+1]={0};
  
 int main()
 {
   for(int i=0;i<28;i++) 
   {
     int kk;
     cin>>kk;
     arr[kk]++;        
   }
   for(int i=1;i<=30;i++)
   {
     if(!arr[i]) cout<<i<<endl;         
   }
   //while(1);      
   return 0;    
 }

 

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;


int main(){  
  int n;
  cin >> n;
  if(n==1){
    cout << "Hello World" << endl;
    return 0;
  }
  int a,b;
  cin >> a >> b;
  cout << a+b << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#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;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

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

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

int main() {
  fast();
  cin >> n >> m;
  ll ans = 0, mx = 0, mn = 2e5;
  for (ll i = 0; i < m; ++i) {
    ll a, b;
    cin >> a >> b;
    mx = max(mx, a);
    mn = min(mn, b);
  }

  for (ll i = mx; i <= mn; ++i) ++ans;

  cout << ans;
  return 0;
}



Measured memory_bytes: 3652
fun solve(n:Int): Boolean {
    for (k in 1..n) {
        if (k*k==n)
            return true
        if (k*k>n)
            break
    }
    return false
}

fun main(args: Array<String>) {
    val (a,b) = readLine()!!.split(" ")
    val n = (a+b).toInt()

    val ans = if (solve(n)) "Yes" else "No"
    println(ans)
}

Measured memory_bytes: 36008
N=int(input())
A=list(map(int, input().split()))
D={}
E={}
for i in range(N):
  a=i+A[i]
  b=i-A[i]
  D.setdefault(a,0)
  E.setdefault(b,0)
  D[a]+=1
  E[b]+=1
ans=0
for i in D:
  if i in E:
    ans+=D[i]*E[i]
print(ans)

Measured memory_bytes: 56800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    string s; cin >> s;
    if(n%2!=0) {
        cout << "No" << endl;
        return 0;
    }
    string a="", b="";
    rep(i,n) {
        if(i<n/2) a+=s[i];
        else b += s[i];
    }
    if(a==b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
cor = [[0] * 2 for i in range(N)]

for i in range(M):
    p, s = input().split()
    p = int(p)
    if(cor[p-1][1] != 1):
        if s == "AC":
            cor[p-1][1] = 1
        elif s == "WA":
            cor[p-1][0] += 1

AC = 0
WA = 0
for i in range(N):
    if cor[i][1] == 1:
        AC += 1
        WA += cor[i][0]
print(AC, WA)

Measured memory_bytes: 13172
# a,pに値が代入される
a,p = map(int,input().split())

# a個の林檎が0の場合、pの欠片分で計算
if a == 0:
 print(p // 2)
# a個の林檎が0以外の場合、a個の林檎からできる欠片分とpの欠片分を足して計算
else:
  print(((a * 3) + p) // 2)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    long long X, Y; cin >> X >> Y;
    if (X % Y == 0) cout << -1 << endl;
    else cout << X << endl;
}


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

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  
  if ((a + W) < b) {
    cout << b - (a + W) << endl;
  }
  else if ((b + W) < a) {
    cout << a - (b + W) << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

int main() {
    cin>>N>>K>>S;
    if(K == 2 || K == 5){
        ll ans = 0;
        rep(i,N){
            ans += (i + 1) * ((S[i] - '0') % K == 0);
        }
        cout<<ans<<endl;
        return 0;
    }
    ll temp = 0, ten = 1;
    vec num(K, 0), v(1, 0);
    Rrep(i,N){
        ll c = S[i] - '0';
        (temp += c * ten)%=K;
        ++num[temp];
        v.push_back(temp);
        (ten *= 10)%=K;
    }
    ll ans = 0;
    /*rep(i,K) cout<<num[i]<<' ';
    cout<<endl;*/
    rep(i,N){
        ans += num[v[i]];
        //cout<<i<<' '<<ans<<endl;
        --num[v[i + 1]];
    }
    cout<<ans<<endl;
}

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

using namespace std;
long long x[200000];
long long sum[200000];
long long n,c,k;
set<long long>q;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i];
        //sum[i]=sum[i-1]+x[i];
        q.insert(x[i]);
    }
    if(q.size()==1)
    {
        cout<<n<<endl;
        return 0;
    }
    sort(x+1,x+1+n);
    for(int i=1;i<=n;i++)
    {
       // cin>>x[i];
        sum[i]=sum[i-1]+x[i];
     //   q.insert(x[i]);
    }
    int num=1;
    for(int i=n-1;i>=1;i--)
    {
        if(2*sum[i]>=x[i+1])
        {
            num++;
        }
        else
        {
            break;
        }
    }
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 6528
S=input()
N=len(S)
pos=[0 for _ in range(N)]
cnts=[1 for _ in range(N)]
for i in range(N):
  first_dir=S[i]
  if first_dir=='R':
    if i>0 and S[i-1]=='R':
      cnts[i]=cnts[i-1]-1
      continue
    while S[i+cnts[i]]=='R':
      cnts[i]+=1
  else:
    if i>0 and S[i-1]=='L':
      cnts[i]=cnts[i-1]-1
      continue
    while S[i-cnts[i]]=='L':
      cnts[i]+=1
    cnts[i]=-cnts[i]
for i in range(N):
  p=i+cnts[i]
  if abs(cnts[i])&1==1:
    p+=cnts[i]//abs(cnts[i])*(-1)
  pos[p]+=1
print(" ".join(str(p) for p in pos))

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

int main()
{

    int N;
    cin >> N;
    int s = 0, a, mn = 100;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        s += a;
        if (a % 10 != 0)
        {
            mn = min(mn, a);
        }
    }
    if (s % 10 != 0)
    {
        cout << s << endl;
    }
    else
    {
        if ((s - mn) % 10 != 0)
            cout << s - mn << endl;
        else
        {
            cout << 0;
        }
    }
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
ans=0
k=[0 for i in range(n)]
for i in range(max(h)):
  p=0
  for j in range(n):
    if h[j]>k[j]:
      k[j]+=1
      if p==0:
        ans+=1
      p=1
    elif h[j]==k[j]:
      p=0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    for(int i = 0; i < K; i++){
        cin >> D[i];
    }
    
    for(int money = N; money <= 10000000; ++money){
        int temp = money;
        vector<int> digit;
        while(temp > 0){
            digit.push_back(temp % 10);
            temp /= 10;
        }
        bool flag = true;
        for(int i = 0; i < digit.size(); ++i){
            for(int j = 0; j < K; ++j){
                if(digit[i] == D[j]){
                    flag = false;
                    break;
                }
            }
            if(!flag)       break;
        }
        if(flag){
            cout << money << endl;
            return 0;
        }
    }
}


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

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll M,D,ans;
int main(){
  cin >> M >> D;
  ans=0;
  for (ll i=1;i<=M;i++){
    for (ll j=1;j<=D;j++){
      ll j1=j/10; ll j2=j%10;
      if (j>10 && j1>=2 && j2>=2 && i==j1*j2) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
import sys

N, M = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(M)]
B = []

for i in range(M):
	if 1 in A[i]:
		B.append(A[i][1])
	elif N in A[i]:
		B.append(A[i][0])

C = set(B)

if len(C) == len(B):
	print("IMPOSSIBLE")
else:
	print("POSSIBLE")

Measured memory_bytes: 62584
#include <bits/stdc++.h>
    
#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;

int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int32_t main(){
    int n;
    cin >> n;
    vector<int> v(n);
    int sum=0;
    REP(i, n){
        cin >> v[i];
        sum+=v[i];
    }

    int s1=0, s2=sum, ans=INF;
    REP(i, n-1){
        s1+=v[i];
        s2-=v[i];
        ans=min(ans, abs(s1-s2));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
  int S, T, B;
  cin >> S;
  T = S / 100;
  B = S % 100;
  if ((T > 0 && T < 13) && (B > 0 && B < 13))
  {
    cout << "AMBIGUOUS" << endl;
  }else if(T > 0 && T < 13){
    cout << "MMYY" << endl;
  }else if(B > 0 && B < 13){
    cout << "YYMM" << endl;
  }else{
    cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, k;
    cin >> n >> k;
    ll l[n];
    rep(i, n) { cin >> l[i]; }

    sort(l, l + n, greater<ll>());

    ll sum = 0;
    rep(i, k) { sum += l[i]; }
    cout << sum << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

#define int long long
#define REP(i,n) for(int i=0;i<n;i++)

int n,a,b;

signed main(void){
    int f=0;
    int s=0;
    int u=1e9;
    cin>>n;
    REP(i,n){
        cin>>a>>b;
        s+=a;
        if(a>b){u=min(b,u);f=1;}
    }
    cout<<f*(s-u)<<endl;
}


Measured memory_bytes: 256