akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
//g++ main.cpp -std=c++14

using namespace std;
using namespace atcoder;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw`(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}
const ll MAX = MOD;

void solve(){
  int N,Q; cin>>N>>Q;
  fenwick_tree<ll> fw(N);
  REP(i,N){
    ll a; cin >> a;
    fw.add(i,a);
  }
  REP(i,Q){
    int t; cin>>t;
    if(t){
      int l,r; cin>>l>>r;
      cout << fw.sum(l,r) << "\n";
    }else{
      int p,x; cin>>p>>x;
      fw.add(p,x);
    }
  }
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 8204
#include <stdio.h>
int main(void)
{
	double r, menseki, ensyuu;

	scanf("%lf", &r);

	menseki = r * r * 3.141592653589;
	ensyuu = 2 * r * 3.141592653589;

	printf("%f %f\n", menseki, ensyuu);

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> takoyaki(n);
  int ans = 0;
  for (int i = 0; i < n; i++) cin >> takoyaki[i];

  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++){
        ans += takoyaki[i] * takoyaki[j];
    }
  }

  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int cnt_divisor(int n)
{
    int sum=0;
    for (int i = 1; i*i <= n; i++)
    {
        if(n%i==0)
        {
            sum++;
            if(i*i!=n)sum++;
        }
    }
    return sum;
}

int main()
{
    int n,ans=0;
    cin>>n;
    for (int i = 1; i <= n; i++)
    {
        if(i%2!=0)
        {
            int m=cnt_divisor(i);
            if(m==8)ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
//#define f first
//#define s second
//#define mp make_pair
#define gg return 0;
#define pii pair < int, int>
 
using namespace std;
 
const int maxn = 132675;
const int INF = (int)1e9;
 
ll a,b[maxn],c,d,cnt,e[(int)2e3 + 1][(int)2e3 + 1],cost[maxn],tout[maxn],mn = INF,mx = -INF,l,r;
 
ll x[maxn],y[maxn],x2[maxn],y2[maxn];
 
ll kol;

bool u[maxn], m, f;
 
vector <int> v;
 /*
void forn( int s, int f, int inter){
	for(int i = s; i <= f; i += inter){
		b[i] = i;
	}
}
*/ 
ll ans;
 
ll pref;
 
//vector <int> g[maxn],d[maxn];
 
ll lvlc,lvl[maxn];
ll pos;
/*
void dfs(int v){
	lvlc++;
	lvl[v] = lvlc;
	d[lvl[v]].pb(v);
	u[v] = 1;
	for(int i = 0; i < g[v].size(); ++i){
		int to = g[v][i];
		if(!u[to]){
			dfs(to);
		}
	}
	lvlc--;
}*/

map <int, int> mp; 
 
char ch;

string s; 

int main()
{
	cin >> s;
	cout << (((s.size() + (s[0] == s[s.size() - 1]))) % 2 ? "First" : "Second");	 
	gg
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include <math.h>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int n;
  cin >> n;
  if (n%1000 == 0) {
    cout << 0 << endl;
  } else {
    cout << (1000 - (n % 1000)) << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
N, M = map(int, input().split())
AB = []
for _ in range(N):
    a, b = map(int ,input().split())
    AB.append((a, b))

AB = sorted(AB)
price = 0
m = 0

for a, b in AB:
    if m + b < M:
        price = price + a * b
        m = m + b
    elif m + b >=M:
        price = price + a * (M - m)
        m = M
        break

print(price)


Measured memory_bytes: 17788
import java.util.Scanner;
import java.util.HashSet;
import java.util.Set;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int n=kbd.nextInt();

   Set<String> set = new HashSet<>();
for (int i = 0; i < n; i++) {
set.add(kbd.next());}

System.out.println(set.size());
}

}


Measured memory_bytes: 76748
#include <bits/stdc++.h> 
using namespace std; 
int n;
const int MAX = 100005;
int a[MAX];

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

    cin >> n;
    for(int i=0; i<n; ++i) cin >> a[i];
    int ans = 0, cur = 0;
    for(int i=1; i<n; ++i) {
        if (a[i] <= a[i-1]) cur += 1;
        else cur = 0;
        ans = max(ans, cur);
    }
    cout << ans << endl;
    return 0; 
}



Measured memory_bytes: 640
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    val (N) = readLineInts()
    val p = Array(N) { readLine()!!.toInt() }

    println(p.sum() - p.max()!! + p.max()!! / 2)
}

Measured memory_bytes: 36328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

   

int main(){
      lint N;
      cin>>N;
      lint x=N;
    if(N%2==1)x--;
    if(N%2==1)cout<<(x-2)*x/2+x<<endl;
    else cout<<x*(x-2)/2<<endl;
        vector<pair<int,int>> h;
    lint p=x;
    repp(i,1,x+1){
        repp(j,1,x+1){
                if(i==j||j==p)continue;
            h.push_back(make_pair(i,j));
        }
        p--;
    }

    rep(i,h.size()){
        lint f,g;
        tie(f,g)=h[i];
        if(f<=g)cout<<f<<" "<<g<<endl;
    }
    if(N%2==1){
        rep(i,N-1){
            cout<<N<<" "<<i+1<<endl;        
    }
    }
      
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int h[N];
  for (int i = 0; i < N; i++) cin >> h[i];
  sort(h, h + N); // sortは引数に先頭と末尾のポインタを指定する
  int m = 1000000000;
  // cout << "hoge\n";
  for (int i = 0; i < N-K+1; i++) {
    m = min(m, h[i+K-1] - h[i]);
  }
  cout << m << endl;
}  

Measured memory_bytes: 640
s = input()
if 13 <= int(s[0:2:]) :
    if 1 <= int(s[2::]) <= 12:
        print('YYMM')
    else:
        print('NA')
elif 1 <= int(s[0:2:]) <= 12:
    if  13 <= int(s[2::]) or int(s[2::]) == 0 :
        print('MMYY')
    else:
        print('AMBIGUOUS')
elif int(s[0:2:]) == 0:
    if 1 <= int(s[2::]) <= 12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
using namespace std;
int n,x,y,ans=0;
inline int SG(int n,int k)
{
	if (n<k) return 0;
	if (n%k==0) return n/k;
	int step=n/k+1,yushu=n%k;
	if (step>=yushu) return SG(n-step,k);
	return SG(n-yushu/step*step,k);
}
int main()
{
	scanf("%d",&n);
	FOR(i,1,n) scanf("%d%d",&x,&y),ans^=SG(x,y);
	if (ans) printf("Takahashi\n");
	else printf("Aoki\n");
	return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	L, R, d := getInt(), getInt(), getInt()
	ans := R/d - (L-1)/d
	out(ans)
}


Measured memory_bytes: 1772
#include<stdio.h>
int main()
{
	int i,j,n;
	int min_i;
	int temp;
	int a[100];
	int count=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		min_i=i;
		for(j=i;j<n;j++)
		{
			if(a[j]<a[min_i])
				min_i=j;
		}
		if(min_i!=i)
		{
			temp=a[i];
			a[i]=a[min_i];
			a[min_i]=temp;
			count++;
		}
	}
	for(i=0;i<n;i++)
	{
		if(i!=n-1)	
			printf("%d ",a[i]);
		else
			printf("%d\n",a[i]);
	}
	printf("%d\n",count);
	return 0;
}

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

typedef long long ll;
typedef pair<int,int>P;
#define INF 99999999
#define MOD (ll)(1e9+7)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);*/
/*--------------------------------------------*/


int main(){
    string s;cin>>s;
    for(int i=0;i<(int)s.size();i+=2)cout<<s[i];
    cout<<endl;
}



/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/


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

#define REP(i,a,b) for(int i=a;i<=b;++i)
typedef long long ll;

using namespace std;

void File(){
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
}

const int maxn=1e5+10;
int n,k,a[maxn];

int main(){
	//File();
	scanf("%d%d",&n,&k);
	REP(i,1,n)scanf("%d",&a[i]);
	REP(i,1,n)if(a[i]==1){
		if(i-k>=1 || i+k<=n)cout<<ceil((n-k)*1.0/(k-1))+1<<endl;
		else if(k==n)cout<<1<<endl;
		else cout<<2<<endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio {
  int it, len;
  char s[LEN + 5];
  fastio() {
    it = len = 0;
  }
  char get() {
    if(it < len) return s[it++];
    it = 0, len = fread(s, 1, LEN, stdin);
    return len ? s[it++] : EOF;
  }
  bool notend() {
    char c;
    for (c = get();c == ' ' || c == '\n';c = get());
    if (it) it--;
    return c != EOF;
  }
  void put(char c) {
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush() {
    fwrite(s, 1, it, stdout);
  }
}buff, bufo;
inline int getint() {
  char c; int res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if(c == '-') sig = -1;
  for (;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll() {
  char c; ll res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char() {
  char c;
  for (c = buff.get(); c == ' ' || c == '\n'; c = buff.get());
  return c;
}
#define maxn 200005
int n, col[maxn], c[3], num[3];
vector <int> adj[maxn], odd, even;
void dfs(int u, int f, int dep) {
  if (dep & 1) odd.push_back(u);
  else even.push_back(u);
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == f) continue;
    dfs(v, u, dep + 1);
  }
}
int main() {
  n = getint();
  for (int i = 1; i < n; i++) {
    int u = getint(), v = getint();
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0, 0);
  num[1] = (n + 2) / 3, num[2] = (n + 1) / 3;
  for (int i = 1; i <= 2; i++) {
    if ((int)odd.size() >= num[i]) {
      for (int j = 1; j <= num[i]; j++) {
        col[odd.back()] = i;
        odd.pop_back();
      }
    } else {
      for (int j = 1; j <= num[i]; j++) {
        col[even.back()] = i;
        even.pop_back();
      }
    }
  }
  c[0] = 3, c[1] = 1, c[2] = 2;
  for (int i = 1; i <= n; i++) {
    putint(c[col[i]], i == n ? '\n' : ' ');
    c[col[i]] += 3;
  }
  bufo.flush();
  return 0;
}


Measured memory_bytes: 21620
import java.util.*;

public class Main {
    public static void main(String[] argv)
    {
	Scanner sc = new Scanner(System.in);
	int a, b;
	a = Integer.parseInt(sc.next());
	b = Integer.parseInt(sc.next());
	if (a * b % 2 != 0)
	    System.out.println("Odd");
	else
	    System.out.println("Even");
    }
}


Measured memory_bytes: 23764
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n, k = map(int, input().split())
    have = set()
    for _ in range(k):
        input()
        for i in map(int, input().split()):
            have.add(i)
    print(n - len(have))

main()

Measured memory_bytes: 9176
#include <iostream>
#include <set>
using namespace std;
int main(void)
{
	int n,q,k=0,num;
	set<int> set;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> num;
		set.insert(num);
	}
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> num;
		if(set.find(num)!=set.end()) k+=1;
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>

int main(void){
    int S,h,m,s;
    
    scanf("%d",&S);
    h=S/3600;
    m=S%3600/60;
    s=S%3600%60;
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2100
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int main(){
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < 4; i++){
		if (s[i] == '2'){
			count++;
		}
	}
	printf("%d\n",count);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int N,M,S[555][2],T[555][2],i,j,p,n,r;

int c(const void *a, const void *b)
{
	int *x=(int *)a;
	int *y=(int *)b;
	return x[0]==y[0]?x[1]-y[1]:x[0]-y[0];
}


int main()
{
	scanf("%d%d",&N,&M);
	for(i=0;i<M;i++)
		scanf("%d%d",&S[i][0],&S[i][1]);
	qsort(S,M,sizeof(int[2]),c);
	for(i=p=0;i<M;i++)
	{
		for(j=0;j<p;j++)
		{
			if(S[i][0]>=T[j][0]&&S[i][0]<T[j][1])
			{
				T[j][1]=S[i][1]<T[j][1]?T[j][1]:S[i][1];
				break;
			}
		}
		if(j==p)
		{
			T[p][0]=S[i][0];
			T[p][1]=S[i][1];
			p++;
		}
	}
	for(i=n=r=0;i<p;i++)
	{
		r+=(T[i][1]-n)+(T[i][1]-T[i][0]);
		n=T[i][0];
	}
	printf("%d\n",r+(N+1-n));
	return 0;
}

Measured memory_bytes: 652
#include<stdio.h>
int main(void){
int a,a1,b,b1,i;
for(i=0;i<3;i++){
scanf("%d",&a);
	if(i!=0){
		if(a1<a){
		a=a1;
		}
	}
a1=a;
}
for(i=0;i<2;i++){
scanf("%d",&b);
	if(i!=0){
		if(b1<b){
		b=b1;
		}
	}
b1=b;
}
printf("%d\n",a1+b1-50);
return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	double l;
	cin>>l;
	printf("%.15lf\n",pow(l / 3,3));
	return 0;
}

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

int code(int x){
    int mx;

    if(x==1){
        mx=300000;
    }else if(x==2){
        mx=200000;
    }else if(x==3){
        mx=100000;
    }else{
        mx=0;
    }

    return mx;
}

int machine(int y){
    int my;

    if(y==1){
        my=300000;
    }else if(y==2){
        my=200000;
    }else if(y==3){
        my=100000;
    }else{
        my=0;
    }

    return my;
}

int main(){
    int x;
    int y;
    int mx,my;

    cin>>x>>y;

    mx=code(x);
    my=machine(y);

    if(x==1&&y==1){
        cout<<mx+my+400000<<endl;
    }else{
        cout<<mx+my<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.stream.Collectors;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            String sortedS = String.join("", s.chars().sorted().mapToObj(c -> "" + (char) c).collect(Collectors.toCollection(ArrayList::new)));
            out.println("abc".equals(sortedS) ? "Yes" : "No");
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

    }
}



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

int main() {
  int A, B;
  cin >> A >> B;
  if(A % 3 == 0 || B % 3 == 0 ||(A + B) % 3 == 0){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3", "2 3", "1 3", "1 2" ].solve == 3 );
	assert( [ "4", "2 3 4", "1 3 4", "4 1 2", "3 1 2" ].solve == 4 );
	assert( [ "3", "2 3", "3 1", "1 2" ].solve == -1 );
}



import std.algorithm;
import std.container;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto ass = new long[][ n ];
	foreach( ref as; ass )
	{
		input.popFront;
		as = input.front.split.to!( long[] );
		as[] -= 1;
	}
	
	auto t = n * ( n - 1 ) / 2;
	auto ds = new long[ n ];
	auto queue = make!DList( iota( 0L, n ) );
	while( !queue.empty )
	{
		auto x = queue.front;
		queue.removeFront;
		
		if( ass[ x ].empty ) continue;
		
		auto y = ass[ x ].front;
		if( ass[ y ].empty ) continue;
		
		auto z = ass[ y ].front;
		if( x != z ) continue;
		
		ass[ x ].popFront;
		ass[ y ].popFront;
		t--;
		
		auto d = max( ds[ x ], ds[ y ] ) + 1;
		ds[ x ] = d;
		ds[ y ] = d;
		queue.insert( x );
		queue.insert( y );
	}
	return ( t == 0 ) ? ds.reduce!max : -1;
}


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

signed main(void)
{
	int r;
	cin >> r;
	if (r < 1200)
		cout << "ABC" << endl;
	else if (r < 2800)
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;
	return 0;
			}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// pairsをsecond優先キーとして昇順ソート
bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first > b.first;
    }
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll dp[2020][2020];

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<pair<ll, ll>> pairs(N);

    for(ll i=0; i<N; i++){
        cin >> pairs[i].second;
        pairs[i].first = i;
    }

    sort(pairs.begin(), pairs.end(), compare_by_b);
    // REP(i, N){
    //     cout << pairs[i].first << " " << pairs[i].second << endl;
    // }

    Fill(dp, 0);
    dp[0][0] = 0;

    REP(i, N){
        ll a = pairs[i].first;
		ll b = pairs[i].second;

        for(ll x=0; x<=i; x++){
            ll y = i-x;

            dp[x+1][y] = max(dp[x+1][y], dp[x][y]+abs(a-x)*b);
            dp[x][y+1] = max(dp[x][y+1], dp[x][y]+abs(a-(N-1-y))*b);
        }
    }
    
    ll ans = 0;
    REP(i, N){
        ans = max(ans, dp[i][N-i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35512
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

void dfs(vector<int> adj[], int sv, vector<bool> &vis){
	vis[sv] = true;
	for(int i = 0; i < adj[sv].size(); i++){
		if(!vis[adj[sv][i]]){
			dfs(adj, adj[sv][i], vis);
		}
	}
}
ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
}  
ll nCr(ll n, ll r) {
    ll x = 1, y = 1;
    rep(i, 0, r) {
        x = x * (n - i) % mod;
        y = y * (i + 1) % mod;
    }
    return x * power(y, mod - 2) % mod;
}

signed main(){
	FASTIO
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	ll p[a], q[b], r[c];
	rep(i, 0, a)
		cin >> p[i];
	rep(i, 0, b)
		cin >> q[i];
	rep(i, 0, c)
		cin >> r[i];
	vector<ll> v;
	ll ans = 0;
	sort(p, p + a, greater<ll>());
	sort(q, q + b, greater<ll>());
	sort(r, r + c, greater<ll>());
	rep(i, 0, x)
		v.pb(p[i]);
	rep(i, 0, y)
		v.pb(q[i]);
	rep(i, 0, c)
		v.pb(r[i]);
	sort(v.begin(), v.end(), greater<ll>());
	rep(i, 0, x + y)
		ans += v[i];
	cout << ans;
    return 0;
}
/*
1 2 2 2 1
2 4
5 1
1000
*/

Measured memory_bytes: 9736
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:19/04/2020
*/
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
#define ld long double
#define ff first
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define tc(t) cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
#define arr(i,n) fab(i,0,n)
#define getmx(v) *max_element(alt(v))
#define gcd(x,y) __gcd(x,y)
#define bs(a,n,x) binary_search(a,a+n,x)
#define up_to_low(c) c|=' '  //"A" -> 'a'
#define low_to_up(c) c&="_"  //'a' -> "A"
#define cb(n) __builtin_popcount(n)
#define rep(a,d,s) iota(a,a+d,s) // s->starting point 
#define lb(v,x) lower_bound(alt(v),x)
#define ub(v,x) upper_bound(alt(v),x)
int dx[4]={0,-1,1,0};
ll mod=1000000007;
int dy[4]={1,0,0,-1};
ll max(ll a,ll b){if(a>b)return a;else return b;} 
ll min(ll a,ll b){if(a<b)return a;else return b;}
bool chckpoweroftwo(ll x){return x && !(x&(x-1));}


ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1;  
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll modInverse(ll a, ll m) 
{ 
    ll x, y,res; 
    ll g = gcdExtended(a, m, &x, &y); 
    if(g!=1)
    res=1;
    else
    res = (x%m + m) % m;
    return res;
} 

ll f[200005];
void factorial()
{ 
    f[0]=1;
    fab(i,1,200005)
    {
        f[i]=(i*f[i-1])%mod;
    }

}
ll ncr(ll n,ll r)
{
    if(r==0)
    return 1;
    return (f[n]*modInverse(f[r],mod)%mod*modInverse(f[n-r],mod)%mod)%mod;
}
ll func(ll r,ll l)
{
    ll x=r*(r+1)/2;
    ll y=l*(l-1)/2;
    return (x-y);
}

bool test=0;
void solve()
{
    
   factorial();    
   ll n,k;
   cin>>n>>k;
   ll ans=0;
   n++;
   fab(i,k,n+1)
   {
       if(i>2)
       {
        ll x=i*(i-1)/2;
        ll y=func(n-1,n-i+1);
        ans=(ans+(n-i)+(y-x+1)%mod)%mod;
       }
       else if(i==2)
       ans=(ans+(n-1)+(n-2))%mod;
       else
       ans=(ans+n)%mod;
   }
    cout<<ans<<endl;
}


















int main()
{
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int m=n;
	int ans=0;
	while(m){
		ans+=m%10;
		m/=10;
	}
	if(n%ans==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define INF 1000000000
using namespace std;

/*
N K
h1 ... hN

N 2,10^5
K 100
hi 10^4
 */

int N,K;
int h[100000];
vector<ll> dp(100000, INF);

int main(){
  cin >> N >> K;
  cin >> h[0];

  dp[0] = 0;  
  FOR_IN(i,1,K){
    cin >> h[i];
    dp[i] = abs(h[i] - h[0]);
  }

  FOR_IN(i,K,N){
    cin >> h[i];
    FOR_IN(j,i-K,i){
      dp[i] = min(dp[i], dp[j] + abs(h[j]-h[i]));
    }
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define print(x) cout<<x;
#define printl(x) cout<<x<<endl;
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
typedef long long int ll;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a+b==3)
        cout<<3;
    else if(a+b==4)
        cout<<2;
    else
        cout<<1;
    
    
    return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX_N=200001;

int c[10][10];
int dist[10];
void dijkstra(int s){
	fill(dist,dist+10,INF);
	priority_queue<pii,vector<pii>,greater<pii>> que;
	dist[s]=0;
	que.push(pii(0,s));

	while(!que.empty()){
		pii p=que.top(); que.pop();
		int v=p.second;
		if(dist[v]<p.first)continue;
		for(int i=0;i<10;i++){
			if(dist[i]>dist[v]+c[v][i]){
				dist[i]=dist[v]+c[v][i];
				que.push(pii(dist[i],i));
			}
		}
	}
}

int main(){
	int h,w;
	cin>>h>>w;
	int a[h][w];
	REP(i,10)REP(j,10)cin>>c[i][j];
	REP(i,h)REP(j,w)cin>>a[i][j];
	int min_dist[10];
	REP(i,10){
		dijkstra(i);
		min_dist[i]=dist[1];
	}
	int cost=0;
	REP(i,h){
		REP(j,w){
			if(a[i][j]!=-1){
				cost+=min_dist[a[i][j]];
			}
		}
	}
	cout<<cost<<endl;
	return 0;
}


Measured memory_bytes: 384
var lines: string[] = [];
var reader: any = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on("line", function(line: string) {
  lines.push(line);
});

reader.on("close", function() {
  var blueCardsNum: number = Number(lines[0]);

  var earnMap: { [key: string]: number } = {};

  for (var i = 1; i < blueCardsNum + 1; i++) {
    if (earnMap[lines[i]]) {
      earnMap[lines[i]] = earnMap[lines[i]] + 1;
    } else {
      earnMap[lines[i]] = 1;
    }
  }

  for (var i = blueCardsNum + 2; i < lines.length; i++) {
    if (earnMap[lines[i]]) {
      earnMap[lines[i]] = earnMap[lines[i]] - 1;
    } else {
      earnMap[lines[i]] = -1;
    }
  }

  var maxKey: string = Object.keys(earnMap).reduce(
    (prev: string, current: string): string => {
      return earnMap[current] > earnMap[prev] ? current : prev;
    }
  );
  console.log(earnMap[maxKey] < 0 ? 0 : earnMap[maxKey]);
});


Measured memory_bytes: 7628
#include <stdio.h>

int main(void){

	int n, max = 0, i;
	int mode[101] = { 0 };

	while( scanf( "%d", &n ) != EOF )
		mode[n] ++;

	for( i = 1; i <= 100; i++)
		if( max < mode[i] )
			max = mode[i];

	for( i = 1; i <= 100; i++) {
		if( mode[i] == max )
			printf("%d\n", i );
	}

	return 0;
}

Measured memory_bytes: 596
def nexti(i):
    if i == 0:
        return 3
    elif i % 10 == 3:
        return i + 2
    elif i % 10== 5:
        return i + 2
    elif i % 10 ==7:
        return nexti(i//10)*10 + 3

n = int(input())
nn = 0
i = 357

while i <= n:
  s = str(i)
  if '3' in s:
    if '5' in s:
      if '7' in s:
        #print(i)
        nn += 1
  if i % 10 == 7:
    i = nexti(i)
  else:
    i +=2
print(nn)

Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
int x,a,b;
int main(void){
	scanf("%d",&x);
	if(x==5)++a;else 
	if(x==7)++b;
	scanf("%d",&x);
	if(x==5)++a;else 
	if(x==7)++b;
	scanf("%d",&x);
	if(x==5)++a;else 
	if(x==7)++b;
	if(a==2&&b==1){
		puts("YES");
		return 0;
	}
	puts("NO");
	return 0;
}

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

int main() {
  for(int n; cin >> n && n; ) {
    vector<int> in(1000, 0), sum(1000, 0);
    while(n--) {
      int h, m, id; char c;
      cin >> h >> c >> h >> h >> c >> m >> c >> id;
      m += h * 60;
      if(c == 'I') {
        in[id] = m;
      } else {
        if(id && in[0]) sum[id] += m - in[id];
        in[id] = 0;
      }
      if(id == 0) {
        if(c == 'I') {
          for(int i = 1; i < 1000; ++i) {
            if(in[i]) in[i] = m;
          }
        } else {
          for(int i = 1; i < 1000; ++i) {
            if(in[i]) sum[i] += m - in[i];
          }
        }
      }
    }
    cout << *max_element(sum.begin(), sum.end()) << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>

int main(){
  char c;
  scanf("%c", &c);

  if(((c=='a'||c=='i')||(c=='u'||c=='e'))||c=='o'){
    printf("%s\n", "vowel");
  }else{
    printf("%s\n", "consonant");
  }

  return 0;
}


Measured memory_bytes: 1564
#include<stdio.h>
int a[22];
int n,rec ;
int solve(int i,int m);
int main(){
	int q,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&q);
    int m[q];
    for(i=0;i<q;i++){
    	scanf("%d",&m[i]);
	}//输入
	for(i=0;i<q;i++){
		if(solve(0,m[i]))
		printf("yes\n");
		else
		printf("no\n");
	} 
	return 0;
}
int solve(int i,int m){
	if(m==0)
	return 1;
	if(i>=n)
	return 0;
    rec=solve(i+1,m)||solve(i+1,m-a[i]);
    return rec;
}


Measured memory_bytes: 2112
n=int(input())
flag=True
ts=0
xs=0
ys=0
for i in range(n):
  te,xe,ye=map(int,input().split())
  if (te-ts)%2 == ((xe+ye)-(xs+ys))%2 and ((xe+ye)-(xs+ys))<=(te-ts):
    flag = True
  else:
    flag = False
    break;
  ts,xs,ys=te,xe,ye
if flag:
  print('Yes')
else:
  print('No')

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }
  sort(ALL(a));
  a.erase(unique(ALL(a)), a.end());
  cout << a.size();
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3644
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
  // 回答を記述
  const lastTest = inputList[0]
  if (lastTest == "ABC") {
    console.log("ARC");
  } else {
    console.log("ABC")
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int p[20];
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> p[i];
	sort(p + 1, p + n + 1);

	int ans = 0;
	for (int i = 1; i < n; i++)
	{
		ans += p[i];
	}
	ans += p[n] / 2;
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
denq = []
for _ in range(m):
    ks = tuple(map(lambda x: int(x)-1, input().split()))
    denq.append(ks[1:])
P = tuple(map(int, input().split()))

ans = 0
for i in range(2**n):
    # switch_states = [(i>>j)&1 for j in range(n)]
    for idq, dq in enumerate(denq):
        counts = 0
        for s in dq:
            counts += (i>>s)&1
        if counts%2 != P[idq]:
            break
    else:
        ans += 1
print(ans)

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

int main() {
	string S; cin >> S;
	if(S.size()%2<1){
	    char c=S[S.size()/2];
	    if(S[S.size()/2-1]!=c) cout << S.size()/2 << endl;
	    else{
	        for(int i=S.size()/2-2; i>=0; --i){
	            if(S[i]!=c || S[S.size()-i-1]!=c){
	                cout << S.size()-i-1 << endl;
	                return 0;
	            }
	        }
	        cout << S.size() << endl;
	    }
	}
	else{
	    char c=S[S.size()/2];
	    for(int i=1; i<=S.size()/2; ++i){
	        if(S[S.size()/2-i]!=c || S[S.size()/2+i]!=c){
	            cout << (int) S.size()/2+i << endl;
	            return 0;
	        }
	    }
	    cout << S.size() << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)


int n;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	cout << n*n << endl;


}

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

int main(){
    int n;
    cin >> n;
    string s[n];
    map<string,int> mp;
    for(int i=0; i<n; i++){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
        mp[s[i]]++;
    }
    ll ans=0;
    for(auto p:mp){
        int q=p.second;
        ans+=(ll)q*(q-1)/2;
    }
    cout << ans << endl;
}

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

int main()
{
  int x;
  int count = 1;

  while (true)
  {
    cin >> x;

    if (x == 0)
    {
      break;
    }

    cout << "Case " << count << ": " << x << endl;
    count++;
  }

  return 0;
}



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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  string s;
  cin>>N>>s;
  vector<int>r,g,b;
  for(int i(0);i<N;i++){
    if(s[i] == 'R') r.push_back(i);
    if(s[i] == 'G') g.push_back(i);
    if(s[i] == 'B') b.push_back(i); 
  }
  ll ans(0);
  for(int i(0);i<N;i++){
    for(int j(i+1);j<N;j++){
      if(s[i] != s[j]){
        int sa = j - i;
        char iro;
        if((s[i] == 'R' && s[j] == 'G') ||( s[i] == 'G' && s[j] == 'R')) iro = 'B';
        else if((s[i] == 'R' && s[j] == 'B') ||( s[i] == 'B' && s[j] == 'R')) iro = 'G';
        else if((s[i] == 'B' && s[j] == 'G') ||( s[i] == 'G' && s[j] == 'B')) iro = 'R';
        ll cnt(0);
        if(iro == 'B'){
          cnt = b.end() - upper_bound(b.begin(),b.end(),j);
        }else if(iro == 'G'){
          cnt = g.end() - upper_bound(g.begin(),g.end(),j);
        }else if(iro == 'R'){
          cnt = r.end() - upper_bound(r.begin(),r.end(),j);
        }
        ans += cnt;
        if(j+sa < N && s[j+sa] == iro){
          ans--;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3672
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ')
                .Select(str => int.Parse(str))
                .ToArray();
            Array.Sort(a);
            Array.Reverse(a);

            int Alice = 0;
            int Bob = 0;
            for (int i = 0; i < N; ++i)
            {
                if (i % 2 == 0)
                {
                    Alice += a[i];
                } else
                {
                    Bob += a[i];
                }
            }
            Console.WriteLine(Alice - Bob);
        }
    }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
int main(){
    list<int> l;
    int n;
    cin >> n;
    string com;
    for (int i=0; i<(n); i++){
        cin >> com;
        if (com == "insert") {
            int key; cin >> key;
            l.push_front(key);
        }
        else if (com == "deleteFirst") {
            l.pop_front();
        }
        else if (com == "deleteLast") {
            l.pop_back();
        }
        else{
            int key; cin >> key;
            for (auto itr1 = l.begin(); itr1 != l.end(); itr1++){
                if (*itr1 == key) {
                    l.erase(itr1);
                    break;
                }
            }
        }
    }
    for (auto itr1 = l.begin(); itr1!=l.end(); itr1++){
        if (itr1 != l.begin()) cout << ' ';
        cout << *itr1;
    }
    cout << endl;
}


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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;

vector<vector<int>> g;
int inf = 1e9+10;

void solve()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    ll base=1;
    while (base <= n) {
        base *= 2;
    }
    vector<ll> tree(base*2);

    vector<ll> dp(n+1, 0); // dp[i] max possible beauty with last element of height i

    for (int i = 0; i < n; ++i) {
        // looking for max dp[i] for i=0...height
        
        ll best = 0;
        ll x = h[i]+base;
        while (x>1) {
            if (x%2==1) {
                best = max(best, tree[x-1]);
            }
            x /= 2;
        }
        dp[h[i]] = best + a[i];

        x = h[i]+base;
        while (x>0) {
                tree[x] = max(tree[x], dp[h[i]]);
            x /= 2;
        }
        /* for (int height = 0; height < h[i]; ++height) { */
        /*     dp[h[i]] = max(dp[h[i]], dp[height]+a[i]); */
        /* } */
    }

    dbg(dp);

    ll res = 0;
    for (int i = 0; i <= n; ++i) {
        res = max(res, dp[i]); 
    }

    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>

#define N 8
#define FREE 1
#define NOT_FREE -1

int board[N][N],col[N],row[N],dpos[2*N-1],dneg[2*N-1];

void printboard(){
  int i,j;

  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(board[i][j]){
      if(row[i] != j)return;
      }
    }
  }
  
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
 }

void putQueen(int i){
  int j;
  
  if(i == N){
  printboard();  
  return;
  }
  
  for(j=0; j < N;j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE ||
       dneg[i-j+N-1] == NOT_FREE)continue;
    
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    
    putQueen(i+1);
    
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
  
 }

int main(){
  int i,j,t,y,k;
  
   for(i = 0;i < N;i++){
     col[i] = FREE;
     row[i] = FREE;
     for(j = 0;j < N;j++){
       board[i][j] = 0;
     }
   }
   for(i = 0;i < 2*N-1;i++){
     dpos[i] = FREE;
     dneg[i] = FREE;
   }
   
  scanf("%d",&k);
 
  for(i=0;i<k;i++){
    scanf("%d%d",&t,&y);
    board[t][y] = NOT_FREE;
  }
  putQueen(0);
  return 0;
}




Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;		//val,mod;
ll inv(ll a,ll m){
	ll b=m,u=1,v=0;
	while(b){
		ll t=a/b;
		swap(a-=t*b,b);
		swap(u-=t*v,v);
	}
	u%=m;
	if(u<0) u+=m;
	return u;
}

struct NTT{
	const int mod,g;
	NTT(int mod,int g) :mod(mod),g(g){}
	ll ex(ll x,ll p){
		ll a=1;
		while(p){
			if(p%2) a=a*x%mod;
			x=x*x%mod;
			p/=2;
		}
		return a;
	}
	ll inv(ll a){
		ll b=mod,u=1,v=0;
		while(b){
			ll t=a/b;
			swap(a-=t*b,b);
			swap(u-=t*v,v);
		}
		u%=mod;
		if(u<0) u+=mod;
		return u;
	}
	void ntt(vector<ll>& a,ll h){
		int N=a.size();
		for(int m=N;m>=2;m/=2){
			int mh=m/2;
			ll w=1;
			rep(i,mh){
				for(int j=i;j<N;j+=m){
					int k=j+mh;
					ll x=(a[j]-a[k]);
					a[j]+=a[k];
					if(a[j]>=mod) a[j]-=mod;
					a[k]=w*x%mod;
					if(a[k]<0) a[k]+=mod;
				}
				w=w*h%mod;
			}
			h=h*h%mod;
		}
		int i=0;
		rep1(j,N-2){
			for(int k=N/2;k>(i^=k);k/=2);
			if(j<i) swap(a[i],a[j]);
		}
	}
	vector<ll> conv(vector<ll> a,vector<ll> b){		// (mod-1)%N==0??§????????¨??????!!
		for(auto& x:a) x%=mod;
		for(auto& x:b) x%=mod;
		int n=a.size()+b.size();
		int N=1;
		while(N<n) N*=2;
		a.resize(N),b.resize(N);
		assert((mod-1)%N==0);
		ll h=ex(g,(mod-1)/N);
		ntt(a,h),ntt(b,h);
		rep(i,N) (a[i]*=b[i])%=mod;
		h=inv(h);
		ntt(a,h);
		h=inv(N);
		rep(i,N) (a[i]*=h)%=mod;
		return a;
	}
};

int main(){
	int N;
	cin>>N;
	vector<ll> A(N*N*2),B;
	rep(i,N) rep(j,N){
		cin>>A[i*2*N+j];
	}
	B=A;
	reverse(all(B));
	auto C=NTT(1224736769,3).conv(A,B);
	vector<ll> mp(1<<21);
	rep(i,N) for(int j=-N+1;j<=N-1;j++){
		if(i==0&&j<=0) continue;
		mp[i*i+j*j]+=C[2*N*N-1-i*2*N+j];
	}
	rep(i,N) rep(j,N){
		int x=A[i*2*N+j];
		mp[0]+=x*(x-1)/2;
	}
	long long sum=0;
	double ave=0;
	rep(i,N*N*2){
		if(mp[i]==0) continue;
		ave+=sqrt(i)*mp[i];
		sum+=mp[i];
	}
	printf("%.12f\n",ave/sum);
	int c=0;
	rep(i,N*N*2){
		if(mp[i]==0) continue;
		printf("%d %lld\n",i,mp[i]);
		c++;
		if(c==10000) break;
	}
}

Measured memory_bytes: 117668