akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
using ll = long long int;

map<ll, ll> sosuu(ll n);
ll pow_rapid(ll n, ll exp);
void test();

// 素因数分解
map<ll, ll> sosuu(ll n) {
  map<ll, ll> res;

  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      res[i]++;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

// 繰り返し二乗法
ll pow_rapid(const ll n, const ll exp) {
  if (exp == 1) {
    return n;
  } else if (exp == 0) {
    return 1;
  }

  if (exp % 2 == 0) {
    ll a = pow_rapid(n, exp / 2);
    return a * a;
  } else {
    ll a = pow_rapid(n, exp / 2);
    return a * a * n;
  }
}
ll gcd(const ll a, const ll b) {
  if (a % b == 0) {
    return b;
  }
  return gcd(b, a % b); 
}

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

void solve() {
  int n;
  cin >> n;
  // map<ll, ll> lcm;
  set<ll> t;

  for (size_t i = 0; i < n; i++) {
    ll ti;
    cin >> ti;
    t.insert(ti);
  }

  // for (auto &&ti : t) {
    // map<ll, ll> mp = sosuu(ti);
    // for (auto &&e : mp) {
    //   lcm[e.first] = max(lcm[e.first], e.second);
    // }
  // }

  // ll ans = 1;
  // for (auto &&e : lcm) {
  //   ll n = pow_rapid(e.first, e.second);
  //   ans *= n;
  // }
  ll ans = 1;
  for (auto &&e : t) {
    ans = lcm(ans, e);
  }
  cout << ans << endl;
  return;
}

int main() {
  test();
  solve();
}

void test() {
  // sosuu test
  {
    map<ll, ll> mp = sosuu(10);
    map<ll, ll> expect_mp = {{2, 1}, {5, 1}};
    assert(mp == expect_mp);
  }
  // sosuu test2
  {
    map<ll, ll> mp = sosuu(1024);
    map<ll, ll> expect_mp = {{2, 10}};
    assert(mp == expect_mp);
  }

  // pow rapid test 1
  {
    ll n = pow_rapid(2, 10);
    assert(n == pow(2, 10));
  }
  // pow rapid test 2
  {
    ll n = pow_rapid(3, 0);
    assert(n == pow(3, 0));
  }
  // pow rapid test 3
  {
    ll n = pow_rapid(10, 9);
    assert(n == pow(10, 9));
  }
  // gcd test 1
  {
    ll n = gcd(32, 1024);
    assert(n == 32);
  }
  // gcd test 2
  {
    ll n = gcd(125, 4);
    assert(n == 1);
  }
  // lcm test 1
  {
    ll n = lcm(125, 4);
    assert(n == 500);
  }
  // lcm test 2
  {
    ll n = lcm(24, 36);
    assert(n == 72);
  }
  // lcm test 3
  {
    ll n = lcm(1, 10000007);
    assert(n == 10000007);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int arr[40]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<arr[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

int used[200200];
vvi G(200200);
int n,cx,cy;
void dfs(int x){
	if(x<100100)cx++;
	else cy++;
	used[x]=true;
	rep(i,G[x].size())if(used[G[x][i]]==0){
		dfs(G[x][i]);
	}
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n;
	rep(i,n){
		int a,b;cin>>a>>b;
		a--;b--;
		G[a].pb(b+100100);
		G[b+100100].pb(a);
	}
	int out=0;
	rep(i,100100)if(G[i].size()){
		cx=cy=0;
		dfs(i);
		out+=cx*cy;
	}
	cout<<out-n<<endl;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;

lli a,b,q;
lli s_[e5];
lli t_[e5];
lli *s;
lli *t;

void solve(lli x){
  // s -> t
  lli next, terminal;
  lli ans = 1000000000000ll;
  next = *lower_bound(s,s+a,x);
  terminal = *lower_bound(t,t+b,next);
  ans = min(ans, abs(next-x)+abs(terminal-next));
  terminal = *(lower_bound(t,t+b,next)-1);
  ans = min(ans, abs(next-x)+abs(terminal-next));
  next = *(lower_bound(s,s+a,x)-1);
  terminal = *lower_bound(t,t+b,next);
  ans = min(ans, abs(next-x)+abs(terminal-next));
  terminal = *(lower_bound(t,t+b,next)-1);
  ans = min(ans, abs(next-x)+abs(terminal-next));
  // t -> s
  next = *lower_bound(t,t+b,x);
  terminal = *lower_bound(s,s+a,next);
  ans = min(ans, abs(next-x)+abs(terminal-next));
  terminal = *(lower_bound(s,s+a,next)-1);
  ans = min(ans, abs(next-x)+abs(terminal-next));
  next = *(lower_bound(t,t+b,x)-1);
  terminal = *lower_bound(s,s+a,next);
  ans = min(ans, abs(next-x)+abs(terminal-next));
  terminal = *(lower_bound(s,s+a,next)-1);
  ans = min(ans, abs(next-x)+abs(terminal-next));
  cout << ans << endl;
}


int main(){
  cin >> a >> b >> q;
  for(lli i = 1;i <= a;i++) cin >> s_[i];
  for(lli i = 1;i <= b;i++) cin >> t_[i];
  s = s_+1;
  t = t_+1;
  s[a] = t[b] = 1000000000000ll;
  s[-1] = t[-1] = -1000000000000ll;
  for(lli i = 0;i < q;i++){
    lli x;
    cin >> x;
    solve(x);
  }
}


Measured memory_bytes: 4096
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<iterator>
#include<string>
#include<sstream>
#include <unordered_map>
#include<cmath>
using namespace std;
#define ll long long
int __gcd(int a,int b){return b==0 ? a : __gcd(b,a%b);}
ll __gcd(ll a,ll b){return b==0 ? a : __gcd(b,a%b);}

const int MaxPrimeNum = 1e7+10, MaxSize = 1e7+10;
int num_prime = 0, MinPrime[MaxSize], MaxPrime[MaxSize];		//分别记录可以整除MaxSize的最小与最大prime的index      //MaxPrime可以改成bit类型数组来记录是否是prime或者是否是Prime幂次方
int fact_num[MaxSize], MinPrime_num[MaxSize];
int prime[MaxPrimeNum], myresult;
 
 
void euler_sieve(int n)
{
	int i, j, len, tmp;
	num_prime = 1;
	for (i = 2; i < n; ++i)
	{
		if (!MinPrime[i])
		{
			prime[len = MinPrime[i] = num_prime++] = i;
			MinPrime_num[i] = 1;	
			fact_num[i] = 2;
		}
		else
		{
			if (myresult < fact_num[i])
			{
				myresult = fact_num[i];
			}
			len = MinPrime[i];
		}
 
		for (j = 1; j < len && (tmp = i * prime[j]) < n; ++j)
		{
			MinPrime[tmp] = j;
			fact_num[tmp] = fact_num[i] << 1;
		    MinPrime_num[tmp] = 1;
		}
 
		if (j == len && (tmp = i * prime[j]) < n)
		{
			MinPrime[tmp] = j;
			MinPrime_num[tmp] = MinPrime_num[i] + 1;
			fact_num[tmp] = fact_num[i] / MinPrime_num[tmp] * (MinPrime_num[tmp]+1);
		}
	}
}


int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int _=1;
    while(_--){
        euler_sieve(1e7+10);
        int n; cin>>n;
        ll ans=0;
        for(int i=1;i<=n;++i) ans+=1ll*i*fact_num[i];
        cout<<ans+1<<"\n";
    }
}

Measured memory_bytes: 123440
# Problem A - Candy Distribution Again

# input
n, x = map(int, input().split())
a_list = list(map(int, input().split()))

# initialization
a_list = sorted(a_list)
person_num = 0

# count process
for i in range(len(a_list)):
    a = a_list[i]
    x = x - a
    if x >= 0:
        person_num += 1

# output
if x>0:
    print(person_num - 1)
else:
    print(person_num)


Measured memory_bytes: 38256
# -*- coding: utf-8 -*-

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    a, b = list(map(int, input().split()))

    if a * b <= 0:
        print('Zero')
    elif (a >= 1) or ((b <= -1) and ((b - a + 1) % 2 == 0)):
        print('Positive')
    else:
        print('Negative')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int dp[50][500][500];
int main(){
    int n,ma,mb; cin>>n>>ma>>mb;
    int a[n],b[n],c[n]; rep(i,n) cin>>a[i]>>b[i]>>c[i];
    // dp[i][j][k]:=i番目まで見てAがj/Bがkになる最小費用
    rep(i,50)rep(j,500)rep(k,500) dp[i][j][k]=INF;
    dp[0][0][0]=0;
    for(int i=1;i<=n;i++){
        rep(j,500)rep(k,500){
            dp[i][j][k]=dp[i-1][j][k];
            if(j-a[i-1]>=0&&k-b[i-1]>=0){
                dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1]);
            }
        }
    }
    int ans=INF;
    for(int j=1;j*ma<500&&j*mb<500;j++){
        ans=min(ans,dp[n][j*ma][j*mb]);
    }
    cout<<(ans!=INF?ans:-1)<<endl;
    return 0;
}


Measured memory_bytes: 49024
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn :: IO Int
    cs <- U.fromList <$> getLine
    q <- readLn :: IO Int
    ks <- map read.words <$> getLine
    mapM_ (print.solve cs) ks

solve :: U.Vector Char -> Int -> Int
solve cs k = fst $ U.foldl' step (U.foldl' step0 (0, emptyQ) pre) post
  where
    (pre, post) = U.splitAt k cs
    step0 (!res, !q) c
        | c == 'C' = (res + score q', q')
        | otherwise = (res, q')
      where
        q' = push c q

    step (!res, !q) c
        | c == 'C' = (res + score q', q')
        | otherwise = (res, q')
      where
        q' = push c $ pop (U.unsafeIndex cs) q

data Q = Q !Int !Int !Int !Int

emptyQ :: Q
emptyQ = Q 0 0 0 0

push :: Char -> Q -> Q
push 'D' (Q d m dm f) = Q (d + 1) m dm f
push 'M' (Q d m dm f) = Q d (m + 1) (dm + d) f
push c q              = q

pop :: (Int -> Char) -> Q -> Q
pop v (Q d m dm f) = case v f of
    'D' -> Q (d - 1) m (dm - m) (f+1)
    'M' -> Q d (m - 1) dm (f+1)
    _   -> Q d m dm (f+1)

score :: Q -> Int
score (Q _ _ dm _) = dm


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

using namespace std;

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

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll N;
  cin >> N;

  ll a = N % 10;

  switch (a) {
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    cout << "hon" << endl;
    break;
  case 0:
  case 1:
  case 6:
  case 8:
    cout << "pon" << endl;
    break;
  case 3:
    cout << "bon" << endl;
  default:
    break;
  }

  return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Chain Disappearance Puzzle
 */
public class Main {

	public static int W = 5;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int H = parseInt(line);
			if (H == 0) break;

			// init
			@SuppressWarnings("unchecked")
			List<Integer>[] board = new ArrayList[W];

			for (int i = 0; i < W; i++) {
				board[i] = new ArrayList<>();
			}

			for (int i = 0; i < H; i++) {
				String[] words = br.readLine().split(" ");
				for (int j = 0; j < W; j++) {
					board[j].add(0, parseInt(words[j]));
				}
			}

			// solve
			int point = 0;
			boolean hasNext = true;

			while (hasNext) {

				hasNext = false;

				// chain
				for (int i = 0; i < H; i++) {
					int min = W, max = -1, stone = 0;
					for (int j = 1; j <= 3; j++) {
						if (board[j].get(i) != 0
								&& board[j].get(i) == board[j - 1].get(i)
								&& board[j].get(i) == board[j + 1].get(i)) {
							min = Math.min(min, j - 1);
							max = Math.max(max, j + 1);
							stone = board[j].get(i);
							hasNext = true;
						}
					}
					if (max - min >= 2) point += stone * (max - min + 1);
					for (int j = min; j <= max; j++) board[j].set(i, 0);
				}
				// drop down
				for (int i = 0; i < W; i++) {
					board[i].removeIf(x -> x == 0);
					while (board[i].size() < H) board[i].add(0);
				}
			}

			System.out.println(point);

		} //end while
	} //end main
}

Measured memory_bytes: 37132
from itertools import product

s = str(input())
a = list(product(['+', ''], repeat=len(s)-1))


ans = 0
tmp = ""
for i in a:
    tmp = ""
    for j in range(len(s)-1):
        tmp += (s[j]+i[j])
    tmp += s[len(s)-1]
    ans += eval(tmp)
print(ans)


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

#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define INTM INT_MAX
#define FOR(i,n)	for(int i=0;i<n;i++)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

bool cmp(int &a,int &b){
        return a<b;                //ascending order
        return a>b;                //descending order
}

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
struct IO{
    ll pow,coin,id;
}srr[100001];

bool cmpsr(IO aa,IO bb){
    if(aa.pow==bb.pow) return aa.coin>bb.coin;
    return (aa.pow<bb.pow);
}

int main()
{
    ll n,k,ops,flag = 1,number;
    cin>>n>>k;
    ll arr[10]={0};
    for(ll i=0;i<k;i++){
        cin>>ops;
        arr[ops] = 1;
    }
    number = n;
    while(flag){
        n = number;
        //cout<<number<<endl;
        ll rsfl = 0;
        while(n>0){
            ll rm = n%10;
            n = n/10;
            if(arr[rm] == 1){
                rsfl = 1;
                break;
            }
        }
        if(rsfl == 0){
            cout<<number<<endl;
            return 0;
        }
        number++;
    }
}



Measured memory_bytes: 256
_rule = {'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(0,3,1,4,2,5),'W':(0,2,4,1,3,5)}
_idx = {'top':0, 'front':1, 'right':2, 'left':3, 'back':4, 'bottom':5}
_idxmap = ((1,2),(1,1),(2,1),(0,1),(3,1),(1,0))

def motion(dlist, direction):
    templist = dlist
    for i in range(len(direction)):
        templist = [templist[r] for r in _rule[direction[i]]]
    return templist

def stopmotion(dlist, num, distination):
    return dlist.index(num) == _idxmap[distination]
    
def search(dlist, top, front):
    ret = ''
    prepos = _idxmap[dlist.index(top)]
    topxpos, topypos = _idxmap[0]
    xpos = topxpos - prepos[0]
    ypos = topypos - prepos[1]
    if xpos <= 0:
        ret = 'W' * abs(xpos)
    else:
        ret = 'E' * abs(xpos)
    ret += 'N' * abs(ypos)
    
    templist = motion(x, ret)
    
    ret = ''
    prepos = _idxmap[templist.index(front)]
    frontxpos, frontypos = _idxmap[1]
    xpos = frontxpos - prepos[0]
    if xpos <= 0:
        ret = 'W' * abs(xpos)
    else:
        ret = 'E' * abs(xpos)
    return motion(templist, ret)
        
x = input().split()

for _ in range(int(input())):
    top, front = input().split()
    templist = search(x, top, front)
    print(templist[_idx['right']])


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> A;
    A.push_back(0);
    int sum = 0;
    for ( int i = 0; i < N; i++ ) {
        int a;
        cin >> a;
        A.push_back(a);        
    }
    A.push_back(0);
    vector<int> X(N+2);
    for ( int i = 1; i < A.size(); i++ ) {
        X[i] = abs(A[i]-A[i-1]);
        sum += X[i];
    }
    for ( int i = 1; i <= N; i++ ) {
        cout << sum - X[i] - X[i+1] + abs(A[i-1]-A[i+1]) << endl;
    }

    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
   int n; cin >> n;
   vector<int> l(n);
   int ans=0;
   rep(i,n) cin >> l[i];
   for(int i=0; i<n-2; i++){
       for(int j=i+1; j<n-1; j++){
           for(int z=j+1; z<n; z++){
               if(l[i] != l[j] && l[i] != l[z] && l[j] != l[z]){
               if(l[i]+l[j]>l[z] && l[i]+l[z]>l[j] && l[z]+l[j]>l[i]) ans++;
               //cout << i << j << z << endl;
           }
           }
       }
   }
   cout << ans << endl;
return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    string s;
    cin >> s;
    bool used[100]={false};
    rep(i, s.size())used[s[i]-'a']=true;
    char m = 'a';
    while(used[m-'a'])m++;
    if(m>'z'){
        while(!s.empty()){
            if(s.back()=='z'){
                used[25]=false;
                s.pop_back();
                continue;
            }
            char tmp=s.back();
            while(tmp<'z'&&used[tmp-'a'])tmp++;
            if(!used[tmp-'a']){
                s.back()=tmp;
                break;
            }
            else{
                used[s.back()-'a']=false;
                s.pop_back();
            }
        }
        if(s.empty()){
            cout << -1 << endl;
            return 0;
        }
    }
    else s+=m;
    cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define N 200010
using namespace std;
inline int read()
{
	int neg=1,num=0;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')neg=-1;
	for(;isdigit(c);c=getchar())num=(num<<1)+(num<<3)+c-'0';
	return neg*num;
}
int n,T;
char s[N];
int main()
{
//	n=read();
	scanf("%s",s+1);
	n=strlen(s+1);
	if(s[n]=='s')
	{
		for(int i=1;i<=n;i++)cout<<s[i];
		cout<<"es"<<endl;
	}
	else
	{
		for(int i=1;i<=n;i++)cout<<s[i];
		cout<<"s"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main() {

  int N;
  cin >> N;
  int x = N % 10;
  
  if (x == 3) {
    cout << "bon" << endl;
  }
  
  else if (x == 0 || x == 1 || x == 6 || x == 8) {
    cout << "pon" << endl;
  }
  
  else {
    cout << "hon" << endl;
  }
}
  
    
    
  
  

Measured memory_bytes: 3588
//119B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n=0;
    double x=0.0, ans=0.0;
    string u= " ";
    cin >> n;
    
    rep(i, n){
        cin >> x >> u;
        if(u=="BTC"){
            ans += x*380000;
        }else{
            ans += x;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int S = 1e4 + 10;
const int inf = 1e13 + 10;
vector<int> cur(S,0),nex(S,0);

struct dat
{
    int w,s,v;
    
    inline bool operator<(const dat & o)
    {
        return s + w < o.s + o.w;
    }
};

signed main()
{
    fast;
    
    int n;
    cin >> n;
  
    dat a[n];
    
    f(i,n) cin >> a[i].w >> a[i].s >> a[i].v;
    
    sort(a,a+n);
    
    f(i,n)
    {
        f(j,S) nex[j] = cur[j];
        
        //try to take ith element if possible
        for(int j=a[i].s;j>=0;j--)
            nex[min(j+a[i].w,S-1)] = max(nex[min(j+a[i].w,S-1)],cur[j] + a[i].v);
       
        swap(cur,nex);
    }
    
    int res = -inf;
    
    for(auto x : cur) res = max(res,x);
    
    cout << res;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N = 1e5 + 5;
int n , dp[N][3];
int main(){
	scanf("%d",&n);
	for (int i = 1; i <= n; ++i){
		int a , b ,c;
		scanf("%d%d%d",&a,&b,&c);
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a;
		dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b;
		dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c;
		
	}
	cout << max( { dp[n][0] , dp[n][1] , dp[n][2] } ) <<endl;
	

}	

Measured memory_bytes: 4852
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int A, B;
char Ans[100][100];

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

  cin >> A >> B;

  rep(i, 50){
    rep(j, 100) Ans[i][j] = '.'; 
  }
  for(int i=50; i < 100; i++){
    rep(j, 100) Ans[i][j] = '#';
  }

  int b_cnt = 0;
  int h = 0;
  int w = 0;
  if (B > 1){
    while(b_cnt < B-1){
      Ans[h][w] = '#';
      b_cnt++;
      w+=2;
      if (w>=100){
        h+=2;
        w=0;
      }
    }
  }

  h = 51;
  w = 0;
  int w_cnt = 0;
  if (A>1){
    while(w_cnt < A-1){
      Ans[h][w] = '.';
      w_cnt++;
      w+=2;
      if (w>=100){
        h+=2;
        w = 0;
      }
    }  
  }

  cout << 100 << ' ' << 100 << endl;

  rep(i,100){
    rep(j, 100){
      cout << Ans[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1e9+7;
int main() {
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++){
	    cin>>a[i];
	}
	ll sum[n];
	sum[n-1]=a[n-1];
	for(int i=n-2;i>0;i--){
	    sum[i]=(a[i]+sum[i+1])%mod;
	}
	ll ans=0;
	for(int i=0;i<n-1;i++){
	    ans=(ans+(a[i]*sum[i+1])%mod)%mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6756
n = int(input())
arr = [int(x) for x in input().split()] 
arr.sort()
prod = 1
flag = 0
for each in arr:
	prod = each * prod
	if prod > 1000000000000000000:
		flag = 1
		break
if flag == 0:
	print(prod)
else:
	print("-1")


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,M;
    cin >> N >> M;
    vector<int> g(N+1,0);
    REP(i,M) {
        int l,r;
        cin >> l >> r;
        l--; r--;
        g[l]++; g[r+1]--;
    }
    REP(i,N) {
        g[i+1] += g[i]; 
    }
    int ans = 0;
    REP(i,N+1) {
        if (g[i] == M) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF = 1ll << 60;

vector<LL> S, T;

int main() {
   int A, B, Q;
   LL s, t, p;
   scanf("%d %d %d", &A, &B, &Q);
   S.push_back(-INF);
   for (int i = 0; i < A; i++) {
      scanf("%lld", &s);
      S.push_back(s);
   }//for
   S.push_back(INF);
   T.push_back(-INF);
   for (int i = 0; i < B; i++) {
      scanf("%lld", &t);
      T.push_back(t);
   }//for
   T.push_back(INF);
   while (Q--) {
      scanf("%lld", &p);
      LL best = INF;
      auto it1 = lower_bound(S.begin(), S.end(), p);
      auto it2 = lower_bound(T.begin(), T.end(), p);
      auto it1prv = it1;
      it1prv--;
      auto it2prv = it2;
      it2prv--;
      LL d1 = *it1;
      LL d2 = *it2;
      LL d1prv = *it1prv;
      LL d2prv = *it2prv;
      best = min(best, max(d1, d2) - p);
      best = min(best, p - min(d1prv, d2prv));
      best = min(best, 2 * (d1 - p) + p - d2prv);
      best = min(best, 2 * (d2 - p) + p - d1prv);
      best = min(best, d1 - p + 2 * (p - d2prv));
      best = min(best, d2 - p + 2 * (p - d1prv));
      printf("%lld\n", best);
   }//while
   return 0;
}//main


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int m[100010];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b,c;cin>>a>>b>>c;
    int d = 100*a+10*b+c;
    cout << (d%4==0?"YES":"NO") << endl;

    return 0;
}

Measured memory_bytes: 256
function main()
  
  dict = Dict{String,Int64}()
  
  N = parse(Int,readline())
  S = ["" for i in 1:N]
  for i in 1:N
    S[i] = chomp(readline())
    dict[S[i]] = get(dict,S[i],0) + 1
  end

  M = parse(Int,readline())
  T = ["" for i in 1:M]
  for i in 1:M
    T[i] = chomp(readline())
  end
  
  count = 0
  ans = 0
  
  for (i,j) in dict
    
    count = j
    
    for k in 1:M
      if i == T[k]
        count -= 1
      end
    end
    
    ans = max(ans,count)
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 113156
n = gets.to_i
x = n.times.map{gets.split.map(&:to_i)}
a = x.map{|a, b| a }.sort
b = x.map{|a, b| b }.sort
if n % 2 == 1
    ma = a[n/2]
    mb = b[n/2]
    puts mb - ma + 1
else
    ma1 = a[n/2]
    ma2 = a[n/2 - 1]
    mb1 = b[n/2]
    mb2 = b[n/2 - 1]
    puts (((mb1 + mb2) / 2.0 - (ma1 + ma2) / 2.0) * 2 + 1).to_i
end

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

const int mod = 1e9 + 7;
const int MN = 5010;

int N;
vector<int> adj[MN];
int dp[MN][MN][2], sz[MN], tmp[MN][2], prec[MN];

void mrg(int u, int v) {
    for(int i = 0; i <= sz[u] + sz[v]; i++) for(int j = 0; j < 2; j++) tmp[i][j] = 0;
    for(int i = 0; i <= sz[u]; i++) {
        for(int j = 0; j <= sz[v]; j++) {
            for(int a = 0; a < 2; a++) {
                for(int b = 0; b < 2; b++) {
                    tmp[i + j][a ^ b] += 1LL * dp[u][i][a] * dp[v][j][b] % mod;
                    tmp[i + j][a ^ b] %= mod;
                }
            }
        }
    }
    for(int i = 0; i <= sz[u] + sz[v]; i++) for(int j = 0; j < 2; j++) dp[u][i][j] = tmp[i][j];
}

void dfs(int u, int p) {
    dp[u][1][0] = 1;
    sz[u] = 1;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;

        dfs(v, u);
        mrg(u, v);
        sz[u] += sz[v];
    }

    for(int i = 2; i <= sz[u]; i += 2) {
        for(int j = 0; j < 2; j++) {
            if(p == -1 && i == sz[u] && j == 0) continue;

            dp[u][0][j ^ 1] += 1LL * dp[u][i][j] * prec[i] % mod;
            dp[u][0][j ^ 1] %= mod;
        }
    }
}

int main() {
    prec[0] = 1;
    for(int i = 2; i < MN; i += 2) {
        prec[i] = 1LL * prec[i - 2] * (i - 1) % mod;
    }

    scanf("%d", &N);

    for(int i = 0; i < N - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(0, -1);

    int ans = 0;
    for(int i = 1; i <= N; i++) {
        ans += 1LL * dp[0][i][0] * prec[i] % mod;
        ans %= mod;
        ans += mod - 1LL * dp[0][i][1] * prec[i] % mod;
        ans %= mod;
    }

    printf("%d", ans);
}


Measured memory_bytes: 195072
N = int(input())
AB = []
for i in range(N):
    AB.append(list(map(int, input().split())))

AB.sort(key=lambda x:x[1])
now = 0
ans = "Yes"
for i in range(N):
    now += AB[i][0]
    if now > AB[i][1]:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 53720
from decimal import *
n,k = list(map(int,input().split()))
ans = Decimal(0)
if n > k-1:
    ans += Decimal((n-k+1)/n)
    for i in range(k-1):
        score = i+1
        cnt = 0
        while score <= k-1:
            score *= 2
            cnt += 1
        ans += Decimal((0.5**cnt)/n)
    print(ans)
else:
    for i in range(n):
        score = i+1
        cnt = 0
        while score <= k-1:
            score *= 2
            cnt += 1
        ans += Decimal((0.5**cnt)/n)
    print(ans)

Measured memory_bytes: 5204
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

int main(){
    int k, x;
    scanf("%d %d", &k, &x);
    printf(500 * k >= x ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define reset(X) memset(X, 0, sizeof(X))
//#define int long long
typedef long long ll;
#define pb push_back
#define se second
#define fi first
#define endl '\n'
#define all(X) X.begin(),X.end()

const int INF=1e9;
const int mod=1e9+7;
const int mod2=998244353;



#define REDN(a) int a;cin>>a;
#define REDL(a,n) int a[n];for(int i=0;i<n;i++) cin>>a[i];
#define REDA(a,n,m) int a[n][m];for(int i=0;i<n;i++)for(int j=0;j<m;j++) cin>>a[i][j];


#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 



int pow(int a, int b)
{
    int prod=1;
    int mult=a;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod2;
        }
        mult*=mult;
        mult%=mod2;
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int mod)
{
    return pow(q, mod-2);
}
const int MAXN=1e5+10;
vector<int> adj[MAXN];
void dfs(vector<int> & depths, int root, int parent, int depth)
{
    depths[root]=depth;
    for(auto i:adj[root])
    {
        if(i!=parent)
        {
            dfs(depths, i ,root,  depth+1);   
        }
    }
}
signed main()
{

  
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r")) {
        freopen ("INPUT.txt" , "r" , stdin);
        // freopen ("output.txt" , "w" , stdout);
    }
    #endif
//---------------------------------------------------------------------------------------------------
    int n, u, v;
    cin>>n>>u>>v;
    for(int i=0;i<n-1;i++)
    {
        int a, b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);

    } 
    vector<int> depths_u(n+1), depths_v(n+1);
    dfs(depths_u, u,u, 0);
    dfs(depths_v, v,v, 0);
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        if(depths_u[i]<depths_v[i])
        {
            mx=max(mx,depths_v[i]);
        }
    }
    cout<<mx-1<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s;cin>>s;

    for(char c='a';c<='z';c++){
        int tmp=count(all(s),c);
        if(tmp%2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
import heapq
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

#条件を下回っている試験は絶対変更しなくてはいけない
ans = 0
rest = 0
ex = [] #分け与えることができる準備度の負の値
heapq.heapify(ex)
for i in range(N):
    if A[i] < B[i]:
        ans += 1
        rest += B[i] - A[i]
    else:
        heapq.heappush(ex, B[i] - A[i])

pre_len = len(ex)
#print(rest)
#print(ex)
while rest > 0:
    if len(ex) <= 0:
        print(-1)
        break
    minus_rest = heapq.heappop(ex)
    rest += minus_rest
else:
    print(ans + (pre_len - len(ex)))


Measured memory_bytes: 24164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int n, d[MAX_N];
    cin >> n;
    REP(i,n) cin >> d[i];
    sort(d,d+n);
    cout << d[n/2] - d[n/2-1] << endl;
    return 0;
}



Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,p[300005],v[2];
void quit(bool x){if(x)printf("No\n"),exit(0);}
void solve(int l,int r)
{
	while(l<=r&&p[l]==l)l++;
	while(l<=r&&p[r]==r)r--;
	if(l>r)return;
	v[0]=v[1]=0;
	for(int i=l;i<=r;i+=2)quit(p[i]>r||p[i]<l||p[i]<v[p[i]>i]),v[p[i]>i]=p[i];
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	int x=1;
	for(int i=1;i<n;i++)
	{
		if((p[i]==i)^(p[i+1]==i+1))continue;
		solve(x,i);
		x=i+1;
	}
	solve(x,n);
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

int main(void) {
  string s; cin >> s;
  ll ans = 0;
  ll b = 0;
  rep(i,sz(s)) {
    if (s[i] == 'W') ans += b; 
    else ++b;
  }
  pl(ans)
  return 0;
}


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

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

    long ans = 12;
    for (long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            long l = n / i;
            long b = 0;
            while (l > 0) {
                l /= 10;
                b++;
            }
            ans = min(ans, b);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef pair<string,int> Psi;
typedef vector<int> Vi;
int N;
vector<string> ss,words[21];
vector<Psi> vpsi;
Vi ans;
bool app[26];
void init(){
	ans.clear();
	ss.clear();
	rep(i,21) words[i].clear();
	vpsi.clear();
	rep(i,26) app[i]=0;
}
const bool lencomp(Psi x,Psi y){
	string s=x.fs,t=y.fs;
	bool a[26]={},b[26]={};
	rep(i,s.size()) a[s[i]-'A']=1;
	rep(i,t.size()) b[t[i]-'A']=1;
	int c=0,d=0;
	rep(i,26) if(a[i]) c++;
	rep(i,26) if(b[i]) d++;
	return c>d;
}
inline bool eq(Vi& a,Vi& b){
	rep(i,26) if(app[i]&&a[i]!=b[i]) return 0;
	return 1;
}
bool dfs(int x,Vi vi){
	if(x==ss.size()){
		if(!ans.empty()&&!eq(ans,vi)) return false;
		ans=vi;
		return true;
	}
	string s=ss[x];
	int L=s.size();
	for(string w:words[L]){
		Vi nvi=vi;
		bool ok=1;
		rep(i,L){
			if(nvi[s[i]-'A']>=0&&nvi[s[i]-'A']+'A'!=w[i]){
				ok=0;
				break;
			}
			if(nvi[w[i]-'A']>=0&&nvi[w[i]-'A']+'A'!=s[i]){
				ok=0;
				break;
			}
			nvi[s[i]-'A']=w[i]-'A';
			nvi[w[i]-'A']=s[i]-'A';
		}
		if(!ok) continue;
		if(!dfs(x+1,nvi)) return false;
	}
	return true;
}
int main(){
	while(true){
		cin>>N;
		if(N==0) break;
		init();
		rep(i,N){
			string s;
			cin>>s;
			words[s.size()].pb(s);
		}
		int I=0;
		while(true){
			string s;
			cin>>s;
			rep(i,s.size()) if(s[i]!='.') app[s[i]-'A']=1;
			if(s.back()=='.'){
				vpsi.pb(Psi(s.substr(0,s.size()-1),I++));
				break;
			}
			vpsi.pb(Psi(s,I++));
		}
		sort(all(vpsi),lencomp);
		for(Psi psi:vpsi) ss.pb(psi.fs);
		if(dfs(0,Vi(26,-1))&&!ans.empty()){
			vector<string> vst(ss.size());
			rep(i,ss.size()) vst[vpsi[i].sc]=ss[i];
			rep(i,vst.size()){
				rep(j,vst[i].size()){
					cout<<(char)(ans[vst[i][j]-'A']+'A');
				}
				cout<<(i+1==vst.size()?".\n":" ");
			}
		}else{
			puts("-.");
		}
	}
}

Measured memory_bytes: 1240
import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        int[] l = new int[Q];
        int[] r = new int[Q];

        for(int i = 0; i < Q; i++){
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }

        // Creating an array of prime numbers

        int[] p = new int[30000];
        p[0] = 2;
        int index = 0;
        for(int i = 3; i < 100000; i++){
            boolean bl = true;
            for(int j = 0;  p[j] * p[j] <= i; j++){
                if(i % p[j] == 0){
                    bl = false;
                    break;
                }
            }
            if(bl == true){
                p[++index] = i;
            }
        }

        int[] d = new int[1000001];
        d[0] = 0;

        Arrays.sort(p);
        for(int i = 1; i < 1000001; i++){
            if(Arrays.binarySearch(p, i) >= 0 && Arrays.binarySearch(p, (i + 1) / 2)  >= 0){
                d[i] = d[i-1] + 1;
            }
            else{
                d[i] = d[i-1]; 
            }
        }
        int[] ans = new int[Q];
        for(int i = 0; i < Q; i++){
            ans[i] = d[r[i]] - d[l[i] - 1];
            System.out.println(ans[i]);
        }
//        for(int i = 0; i < 30; i++){
  //          System.out.println(i + " " +d[i]);
    //    }
    }
}

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

int main(){

  	//inputの値
  	int N;
	cin >> N;
	int countYakusuu;
  	int count=0;
  
  	//N個の値を1から素朴に中身チェックをする。
  	for( int i=1 ; i<= N ; i++ ){
    	
      //奇数かどうか
      if( i%2 == 1){
      		
        	countYakusuu = 0;
        	
        	for( int j = 1 ; j <= i ; j++ ){
            	
              	if( i % j == 0){
                
                	countYakusuu++;
                  	
                }
            
            }
        
        	if(countYakusuu == 8){
            
              	count++;
              
            }
        	
        	
      }
    
    
    
    }
  
  cout << count << endl;
  
}

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

typedef long long ll;
using namespace std;
int main()
{
	string b;
	cin >> b;
	for (size_t i = 0; i < b.size(); i++)
	{
		if (i % 2 == 0)
		{
			cout << b[i];
		}
	}
}

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

long long int N, a, b[100000], i;
char c;

inline long long int p(long long int n){
    long long int ret = 1, bi = 2;
    while(n){
        if(n & 1){
            ret *= bi;
            ret %= 1000000007;
        }
        bi *= bi;
        bi %= 1000000007;
        n >>= 1;
    }
    return ret;
}

int main(){
    for(c = getchar();c != 10;c = getchar()){
        N *= 10;
        N += c - 48;
    }
    for(i = 0; i < N; ++i){
        for(c = getchar(), a = 0;c != 32 && c != 10;c = getchar()){
            a *= 10;
            a += c - 48;
        }
        ++b[a];
    }
    if(*b != (N & 1)){
        puts("0");
        return 0;
    }
    for(i = (N & 1) + 1; i < N; i += 2){
        if(b[i] != 2){
            puts("0");
            return 0;
        }
    }
    cout << p(N / 2) << endl;
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC176
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            var ans = s[0] / s[1];
            if(s[0]%s[1]!=0){
                ans++;
            }
            WriteLine(ans* s[2]);
        }

        public static int LowerBound<T>(T[] a, T v)
        {
            return LowerBound(a, v, Comparer<T>.Default);
        }

        public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res == -1) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
        public static int UpperBound<T>(T[] a, T v)
        {
            return UpperBound(a, v, Comparer<T>.Default);
        }

        public static int UpperBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res <= 0) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
    }
}


Measured memory_bytes: 28012
_ = input()
num_list = input().split(" ")
num_list = list(map(lambda x:int(x), num_list))
shift_counter = 0

def checker(num_list):
  for n in num_list:
    if n % 2 != 0:
      return True
  return False

while(True):
  if checker(num_list):
    print(shift_counter)
    break
  else:
    num_list = [int(n/2) for n in num_list]
    shift_counter += 1

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
 
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);
		Task solver = new Task();
		solver.solve(in, out);
		out.close();
	}
	
	
	static class Task{
		long M = (long) (1e18);
		
		public void solve(InputReader in, PrintWriter out) {
			String s = in.next();
			long len = s.length();
			long res = len*(len-1)/2;
			long[] count = new long[26];
			for(char c : s.toCharArray()) 
				count[c-97] ++;
			for(long e: count) 
				res -= e*(e-1)/2;
			out.print(res+1);
		}//solve

		
		}//Task
	
	
	
	//InputReader
	static class InputReader{
		public 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 float nextFloat() {
			return Float.parseFloat(next());
		}
		
	}
}

Measured memory_bytes: 26708