akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define maxN 1e5


int myFunction(int n, const vector <int> a){
    int ans = 0;
    vector <int> v(n);
    iota(v.begin(), v.end(), 1);
    do {
        bool flag = true;
        for(int i=0; i<n; i++){
            if (a[i] != v[i]){
                flag = false;
            }
        }
        if(flag)
            break;
        ++ans;
    } while(next_permutation(v.begin(), v.end()));

    return ans;
}

int main(){
    Omar45
    ll N; cin >> N;
    vector <int> arr(N), brr(N);
    for(int i=0; i<N; i++)
        cin >> arr[i];
    for(int i=0; i<N; i++)
        cin >> brr[i];
    int a = myFunction(N, arr);
    int b = myFunction(N, brr);
    cout << abs(a-b);
    return 0;
}


Measured memory_bytes: 256
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as M
import           Data.List
import           Data.Maybe
import           Data.Ord
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readLine :: Read a => IO [a]
readLine = map (read . BS.unpack) . BS.words <$> BS.getLine

readLines :: Read a => Int -> IO [[a]]
readLines n = replicateM n readLine

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main :: IO ()
main = do
  [s, t] <- words <$> getLine
  [a, b] <- map read . words <$> getLine
  [u]    <- words <$> getLine
  putStrLn $ solve s t a b u
  return ()

solve :: String -> String -> Int -> Int -> String -> String
solve s t a b u | s == u    = show (a - 1) ++ " " ++ show b
                | otherwise = show a ++ " " ++ show (b - 1)


Measured memory_bytes: 508
A,B = map(int,input().split())
A -= 1
B -= 1
K = 50
print(100,100)
grid1 = [['#']*100 for i in range(50)]
grid2 = [['.']*100 for i in range(50)]
for r in range(0,50,2):
    for c in range(0,100,2):
        if A > 0:
            grid1[r][c] = '.'
            A -= 1
        else:
            break

for r in range(1,50,2):
    for c in range(0,100,2):
        if B > 0:
            grid2[r][c] = '#'
            B -= 1
        else:
            break
for row in grid1:
    print(''.join(row))

for row in grid2:
    print(''.join(row))



Measured memory_bytes: 38384
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on August 2, 2018, 11:10 PM
 */

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define Axiom 1
#define Flaw 0
#define Void 0
#define Bi_Force 2
#define Quad_Force 4
#define Penta_Force 5

/*
 * 
 */

int ow[] = {-1, 0, 1, 0};
int oh[] = {0, 1, 0, -1};
int round_table[Quad_Force][Quad_Force], lancelot = Void;

void interchange(int *apple, int *pen);
int getYourFatAssHereHeuriChan();
int scrutinize(int intensity, int quondam, int loki, int odin);
void unravel(int loki, int odin);

int main()
{
    int loki, odin;
    for(int i = Void; i < Quad_Force; ++i)
    {
        for(int j = Void; j < Quad_Force; ++j)
        {
            scanf("%d", &round_table[i][j]);
            if(round_table[i][j] == Void )
            {
                loki = i;
                odin = j;
            }
        }
    }
    
    unravel(loki, odin);
    
    return EXIT_SUCCESS;
}

void interchange(int *apple, int *pen)
{
    int apple_pen = *apple;
    *apple = *pen;
    *pen = apple_pen;
}

int getYourFatAssHereHeuriChan()
{
    int heuri_chan = Void, arthur;
    for(int i = Void; i < Quad_Force; ++i)
    {
        for(int j = Void; j < Quad_Force; ++j)
        {
            if(round_table[i][j] != Void)
            {
                arthur = round_table[i][j] - 1;
                heuri_chan = abs((arthur / Quad_Force) - i) + abs((arthur % Quad_Force) - j) + heuri_chan;
            }
        }
    }
    return heuri_chan;
}
 
int scrutinize(int intensity, int quondam, int loki, int odin)
{
    int heuri_chan;
    heuri_chan = getYourFatAssHereHeuriChan();
    if(heuri_chan + intensity > lancelot) return Flaw;
    if(heuri_chan == Void) return Axiom;
    for(int i = Void; i < Quad_Force; ++i)
    {
        if(abs(i - quondam) == Bi_Force) continue;
        
        int hel = loki + ow[i],gungnir = odin + oh[i];
        if(hel < Void || gungnir < Void || hel >= Quad_Force || gungnir >= Quad_Force) continue;
        
        interchange(&round_table[hel][gungnir], &round_table[loki][odin]);
        if(scrutinize(intensity+1, i, hel, gungnir)) return Axiom;
        
        interchange(&round_table[hel][gungnir], &round_table[loki][odin]);
    }
    return Flaw;
}
 
void unravel(int loki, int odin)
{
    for(;;)
    {
        if(scrutinize(0, 100, loki, odin))
        {
            printf("%d\n", lancelot);
            return;
        }
        lancelot++;
    }
}

 


Measured memory_bytes: 2108
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const int MOD=(1e9)+7;
const int mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;cin >>x;
  if(x>=30) cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}

Measured memory_bytes: 3632
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long K, long[] A) {
    alias toBins = (long x) => x.to!ulong
        .toChars!2
        .to!string
        .rightJustify(63, '0');
    
    auto a = A.map!toBins.array;
    auto k = toBins(K);
    bool lessThanK = false;
    string argmax;
    foreach (i; 0 .. 63) {
        if (!lessThanK && k[i] == '0') {
            argmax ~= "0";
            continue;
        }

        long zeros;
        long ones;
        foreach (b; a.transversal(i)) {
            if (b == '0') zeros++;
            if (b == '1') ones++;
        }

        if (zeros < ones) {
            argmax ~= "0";
            if (k[i] == '1')
                lessThanK = true;
        } else {
            argmax ~= "1";
        }
    }
    
    alias f = (long x) => A.map!(a => x ^ a).sum;

    return f(
        argmax
            .retro
            .enumerate
            .map!(t => t[1] == '1' ? 2 ^^ t[0] : 0)
            .sum);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long K;
    K = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, K, A);
    else
        solve(N, K, A).writeln;
}


Measured memory_bytes: 23960
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b == c || b + c == a || c + a == b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3580
<?PHP
fscanf(STDIN, "%s", $s);
$slist = str_split($s);
sort($slist);
if($slist[0]==$slist[1] && $slist[2]==$slist[3] && $slist[1]!=$slist[2]){
  echo 'Yes';
}else{
  echo 'No';
}
  


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

typedef pair<int, int> ii;
typedef long long ll;

const int N = 55;
int n, k;
int X[N], Y[N];
ii p[N];
bool check(int a, int b, int c, int d) {
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        auto [x, y] = p[i];
        if (x >= X[a] && x <= X[b] && y >= Y[c] && y <= Y[d])
            ++cnt;
    }
    return cnt >= k;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> X[i] >> Y[i];
        p[i] = {X[i], Y[i]};
    }
    sort(X, X + n);
    sort(Y, Y + n);
    ll ans = LLONG_MAX;
    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            for (int k = 0; k < n; ++k) {
                for (int l = k; l < n; ++l) {
                    if (check(i, j, k, l)) {
                        ans = min(ans, 1LL * (X[j] - X[i]) * (Y[l] - Y[k]));
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3628
#include <stdio.h>
#define sinv(X) ((X) == 'o' ? 'x' : 'o')
#define ainv(X) ((X) == 'S' ? 'W' : 'S')

int n;
char s[100005];
char a[100005];
char ch[] = {'S', 'W'};

int f(void);

int main()
{
    scanf("%d", &n);
    scanf("%s", s);

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            a[0] = ch[i];
            a[1] = ch[j];

            if (f()) {
                printf("%s\n", a);
                return 0;
            }
        }
    }

    printf("-1\n");
    
    return 0;
}

int f(void)
{
    char op;
    
    for (int i = 1; i < n; i++) {
        op = s[i];

        if (a[i] == 'W') {
            op = sinv(op);
        }

        if (op == 'o') {
            a[i + 1] = a[i - 1];
        }
        else {
            a[i + 1] = ainv(a[i - 1]);
        }
    }

    op = s[0];
    if (a[0] == 'W') {
        op = sinv(op);
    }

    if (a[n] == a[0] &&
        op == 'o' && a[n - 1] == a[1]) {
        a[n] = 0;
        return 1;
    }

    if (a[n] == a[0] &&
        op == 'x' && a[n - 1] != a[1]) {
        a[n] = 0;
        return 1;
    }

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int x = sc.nextInt();

			if (x == 0) {
				System.out.println("1");
			} else {
				System.out.println("0");
			}
		}
	}
}


Measured memory_bytes: 35668
import sys
from collections import deque


def main():
    vertex_num, operation_num = map(int, sys.stdin.buffer.readline().split())
    tree = [[] for _ in range(vertex_num)]
    for _ in range(vertex_num - 1):
        a, b = map(lambda x: int(x) - 1, sys.stdin.buffer.readline().split())
        tree[a].append(b)
        tree[b].append(a)
    answer = [0 for _ in range(vertex_num)]
    checked = [True for _ in range(vertex_num)]
    checked[0] = False
    for _ in range(operation_num):
        p, x = map(int, sys.stdin.buffer.readline().split())
        answer[p - 1] += x
    q = deque([0])
    empty_deque = deque()
    while not q == empty_deque:
        now = q.popleft()
        for next_vertex in tree[now]:
            if checked[next_vertex]:
                checked[next_vertex] = False
                answer[next_vertex] += answer[now]
                q.append(next_vertex)
    print(" ".join(map(str, answer)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 67180
#include<stdio.h>

int main(void) {
	long long n, m;
	scanf("%lld", &n);
	m = n % 1000;
	if (m != 0) {
		m = 1000 - m;
	}
	else {
		m = 0;
	}
	printf("%lld", m);

	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
 
 
int main(){
    ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
ll n;cin>>n;
  ll ans=0;
  ll cnt[100001];
  fill(cnt,cnt+100001,0);
  rep(i,0,n){
ll a;cin>>a;
    ans+=a;
    cnt[a]++;
  }
  ll q;cin>>q;
  while(q--){
    ll b,c;cin>>b>>c;
    ll u=b*cnt[b];
    ll uu=c*cnt[b];
    
    cnt[c]+=cnt[b];
    cnt[b]=0;
    ans+=-u+uu;
    cout<<ans<<endl;
  }
}

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

int main() {

  string S, T; cin >> S >> T;
  int ans = 0;
  if (S.at(0) == T.at(0)) {
    ans++;
  }
  if (S.at(1) == T.at(1)) {
    ans++;
  }
  if (S.at(2) == T.at(2)) {
    ans++;
  }
  cout << ans << endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        String s = stdIn.next();
        String t = stdIn.next();
        char[] s1 = new char[200000];
        char[] s2 = new char[200000];
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            s1[i] = s.charAt(i);
            s2[i] = t.charAt(i);
           if (s1[i] != s2[i]) {
               s1[i] = s2[i];
               count++;
           }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 42024
import java.util.Scanner;
public class Main {
	public static int Max = 24 * 60 * 60;
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int n = sc.nextInt();
				if(n == 0) break;
				
				int[] t = new int[Max];
				for(int i=0; i<n; i++) {
					String[] s = sc.next().split(":");
					int start = Integer.parseInt(s[0])*3600 + Integer.parseInt(s[1])*60+Integer.parseInt(s[2]);
					
					String[] e = sc.next().split(":");
					int end = Integer.parseInt(e[0])*3600 + Integer.parseInt(e[1])*60+Integer.parseInt(e[2]);
					
					t[start]++;
					if(end < Max) t[end]--;
				}
				
				int max = 0;
				for(int i=1; i<Max; i++) {
					t[i] += t[i-1];
					max = Math.max(max, t[i]);
				}
				System.out.println(max);
			}
		}
	}
}



Measured memory_bytes: 104288
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

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

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, K int

func main() {
	sc.Split(bufio.ScanWords)

	N, K = nextInt(), nextInt()

	fmt.Println(K * powInt(K-1, N-1))
}


Measured memory_bytes: 1772
// In God We Trust


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

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second

# define int long long

signed main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool three[1000];
  bool two[100];
  bool one[10];
  for (int i = 0 ; i < 10; i++)
    one[i] = false;
  for (int i = 0; i < 100; i++)
    two[i] = false;
  for (int i = 0; i < 1000; i++)
    three[i] = false;
  
  for (int i = 0; i < n; i++){
    int cur = (int)(s[i] - '0');
    for(int i = 0 ; i < 100; i++)
      if (two[i])
	three[i * 10 + cur] = true; 
    for (int i = 0; i < 10; i++)
      if (one[i])
	two[i * 10 + cur] = true;
    one[cur] = true;
  }
  int count = 0;
  for (int i = 0; i< 1000; i++)
    if (three[i]){
      count ++;
    }
  cout << count << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++){
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  int count = 1;
  for(int i=1; i<n; i++){
    if(d[i] != d[i-1]){
      count ++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200010,mod = 998244353;
int n,k,m;
ll p[N];
ll ksm(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
ll c(int a,int b)
{
	return p[a]*ksm(p[a-b],mod-2)%mod*ksm(p[b],mod-2)%mod;
}
int main()
{
	
	cin>>n>>m>>k;
	
	p[0]=1;
	for(int i=1;i<=n;i++) p[i]=p[i-1]*i%mod;
	ll ans=0;
	for(int i=0;i<=k;i++)
		ans=(ans+m*c(n-1,i)%mod*ksm(m-1,n-i-1)%mod)%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int q = sc.nextInt();
		long max = (long)1e12; long min = -1*(long)1e12;
		long[] s = new long[a+2]; s[0] = min; s[a+1] = max;
		long[] t = new long[b+2]; t[0] = min; t[b+1] = max;
		for (int i = 1; i < a+1; i++) {
			s[i] = sc.nextLong();
		}
		for (int i = 1; i < b+1; i++) {
			t[i] = sc.nextLong();
		}
		StringBuilder sb = new StringBuilder();
		long x = 0; int l = 0;int r = 0; int mid = 0;
		long sl = 0, sr = 0, tl = 0, tr = 0;
		long ans = 0;
		for (int i = 0; i < q; i++) {
			x = sc.nextLong();
			l = -1; r = a+2;
			while(r-l>1) {
				mid = (r+l)/2;
				if(s[mid]>x) {
					r = mid;
				}else {
					l = mid;
				}
			}
			sl = s[l]; sr = s[r];

			l = -1; r = b+2;
			while(r-l>1) {
				mid = (r+l)/2;
				if(t[mid]>x) {
					r = mid;
				}else {
					l = mid;
				}
			}
			tl = t[l]; tr = t[r];
			ans = Math.min((x-sl)+(tr-sl),(x-sl)+Math.abs(tl-sl));
			ans = Math.min(ans, (sr-x)+(sr-tl));
			ans = Math.min(ans,(sr-x)+Math.abs(tr-sr));
			ans = Math.min(ans, (tr-x)+(tr-sl));
			ans = Math.min(ans, (tr-x)+Math.abs(sr-tr));
			ans = Math.min(ans, (x-tl)+Math.abs(tl-sl));
			ans = Math.min(ans,(x-tl)+(sr-tl));
			sb.append(String.valueOf(ans));
			sb.append("\n");
		}
		System.out.println(new String(sb));
		sc.close();
	}
}

Measured memory_bytes: 97556
#include<stdio.h>

int main()
{
	int A1,A2,A3;
	
	scanf("%d %d %d",&A1,&A2,&A3);
	
	if(A1+A2+A3<22){
		printf("win");
	}
	else{
		printf("bust");
	}
	
	return 0;
}

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

using namespace std;
using ll = long long;

const ll INF = 1LL << 50;

ll f(int k, ll a) {
    if (k == 2) {  // 奇数の区間
        return (a + 1) % 2;
    } else if (1 <= k && k <= 3) {  // 偶数の区間
        return (a == 0 ? 2 : a % 2);
    } else {  // 無の区間
        return a;
    }
}

int main() {
    int N;
    cin >> N;
    ll a[N + 2];
    for (int i = 1; i <= N; ++i) cin >> a[i];
    a[N + 1] = 0;

    ll dp[N + 2][5];
    fill(dp[0], dp[1], 0);
    fill(dp[1], dp[N + 2], INF);

    for (int i = 1; i <= N + 1; ++i) {
        for (int k = 0; k < 5; ++k) {
            ll m = *min_element(dp[i - 1], dp[i - 1] + k + 1);
            dp[i][k] = m + f(k, a[i]);
        }
    }

    cout << dp[N + 1][4] << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

bool isOK(const string& a, const string& b) { return a.back() == b[0] && b.back() == a[0]; }
string toStr(ll a) {
  stringstream ss;
  ss << a;
  return ss.str();
}

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  map<ll, ll> M;
  for (ll i = 1; i <= N; i++) {
    string s = toStr(i);
    ll big = (s[0] - '0') * 10;
    ll small = s.back() - '0';
    if (big == 0 || small == 0) continue;
    M[big + small]++;
  }
  ll ans = 0;
  for (ll i = 11; i < 100; i++) {
    if (i % 10 == 0) continue;
    try {
      ll cnt = M.at(i);
      ll big_inv = i / 10;
      ll small_inv = i % 10;
      ll inv_num = big_inv + small_inv * 10;
      ll inv_cnt = M.at(inv_num);
      ans += cnt * inv_cnt;
    } catch (...) {
      continue;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int N=100005;
int n,size[N],st[N],to[N<<1],tto[N],last[N],Next[N<<1],edge;
long long D;
struct note{
	long long dis;
	int x;
}d[N];
bool cmp(note x,note y){
	return x.dis>y.dis;
}
using std::map;
map<long long,int> m;
void add(int x,int y){
	to[++edge]=y;
	Next[edge]=last[x];
	last[x]=edge;
}
int dfs(int x,int fa,long long now){
	D+=now;
	for (int i=last[x];i;i=Next[i])
		if (to[i]!=fa)
			dfs(to[i],x,now+1);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%lld",&d[i].dis);
		d[i].x=i;
		m[d[i].dis]=i;
	}
	std::sort(d+1,d+n+1,cmp);
	for (int i=1;i<=n;i++) size[i]=1;
	for (int i=1;i<n;i++){
		long long dis=d[i].dis;
		int x=d[i].x;
		long long t=dis-abs(n-2*size[x]);
		int fa=m.find(t)->second;
		if (fa==x || !fa){
			puts("-1");
			return 0;
		}
		size[fa]+=size[x];
		st[i]=x,tto[i]=fa;
		add(x,fa),add(fa,x);
	}
	dfs(d[n].x,0,0);
	if (D!=d[n].dis){
		puts("-1");
		return 0;
	}
	for (int i=1;i<n;i++) printf("%d %d\n",st[i],tto[i]);
}

Measured memory_bytes: 14720
from collections import deque, Counter
def prime_factorize(n):
    a = deque([])
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
A = Counter(prime_factorize(N))
B = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66]
ans = 0
for i in A:
    for j in range(len(B)):
        if B[j] <= A[i] < B[j + 1]:
            ans += (j + 1)
            break
print(ans)

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

int main() {
    int N; cin >> N;
    vector<int> L(N*2);
    for (int i = 0; i < N*2; ++i) cin >> L[i];
    sort(L.begin(), L.end());
    int res = 0;
    for (int i = 0; i < N*2; i += 2) res += L[i];
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   set<string> st;
   cin >> n;
   for(int i = 0;i < n;i++) {
       string f;
       cin >> f;
       st.insert(f);
   }
   cout << st.size() << endl;

}

Measured memory_bytes: 19144
//感人肺腑..
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=100005;
int v[N<<2],l[N<<2],w[N<<1],h[N],d[N];
int f[N],g[N],ans[N],n,c=1;

void adde(int a,int b){
	v[++c]=b,l[c]=h[a],h[a]=c;
	v[++c]=a,l[c]=h[b],h[b]=c;
	d[a]++,d[b]++;
}

void euler_Orz(int u){
	for(int k;k=h[u];){
		h[u]=l[k];
		if(w[k>>1]) continue;
		w[k>>1]=1+(k&1);
		euler_Orz(v[k]);
	}
}

int main(){
	read(n);
	rep(i,1,n){
		read(f[i]);
		if(f[i]==-1) f[i]=0;
		adde(f[i],i);
	}
	rep(i,1,n){
		read(g[i]);
		if(g[i]==-1) g[i]=0;
		adde(g[i],i);
	}
	rep(i,0,n) if(d[i]&1){
		puts("IMPOSSIBLE");
		return 0;
	}
	rep(i,0,n) euler_Orz(i);
	rep(i,1,n){
		if(w[i]==1) ans[i]--,ans[f[i]]++;
		else ans[i]++,ans[f[i]]--;
	}
	puts("POSSIBLE");
	rep(i,1,n) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 9472
// http://www.sousakuba.com/Programming/gs_hittest_point_triangle.html
#include <iostream>
using namespace std;
bool solve(double x1, double y1, double x2, double y2, double x3, double y3, double xp, double yp){
	double z1, z2, z3;
	z1 = (xp - x1) * (y2 - y1) - (yp - y1) * (x2 - x1);
	z2 = (xp - x2) * (y3 - y2) - (yp - y2) * (x3 - x2);
	z3 = (xp - x3) * (y1 - y3) - (yp - y3) * (x1 - x3);
	if(z1 > 0 && z2 > 0 && z3 > 0) return 1;
	else if(z1 < 0 && z2 < 0 && z3 < 0) return 1;
	else return 0;
}

int main(){
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		if(solve(x1, y1, x2, y2, x3, y3, xp, yp)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int S = Integer.parseInt(sc.next());
      int W = Integer.parseInt(sc.next());

      if(W>=S){
        System.out.println("unsafe");
      }else{
        System.out.println("safe");
      }

    }
}


Measured memory_bytes: 35724
# -*- coding: utf-8 -*-
import collections


def main():
    n = int(input())
    s = [input() for i in range(n)]

    most_counters = collections.Counter(s).most_common()
    most_count = most_counters[0][1]

    for t in sorted(map(lambda x: x[0], filter(lambda x: x[1] == most_count, most_counters))):
        print(t)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45076
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int h, w;
vs fld, t;
int dp[333][333][333], cost[333][333][333];

int get_cost(int i, int j, int k)
{
	if (cost[i][j][k] >= 0) return cost[i][j][k];
	int res;
	if (j == h || k == h) res = 0;
	else
	{
		res = get_cost(i, j + 1, k + 1);
		if (t[i][h - j - 1] == t[i + 1][h - k - 1]) res++;
	}
	return cost[i][j][k] = res;
}

int solve(int i, int j, int k)
{
	if (dp[i][j][k] >= 0) return dp[i][j][k];
	int res;
	if (j == h || k == h) res = 0;
	else res = min(solve(i, j + 1, k), solve(i, j, k + 1)) + get_cost(i, j, k);
	return dp[i][j][k] = res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	MS(dp, -1);
	MS(cost, -1);
	cin >> h >> w;
	fld.resize(h);
	REP(i, h) cin >> fld[i];
	t.resize(w);
	REP(i, h)REP(j, w)
	{
		t[j] += fld[i][j];
	}
	int ans = 0;
	REP(i, w - 1) ans += solve(i, 0, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 289024
/*
 Author: LargeDumpling
 Email: LargeDumpling@qq.com
 Edit History:
	2017-08-20	File created.
*/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const long long mod=1000000007;
int n,state[55];
char str[2][55];
long long f[55];
int main()
{
	scanf("%d",&n);
	scanf("%s%s",str[0]+1,str[1]+1);
	memset(state,-1,sizeof(state));
	for(int i=1;i<=n;i++)
	{
		if(str[0][i]==str[1][i])
			state[i]=0;
		if(1<i&&str[0][i]!=str[1][i]
				&&str[0][i-1]==str[0][i]
				&&str[1][i-1]==str[1][i])
			state[i]=1;
		if(i==1)
		{
			if(state[i]==0) f[i]=3;
			else f[i]=-1;
		}
		else if(i==2)
		{
			if(state[i]==0) f[i]=f[i-1]*2LL%mod;
			else if(state[i]==1) f[i]=6;
		}
		else if(state[i]==0)
		{
			if(state[i-1]==0) f[i]=f[i-1]*2LL%mod;
			else if(state[i-1]==1) f[i]=f[i-1];
		}
		else if(state[i]==1)
		{
			if(state[i-2]==0) f[i]=f[i-2]*2LL%mod;
			else if(state[i-2]==1)
				f[i]=f[i-2]*3LL%mod;
		}
	}
	printf("%lld",f[n]);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int T = scan.nextInt();
        int X = scan.nextInt();
        double ans = (double)T/(double)X;
        scan.close();
            System.out.println(ans);

    }
}

Measured memory_bytes: 23764
{$R-,S-,Q-,I-,O+}
var n,h,left:int64;
begin
  readln(n);
  while n>0 do begin
    read(h);
    if left < h then
      left:=h-1
    else if left = h then
    else begin
      writeln('No');
      exit;
    end;
    dec(n);
  end;
  writeln('Yes');
end.

Measured memory_bytes: 128
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		TreeSet<Integer> S = new TreeSet<Integer>();
		int q = sc.nextInt();
		for(int i = 0; i < q; i++){
			int com = sc.nextInt();
			int x = sc.nextInt();
			if(com == 0){
				S.add(x);
				System.out.println(S.size());
			}else if(com == 1){
				if(S.contains(x)) System.out.println(1);
				else System.out.println(0);
			}else S.remove(x);
		}
	}
}



Measured memory_bytes: 149472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


// combination
const int MAX = 510000;
const int MOD = 998244353;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int64_t modpow(int64_t x, int64_t n) {
    x = x%MOD;
    if(n==0) return 1;  //再帰の終了条件

    else if(n%2==1) {
        return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
    }
    else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}

int main() {
  ll N,M,K;
  ll const mod = 998244353;
  cin >> N >> M >> K;
  ll ans=1;
  // ######;
  COMinit();
  vector<ll> memo(K+1);
  rep(i,K+1) {
    if (i==0) memo[i] = M*modpow(M-1,N-1)%mod;
    else {
      
      memo[i] = M*modpow(M-1,N-i-1)%mod*COM(N-1,i)%mod;
      // cout << COM(N-1,i) << endl;
      memo[i]%=mod;
      memo[i] += memo[i-1];
    }
    memo[i]%=mod;
  }
  // rep(i,K+1) cout << memo[i] << ' ';
  // cout << endl;
  if (memo[K]<0) memo[K]+=mod;
  cout << memo[K] << endl;
}

Measured memory_bytes: 16660
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	string s;
	cin>>s;
	n=s.size();
	vl a(n,0);
	vl p;
	rep(i,n-1){
		if(s[i]=='R' and s[i+1]=='L')p.push_back(i);
	}
	rep(i,n){
		if(s[i]=='R'){
			ll pos = lower_bound(all(p),i)-p.begin();
			pos = p[pos];
			if((pos-i)%2)a[pos+1]++;
			else a[pos]++;
		}else{
			ll pos = lower_bound(all(p),i)-p.begin();
			pos = p[pos-1];
			if((pos-i)%2)a[pos+1]++;
			else a[pos]++;
		}
	}
	puta(a);
	return 0;
}

Measured memory_bytes: 2632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp
//#pragma comment(linker, "/STACK:1024000000,1024000000") 
//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const int MAX=5e5+10;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const ll MOD=1e9+7;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}
int x,y,z;
vector<string>s;
int main()
{
    scanf("%d%d%d",&x,&y,&z);
    for(int i=0;i<x;i++)s.pb("a");
    for(int i=0;i<y;i++)s.pb("b");
    for(int j=0;j<z;j++)s.pb("c");
    while(s.size()>1)
    {
        sort(s.begin(),s.end());
        s[0]+=s[s.size()-1];
        s.pop_back();
    }
    cout<<s[0]<<"\n";
}
/*
8
11011011
*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char temp='a';
		char[] s = sc.next().toCharArray();
		String ans = "Good";
		for (char c : s) {
			if(temp == c) {
				ans = "Bad";
			}
			temp = c;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = input()
ans = 0
for l in range(10):
    for i in range(n):
        if int(s[i]) == l:
            break
    else:
        continue
    for r in range(10):
        for j in range(i+1,n):
            if int(s[j]) == r:
                break
        else:
            continue
        num = [True]*10
        for k in range(j+1,n):
            if num[int(s[k])]:
                ans += 1
                num[int(s[k])] = False
print(ans)

Measured memory_bytes: 42588
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;
ll a, b, q;
vector<ll> s, t, x;

void solve() {
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    rep(i, q) {
        auto s_b = lower_bound(s.begin(), s.end(), x[i]);
        auto t_b = lower_bound(t.begin(), t.end(), x[i]);

        ll l_s = *s_b, l_t = *t_b;
        ll s_pre = *(s_b - 1), t_pre = *(t_b - 1);
        ll ans = ll_inf;
        ans = min({ans,
                   max(l_s - x[i], l_t - x[i]),
                   min(x[i] - s_pre, l_t - x[i]) * 2 + max(x[i] - s_pre, l_t - x[i]),
                   min(x[i] - t_pre, l_s - x[i]) * 2 + max(x[i] - t_pre, l_s - x[i]),
                   max(x[i] - s_pre, x[i] - t_pre)
                  });
        cout << ans << endl;
    }
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        cin >> a >> b >> q;
        s.resize(a), t.resize(b), x.resize(q);
        rep(i, a) cin >> s[i];
        rep(i, b) cin >> t[i];
        rep(i, q) cin >> x[i];
        s.emplace_back(ll_inf);
        s.emplace_back(-ll_inf);
        t.emplace_back(-ll_inf);
        t.emplace_back(ll_inf);
        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
    int N;cin>>N;
    string S = to_string(N);

    int length = S.size();

    char check = S.at(length-1);
    
    if(check=='3'){
        cout<<"bon"<<endl;
    }else if(check=='0' || check=='1' || check=='6' || check=='8'){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;

    }



}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a = scanner.nextInt();
		
		int total = n*n;
		
		System.out.println(total-a);
		
		scanner.close();
	}

}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
void solve(){
	float d, t, s;
  cin >> d>>t>>s;
  float ans = d/s;
  
  if(ans <= t)
    cout << "Yes";
  else
    cout << "No";

}
int32_t main(){
 	int testcases = 1;
  	//cin >> testcases;
  while (testcases--){
  		solve();
  }
}

Measured memory_bytes: 3688
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) throws IOException {
		MScanner sc = new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		//int n=sc.nextInt();
		//int[]in=new int[n];for(int i=0;i<n;i++)in[i]=sc.nextInt();
		int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();
		pw.print(Math.max(0, c-(a-b)));		
		pw.close();
		pw.flush();
 
	}
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main() {
  int n,m;
  cin>>n>>m;
  vector<int> ac(n,0),wa(n,0);
  rep(i,m) {
    int p;
    string s;
    cin >> p >> s;
    --p;
    if (ac[p]) continue;
    if (s=="AC") {
      ac[p]=1;
    } else {
      wa[p]++;
    }
  }
  int AC = 0, WA = 0;
  rep(i,n) {
    if (ac[i]) {
      AC += ac[i];
      WA += wa[i];
    }
  }
  cout << AC << " " << WA << endl;
  return 0;
}

Measured memory_bytes: 1024
// solution is at the bottom

import kotlin.math.*
import kotlin.system.exitProcess

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(true) {
            when(c) {
                '\n', Char.MIN_VALUE -> return@buildString
                else -> {
                    append(c)
                    c = readChar()
                }
            }
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

fun main() {
    val s = read()
    val t = read()

    val n = s.length
    var res = n + 1

    for (i in 0 until n - t.length + 1) {
        var count = 0
        for (pos in 0 until t.length) {
            if (s[i + pos] != t[pos]) {
                count++
            }
        }

        res = min(res,  count)
    }

    println(res)
}


Measured memory_bytes: 34100
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]

add = []
for i in range(2**n):
    skill = [0] * (m+1)
    for j in range(n):
        if (i>>j)&1:
            skill = list(map(sum, zip(skill, l[j])))
    if min(skill[1:]) >= x:
        add.append(skill)
if add:
    add.sort()
    print(add[0][0])
else:
    print(-1)

Measured memory_bytes: 11228
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    while b > 0:
        a, b = b, a % b
    return a

n, m = map(int, input().split())
a = list(map(int, input().split()))

x = 1
for i in range(n):
    b = a[i] // 2
    x = x * b // gcd(x, b)
if any(2 * x // y % 2 == 0 for y in a):
    print(0)
    quit()
print((m - x) // (2 * x) + 1)




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

int main() {
int X;
  cin >> X;
  int th = 0;
  int fi = 0;
  th = X/500;
  X = X%500;
  fi = X/5;
  cout << th * 1000 + fi * 5 << endl;
}

Measured memory_bytes: 256