akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn calc_score(c: &Vec<i64>, t: &Vec<usize>, s: &Vec<Vec<i64>>) -> i64 {
    let d = s.len();
    let mut score = 0;
    let mut last = vec![0; 26];
    for i in 0..d {
        score += s[i][t[i]];
        last[t[i]] = i + 1;
        for qi in 0..26 {
            score -= c[qi] * (i as i64 + 1 - last[qi] as i64);
        }
    }
    score
}

fn main() {
    let d = read::<usize>();
    let c = read_vec::<i64>();
    let mut s = vec![vec![]; d];
    for i in 0..d {
        s[i] = read_vec::<i64>();
    }

    let mut answers = vec![];

    for i in 0..d {
        let mut max_idx = 0;
        for j in 0..26 {
            if s[i][j] > s[i][max_idx] {
                max_idx = j;
            }
        }
        answers.push(max_idx);
    }
    let mut cur_score = calc_score(&c, &answers, &s);

    let mut xor = Xorshift::new();
    for _ in 0..250000 {
        let rd = xor.next() as usize % d;
        let rq = xor.next() as usize % 26;

        let prev = answers[rd];
        answers[rd] = rq;
        let score = calc_score(&c, &answers, &s);
        if score > cur_score {
            cur_score = score;
        } else {
            answers[rd] = prev;
        }
    }

    for ans in answers {
        println!("{}", ans + 1);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[derive(Debug)]
pub struct Xorshift {
    seed: u64,
}
impl Xorshift {
    pub fn new() -> Xorshift {
        Xorshift {
            seed: 0xf0fb588ca2196dac,
        }
    }
    pub fn with_seed(seed: u64) -> Xorshift {
        Xorshift { seed: seed }
    }
    #[inline]
    pub fn next(&mut self) -> u64 {
        self.seed = self.seed ^ (self.seed << 13);
        self.seed = self.seed ^ (self.seed >> 7);
        self.seed = self.seed ^ (self.seed << 17);
        self.seed
    }
    #[inline]
    pub fn rand(&mut self, m: u64) -> u64 {
        self.next() % m
    }
}


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


int main(){
  int n,m,v,k[1000],a[1000][1000],memo[1000]={0},g=0,x;
  cin >> n >> m;
  FOR(i,n){
    cin >> k[i];
    v=k[i];
    FOR(j,v){
      cin >> a[i][j];
      x=a[i][j];
      memo[x]+=1;
    }
  }
  FOR(i,m+1){
    if(memo[i]==n){
      g++;
    }
  }
  cout << g << endl;
  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string ss;
		cin>>ss;
		mp[ss]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
}

Measured memory_bytes: 3632
class UnionFind:
    def __init__(self, num):
        self.table = [-1 for _ in range(num)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)

        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False
N,M = map(int,input().split())
u = UnionFind(N)
for i in range(M):
    x,y,z = map(int,input().split())
    x -= 1
    y -= 1
    u.union(x,y)
ans = []
for i in range(N):
    ans.append(u.find(i))
ans = len(set(ans))
print(ans)

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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

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

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a[3];
    F0R(i,3) cin >> a[i];
    sort(a,a+3);
    if((a[1] - a[0])%2 == 0) {
      cout << (a[1] - a[0])/2 + a[2]-a[1] << endl;
      return 0;
    }

    a[0]++;
    a[2]++;
    cout << 1 + (a[1]-a[0])/2 + a[2]-a[1] << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int D = 8e3 + 10;

bool dp[D][2 * D], seen[D][2 * D];
int d = 0;

bool solve(vector <int> &a, int i, int j);

int main() {
	string s; int x, y;
	cin >> s >> x >> y;
	int cur = 0, n = s.length(), st = 0;
	vector <int> moves[2];
	while (st < n and s[st] == 'F') {
		--x;
		++st;
	}

	moves[1].push_back(0);
	for (int i = st; i < n; ++i) {
		if (s[i] == 'T') {
			moves[cur].push_back(0);
			cur = 1 - cur;
		}  else {
			++moves[cur].back();
		}
	}

	x = abs(x);
	y = abs(y);
	d = x;
	bool ans = solve(moves[0], moves[0].size() - 1, x);
	memset(seen, 0, sizeof(seen));
	d = y;
	if (ans and solve(moves[1], moves[1].size() - 1, y)) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

bool solve(vector <int> &a, int i, int j) {
	if (i < 0) {
		return (j == 0);
	} else if (j >= d + D or j <= d - D) {
		return false;
	} else if (seen[i][j + D - d]) {
		return dp[i][j + D - d];
	}

	seen[i][j + D - d] = true;
	dp[i][j + D - d]   = solve(a, i - 1, j + a[i]) or solve(a, i - 1, j - a[i]);
	return dp[i][j + D - d];
}

Measured memory_bytes: 188928
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())

    S = [list(input()) for _ in range(H)]
    # print(S)
    check = [[10 ** 9 for i in range(W)] for j in range(H)]
    if S[0][0] == "#":
        check[0][0] = 1
    else:
        check[0][0] = 0
    for i in range(1, W):
        left = check[0][i - 1]
        if S[0][i] == "#":
            if S[0][i - 1] == "#":
                check[0][i] = left
            else:
                check[0][i] = left + 1
        else:
            check[0][i] = left
    for i in range(1, H):
        up = check[i - 1][0]
        if S[i][0] == "#":
            if S[i - 1][0] == "#":
                check[i][0] = up
            else:
                check[i][0] = up + 1
        else:
            check[i][0] = up
    for i in range(1, H):
        for j in range(1, W):
            # print(S[i][j])
            left = check[i][j - 1]
            up = check[i - 1][j]
            if S[i][j] == "#":
                if S[i][j - 1] == "#" and S[i - 1][j] == "#":
                    check[i][j] = min(left, up)
                elif S[i][j - 1] != "#" and S[i - 1][j] == "#":
                    check[i][j] = min(left + 1, up)
                elif S[i][j - 1] == "#" and S[i - 1][j] != "#":
                    check[i][j] = min(left, up + 1)
                else:
                    check[i][j] = min(left, up) + 1
            else:
                check[i][j] = min(left, up)
    # print(check)
    print(check[-1][-1])


main()


Measured memory_bytes: 3316
n, m = map(int,input().split())
shops = sorted([list(map(int, input().split())) for i in range(n)])
buydrinks = 0
cost = 0

for i in range(n):
    cost += shops[i][0] * shops[i][1]
    buydrinks += shops[i][1]
    if buydrinks >= m:
        cost -= (buydrinks - m) * shops[i][0]
        break

print(cost)

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int gcd(int a , int b){
    while(a > 0 && b > 0){
        if(a > b)   a %= b;
        else    b %= a;
    }
    return a + b;
}

int a , b , k;

int main()
{
    _FastIO;
    cin >> a >> b >> k;
    int n = gcd(a , b);
    vector<int> v;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            v.push_back(i);
            if(i * i != n){
                v.push_back(n / i);
            }
        }
    }
    sort(v.begin() , v.end());
    reverse(v.begin() , v.end());
    cout <<v[k - 1] << endl;
    return 0;
}


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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum = 0, fg = 1;
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

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

int n, k;

inline void input()
{
	n = read<int>(), k = read<int>();
}

inline void solve()
{
	int cnt0 = n / k, cnt1 = 0;
	if(k % 2 == 0) cnt1 = n / k + (n % k >= k / 2);
	printf("%lld\n", (LL) cnt0 * cnt0 * cnt0 + (LL) cnt1 * cnt1 * cnt1);
}

int main()
{
	input();
	solve();

	return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

vs split(string str, string delim) {
	vs result;
	int pos;

	while ((pos = str.find_first_of(delim)) != str.npos) {
		if (pos > 0) {
			result.push_back(str.substr(0, pos));
		}
		str = str.substr(pos + 1);
	}
	if (str.length() > 0) {
		result.push_back(str);
	}

	return result;
}

int main() {
	string line;
	while (getline(cin, line)) {
		vs str = split(line, " ");
		int size = str.size();
		stack<double> S;
		REP(i, size) {
			if (str[i] == "+") {
				double b = S.top();
				S.pop();
				double a = S.top();
				S.pop();
				S.push(a + b);
			}
			else if (str[i] == "-") {
				double b = S.top();
				S.pop();
				double a = S.top();
				S.pop();
				S.push(a - b);
			}
			else if (str[i] == "*") {
				double b = S.top();
				S.pop();
				double a = S.top();
				S.pop();
				S.push(a * b);
			}
			else if (str[i] == "/") {
				double b = S.top();
				S.pop();
				double a = S.top();
				S.pop();
				S.push(a / b);
			}
			else {
				S.push(toInt(str[i]));
			}
		}
		double ans = S.top();
		printf("%.6f\n", ans);
	}
}

Measured memory_bytes: 1288
# include <iostream>
# include <queue>
# include <vector>
# include <string>
using namespace std;
int main(void)
{
	int k;
	priority_queue<int,vector<int>,less<int>> a;
	string s;
	while(cin>>s)
	{
		if(s == "end") break;
		if(s == "insert")
		{
			scanf("%d",&k);
			a.push(k);
		}
		else
		{
			printf("%d\n",a.top());
			a.pop();
		}
	}
	return 0;
} 


Measured memory_bytes: 7216
#include<bits/stdc++.h>
using namespace std;
const int N=304;
int a[N],cnt[4];
long double memo[N][N][N],n;
bool vis[N][N][N];
long double dp (long double a,long double b,long double c,long double emp)
{
    if (emp==n)
        return 0;
    long double &ret=memo[(int)a][(int)b][(int)c];
    bool &ret1=vis[(int)a][(int)b][(int)c];
    if (ret1)
        return ret;
    ret=0;
    ret1=1;
    if (a)
        ret=((dp(a-1,b,c,emp+1)+1.0)*(a/n));
    if (b)
        ret+=((dp(a+1,b-1,c,emp)+1.0)*(b/n));
    if (c)
        ret+=((dp(a,b+1,c-1,emp)+1.0)*(c/n));
    ret+= (emp/n);
    ret/=(1.0-(emp/n));
    return ret;
}
int main()
{
    memset(memo,-1,sizeof memo);
    cin >>n;
    for (int i=0;i<n;i++)
    {
        cin >>a[i];
        cnt[a[i]]++;
    }
    cout <<fixed<<setprecision(10)<<dp(cnt[1],cnt[2],cnt[3],0);
    return 0;
}


Measured memory_bytes: 466816
#include <iostream>

using namespace std;
int main() {
    bool cards[4][14];
    int n,rank;
    char suit;

    for (int s=0;s<4;s++)
        for(int r=1;r<=13;r++)
            cards[s][r] = 0;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>> suit >>rank;
        if(suit=='S')cards[0][rank]=1;
        if(suit=='H')cards[1][rank]=1;
        if(suit=='C')cards[2][rank]=1;
        if(suit=='D')cards[3][rank]=1;
    }

    for(int s=0;s<4;s++){
        for(int r=1;r<=13;r++){
            if(cards[s][r])continue;
            if(s == 0) suit='S';
            if(s == 1) suit='H';
            if(s == 2) suit='C';
            if(s == 3) suit='D';
            cout<< suit <<' '<< r << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3084
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


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

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a, b, c;

	cin >> a;
	cin >> b;
	cin >> c;

	cout << a[0] << b[1] << c[2] << endl;
	
	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie();
	ll n;
	cin>>n;
	ll now=100;
	for(ll i=1;;i++){
		now+=now*0.01;
		if(now>=n){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

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

#define MAX 2000000
#define INFTY 1000000

int n, a[MAX+1];

void maxHeapify(int i){
  int m, k, largest, tmp;
  m = 2*i;
  k = 2*i+1;

  if(m <= n && a[m] > a[i])
    largest =m;
  else
    largest = i;
  if(k <= n && a[k] >  a[largest])
    largest = k;

  if(largest != i) {
    tmp = a[i];
    a[i] = a[largest];
    a[largest] = tmp;
    maxHeapify(largest);
  }
  
}

int extract(){
  int maxv;
  if(n < 1)
    return -INFTY;
  maxv = a[1];
  a[1] = a[n--];
  maxHeapify(1);
  return maxv;
  
}

void increaseKey(int i, int key){
  int tmp;

  if(key <a[i])
    return ;
  a[i] = key;
  while(i > 1 && a[i/2] < a[i]) {
    tmp = a[i];
    a[i] = a[i/2];
    a[i/2] = tmp;
    i /= 2;
  }
  
}

void insert(int key){
  n++;
  a[n] = -INFTY;
  increaseKey(n, key);
  
}

int main(){
  int key;
  char command[10];

  while(1) {
    scanf("%s", command);
    if(strcmp(command, "end") == 0)
      break;
    if(strcmp(command, "insert") == 0) {
      scanf("%d", &key);
      insert(key);
    }
    else {
      printf("%d\n", extract());
    }
  }
  
  return 0;
  
}



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int main() {
  int minn = 1000;
  int a;
  int res = 0;
  REP(i, 5) {
    cin >> a;
    if (a%10) minn = min(minn, a%10);
    res += (a+9)-((a+9)%10);
  }
  if (minn != 1000) res = res - (10-minn);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3568
#include<stdio.h>
int main(void){
    char c[2];
    scanf("%s",c);
    if((c[0]=='a')||(c[0]=='i')||(c[0]=='u')||(c[0]=='e')||(c[0]=='o')){
        printf("vowel");
    }
    else
    {
        printf("consonant");
    }
return 0;
}

Measured memory_bytes: 128
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  ll n;
  cin>>s>>n;
  ll dp[10001][2][100];
  rep(i,s.size()+1) rep(j,2) rep(k,100) dp[i][j][k]=0; 
  dp[0][0][0]=1;
  rep(i,s.size()){
    rep(smaller,2){
      rep(mod,n){
        ll lim=(smaller ? 9 : s[i]-'0');
        for(ll num=0;num<=lim;num++){
          dp[i+1][smaller || (num<lim)][(mod+num)%n]+=dp[i][smaller][mod];
          dp[i+1][smaller || (num<lim)][(mod+num)%n]%=MOD;
        }
      }
    }
  }
  if(dp[s.size()][1][0]+dp[s.size()][0][0]-1<0) cout<<(dp[s.size()][1][0]+dp[s.size()][0][0]-1+MOD)<<endl;
  else cout<<(dp[s.size()][1][0]+dp[s.size()][0][0]-1)%MOD<<endl;
}

Measured memory_bytes: 15872
n, m, l = map(int, input().split())

A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for j in range(m)]
C = [ [sum([A[k][j] * B[j][i] for j in range(m)]) for i in range(l)] for k in range(n)]

for i in range(n):
    C[i] = map(str, C[i])
    print(" ".join(C[i]))

Measured memory_bytes: 8904
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.Random;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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);
        ACandyDistributionAgain solver = new ACandyDistributionAgain();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACandyDistributionAgain {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int[] a = in.readIntArray(n);
            Util.safeSort(a);

            int answer = 0;
            for (int i = 0; i < n; i++) {
                x -= a[i];
                if (x < 0)
                    break;
                answer++;
            }

            if (x > 0)
                answer--;

            out.println(answer);
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readIntArray(int n) {
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextInt();
            }
            return x;
        }

    }

    static class Util {
        public static void safeSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {
        }

    }
}



Measured memory_bytes: 25656
import math

n, m = map(int, input().split(" "))
xL = sorted(list(map(int, input().split(" "))))

diff = [0 for _ in range(m - 1)]

for i in range(m - 1):
    diff[i] = xL[i + 1] - xL[i]

diff = sorted(diff, reverse=True)

print(sum(diff[n - 1:]))

Measured memory_bytes: 20400
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string.h>
#define MAX_V 300
#define INF 100000000000000
using namespace std;

struct edge {long long to,cap,rev;};

vector<edge> G[MAX_V];
long long level[MAX_V],iter[MAX_V];

void add_edge(int from, int to, long long cap){
		G[from].push_back((edge){to,cap,(long long)G[to].size()});
		G[to].push_back((edge){from,0,(long long)G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front();
		que.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e = G[v][i];
			if(e.cap>0 && level[e.to]<0){
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

long long dfs(int v, int t, long long f){
	if(v==t) return f;
	for(int i = iter[v];i<G[v].size();i++){
		edge &e = G[v][i];
		if(e.cap>0 && level[v]<level[e.to]){
		int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
	
long long max_flow(int s, int t){
	long long flow = 0;
	for(;;){
		bfs(s);
		if(level[t]<0) return flow;
		memset(iter,0,sizeof(iter));
		long long f;
		while((f=dfs(s,t,INF))>0){
			flow += f;
		}
	}
}

int main(){
	int n,s,t;
	long long sum=0,a[110];
	cin >> n;
	s = 0; t = n+1;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		for(int j=1;j<i;j++){
			if(i%j==0){
				add_edge(i,j,INF);
			}
		}
		if(a[i]>0){
			add_edge(s,i,a[i]);
			sum += a[i];
		}else{
			add_edge(i,t,-a[i]);
		}
	}
	
	long long f = max_flow(0,n+1);
	cout << sum - f << endl;
}
		
			

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

using namespace std;
int main()
{
  string S;
  cin >> S;
  int ans=1000000;
  for(int n=0;n<2;n++)
    {
      int tmp = 0;
      for(int i=0;i<S.size();i++)
	{
	  if( (int)(S[i]-'0') != (i+n)%2 )
	    tmp++;
	}
      ans = min(ans, tmp);
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int search(int a[],int n,int key){
  int i = 0;
  a[n]=key;
  while(a[i]!=key) i++;
  return i != n;
}


int main(){


int n,m;
int a[10005]={};
int b[505]={};

cin >> n;

for(int i=1;i<=n;i++){
  cin >> a[i];
 }
 int key;
cin >> m;
int c=0;
for(int i=1;i<=m;i++){
  cin >> key;
  if(search(a,n,key)) c++;
 }





    cout << c << endl;

}

Measured memory_bytes: 1208
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
using pii=std::pair<int,int>;

using namespace std;

int n,m;
pii ab[100005];
int parent[100005],size[100005];
int ans[100005];
class DDecayedBridges {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n >> m;
		f(i,0,n)
			make_set(i);
		f(i,0,m)
		{
			in >> ab[i].first >> ab[i].second;
			ab[i].first--;
			ab[i].second--;
		}
		int root=ab[m-1].second;
		int goodpairs=0;
		f(i,0,m)
		{
            ans[m-1-i]=(n*(n-1))/2-goodpairs;
		    goodpairs+=union_sets(ab[m-1-i].first,ab[m-1-i].second);
		}
		f(i,0,m)
			out << ans[i] << "\n";
	}
	void make_set(int x)
	{
		parent[x]=x;
		size[x]=1;
	}
	int find_parent(int x)
	{
		if(parent[x]==x)
			return x;
		return parent[x]=find_parent(parent[x]);
	}

	int union_sets(int x,int y)
	{
		x=find_parent(x);
		y=find_parent(y);
		if(x!=y)
		{
			if(size[x]<size[y])
				swap(x,y);
			parent[y]=x;
			size[x]+=size[y];
			return (size[x]-size[y])*size[y];
		}
		return 0;
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	DDecayedBridges solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5248
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const long long inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;

ll n, k;

struct node{
	ll w;
	ll v;
}a[100005];

ll dp[100005];

int main(){
	cin >> n >> k;
	ll sumv = 0; 
	for(ll i = 1; i <= n; i++){
		cin >> a[i].w >> a[i].v;
		sumv += a[i].v;
	}
	for(int i = 1; i <= 1e5; i++){
		dp[i] = INF;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1e5; j >= a[i].v; j--){
			dp[j] = (dp[j] < (dp[j - a[i].v] + a[i].w) ? dp[j] : (dp[j - a[i].v] + a[i].w));
		}
	}
	ll ans = 0;
	for(int i = 1e5; i >= 1; i--){
		if(dp[i] <= k){
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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

  int n;
	cin >> n;
	int a, b, c, d;
	int poi[n] = {};
	int N = n * (n - 1) / 2;
	P rank[n];

	rep(i, N) {
		cin >> a >> b >> c >> d;
		if(c > d) {
			poi[a - 1] += 3;
		} if(c == d) {
			poi[a - 1]++;
			poi[b - 1]++;
		} if(c < d) {
			poi[b - 1] += 3;
		}
	}
	//rep(i, n) cout << poi[i] << " ";
	rep(i, n) {
		rank[i].first = poi[i];
	}
	sort(rank, rank + n, greater<P>());
	rep(i, n) {
		if(!i) rank[i].second = 1;
		else if(rank[i].first == rank[i - 1].first) rank[i].second = rank[i - 1].second;
		else rank[i].second = i + 1;
	}
	rep(i, n) {
		int np = poi[i];
		rep(j, n) {
			if(rank[j].first == np) {
				cout << rank[j].second << endl;
				break;
			}
		}
	}
	//rep(i, n) cout << rank[i].first << " " << rank[i].second << endl;
  return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

const ll INF = 1e9;
const long long INFL = 1LL<<60;

int delete_stone(vector<vector<int>>& c, const int& k) {
  int h = c.size();
  int w = c[0].size();
  int score = 0;
  for (int i = 0; i < h; i++) {
    for (int l = 0; l < w;) {
      int r = l + 1;
      for (; r < w && c[i][l] == c[i][r]; r++);
      if (r - l >= k) {
        score += c[i][l] * (r - l);
        for (; l < r; l++) c[i][l] = 0;
      }
      l = r;
    }
  }
  return score;
}

void move_stone(vector<vector<int>>& c) {
  int h = c.size();
  int w = c[0].size();
  rep(j, w) {
    vector<int> tmp(h, 0);
    int l = 0;
    for (int i = h - 1; i >= 0; i--) {
      if (c[i][j] != 0) tmp[l++] = c[i][j];
    }
    for (int i = h - 1; i >= 0; i--) {
      c[i][j] = tmp[h - 1 - i];
    }
  }
}

int calc(vector<vector<int>> c, int h, int w, const int& k) {
  c[h][w] = 0;
  move_stone(c);
  int score = 0;
  for (int i = 1; ; i *= 2) {
    int tmp = delete_stone(c, k);
    if (tmp == 0) break;
    score += tmp * i;
    move_stone(c);
  }
  return score;
}

int main() {
  int h, w, k;
  cin >> h >> w >> k;

  vector<vector<int>> c(h, vector<int>(w, 0));

  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) c[i][j] = int(s[j] - '0');
  }

  int ans = 0;

  rep(i, h) {
    rep(j, w) {
      chmax(ans, calc(c, i, j, k));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
const int N = 1009;
int n, m, D[N][N];
int gx[] = {-1, 1, 0, 0}, gy[] = {0, 0, -1, 1};
char A[N][N];
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%s", &A[i]);
	memset(D, 63, sizeof(D));
	queue < pair < int , int > > qu;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (A[i][j] == '#')
				D[i][j] = 0, qu.push({i, j});
	int Mx = 0;
	while (qu.size())
	{
		int i = qu.front().first;
		int j = qu.front().second;
		qu.pop();
		for (int h = 0; h < 4; h++)
		{
			int tx = i + gx[h], ty = j + gy[h];
			if (tx >= 0 && ty >= 0 && tx < n && ty < m && D[tx][ty] > D[i][j] + 1)
				D[tx][ty] = D[i][j] + 1, qu.push({tx, ty});
		}
		Mx = max(Mx, D[i][j]);
	}
	printf("%d\n", Mx);
	return 0;
}


Measured memory_bytes: 13456
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) throws IOException {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		// ??¨???????????£????????????????????????????????????
		List<String> all = new ArrayList<String>();
		for (char c : "SHCD".toCharArray()) {
			for (int i = 1; i <= 13; i++) {
				all.add(String.format("%c %d", c, i));
			}
		}
		
		// ?????£???????????????????????????????????????
		int count = sc.nextInt();
		sc.nextLine();
		for (int i = 0; i < count; i++) {
			all.remove(sc.nextLine());
		}
		
		// ?????£??????????????????
		for (String s : all) {
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 26368
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
        c-=b; 
        if(c<=0) {cout<<"Yes";return;}
        a-=d;
        if(a<=0) {cout<<"No";return;}
    }
}
int  main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3624
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a, b,c,d = map(int, input().split())
if a+b>c+d:
    print("Left")
elif a+b==c+d:
    print("Balanced")
else:
    print("Right")

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

int main(){
  int64_t N;
  cin >> N;
  double sq=sqrt(N);
  int x=(int)sq;
  if(sq==x){
    cout << to_string(x).size() << endl;
    return 0;
  }
  for(int64_t i=x;i>=1;i--){
    if(N%i==0){
      int64_t y=N/i;
      cout << to_string(y).size() << endl;
      return 0;
    }
  }
  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>
#include <climits>
#include <limits>

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())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++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

int main() {
	string s; cin >> s;
	LL l = s.size();
	LL ans = 1;
	//探索するアルファベット決め
	for (int i = 0; i < 26; i++) {
		
		//何個含まれてるか数える
		int cnt = 0;
		for (int j = 0; j < s.size(); j++) {
			if (s[j] == (i + 'a')) {
				cnt++;
			}
		}

		// i<jでi番目とj番目が違う組を数えたい
		int now = cnt;
		for (int j = 0; j < s.size(); j++) {
			if (s[j] == (i + 'a')) {
				now--;
				ans += (l - 1 - j - now);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
using System;

class Program
{
    static void Main(string[] args)
    {
        int i, j;

        int n = int.Parse(Console.ReadLine());
        string[] strInput = Console.ReadLine().Split(' ');
        int[] a = new int[n];

        for(i = 0; i < n; i++)
        {
            a[i] = int.Parse(strInput[i]);
        }

        int result = 0;

        for (i = 0; i < n; i += 2)
        {
            if (a[i] % 2 == 1)
            {
                result++;
            }
        }

        Console.WriteLine(result);

        return;
    }
}

Measured memory_bytes: 27380
N = int(input())
dp = [[0 for i in range(N+1)] for j in range(N+1)]
out = [0 for i in range(N+1)]
re = 1
for i in range(N+1):
    if i < 2:
        continue
    for j in range(i+1):
        if j<2:
            continue
        if i%j == 0:
            dp[i][j] = 1
            for k in range(int(i/j)+1):
                dp[i][k] += dp[int(i/j)][k]
            break

for i in range(N+1):
    for j in range(i+1):
        out[j] += dp[i][j]

for o in out:
    re*=(o+1)

print(re%(10**9+7))

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

using namespace std;

int main(){
    int a, b, t;

    cin >> a >> b >> t;

    int total = 0;
    for(int s = 1; s<=t+0.5; ++s){
        if(s%a == 0){
            total+=b;
        }
    }

    cout << total << endl;

    return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<int> sum(n + 1);
    REP(i, 1, n){
        if(s[i - 1] == 'A' && s[i] == 'C'){
            ++sum[i + 1];
        }
    }

    REP(i, 1, n + 1){
        sum[i] += sum[i - 1];
    }

    rep(i, q){
        int l, r;
        cin >> l >> r;
        if(sum[l] != sum[l - 1]){
            cout << sum[r] - sum[l - 1] - 1 << endl;
        }else{
            cout << sum[r] - sum[l - 1] << endl;
        }
    }

    return 0;
}

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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const ll INF = 1e9 + 1;
const ll MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

ll N, M;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    vector<ll> f(N + 1);
    f[0] = 1;
    f[1] = 1;
    if( M == 0){
        LREP(i, 2, N + 1) f[i] = (f[i-1] + f[i-2]) % MOD;
        cout << f[N] << '\n';
        return 0;
    }
    vector<ll> a(M);
    LREP(i, 0, M) cin >> a[i];
    f[0] = 1;
    ll idx = 0;
    LREP(i, 1, N + 1){
        if(idx <= M && a[idx] == i){
            f[i] = 0;
            idx += 1;
        }else if(i == 1){
            f[i] = 1;
        }else{
            f[i] = (f[i-1] + f[i-2]) % MOD;
        }
    }
    cout << f[N] << '\n';
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
struct Point{double x,y;};
Point operator -(Point a,Point b){return (Point){a.x-b.x,a.y-b.y};}
double cross(Point a,Point b){return a.x*b.y-a.y*b.x;}
double dot(Point a,Point b){return a.x*b.x+a.y*b.y;}
double norm(Point a){return a.x*a.x+a.y*a.y;}
void read(Point &a){a.x=read(),a.y=read();}
int Clockwise(Point p0,Point p1,Point p2)
{
	Point v1=p1-p0,v2=p2-p0;
	if(cross(v1,v2)>0)return -2;
	if(cross(v1,v2)<0)return 2;
	if(dot(v1,v2)<0)return -1;
	if(norm(v1)<norm(v2))return 1;
	return 0;
}
bool Intersect(Point p0,Point p1,Point p2,Point p3)
{
	if(Clockwise(p0,p1,p2)*Clockwise(p0,p1,p3)>0)return 0;
	if(Clockwise(p2,p3,p0)*Clockwise(p2,p3,p1)>0)return 0;
	return 1;
}
int main()
{
	int q=read();while(q--)
	{
		Point p0,p1,p2,p3;
		read(p0),read(p1),read(p2),read(p3);
		printf("%d\n",Intersect(p0,p1,p2,p3));
	}
	return 0;
}



Measured memory_bytes: 3204