akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define outwp10(i) cout<<fixed<<setprecision(10)<<i<<"\n";

int main()
{
  int n;
  while(cin>>n)
  {
    if(n==0) return 0;
    vector<double> v(n);
    double sum = 0, var = 0;
    rep(i,n)
    {
      cin>>v[i];
      sum+=v[i];
    }
    sum/=n;
    rep(i,n)
    {
      var += pow(sum-v[i], 2);
    }
    cout << fixed << setprecision(10) << pow(var/n, 0.5) << "\n";
  }
}


Measured memory_bytes: 3404
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int T;cin >> T;
for(int t = 0;t <T; t++){
string N;cin>>N;
const int d = N.size();
int p=-1;
for(const char c:N){p+=c-'0';};
p/=9;
cout << ((p+d)%2==0?"Fabre wins.":"Audrey wins.") << endl;
}
return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int n,m;
const int MOD=1e9+7;

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

	cin>>n>>m;
	if(abs(n-m)>1) {
		cout<<0<<endl;
		return 0;
	}
	ll inu=1,saru=1;
	REP(i,min(n,m)) (inu*=(i+1))%=MOD,(saru*=(i+1))%=MOD;
	if(n>m) (inu*=n)%=MOD;
	else if(m>n) (saru*=m)%=MOD;
	if(n==m) cout<<(inu*saru*2)%MOD<<endl;
	else cout<<(inu*saru)%MOD<<endl;

	return 0;
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 1;
	ll tmp;
	int n, k; cin >> n >> k;
	ans *= k;
	REP(i, n-1) ans *= k-1;
	cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int a, b, c;
  int aa;
  set<int> st;
  for(c =0; c<=100000; c++){
    a = X - c;
    b = Y - c;
    st.insert(max(0, a)*A + max(0, b)*B + 2*c*C);
  }

  auto ans = st.begin();
  cout << *ans << endl;
  return 0;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int N = sc.nextInt();
    ArrayList<Integer> A = new ArrayList<Integer>();
    while(sc.hasNext()){
        A.add(sc.nextInt());
    }
    int[] right = new int[N];
    int max = 0;
    for(int i = 0;i < N-1;i++){
        if(i == N-2){
            right[i+1] = ((K - A.get(i+1)) + A.get(0)) ;
            // System.out.println("right[i+1]" + right[i+1]);
        }
        right[i] = A.get(i+1) - A.get(i);
        // System.out.println(A.get(i+1));
        // System.out.println(A.get(i));
    }   
    for(int i = 0;i < N-1;i++){
                if(max < Math.max(right[i+1],right[i]))
        max = Math.max(right[i+1],right[i]);
        // System.out.println("max" + max);
    }
    System.out.println(K - max);
  }
  
}

Measured memory_bytes: 94740
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int lastDigit=n%10;
  if(lastDigit==3){
    cout<<"bon"<<endl;
  }else if(lastDigit==0||lastDigit==1||lastDigit==6||lastDigit==8){
  cout<<"pon"<<endl;
  }else{
  cout<<"hon"<<endl;
  }


return 0;
}


Measured memory_bytes: 3552
#include <iostream>

using namespace std;

int N,M,L,R,i_min=-1,i_max=100010;
int main(){
  cin >> N >> M;
  for(int i=0;i<M;i++){
    cin >> L >> R;
    i_min=max(i_min,L);
    i_max=min(i_max,R);
  }
  cout << max(i_max-i_min+1,0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    vector<long long> dp(n + 2, 0);
    dp[0] = 2;
    dp[1] = 1;

    for (int i = 2; i <= n; ++i) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }

    cout << dp[n] << '\n';

    return 0;
}

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

int main(int argc, const char * argv[]) {
    string c;
    cin >> c;
    
    if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o") {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int N = 4001;
int dp[N][N];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s, t;
	while(1){
		cin >> s;
		if(cin.eof() || s == "0"){ break; }
		cin >> t;
		
		for(size_t i = 0; i < s.size(); ++i){
			for(size_t j = 0; j < t.size(); ++j){
				dp[i][j] = 0;
			}
		}
		
		int ans = 0;
		for(size_t i = 0; i < s.size(); ++i){
			for(size_t j = 0; j < t.size(); ++j){
				if(s[i] == t[j]){
					dp[i + 1][j + 1] = dp[i][j] + 1;
					ans = max(ans, dp[i + 1][j + 1]);
				}
				else
					dp[i + 1][j + 1] = 0;
			}
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 63744
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> h(n), dp(n+1);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

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

double dp[301][301][301];

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

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

        p[a]++;
    }

    dp[0][0][0] = 0;
    for (int i = 0; i <= p[3]; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                int l = i + j + k;
                if (l == 0) continue;
                if (l > n) break;
                double s = n;
                if (i > 0) s += dp[i - 1][j + 1][k] * i;
                if (j > 0) s += dp[i][j - 1][k + 1] * j;
                if (k > 0) s += dp[i][j][k - 1] * k;
                dp[i][j][k] = s / l;
            }
        }
    }

    printf("%.12f\n", dp[p[3]][p[2]][p[1]]);

    return 0;
}

Measured memory_bytes: 213248
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
 ll n,f=0;
 cin>>n;
 for(int i=1;i<=n;i++)
 {
    ll x;
    cin>>x;
    if(x%2==0)
    {
        if(x%3!=0&&x%5!=0)
            {f=1;}

    }
 }
 if(!f)
   cout<<"APPROVED"<<endl;
else
{
    cout<<"DENIED"<<endl;
} 

}
return 0;
}

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

int main() {
  int A, B, C, D, N;
  int k = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> A;
    B = A % 2;
    C = A % 3;
    D = A % 5;
    if (B == 1 || C == 0 || D == 0)
      continue;
    cout << "DENIED" << endl;
    k = 1;
    break;
  }
  if (k == 0)
    cout << "APPROVED" << endl;
  return 0;
}

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

using namespace std;

int main(){
	int N, t, a;
	unsigned long long int m, mt, ma, pre_t, pre_a;

	cin>>N;
	cin>>t>>a;
	pre_t=t;
	pre_a=a;
	for(int i=1; i<N; i++){
		cin>>t>>a;
		mt=(pre_t%t==0)?pre_t/t:pre_t/t+1;
		ma=(pre_a%a==0)?pre_a/a:pre_a/a+1;
		m=max(mt, ma);
		pre_t=t*m;
		pre_a=a*m;
	}
	cout<<pre_t+pre_a<<endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

int main(){
	unsigned N = 0;
	std::cin >> N;
	std::vector<int> A(N), B(N), C(N);
	for(int i = 0; i < N; ++i)
		std::cin >> A[i];
	for(int i = 0; i < N; ++i)
		std::cin >> B[i];

	uint64_t greater = 0, lesser = 0, odds = 0;
	for(int i = 0; i < N; ++i)
		if(A[i] > B[i]) greater += A[i] - B[i];
		else lesser += B[i] - A[i], odds += (B[i] - A[i]) % 2;
	std::cout << (2*greater + odds <= lesser ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 384
N, K = map(int, input().split())
A = list(map(int, input().split()))
import fractions

if K > max(A):
    print('IMPOSSIBLE')
else:
    g = A[0]
    for i in range(N - 1):
        g = fractions.gcd(g, A[i + 1])
    #print(g)

    ok = False
    for val in A:
        if val >= K and (val - K) % g == 0:
            ok = True
    if ok:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


Measured memory_bytes: 82196
import java.util.*;    
public class Main{
      public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        char a = sc.next().charAt(0);
        if (Character.isUpperCase(a)){
    		System.out.println('A');
        }
        else{
          System.out.println('a');
        }
      }
    }

Measured memory_bytes: 35572
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

long long n,k;
long double p[25],ans;

void get_p()
{
    p[0]=1;
    for (int i=1;i<=20;i++)
    {
        p[i]=p[i-1]*0.5;
    }
}

int get_cnt(long long x)
{
    int re=0;
    while (x<k)
    {
        x*=2;
        re++;
    }
    return re;
}

int main()
{
    get_p();
    scanf("%lld%lld",&n,&k);
    for (int i=1;i<=min(n,k-1);i++)
    {
        int cnt=get_cnt(i);
        ans+=(1.0/n)*p[cnt];
    }
    if (n>=k)
    {
        ans+=(n-k+1)/(long double)n;
    }
    printf("%0.12Lf",ans);
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 128
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

lf dp[MAXn];


int main()
{
    IOS();
    dp[0] = 1;
    ll n;
    cin>>n;
    REP(i,n)
    {
        lf p;
        cin>>p;
        for(int i = n;i >= 0;i--)
        {
            if(i)dp[i] = p * dp[i-1] + (1-p) * dp[i];
            else dp[i] = (1-p) * dp[i];
        }
    }
    lf ans = 0;
    REP1(i,n)if(2 * i >= n)ans += dp[i];
    cout<<fixed<<setprecision(12)<<ans<<endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;
typedef long long ll;

struct st {
	ll b, c;
} x[N];
ll n, m, ans, a[N], y[N];

bool cmp(st p, st q) {
	return p.c > q.c;
}

int main() {
	int i, j, k;
	cin >> n >> m;
	for(i=0; i<n; i++) scanf("%lld", &a[i]);
	sort(a, a+n);
	for(i=0; i<m; i++) scanf("%lld%lld", &x[i].b, &x[i].c);
	sort(x, x+m, cmp);
	for(i=k=0; i<m; i++) {
		for(j=0; j<x[i].b && k<n; j++, k++) {
			y[k] = x[i].c;
		}
	}
	for(i=0; i<n; i++) ans += max(a[i], y[i]);
	cout << ans;
	return 0;
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

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

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int n;
int inp[N];

int ans[1234][1234];

int main(){
    fastScan(n);
    if(n == 1){
        puts("Yes");
        puts("2");
        puts("1 1");
        puts("1 1");
        return 0;
    }
    int flag = 0, col = 0, r, c;
    for(int i = 2; i <= 10000; i++){
        if((i * (i + 1)) / 2 == n){
            flag = 1;
            col = i;
            r = i + 1; c = i;
            break;
        }
    }
    if(flag == 0){
        puts("No");
        return 0;
    }
    int x = 1, y = 1, nn = 1;
    while(nn <= n){
        for(int i = y, j = nn; i <= y + col - 1; i++, j++){
            ans[x][i] = j;
        }
        for(int i = x + 1, j = nn; i <= x + col; i++, j++){
            ans[i][y] = j;
            nn++;
        }
        col--;
        x++; y++;
    }
    puts("Yes");
    printf("%d\n", r);
    for(int i = 1; i <= r; i++){
        printf("%d", c);
        for(int j = 1; j <= c; j++){
            printf(" %d", ans[i][j]);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 5504
import java.util.*;

public class Main {

  static Scanner in = new Scanner(System.in);
	int[] a, b, c;
	void solve() {
		int n = in.nextInt();
		a = new int[n]; b = new int[n]; c = new int[n];
		for(int i = 0; i < n; i++) a[i] = in.nextInt();
		for(int i = 0; i < n; i++) b[i] = in.nextInt();
		for(int i = 0; i < n; i++) c[i] = in.nextInt();
		Arrays.sort(a); Arrays.sort(b); Arrays.sort(c);
		long sum = 0;
		for(int i = 0; i < n; i++){
			long t = search_small(a, b[i]);
			long s = search_big(c, b[i]);
			s = s <= 0 ? n + s : n - s - 1; 
			sum += s * t;
		}
		System.out.println(sum);
	}

  int search_small(int[] x, int key){
	  int left = 0, right = b.length;
	  while(left < right){
		   int mid = (left + right) / 2;
		   if(x[mid] == key && mid > 0 && x[mid - 1] != key) return mid;
		   else if(key <= x[mid]) right = mid;
		   else left = mid + 1;
	  }
	  return left;
  }
  int search_big(int[] x, int key){
	int left = 0, right = b.length;
	while(left < right){
		 int mid = (left + right) / 2;
		 if(x[mid] == key && mid < x.length - 1 && x[mid + 1] != key) return mid;
		 else if(key < x[mid]) right = mid;
		 else left = mid + 1;
	}
	return -1 * left;
}
  
  public static void main(String[] args) {
	  new Main().solve();
  }
}

Measured memory_bytes: 97752
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

u64 nCr(u64 n, u64 r) {
    u64 a = 1, b = 1;
    for (u64 i = 1; i <= r; i++) {
        a *= (n - i + 1); b *= i;
    }
    return a / b;
}

void Main() {
    i32 N;
    cin >> N;
    map<string, i64> S;
    for (i32 i = 0; i < N; i++) {
        string s;
        cin >> s;
        sort(ALL(s));
        if (S.find(s) != S.end()) S[s]++;
        else S.insert(make_pair(s, 1));
    }
    i64 sum = 0;
    for (auto&& x: S) {
        if (x.second != 1) sum += nCr(x.second, 2);
    }
    cout << sum << endl;
}


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

using namespace std;

#define maxn 200005
#define ll long long int
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<<endl
#define IN freopen("input.txt","r",stdin)

const int N = (int)2e5+5;
ll ara[N] , csum[N];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN;
    ll n ,k;
    cin >> n >> k;
    for(int i = 1;  i <= n; i++){
        cin >> ara[i];
    }
    csum[1] = ara[1];
    for(int i = 2 ; i <= n; i++){
        csum[i] = csum[i-1] + ara[i];
    }
    map< ll , ll > mp;
    mp[ 0 ] = 1LL;
    ll ans = 0LL;
    for(int i = 1; i <= n; i++){
        if( (i-k) >=0 ){
            mp[ (csum[i-k] - i + k ) % k ]--;
        }
        ans+=mp[ (csum[i] - i + k ) % k];
        mp[ (csum[i] - i + k ) % k]++;
    }
    cout<< ans << "\n";
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ses   "\n"
#define whp   " "
#define mxi 99999

#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define PI acos(-1)
#define sz(a) long long(a.size())
#define ff first
#define ss second
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)

#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)

#define MS(a,b) memset(a,b,sizeof(a));

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll fx[4]= {1,-1,0,0};
ll fy[4]= {0,0,1,-1};

typedef vector<ll> vll;
typedef vector<string> vss;
typedef vector<pair<ll,ll > > vpr;
typedef vector<pair<string,ll > > vspr;
typedef list<ll> li;
typedef list<string> ls;
typedef list<pair<ll,ll> > lpr;
typedef list<pair<string,ll> > lspr;


bool rs(ll a, ll b){return(a>b);}
int main()
{

    map<ll,ll>m;
    ll n,c1=0,c2=0,c3=0,c4=0;
    cin>>n;
    for(ll i=0; i<n; i++){
        string s; cin>>s;
        if(s=="AC")c1++;
        if(s=="WA")c2++;
        if(s=="TLE")c3++;
        if(s=="RE")c4++;
    }
    cout<<"AC x "<<c1<<endl;
    cout<<"WA x "<<c2<<endl;
    cout<<"TLE x "<<c3<<endl;
    cout<<"RE x "<<c4<<endl;


return 0;
}


Measured memory_bytes: 3628
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val v = List.fill(n)(sc.nextLong)
  val c = List.fill(n)(sc.nextLong)

  val ans = (v zip c).map(p => max(p._1 - p._2, 0L)).sum

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 27344
#include"iostream"
using namespace std;
int search(int a[], int n, int key);
int main()
{
	int m, n,i,k=0;
	cin >> m;
	int* a = new int[m];
	for (i = 0; i < m; ++i)
		cin >> a[i];
	cin >> n;
	int* b = new int[n];
	for (i = 0; i < n; ++i)
	{
		cin >> b[i];
		if (search(a, m, b[i]))++k;
	}
	cout << k << endl;
	return 0;
}
int search(int a[], int n, int key)
{
	int i;
	for (i = 0; i < n; ++i)
		if (a[i] == key)break;
	return i != n;
}


Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
using namespace std;
static const uint64_t MOD = 1000000007LL;
// uint64_t dp[100005][13];

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

    map<long, long> m;
    for (int i = 0; i < n; i++) {
        long a, b;
        cin >> a >> b;
        m[b] += a;
    }

    long t = 0;
    for (auto e: m) {
        long duration = e.second;
        long deadline = e.first;
        if (t + duration > deadline) {
            cout << "No" << endl;
            return 0;
        }
        t += duration;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 12800
import re
class Num:
    def __str__(self):
        return str(self.x)
    def __init__(self, value):
        self.x = value
    def __add__(self, value):
        return Num(self.x + value.x)
    def __sub__(self, value):
        return Num(self.x - value.x)
    def __mul__(self, value):
        return Num(self.x * value.x)
    def __truediv__(self, value):
        return Num(int(self.x / value.x))

N = int(input())
for i in range(N):
    s = input()[:-1]
    s = re.sub(r'(\d+)',r'Num(\1)',s)
    print(eval(s))


Measured memory_bytes: 6608
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	char buf[200];

	scanf("%s",buf);

	int ans = 0;

	for(int i = 0; buf[i] != '*'; i++){
		if(buf[i] == '('){
			ans++;
		}else{ //buf[i] == ')'
			ans--;
		}
	}

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

	return 0;
}

Measured memory_bytes: 3204
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int d,n;
  cin >> d >> n;

  if (d == 1){
    if (n == 100){
      cout << 10100 << '\n';
      return 0;
    }
    
    cout << 100 * n << '\n';
    return 0;
  }
  if (d == 2){
    if (n == 100){
      cout << 1010000 << '\n';
      return 0;
    }
    
    cout << 10000*n << '\n';
    return 0;
  }
  
  if (n != 100){
    cout << n << '\n';
  }else{
    cout << 101 << '\n';
  }
  
  
  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> P;

int main(){
  int N;
  while(cin>>N){
    vector<P> v(N);
    REP(i,N)cin>>v[i].second>>v[i].first;
    sort(v.begin(), v.end());
    priority_queue<int> que;
    int time = 0;
    REP(i,N){
      que.push(v[i].second);
      time += v[i].second;
      while(!que.empty() && time > v[i].first){
        time -= que.top();
        que.pop();
      }
    }
    cout<<que.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int  H, W;
    cin >> H >> W;

    char S[H][W];
    char A[H][W];
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cin >> S[i][j];
        }
    }

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            int count = 0;

            if (S[i][j] == '#'){
                A[i][j] = '#';
            }
            
            else if (S[i][j] == '.'){
                if (i - 1 >= 0 && S[i-1][j] == '#'){
                    count++;
                }
                if (i + 1 < H && S[i+1][j] == '#'){
                    count++;
                }
                if (j - 1 >= 0 && S[i][j-1] == '#'){
                    count++;
                }
                if (j + 1 < W && S[i][j+1] == '#'){
                    count++;
                }
                if (i - 1 >= 0 && j - 1 >= 0 && S[i-1][j-1] == '#'){
                    count++;
                }
                if (i + 1 < H && j - 1 >= 0 && S[i+1][j-1] == '#'){
                    count++;
                }
                if (i - 1 >= 0 && j + 1 < W && S[i-1][j+1] == '#'){
                    count++;
                }
                if (i + 1 < H && j + 1 < W && S[i+1][j+1] == '#'){
                    count++;
                }
                A[i][j] = char('0' + count);
            }
        }
    }

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << A[i][j];
            if (j == W - 1){
                cout << endl;
            }
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;

double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll A,B;
	cin>>A>>B;
	cout<<A*B<<endl;
}

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


typedef unsigned long long int ulint;

int main(){
  ulint N;
  cin >> N;

  vector<ulint> a;
  for (int i = 0; i < N; ++i) {
    ulint in;
    cin >> in;
    a.push_back(in);
  }

  if (find(a.begin(), a.end(), 1) == a.end()) {
    cout << -1 << endl;
    return 0;
  }

  ulint k = 1;
  
  for (int i = 0; i < N; ++i) {
    // cout << "k=" << k << " i=" << i << endl;
    if (a[i] == k) {
      ++k;
    }
  }
  
  --k;
  
  // cout << "k=" << k << endl;

  cout << N - k << endl;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define fs first
#define sc second

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// 1次元vectorの出力
template <class S>
void print(vector<S> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    cerr << v[i] << ' ';
  }
  cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    for (ll j = 0; j < (ll)v[i].size(); j++) {
      cerr << v[i][j] << ' ';
    }
    cerr << endl;
  }
}

int main(void) {
	int n,k;
	cin >> n >> k;
	mint ans;
	vector<mint> c(k+1);
	for(int i=k; i>0; i--){
		c[i] = mint(k/i).pow(n);
		int tmp = i;
		while(1){
			tmp+=i;
			if(tmp > k) break;
			c[i] -= c[tmp];
		}
		ans += c[i]*i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
long long arr[300005];
long long psum[300005];
int main(){
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>arr[i];
	for(int i=1; i<=n; i++) arr[i+n] = arr[i];
	for(int i=1; i<=2*n; i+=2) arr[i]*=-1;
	for(int i=1; i<=2*n; i++) psum[i]+=psum[i-1]+arr[i];
	for(int i=1; i<=n; i++){
		int fin = i+n-1; 
		long long total = psum[fin]-psum[i-1];
		if(i%2) cout<<total*-1<<" ";
		else cout<<total<<" ";
	}
}

Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
int main() {
	int A, B; 
    cin >> A >> B;
    for(int x=1; x<10001; ++x) {
        int a = x * 8 / 100;
        int b = x * 10 / 100;
        if (a == A && b == B) {
            cout << x << endl;
			return 0;
		}
	}
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
bool pri(int p) {
  if(p<2) return false;
  for(int i=2;i<=sqrt(p);i++) {
    if(p%i==0) return false;
  }
  return true;
}
signed main() {
  int n;
  cin>>n;
  int cnt=1;
  rep(i,55555) {
    if(pri(i)) {
      if(i%5==1) {
        if(cnt<n) {
          cout<<i<<" ";
          cnt++;
        }
        else {
          cout<<i<<endl;
          break;
        }
      }
    }
  }
}

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

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
 
 int n;
 vector<vi> arr,dp;

 int go(int idx, int p){
	 if(idx >= n) return 0;
	 if(dp[idx][p] != -1) return dp[idx][p];
	 //~ if(p1 == p2){
		 //~ if(p1==0){
			 //~ return max(go(idx+1,0,1)+arr[idx][1], go(idx+1,0,2)+arr[idx][2]);
		 //~ }
		 //~ else if(p1 == 1){
			 //~ return max(go(idx+1,1,0)+arr[idx][0], go(idx+1,1,2)+arr[idx][2]);
		 //~ }
		 //~ else{
			 //~ return max(go(idx+1,2,0)+arr[idx][0], go(idx+1,2,1)+arr[idx][1]);
		 //~ }
	 //~ }
	 
	 return dp[idx][p] = max(go(idx+1,(p+1)%3)+arr[idx][(p+1)%3], go(idx+1, (p+2)%3)+arr[idx][(p+2)%3]);
	 
 }
 
int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	//srand (time(NULL));
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
    
   
	int1(n);
	
	fors(i,0,n){
		lli a,b,c;
		lint3(a,b,c);
		vi tmp,tmp1(3,-1);
		dp.pb(tmp1);
		tmp.pb(a);
		tmp.pb(b);
		tmp.pb(c);
		arr.pb(tmp);
	}
	cout<<(max(max(arr[0][0]+go(1,0),arr[0][1]+go(1,1)),arr[0][2]+go(1,2)));
	
    return 0;
}


Measured memory_bytes: 18144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
ll mod = 1e9 + 7;

ll memo[2005];

ll solve(ll n) {
  if (n == 1 || n == 2) {
    return 0;
  }
  if (n == 3 || n == 4) {
    return 1;
  }

  if (memo[n] != 0) {
    return memo[n];
  }

  
  return memo[n] = (solve(n - 1) % mod + solve(n - 3) % mod) % mod;
}
int main() {
  int n;
  cin >> n;
  memo[0] = memo[1] = 0;
  memo[2] = memo[3] = 1;

  cout << solve(n) << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 500'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  int64 x, k, d;
  cin >> x >> k >> d;
  if (x > 0) {
    d = -d;
  }
  int64 v = min(k, -x / d);
  k -= v;
  int64 ans = x + d * v;
  if (k & 1) {
    ans += d;
  }
  cout << abs(ans) << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

struct edge {Int to, cost;};
const int MAX_V = 110000;
vector<edge> G[MAX_V];
Int d[MAX_V];
int V;

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V, LINF);
    d[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

Int ans[110000];

int main() {
    cin >> V;
    rep(i,V-1) {
        Int u, v, c;
        cin >> u >> v >> c;
        u--, v--;
        edge e1 = {u, c};
        G[v].push_back(e1);
        edge e2 = {v, c};
        G[u].push_back(e2);
    }
    int q, k;
    cin >> q >> k;
    k--;
    dijkstra(k);
    rep(i,q) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        ans[i] = d[x] + d[y];
    }
    rep(i,q) cout << ans[i] << endl;
}

Measured memory_bytes: 11376
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S = readline().rstrip().decode('utf-8')

def solve_partial(S):
    INF = 10**18
    """
    ・Sは1から始まり、1で終わる
    ・Sは00を含まない
    ・したがって、Sは1,01に分解可能
    ・残る最小個数を調べるdp。これは、1, 101111,111101 の3種を数えることと同じ
    ・a, b0cccc, dddd0e として、「現在の1がどれであるか -> 最小個数」でdp
    ・個数はa,b,eのときに数える
    """
    S = S.replace('01','2')
    a,b,c,d,e = 1,1,INF,0,INF
    for x in S[1:]:
        if x == '1':
            a2 = min(a,c,e)+1
            b2 = min(a,c,e)+1
            c2 = c
            d2 = min(a,c,d,e)
            e2 = INF
        else:
            a2 = min(a,c,e)+1
            b2 = min(a,c,e)+1
            c2 = b
            d2 = min(a,c,e)
            e2 = d+1
        a,b,c,d,e = a2,b2,c2,d2,e2
    return len(S)-min(a,c,e)

answer = 0
for x in S.split('00'):
    x = x.strip('0')
    if x:
        answer += solve_partial(x)

print(answer)

Measured memory_bytes: 8360
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::u128;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<f64>();
    let a1 = line[0] as u128 /100*100;
    let a2 = line[0] as u128%100;
    let b = line[1];
    let b1 = (line[1] as f64).floor() as u128;
    let b2 = (line[1] *100.0+0.00000001) as u128%100;

    // dbg!(a1);
    // dbg!(a2);
    // dbg!(b);
    // dbg!(b1);
    // dbg!(b2);
    //println!("{}", ans_int + ans_f);
    println!("{}",
             a1*b1+b1*a2+(a1/100*b2) + (b2*a2/100)
    );
}


Measured memory_bytes: 2696
//区間加算、区間min

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;


class LazySegmentTree {
public:
    int N;
    vector<ll> node, lazy;
    ll INF = (1LL << 60);

    LazySegmentTree(int _N, ll *a) {
        N = 1;
        while(N < _N) N *= 2;
        node.resize(2 * N - 1, INF);
        lazy.resize(2 * N - 1, 0);

        for(int i = 0; i < _N; i++){
            int k = i + N - 1;
            node[k] = a[i];
        }
        for(int i = N - 2; i >= 0; i--) {
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    LazySegmentTree(vector<ll> a) {
        int sz = a.size();
        N = 1;
        while(N < sz) N *= 2;
        node.resize(2 * N - 1, INF);
        lazy.resize(2 * N - 1, 0);

        for(int i = 0; i < sz; i++){
            int k = i + N - 1;
            node[k] = a[i];
        }
        for(int i = N - 2; i >= 0; i--) {
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    //[a, b) に c に加算
    void update(int a, int b, ll c) {
        Update(a, b, c, 0, 0, N);
    }

    void Update(int a, int b, ll c, int k, int l, int r) {
        eval(k, l, r);

        //範囲外
        if(b <= l || r <= a) return;

        //完全被覆
        else if(a <= l && r <= b) {
            lazy[k] = c;
            eval(k, l, r);
        }

        //一部被覆
        else {
            Update(a, b, c, 2 * k + 1, l, (l + r) / 2);
            Update(a, b, c, 2 * k + 2, (l + r) / 2, r);
            node[k] = min(node[2 * k + 1], node[2 * k + 2]);
        }

        return;
    }

    //[a, b)のmin
    ll query(int a, int b) {
        return Query(a, b, 0, 0, N);
    }

    ll Query(int a, int b, int k, int l, int r) {
        eval(k, l, r);

        //範囲外
        if(b <= l || r <= a) return INF;

        //完全被覆
        else if(a <= l && r <= b) {
            return node[k];
        }

        //一部被覆
        else {
            ll v1 = Query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll v2 = Query(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(v1, v2);
        }
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2 * k + 1] += lazy[k];
                lazy[2 * k + 2] += lazy[k];
            }
            lazy[k] = 0;
        }
        return;
    }
};

int main(){
    int N, Q;
    cin >> N >> Q;
    ll a[N];
    fill(a, a + N, 0);

    vector<ll> ans;

    LazySegmentTree sg = LazySegmentTree(N, a);
    for(int q = 0; q < Q; q++) {
        int id, s, t, x;
        cin >> id;

        if(id == 0) {
            cin >> s >> t >> x;
            sg.update(s, t + 1, x);
        }
        else {
            cin >> s >> t;
            ans.push_back(sg.query(s, t + 1));
        }
    }

    for(ll val : ans) {
        cout << val << endl;
    }

    return 0;
}


Measured memory_bytes: 8772
#include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

int main() {
int n, x;

while (1) {
cin >> n >> x;

if (n == 0 && x == 0) return 0;

    int cnt = 0;
for (int i = 1; i <= n; i++) {
for (int j = i+1; j <= n; j++) {
for (int k = j+1; k <= n; k++) {
if (i + j + k == x) cnt++;
}
}
}
cout << cnt << endl;
}


return 0;
}



Measured memory_bytes: 3092
using System;
using System.Linq;
class program{
  static void Main(){
    int k = int.Parse(Console.ReadLine());
    var wr = Console.ReadLine();
    int rct = wr.Count(c => c == 'R');
    int ans = rct;
    for(int i = 0;i < rct; i++){
      if(wr[i] == 'R') ans--;
    }
    Console.Write(ans);
  }
}

Measured memory_bytes: 28692