akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dp[320][32];
ll get(vector<int>v, int c, int s)
{
	for (int i = 0; i < 320; i++)for (int j = 0; j < 32; j++)dp[i][j] = 0;
	dp[0][0] = 1;
	int num = v.size();
	for (int i = 0; i < c*(num + 1); i++)
	{
		int t = i % (num + 1) - 1;
		if (t == -1)continue;
		for (int j = 0; j < i; j++)
		{
			for (int k = 0; k < (1 << num); k++)
			{
				if (k&(1 << t))continue;
				if (j < i - (num + 1)*v[t])dp[j][k + (1 << t)] += dp[j][k];
				else dp[i][k + (1 << t)] += dp[j][k];
			}
		}
	}
	ll ans = 0;
	for (int i = (c - s)*(num + 1); i <= 320; i++)
	{
		//if (dp[i][(1 << num) - 1]>0)printf("%d %lld\n", i, dp[i][(1 << num) - 1]);
		ans += dp[i][(1 << num) - 1];
	}
	//for (int i = 0; i < v.size(); i++)printf("%d ", v[i]);
	//printf("%lld\n", ans);
	return ans;
}
int main()
{
	int num, len;
	scanf("%d%d", &num, &len);
	vector<int>v;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		v.push_back(z);
	}
	sort(v.begin(), v.end());
	int s = v[v.size() - 1];
	v.pop_back();
	ll sum = 0;
	ll cnt = 0;
	for (;;)
	{
		sum += get(v, len, s);
		cnt++;
		if (!next_permutation(v.begin(), v.end()))break;
	}
	for (int i = 0; i < num - 1; i++)cnt *= len;
	printf("%.20lf\n", double(sum) / double(cnt));
}

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

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

    char r[4] = {};

    int f = 1;
    for (int h = 0; h < m; h++) {
        int s, c;
        cin >> s >> c;
        s--; c += '0';

        if (r[s] && r[s] != c) f = 0;
        r[s] = c;
    }

    if (n > 1 && r[0] == '0') f = 0;
    if (n == 1 && !r[0]) r[0] = '0';
    if (!r[0]) r[0] = '1';
    for (int i = 1; i < n; i++) {
        if (!r[i]) r[i] = '0';
    }

    if (f) {
        cout << r << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main
{
	public static void main(String args[]) throws IOException
	{
		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		
		int S = Integer.parseInt(str);
		
		int h = S/3600;
		int m =	(S-h*3600)/60;
		int s = (S-h*3600-m*60);
		
		System.out.println(h+":"+m+":"+s);
	}
}

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

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

    for( int i = 1; i <= n; i++ )
    {
        cout << m[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 13004
#include <bits/stdc++.h>
using namespace std;
int n, a[100005], ans;
inline bool cmp(const int &a, const int &b) {return a > b;}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n, cmp);
	for (int i = 1; i <= n; i ++)
		if (i + 1 > a[i + 1])
		{
			for (int j = i + 1; a[j] == i; j ++) ans ^= 1;
			ans |= (a[i] - i) & 1;
			puts(ans ? "First" : "Second");
			return 0;
		}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl "\n"
#include <set>


using namespace std;
int main(){
    
ios_base::sync_with_stdio(false);
    cin.tie(NULL);    

int n, w; cin>>n>>w;
vector <long long int> a,values;
for (int i=0; i<n; i++)
{
	long long int temp1, temp2;
	cin>>temp1>>temp2;
	a.push_back(temp1);
	values.push_back(temp2);
}

long long int dp[w+1][n];
for (int j=0; j<n; j++)
{
	for (long long int i=0; i<w+1; i++)
	{
		dp[i][j]=-1;
	}
}
dp[0][0]=0;
dp[a[0]][0]=values[0];

for (int j=0; j<n-1; j++)
{
	for (long long int i=0; i<w+1; i++)
	{
		if (dp[i][j] != -1)
		{
			dp[i][j+1]=max (dp[i][j+1], dp[i][j]);
			
			if (i+a[j+1]<=w)
			{
				dp[i+a[j+1]][j+1] = max(dp[i+a[j+1]][j+1],  dp[i][j]+values[j+1]);
			}
		}
	}
}
long long int ans=-1;
for (long long int i=0; i<=w; i++)
{
	ans=max(ans, dp[i][n-1]);
}

cout<<ans<<endl;
}
	
	

Measured memory_bytes: 78336
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>

using namespace std;
int main(){

string s;
cin >>s;
int n=s.length();
int count =0;
for(int i=0 ; i<n-1;i++){
  if(s[i]!=s[i+1])count++;
}
cout <<count<<endl;
}


Measured memory_bytes: 512
import math
while True:
    a, op, b = map(str, input().split())
    a, b = int(a), int(b)
    if op=='+':
        print(math.floor(a+b))
    elif op=='-':
        print(math.floor(a-b))
    elif op=='*':
        print(math.floor(a*b))
    elif op=='/':
        print(math.floor(a/b))
    else:
        break

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

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

const long long MOD = 1000000007;

int main(){
  int n,cnt;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  //vector<int> cnt(n,0);
  set<int> ans;
  for(int i=n-1;i>=0;i--){
    cnt=0;
    for(int j=1;(i+1)*j<=n;j++){
      if(ans.count((i+1)*j)) cnt++;
    }
    if(cnt%2!=a.at(i)) ans.insert(i+1);
  }
  cout << ans.size() << endl;
  if(ans.size()){
    for(int x:ans){
      cout << x << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 7808
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll ans = 1000;
  ll st = 0;
  for(int i = 0; i < n - 1; i++) {
    if(a[i] > a[i + 1]) {
      ans += a[i] * st;
      st = 0;
    }else if(a[i] < a[i + 1]){
      st += ans / a[i];
      ans %= a[i]; 
    }
  }
  ans += a[n - 1] * st;
  st = 0;
  cout << ans << endl;
  return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T min_index(const vector<T>& v) {
    return distance(v.begin(), min_element(v.begin(), v.end()));
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

template<class T> T max_index(const vector<T>& v) {
    return distance(v.begin(), max_element(v.begin(), v.end()));
}

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

    int N = next<int>(), M = next<int>();
    auto A = next<vector<int>>(N), score = vector<int>(N, 0);

    times(M, j) {
        int B = next<int>();
        times(N, i) if(A[i] <= B) {
            score[i]++;
            break;
        }
    }
    #ifdef debug
        cout << score ln;
    #endif

    cout << max_index(score) + 1 ln;

    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    cout << n/2 + (n%2) << endl;
}

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

int main() {
    uint32_t n, q;
    uint64_t s = 0;
    map<uint32_t, uint32_t> a;

    cin >> n;
    for (uint32_t i = 0; i < n; ++i) {
        uint32_t a_; cin >> a_;
        ++a[a_];
        s += a_;
    }
    cin >> q;

    while (q--) {
        uint32_t b, c;
        cin >> b >> c;

        if (auto it = a.find(b); it != a.end()) {
            s -= it->second * b;
            s += it->second * c;
            a[c] += it->second;
            a.erase(it);
        }

        cout << s << endl;
    }
}


Measured memory_bytes: 6596
#include <iostream>
#include <bitset>
#include <map>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
using namespace std;

int main() {

    int N, M;
    cin >> N >> M;
    
    if(N > M){
        cout << "safe" << endl;
    }
    else{
        cout << "unsafe" << endl;
    }
    return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
 
const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;
 
int main() {
  int x, a;
  cin >> x >> a;

  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N;

int main() {
    cin >> N;
    vector<int> A(N);
    map<int, int> m;
    REP(i, N) {
        cin >> A.at(i);
        m[A[i]]++;
        m[A[i] - 1]++;
        m[A[i] + 1]++;
    }

    int ans = 0;
    for (auto i : m) {
        chmax(ans, i.second);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
    int key;
    struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

struct Node *find(struct Node *u,int k){
    while(u != NIL && k != u->key){
        if(k < u->key)
            u=u->left;
        else
            u=u->right;
    }
    return u;
}

void insert(int k){
    struct Node *y=NIL;
    struct Node *x=root;
    struct Node *z;

    z=(struct Node *)malloc(sizeof(struct Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x != NIL){
        y=x;
        if(z->key < x->key){
            x=x->left;
        }
        else
            x=x->right;
    }
    z->parent=y;
    if(y==NIL)
        root=z;
    else{
        if(z->key < y->key)
            y->left=z;
        else
            y->right=z;
    }
}

void inorder(struct Node *u){
    if(u==NIL)
        return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(struct Node *u){
    if(u==NIL)
        return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main(void){
    int n,i,x;
    char line[7];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",line);
        if(!strcmp(line,"insert")){
            scanf("%d",&x);
            insert(x);
        }
        else if(!strcmp(line,"print")){
            inorder(root);
            puts("");
            preorder(root);
            puts("");
        }
        else{
            scanf("%d",&x);
            struct Node *temp=find(root,x);
            if(temp != NIL)
                puts("yes");
            else puts("no");
        }
    }
    return 0;
}

Measured memory_bytes: 19360
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
	// your code goes here
	int x,y;
	cin >> x >> y;
	if(y>x*4 || y<x*2){
	    cout << "No" << endl;
	    return 0;
	}
	if(y%2!=0){
	    cout << "No" << endl;
	    return 0;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		int a = 0;
		int b = 0;
		int t = 0;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(
				System.in))) {
			String[] tmp = br.readLine().split("\\s");
			a = Integer.parseInt(tmp[0]);
			b = Integer.parseInt(tmp[1]);
			t = Integer.parseInt(tmp[2]);
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}

		int sum = 0;
		for (int i = 1; i <= t; i++) {
			if (i % a == 0) {
				sum += b;
			}
		}

		System.out.println(sum);
	}

}

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

struct ca
{
  int idx,st,et,aidx;
};

int prime[1000001]={};

long power(long x,  long y, long p)  
{  
    long res = 1;     
  
    x = x % p; 
   
    if (x == 0) return 0; 
  
    while (y > 0)  
    {  
         
        if (y & 1)  
            res = (res*x) % p;  
  
        
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  

void pr()
{
  prime[1]=0;

 for(int i=2;i*i<1000001;i++)
  if(prime[i]==0)
  for(int j=i*i;j<1000001;j+=i)
  prime[j]=1;

}

int countSetBits( int n) 
{ 
     int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
  
bool cmp1(ca c1,ca c2)
{
  if(c1.st<c2.st)
   return true;

  if(c1.st==c2.st && c1.idx<c2.idx)
   return true;

  return false;
}

bool cmp2(ca c1,ca c2)
{
  
  if(c1.idx<c2.idx)
  return true;
  return false;
}








int main()
{

  ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   //pr();
  int t;
  // cin>>t;
   t=1;
  int id=1;

  while(t--)
{
       int n,k;
       cin>>n>>k;

    long long pre= 0,suf=0;
     long long count=0;

    for(int i=0;i<k;i++)
     pre+=i;

    for(int i=n,j=0;j<k;i--,j++)
    suf+=i;

   count = (count+((suf-pre+1)%mod))%mod;

    for(int i=k,j=n-k;i<=n;i++,j--)
  {
     //cout<<count<<endl;
      pre+=i;
         suf+=j;

     count = (count+((suf-pre+1)%mod))%mod;
 }

  cout<<count;

   
}



return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
int dp[201][201];
int main(void){
	int i,j,k,d,n,t[201],a[201],b[201],c[201],max=-1,z;
	scanf("%d %d",&d,&n);
	for(i=1;i<=d;i++){
		for(j=0;j<n;j++) dp[i][j]=-1;
	}
	for(i=1;i<=d;i++) scanf("%d",&t[i]);
	for(i=0;i<n;i++) scanf("%d %d %d",&a[i],&b[i],&c[i]);
	for(i=0;i<n;i++){
		if(a[i]<=t[1]&&t[1]<=b[i]) dp[1][i]=0;
	}
	for(i=1;i<d;i++){
		for(j=0;j<n;j++){
			if(dp[i][j]!=-1){
				for(k=0;k<n;k++){
					if(a[k]<=t[i+1]&&t[i+1]<=b[k]){
						z=c[j]-c[k];
						if(z<0)	z=z*-1;
						if(dp[i+1][k]<dp[i][j]+z) dp[i+1][k]=dp[i][j]+z;
					}
				}
			}
		}
	}
//	for(i=1;i<=d;i++){
//		for(j=0;j<n;j++) printf("%d ",dp[i][j]);
//		printf("\n");
//	}
	for(i=0;i<n;i++){
		if(max<dp[d][i]) max=dp[d][i];
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 756
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int main() {
  int n;
  cin >> n;
  int x[n];
  int h = 0, l = 10000;
  for (int i = 0 ; i < n; i++) {
    cin >> x[i];
    l = min(l, x[i]);
    h = max(h, x[i]);
  }
  long long res = INT_MAX;
  for (int p = l ; p <= h; p++) {
    long long pt = 0;
    for (int j = 0; j < n; j++) {
      pt += (x[j] - p) * (x[j] - p);
    }
    res = min(res, pt);
  }
  cout << res << endl;
  return 0;
}



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

using ll = long long;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - b - a < 0) {
        cout << "No\n";
        return 0;
    }
    if (4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_N = 200000;

struct Node {
  int idx;
  int skipCnt;
  int takeCnt;
  ll sum;

  Node(int idx = -1, int skipCnt = -1, int takeCnt = -1, ll sum = -1) {
    this->idx = idx;
    this->skipCnt = skipCnt;
    this->takeCnt = takeCnt;
    this->sum = sum;
  }

  bool operator>(const Node &n) const {
    return idx > n.idx;
  }
};

int main() {
  int N;
  cin >> N;
  ll dp[N][3];
  int takeLimit = N / 2;
  int skipLimit = (N % 2 == 0) ? 1 : 2;

  vector<ll> A;
  ll a;

  for (int i = 0; i < N; ++i) {
    cin >> a;
    A.push_back(a);

    for (int s = 0; s < 3; ++s) {
      dp[i][s] = LLONG_MIN;
    }
  }

  priority_queue <Node, vector<Node>, greater<Node>> pque;
  pque.push(Node(0, 0, 0, 0));
  ll ans = LLONG_MIN;

  while (!pque.empty()) {
    Node node = pque.top();
    pque.pop();

    // fprintf(stderr, "[%d, skipCnt: %d, takeCnt: %d, %lld]\n", node.idx, node.skipCnt, node.takeCnt, node.sum);

    if (node.takeCnt == takeLimit) {
      ans = max(ans, node.sum);
      continue;
    }

    if (node.sum <= dp[node.idx][node.skipCnt]) continue;
    dp[node.idx][node.skipCnt] = max(dp[node.idx][node.skipCnt], node.sum);

    if (node.skipCnt == skipLimit) {
      int nextIdx = node.idx + 2;
      ll sum = node.sum + A[node.idx];

      pque.push(Node(nextIdx, node.skipCnt, node.takeCnt + 1, sum));
    } else {
      // skip taking number
      pque.push(Node(node.idx + 1, node.skipCnt + 1, node.takeCnt, node.sum));

      // no skip
      pque.push(Node(node.idx + 2, node.skipCnt, node.takeCnt + 1, node.sum + A[node.idx]));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9748
#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;
    cin >> n;

    string s[n];
    rep(i, n) {
        string temp;
        cin >> temp;
        char c[10];
        temp.copy(c, 10);
        sort(c, c + 10);
        string s_temp(c, 10);
        s[i] = s_temp;
    }

    sort(s, s + n);

    Bint ans = 0;
    vector<int> ans_array;
    int index_l = 0, index_r = 0;
    rep(i, n) {
        if (s[index_l] == s[i]) {
            index_r = i;
        } else {
            ans_array.push_back(index_r - index_l + 1);
            index_l = i;
            index_r = i;
        }
    }
    ans_array.push_back(index_r - index_l + 1);

    rep(i, ans_array.size()) {
        int num = ans_array[i];
        if (num <= 1) {
            continue;
        }
        ans += comb(num, 2);
    }

    cout << ans << 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: 6396
#include<stdio.h>
int h[200010],to[400010],nex[400010],M;
void add(int a,int b){
	M++;
	to[M]=b;
	nex[M]=h[a];
	h[a]=M;
}
char s[200010];
int c[200010],d[200010][2],st[200010];
bool del[200010],ins[200010];
int main(){
	int n,m,i,x,y;
	scanf("%d%d%s",&n,&m,s+1);
	for(i=1;i<=n;i++)c[i]=s[i]=='B';
	while(m--){
		scanf("%d%d",&x,&y);
		d[x][c[y]]++;
		add(x,y);
		if(x!=y){
			d[y][c[x]]++;
			add(y,x);
		}
	}
	M=0;
	for(i=1;i<=n;i++){
		if(d[i][0]==0||d[i][1]==0)ins[st[++M]=i]=1;
	}
	while(M){
		del[x=st[M--]]=1;
		ins[x]=0;
		for(i=h[x];i;i=nex[i]){
			if(!del[to[i]]){
				d[to[i]][c[x]]--;
				if((d[to[i]][0]==0||d[to[i]][1]==0)&&!ins[to[i]])st[++M]=to[i];
			}
		}
	}
	for(i=1;i<=n;i++){
		if(!del[i]){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 10001
#define PI 3.1415926535897932384
#define F first
#define S second
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair




int main() 
{ 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout); 
#endif
ll n,w;
cin>>n>>w;
vector <pair<ll,ll>> v;
fr(n){
    ll x,y;
    cin>>x>>y;
    v.pb({x,y});
}
sort(all(v));
ll dp[w+1][n+1];
rep(i,0,w+1){
    rep(j,0,n+1){
        if(i==0) dp[i][j]=0;
        else if(j==0) dp[i][j]=0;
        else{
            dp[i][j]=dp[i][j-1];
            if(v[j-1].F<=i){
                dp[i][j]=max(dp[i][j],dp[i-v[j-1].F][j-1]+v[j-1].S);
            }
        }
    }
}
/*rep(i,0,w+1){
    rep(j,0,n+1){
        cout<<dp[i][j]<<" ";
    }
    cout<<endl;
}*/
cout<<dp[w][n];


    return 0; 
} 

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const double eps = 1e-9;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

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

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

signed main() {
  lint ans = 1;
  int n = in();
  for (int i = 0; i < n; ++i) {
    lint t = in();
    ans = lcm(t, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] s = new String[h];
        for (int i = 0; i < h; i++) {
            s[i] = sc.next();
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < w + 2; i++) {
            sb.append('#');
        }
        System.out.println(sb);
        for (int i = 0; i < h; i++) {
            System.out.println("#" + s[i] + "#");
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 22996
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
const int N = 2e5 + 5; 
using namespace std;

int n, m, cntl, cntr, stk[N], top;
struct node { int l, r; } p[N]; 
priority_queue<int, vector<int>, greater<int> > q; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

bool cmp(node a, node b) { return a.l < b.l; }

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> ();
	for(int i = 1; i <= n; i++) p[i].l = read <int> (), p[i].r = read <int> ();
	sort(p + 1, p + n + 1, cmp); 
	for(int i = 1; i <= n; i++)
	{
		if(cntl < p[i].l) cntl++, q.push(p[i].r); 
		else
		{
			if(q.empty()) stk[++top] = p[i].r; 
			else if(p[i].r > q.top())
				stk[++top] = q.top(), q.pop(), q.push(p[i].r);
			else stk[++top] = p[i].r; 
		}
	}
	sort(stk + 1, stk + top + 1); 
	for(int i = top; i >= 1; i--)
	{
		if(cntr + cntl == m) continue; 
		if(cntr < m - stk[i] + 1) cntr++; 
	}
	printf("%d\n", n - cntl - cntr); 
	return 0; 
}


Measured memory_bytes: 5516
#include<stdio.h>

int main()
{
	char stage[10][10]={};
	char state[2]={};
	int x=0,y=0;
	int i,j;
	
	
	for(i=0;i<9;i++)scanf("%s",stage[i]);
	state[0]='R';
	while(1)
	{
		if((x==0 && y==0 && state[0]!='R') || (x==0 && y==1 && state[0]=='U'))
		{
			if(state[0]=='U')
				printf("U\n");
			else printf("L\n");
			break;
		}
		
		if(state[0]=='R')
		{
			if(stage[y-1][x+1]=='1' && y>=1)
			{
				y--;
				x++;
				state[0]='U';
			}
			else if(stage[y][x+1]=='1' && x<=3)
			{
				x++;
				state[0]='R';
			}
			else if(stage[y+1][x+1]=='1' && y<=7)
			{
				y++;
				x++;
				state[0]='D';
			}
			else
				state[0]='L';
			printf("R");
		}
		else if(state[0]=='D')
		{
			if(stage[y+1][x]=='1' && y<=7)
			{
				y++;
				state[0]='R';
			}
			else if(stage[y+2][x]=='1' && y<=6)
			{
				y+=2;
				state[0]='D';
			}
			else if(stage[y+1][x-1]=='1' && x>=1)
			{
				y++;
				x--;
				state[0]='L';
			}
			else
				state[0]='U';
			printf("D");
		}
		else if(state[0]=='L')
		{
			if(stage[y+1][x]=='1' && y<=7)
			{
				y++;
				state[0]='D';
			}
			else if(stage[y][x-1]=='1' && x>=1)
			{
				x--;
				state[0]='L';
			}
			else if(stage[y-1][x]=='1' && y>=1)
			{
				y--;
				state[0]='U';
			}
			else
				state[0]='R';
			printf("L");
		}
		else if(state[0]=='U')
		{
			if(stage[y-1][x-1]=='1' && x>=1)
			{
				x--;
				y--;
				state[0]='L';
			}
			else if(stage[y-2][x]=='1' && y>=2)
			{
				y-=2;
				state[0]='U';
			}
			else if(stage[y-1][x]=='1' && x<=3)
			{
				y--;
				state[0]='R';
			}
			else
				state[0]='D';
			printf("U");
		}
	}
return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n, k; cin >> n >> k;
  ll ans = k;
  for(int i=0;i<n-1;++i) {
    ans *= k-1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

res = 0
cc = float('inf')
for i in range(n):
    d = (1000 * t - 6 * h[i]) - 1000 * a
    if d < 0: d = -d
    if cc > d:
        cc = d
        res = i + 1
print(res)

Measured memory_bytes: 3064
function gcd(a, b) {
	while (true) {
		if (a > b) {
			a = a % b;
			if (a === 0) return b;
		} else {
			b = b % a;
			if (b === 0) return a;
		}
	}
}
 
const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
 
const NS = lines[0].split(' ');
const N = Number(NS[0]);
const S = Number(NS[1]);
 
console.log(3 * (N - gcd(N - S, S)));

Measured memory_bytes: 7372
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
using namespace std;
int main(){
  int n, t, a, x;
  cin >> n >> t >> a;
  int rsl=0;
  int c = 1<<30;
  for(int i=1; i<= n; i++){
    cin >> x;
    int d = (1000*t - x*6) - a*1000;
    if (d<0) d = -d;
    if (c>d) c=d, rsl = i;
  }
  cout << rsl << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n;
	ll from, to;
	while(cin >> n >> from >> to, n){
		from--; to--;
		
		vi upper;
		string ans;
		rep(i, n) if(from >> (n - i - 1) & 1) upper.pb(0);
		else{
			upper.pb(1);
			from = ~from;
		}
		reverse(all(upper));
		//dbg(upper);
		rep(i, n){
			ans.pb((to >> n - i - 1 & 1) == upper[i] ? 'R' : 'L');
			if(upper[i]) to = ~to;
			to &= (1ll << (n - i)) - 1;
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3124
def solve():
    X, Y = map(int, input().split())

    ans = 0
    if X == 1 and Y == 1:
        ans += 400000
    
    for i in [X, Y]:
        if i == 3:
            ans += 100000
        if i == 2:
            ans += 200000
        if i == 1:
            ans += 300000
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
function main()
    x = pread(Int)
    if x >= 1800
        a = 1
    elseif x >= 1600
        a = 2
    elseif x >= 1400
        a = 3
    elseif x >= 1200
        a = 4
    elseif x >= 1000
        a = 5
    elseif x >= 800
        a = 6
    elseif x >= 600
        a = 7
    elseif x >= 400
        a = 8
    end
    println(a)
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


Measured memory_bytes: 182596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, q;
  string s;
  cin >> n >> s >> q;

  set<ll> st;
  map<char, set<ll>> place;
  for (char c = 'a'; c <= 'z'; c++) place[c] = st;
  for (ll i = 0; i < n; i++) {
    place[s[i]].insert(i);
  }

  /*for (ll i = 0; i < 26; i++) {
    for (ll j = 0; j < n - 1; j++) {
      cout << v[i][j] << " ";
    }
    cout << v[i][n - 1] << endl;
  }*/

  for (ll i = 0; i < q; i++) {
    ll x;
    cin >> x;

    if (x == 1) {
      ll y;
      char c;
      cin >> y >> c;

      if (s[y - 1] == c) continue;

      place[s[y - 1]].erase(y - 1);
      place[c].insert(y - 1);
      s[y - 1] = c;
    }
    else {
      ll l, r;
      cin >> l >> r;

      ll cnt = 0;
      for (char c = 'a'; c <= 'z'; c++) {
        auto itr = place[c].lower_bound(l - 1);
        if (itr != place[c].end() && *itr < r) {
          cnt++;
        }
      }
      cout << cnt << endl;
    }
  }
}

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

typedef long long ll;
typedef long double ld;
const ll M=1e9+7;
const ll MAXN=1e6+7;
const ld pi=acos(-1);

#define gi(n) ll n=read()
#define endl '\n'
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define per(i,a,b) for(ll i=b-1; i>=a; --i)

typedef vector<ll> V;
typedef vector<V> VV;
typedef set<ll> S;
typedef pair<ll,ll> pl;
typedef vector<pl> Vp;

#define all(v) v.begin(),v.end()
#define pb push_back
#define fs first
#define sc second

inline ll read(){
	ll x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}

ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll pow1(ll p,ll d, ll P){return d?(pow1(p*p%P,d>>1,P)*(d&1?p%P:1))%P:1;}
ll mul(ll a,ll b,ll P){return b?(mul(a*2%P,b>>1,P)+(b&1?a:0))%P:0;}
ll pow1(ll p,ll d, ll P){return d?mul(pow1(mul(p,p,P),d>>1,P),(d&1?p%P:1),P):1;}

V prime;
bool is_composite[MAXN];
void sieve (ll n){
	std::fill (is_composite, is_composite + n, false);
	rep(i,2,n){
		if(!is_composite[i]) prime.pb(i);
		for(ll j = 0; j < prime.size() && i*prime[j] < n; ++j){
			is_composite[i*prime[j]] = true;
			if(i % prime[j] == 0) break;
		}
	}
}
ll modInverse(ll a, ll m){
	ll m0=m,y=0,x=1;
	if(m==1) return 0;
	while(a>1){
		ll q=a/m,t=m;
		m=a%m;
		a=t; 
		t=y;

		y = x-q*y; 
		x = t;
	}
	if(x<0) x += m0;
	return x; 
}

void doit(){
	string s;
	cin>>s;
	V v;
	ll n=s.size(),p=0;
	rep(i,0,n){
		if(s[i]=='R'){
			ll c=0;
			while(s[i]=='R' && i<n) c++,i++;
			p=max(p,c);
		}
	}
	cout<<p;
}

int main(){
//	for(gi(t);t--;cout<<endl)
		doit();
	return 0;
}

Measured memory_bytes: 3632
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		long[] a = new long[3*N];
		for(int i = 0; i < 3*N; i++) a[i] = sc.nextLong();
		Arrays.sort(a);
		long ans = 0;
		for(int i = N; i < 3*N; i += 2) ans += a[i];
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 25188
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976
 
int main(){
	lint a,b,c;cin>>a>>b>>c;
	c=min(c,a+b+1);
	cout<<b+c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  int n = s.size();
  REP(i, n){
    bool ok = true;
    REP(j, n){
      if(s[j] != t[(j + i) % n]){
        ok = false;
        break;
      }
    }
    if(ok){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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


signed main(){
	
	
	string s,t = "2019/04/30";
	cin >> s;
	
	if(s > t) cout << "TBD" << endl;
	else cout << "Heisei" << endl;
	
	return 0;

}

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

int main() {
    int n, x; cin >> n >> x;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    sort(begin(a), end(a));
    vector<long long> acc(n + 1);
    for (int i = 0; i < n; i++) acc[i + 1] = acc[i] + a[i];
    if (acc.back() < x) return !(cout << n - 1 << endl);
    cout << prev(upper_bound(begin(acc), end(acc), x)) - begin(acc) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    if(a == "H"){
        if(b == "H") cout << "H" << endl;
        else cout << "D" << endl;
    }
    else {
        if(b == "D") cout << "H" << endl;
        else cout << "D" << endl;
    }
    return 0;
}

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


using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

//400*400*40=64*10^5程度なので余裕
//dp[i番目まで使った時の][aをjグラム][bをkグラム含んでいる状態の]
//最小コスト
int dp[41][420][420];

int main() {

	//境界条件受け取り
	int n, ma, mb; cin >> n >> ma >> mb;
	
	//dpテーブル初期化
	for (int i = 0; i < 41; i++) {
		for (int j = 0; j < 420; j++) {
			for (int k = 0; k < 420; k++) {
				dp[i][j][k] = INF;
			}
		}	
	}

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

	//遷移
	for (int i = 0; i < n; i++) {
		int a, b, c; cin >> a >> b >> c;
		for (int j = 0; j < 401; j++) {
			for (int k = 0; k < 401; k++) {

				//遷移元に到達していなければ、枝刈り。
				if (dp[i][j][k] == INF)continue;

				//取らない
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				//取る
				dp[i + 1][a + j][b + k] = min(dp[i + 1][a + j][b + k], dp[i][j][k] + c);
			}
		}
		
	}

	//求める比になってるものだけピックアップしてその中の最小を出力。
	//aとbがma:mb b*ma=a*mbとなっている所。

	int ans = INF;

	for (int i = 1; i < 401; i++) {
		for (int j = 1; j < 401; j++) {
			if (i*mb != j * ma) continue;

			ans = min(ans, dp[n][i][j]);
		}
	}


	if (ans == INF) {
		cout << "-1" << endl;
	}
	else {
		cout << ans << endl;
	}
	
	return 0;
}

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

public class Main {
	static Scanner in;
	static PrintWriter out;

	static void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		out.println((n-1)*(m-1));
	}

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
		out.close();
		in.close();
	}

}


Measured memory_bytes: 21972
H,W,K=map(int,input().split())
c=[]
for i in range(H):
    s=input()
    c.append(s)
blackh=[]
ans=0
for i in range(H):
    h=0
    for j in range(W):
        if c[i][j]=="#":
            h+=1
    blackh.append(h)
blackw=[]
for i in range(W):
    w=0
    for j in range(H):
        if c[j][i]=="#":
            w+=1
    blackw.append(w)
al=sum(blackw)
for i in range(2**H):
    for j in range(2**W):
        b=0
        h=[]
        w=[]
        for k in range(H):
            if ((i>>k)&1):
                b+=blackh[k]
                h.append(k)
        for l in range(W):
            if ((j>>l)&1):
                b+=blackw[l]
                w.append(l)
        for m in w:
            for n in h:
                if c[n][m]=="#":
                    b-=1
        if b==al-K:
            ans+=1
print(ans)

Measured memory_bytes: 9284
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
    char T[1001],P[1001];
    
    cin >> T >> P;
    int tlen,plen;
    
    tlen = strlen(T);
    plen = strlen(P);
    
    int count = 0;
    
    for (int i = 0; i < tlen - plen + 1; i++) {
        if (T[i] == P[count]) {
            bool flag = true;
            for (int j = 1; j < plen; j++) {
                if (T[i+j] != P[j]) {
                    flag = false;
                    break;
                }
            }
            if (flag) printf("%d\n",i);
        }
    }
    return 0;
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
#define P pair<ll,ll>
#define fs first
#define sc second
using namespace std;

int main(){
 
  ll a, b, c, d;
  string s;
  cin >> s;

  a = s[0] - '0';
  b = s[1] - '0';
  c = s[2] - '0';
  d = s[3] - '0';
    
  rep(i,0,pow(2,3)){
    ll temp1,temp2,temp3;
    char c1,c2,c3;
    if(i & 1){
      temp1 = b;
      c1 = '+';
    }
    else{
      temp1 = -b;
      c1 = '-';
    }
    
    if((i >> 1) & 1){
      temp2 = c;
      c2 = '+';
    }
    else{
      temp2 = -c;
      c2 = '-';
    }

    if((i >> 2) & 1){
      temp3 = d;
      c3 = '+';
    }
    else{
      temp3 = -d;
      c3 = '-';
    }

    if(a + temp1 + temp2 + temp3 == 7){
      cout << a << c1 << b << c2 << c << c3 << d <<"=7" << endl;
      break;
    }
  }



  return 0;
}

Measured memory_bytes: 256