akhauriyash/Code-Regression huggingface dataset:
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  1000000007
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n,ans=1; cin>>n;
    for (int i=1;i<=n;i++) ans = (ans*i) %mod;
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long div = (int) Math.sqrt(n);

		while (div > 0) {
			if (n % div == 0) {
				long ans = (div + (n / div) - 2);
				System.out.println(ans);
				return;
			}else {
				div--;
			}
		}
	}
}

Measured memory_bytes: 22868
#!/usr/bin/env python
# coding: utf-8

# In[12]:


S = input()


# In[17]:


length = len(S)
if length == 1:
    print(1)
elif length == 2:
    if S[0] == S[1]:
        print(1)
    else:
        print(2)
else:
    dp = [0]*length
    dp[0] = 1
    if S[0] == S[1]:
        dp[1] = 1
    else:
        dp[1] = 2
    if S[0] != S[1] and S[1] != S[2]:
        dp[2] = 3
    else:
        dp[2] = 2

    for i in range(3, length):
#         print(dp)
        if S[i-1] == S[i]:
            dp[i] = dp[i-3] + 2
        else:
            dp[i] = dp[i-1] + 1
    print(dp[-1])


# In[5]:





# In[ ]:






Measured memory_bytes: 74704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoundHound3
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            var d = int.Parse(line[2]);

            var r = Calc(n, m, d);
            Console.WriteLine(r);
        }

        public static double Calc(int n = 2, int m = 3, int d = 1)
        {
            double numPattern;

            if (d != 0)
            {
                numPattern = (n - d) * 2;
            }
            else
            {
                numPattern = n;
            }

            return (numPattern / Math.Pow(n, 2)) * (m - 1);
        }
    }
}


Measured memory_bytes: 11092
// 物极必反

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9;
const double PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

vector<long long> adj[N];
bool used[N];
long long dp[N];

void solve(){
    long long n, m; cin >> n >> m;

    for(long long i = 0; i < m; i++){
        long long u, v; cin >> u >> v;
        adj[u].append(v);
    }

    function<void(long long)> dfs = [&](long long v){
        used[v] = true;
        for(auto to : adj[v]){
            if(!used[to]){
                dfs(to);
            }
            dp[v] = max(dp[v], dp[to] + 1);
        }
    };

    long long ans = 0;
    for(long long i = 1; i <= n; i++){
        if(!used[i]){
            dfs(i);
        }
        ans = max(ans, dp[i]);
    }

    cout << ans;
}

int main(){
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long q = 1; // cin >> q;

    while(q--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 13336
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
import math
def hoge(low, high, A, K):
    cnt = 0
    cut = (low + high) // 2
    for i in A:
        cnt += math.ceil(i / cut) - 1
        if cnt > K:
            return True
    return False
low = 1
high = max(A) + 1
cnt = 0
while True:
    if hoge(low,high,A,K):
        low = (low+high) // 2
    else:
        if high == (low + high) // 2 +1:
            if hoge(low,low,A,K):
                low += 1
        else:
            high = (low + high) // 2 +1
    if high - low == 1:
        break
    if cnt == max(A):
        break
    else:
        cnt += 1
print(low)

Measured memory_bytes: 30776
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

const int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> c(n,0);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        c[a-1]++;
        c[b-1]++;
    }
    rep(i,n){
        if(c[i]%2==1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;

int main() {
    string S;
    cin >> S;
    if(S == "Sunny")
        S = "Cloudy";
    else if(S == "Cloudy")
        S = "Rainy";
    else
        S = "Sunny";
    cout << S << endl;
    return 0;
}


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


struct nums{
  int a;
  int b;
  int c;
  int d;
};




int main(){
  int n, m, q; cin >> n >> m >> q;
  vector<nums> numrow(q);
  vector<int> A(n);
  unsigned long long ans = 0;
  for (int i = 0; i < q; i++)
  {
    cin >> numrow.at(i).a >> numrow.at(i).b >> numrow.at(i).c >> numrow.at(i).d;
    numrow.at(i).a--;
    numrow.at(i).b--; //zero indexed
  }
  
  int a[10];
  for (a[0] = 1; a[0] <= m; a[0]++)
  for (a[1] = a[0]; a[1] <= m; a[1]++)
  for (a[2] = a[1]; a[2] <= m; a[2]++)
  for (a[3] = a[2]; a[3] <= m; a[3]++)
  for (a[4] = a[3]; a[4] <= m; a[4]++)
  for (a[5] = a[4]; a[5] <= m; a[5]++)
  for (a[6] = a[5]; a[6] <= m; a[6]++)
  for (a[7] = a[6]; a[7] <= m; a[7]++)
  for (a[8] = a[7]; a[8] <= m; a[8]++)
  for (a[9] = a[8]; a[9] <= m; a[9]++)
  {
    unsigned long long tmp = 0;
    for (int i = 0; i < n; i++)
    {
      A.at(i) = a[i];
    }

    /*
    for (auto &&i : A)
    {
      cout << i << " ";
    }
    cout << endl;
    */

    for (int j = 0; j < q; j++)
    {
      if(A.at(numrow.at(j).b) - A.at(numrow.at(j).a) == numrow.at(j).c)tmp += numrow.at(j).d;
    }
    //cout << "tmp: " << tmp << endl;
    ans = max(tmp, ans);

  }
  
  cout << ans << "\n";
  
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    ll X;
    cin >> X;

    ll cc=0,idx=1;

    while(1){
    	cc+=idx;
    	idx++;
    	if(cc>=X)
    		break;
    }

    cout << idx-1 << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
  a.append(int(input()))

def solve2(a):
  i = 1
  j = n-1
  s = 0
  x = y = a[0]
  r = True
  while i<j:
    if r:
      s += abs(a[j] - x) + abs(a[j-1] - y)
      x = a[j]
      y = a[j-1]
      j -= 2
    else:
      s += abs(a[i] - x) + abs(a[i+1] - y)
      x = a[i]
      y = a[i+1]
      i += 2
    r = not r
  if i == j:
    s += max(abs(a[i] - x), abs(a[i]-y))
  return s

print(max(solve2(sorted(a)), solve2(sorted(a, reverse=True))))


Measured memory_bytes: 8284
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int c = 0;

void merge(int S[], int min, int mid, int max)
{
	int i, j, k;
	int n1 = mid - min;
	int n2 = max - mid;
	
	for(i = 0; i < n1; i++)
	{
		L[i] = S[min + i];
	}
	for(i = 0; i < n2; i++)
	{
		R[i] = S[mid + i];
	}
	
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	i = 0;
	j = 0;
	
	for(k = min; k < max; k++)
	{
		if(L[i] <= R[j])
		{
			S[k] = L[i];
			i++;
		}
		else
		{
			S[k] = R[j];
			j++;
		}
		c++;
	}
}

void mergeSort(int S[], int min, int max)
{
	if(min + 1 < max)
	{
		int mid = (min + max) / 2;
		mergeSort(S, min, mid);
		mergeSort(S, mid, max);
		merge(S,min, mid, max);
	}
}

int main(void)
{
	int n, i;
	
	scanf("%d", &n);
	int S[n];
	
	for(i = 0; i < n; i++)
	{
		scanf("%d", &S[i]);
	}
	
	mergeSort(S,  0, n);
	
	for(i = 0; i < n; i++)
	{
		if(i != n - 1)
		{
			printf("%d ", S[i]);
		}
		else
		{
			printf("%d\n", S[i]);
		}
	}
	
	printf("%d\n", c);
	
	return 0;
}


Measured memory_bytes: 5576
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
const int MM = 1e5+2;

int n, c[MM], ans, out[MM];
vector<pair<int, int>> adj[MM];

void dfs(int cur, int pre){
    int cnt = 1;
    for(auto e: adj[cur]){
        int u = e.first;
        if(u == pre) continue;
        if(cnt == c[cur])
            cnt++;
        out[e.second] = c[u] = cnt++;
        dfs(u, cur);
    }
}

int main(){
    
    scan(n);
    
    for(int i = 0,a,b; i < n-1; i++){
        scan(a, b);
        adj[a].push_back({b, i});
        adj[b].push_back({a, i});
    }
    
    dfs(1, 0);
    
    for(int i = 0; i < n-1; i++)
        ans = max(ans, out[i]);
    print(ans);
    for(int i = 0; i < n-1; i++)
        print(out[i]);
    
    return 0;
}

Measured memory_bytes: 8576
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;;
  scanf("%d%d", &n, &m);
  vector<int> a(m);
  int sum = 0;
  for (int i = 0; i < m; ++i) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  sort(a.begin(), a.end());
  sum -= a[m - 1];
  int ret = max(0, a[m - 1] - sum - 1);
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 256
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%lld\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();
	data->getInput();

	AtCoder::BigNum big = data->getBigNum();

	AtCoder::Ans* ans = new AtCoder::Ans();

	if (1 == big[0] ||
		1 == big[1]) {
		printf("1\n");
	} else {
		big.push_back(big[0] * big[1]);
		ans->increment(big[2] / 2);
		if (0 != big[2] % 2) {
			ans->increment();
		}
		
		ans->showResult();
	}

	delete(ans);
	delete(data);

	return 0;
}


Measured memory_bytes: 504
#include<stdio.h>

int main(void)
{
    char s[4];
    char judge1;
    char judge2;
    int ans1 = 0;
    int ans2 = 0;
    
    int i;

    scanf("%s\n", s );

    judge1 = s[0];
    if( s[0] != s[1] )
    {
        judge2 = s[1];
    }
    else if( s[1] != s[2] )
    {
        judge2 = s[2];
    }
    else if( s[2] != s[3])
    {
        judge2 = s[3];
    }
    else
    {
        judge2 = 0;
    }
    
    
    for( i = 0; i < 4; i++ )
    {
        if( s[i] == judge1 )
        {
            ans1 += 1;
        }
        if( s[i] == judge2 )
        {
            ans2 += 1;
        }
    }

    if ( (ans1 == 2) && (ans2 == 2) )
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 100005;
struct Edge {
    int next, to;
    Edge(int a=0, int b=0) : next(a), to(b) {}
} e[maxn << 1];
int head[maxn], tot = 1;
void Add(int u, int v) {
    e[++tot] = Edge(head[u], v); head[u] = tot;
}

int N, leaf[maxn << 1], vis[maxn << 1];

int Leaf(int p) {
    if(vis[p]) return leaf[p]; vis[p] = 1;
    int x = e[p].to, c = 0;
    for(int i = head[x]; i; i = e[i].next) 
	if(p ^ i ^ 1) c += Leaf(i);
    return leaf[p] = (c == 0);
}
int main() {
    scanf("%d", &N);
    for(int i = 1, u, v; i < N; ++i) {
	scanf("%d %d", &u, &v);
	Add(u, v); Add(v, u);
    }
    bool Win = false;
    for(int x = 1; x <= N; ++x) {
	if(Leaf(x)) continue;
	int c = 0;
	for(int i = head[x]; i; i = e[i].next) c += Leaf(i);
	if(c > 1) Win = true;
    }
    puts(Win ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 3712
from collections import Counter

N, M = map(int, input().split())
input_counter = Counter()

for i in range(1, N+1):
        input_counter[int(i)] = 0

for j in range(M):
    for i in input().split():
        input_counter[int(i)] += 1

for element in input_counter.keys():
    print(input_counter[element])

Measured memory_bytes: 3316
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 W, H, x, y;
    	double ans1;
    	int ans2;
    	
        void solve(InputReader in, PrintWriter out) {
        	W = in.nextLong();
        	H = in.nextLong();
        	x = in.nextLong();
        	y = in.nextLong();
        	
        	ans1 = W*H/2.0;
        	ans2 = (W % 2 == 0 && W / 2 == x) && (H % 2 == 0 && H / 2 == y) ? 1 : 0;
        	
        	out.println(ans1 + " " + ans2);
        }
        
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 22100
#include <stdio.h>
#include <math.h>

int primenumber(int n);

int main(void)
{
    int n;

    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }

        printf("%d\n", primenumber(n));
    }
    return (0);
}
int primenumber(int n)
{
    int i,j;
    int x;
    int flag;
    int sum;

    i = 0;
    x = 2;
    sum = 0;
    while (i < n){
        flag = 0;
        if (x % 2 == 0 && x != 2){
                flag = 1;
            }
        for (j = 3; j <= sqrt(x); j++){
            if (x % j == 0){
                flag = 1;
                break;
            }
        }
        if (flag == 0){
            i++;
            sum += x;
            //printf("<%d %d %d>\n", i, sum, x);
        }
        x++;
    }
    return (sum);
}


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

using namespace std;

int main()
{
	int n, m;
	int a[51], b[51], c[51], d[51];
	int min;
	int sub;
	
	cin >> n >> m;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
	}
	
	for (int i = 0; i < n; i++) {
		min = abs(a[i] - c[0]) + abs(b[i] - d[0]);
		sub = 1;
		for (int j = 0; j < m; j++) {
			if (min > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				sub = j + 1;
			}
		}
		cout << sub << endl;
	}
	
	return (0);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        boolean isFlag=false;
        String str = br.readLine();
        String strstr = str + str;
        String expect = br.readLine();
        if(strstr.matches(".*" + expect + ".*")) 
            System.out.println("Yes");
        else 
            System.out.println("No");
    }
}

Measured memory_bytes: 17048
use std::io::BufRead;

fn main() {
  let stdin = std::io::stdin();
  let mut buf = String::new();
  stdin.read_line(&mut buf).unwrap();
  let n = buf.trim().parse::<usize>().unwrap();

  let score = stdin.lock().lines().take(n).fold((0, 0), |acc, line| {
    let line = line.unwrap();
    let mut ite = line.split_whitespace();
    let w1 = ite.next().unwrap();
    let w2 = ite.next().unwrap();

    if w1 > w2 {
      (acc.0 + 3, acc.1)
    } else if w1 == w2 {
      (acc.0 + 1, acc.1 + 1)
    } else {
      (acc.0, acc.1 + 3)
    }
  });

  println!("{} {}", score.0, score.1);
}


Measured memory_bytes: 5040
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];
        vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var R = vals[0];
        var S = vals[1];
        var P = vals[2];
        var T = Console.ReadLine();

        var point = new Dictionary<char, int>();
        point['s'] = R;
        point['p'] = S;
        point['r'] = P;

        var score = 0;
        for (int i = 0; i < K; i++)
        {
            char prev = '-';
            for (int j = i; j < N; j+=K)
            {
                if(T[j] != prev)
                {
                    score += point[T[j]];
                    prev = T[j];
                }
                else
                {
                    prev = '-';
                }
            }
        }

        Console.WriteLine(score);
    }
}

Measured memory_bytes: 13664
import math
while True:
    q=int(input())
    if q==-1:
        break
    x=q/2
    while True:
        if math.fabs((x**3)-q)<0.00001*q:
            break
        x=x-(x**3-q)/(3*(x**2))
    print(f'{x:.6f}')
        


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

void gen(const std::vector<int> &d, std::vector<std::vector<int>> &ans,
  const std::vector<int> &cur) {
  for (const auto i : d) {
    if (std::find(cur.cbegin(), cur.cend(), i) == cur.cend()) {
      auto tmp = cur;
      tmp.push_back(i);
      if (tmp.size() == d.size()) {
        ans.push_back(std::move(tmp));
      } else {
        gen(d, ans, tmp);
      }
    }
  }
}

int main() {
  int64_t n, m, r;
  std::cin >> n >> m >> r;
  std::vector<int> d(r);
  for (auto &i : d) {
    std::cin >> i;
    i--;
  }
  std::vector<std::vector<int64_t>> c(n,
    std::vector<int64_t>(n, 1000000000000000));
  for (int64_t i = 0; i < n; i++) {
    c[i][i] = 0;
  }

  for (int64_t i = 0; i < m; i++) {
    int64_t a_i, b_i, c_i;
    std::cin >> a_i >> b_i >> c_i;
    c[a_i - 1][b_i - 1] = c[b_i - 1][a_i - 1] = c_i;
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        c[i][j] = std::min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  std::vector<std::vector<int>> ans;
  gen(d, ans, {});

  int64_t len = 1000000000000000;
  for (const auto &i : ans) {
    int64_t tmp = 0;
    for (int j = 0; j < i.size() - 1; j++) {
      tmp += c[i[j]][i[j + 1]];
    }
    len = std::min(len, tmp);
  }

  std::cout << len << std::endl;
  return 0;
}


Measured memory_bytes: 4152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

string lcs(string s1, string s2) {
  vector<int> dp;
  string ret;
  for (auto s : s2) {
    int bgn_i = 0;
    int chr_i = 1;
    rep(i, 0, int(dp.size())) {
      chr_i = s1.find(s, bgn_i) + 1;
      if (not chr_i) break;
      dp[i] = min(dp[i], chr_i);
      bgn_i = dp[i];
    }
    if (chr_i) {
      chr_i = s1.find(s, bgn_i) + 1;
      if (chr_i) {
        dp.push_back(chr_i);
        ret += s1[chr_i-1];
      }
    }
  }
  return ret;
}


int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  int N;
  cin >> N;
  vector<string> S(N);
  rep(i, 0, N) {
    cin >> S[i];
    sort_(S[i]);
  }

  string ans;
  ans = accumulate(S.begin(), S.end(), S[0], lcs);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ld ans;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>k;
    rep(i,n){
        ll now=i+1;
        ll kaisuu=0;
        while(1){
            if(now>=k)break;
            now*=2;
            kaisuu++;
        }
        ld nans;
        nans=((long double)1/n);
        ld add=1.0;
        rep(i,kaisuu){
            add*=((long double)1/2);
        }
        ans+=(nans*add);
    }
    doublecout(ans);
    return 0;
}


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

using namespace std;
int main(){
    vector<int> a;
    int N, tmp, x, y;
    cin >> N;
    x = 0;
    y = 0;
    for(int i=0;i<N;i++){
        cin >> tmp;
        if(tmp%2 != 0) x++;
        else if(tmp%4 == 0) y++;
    }
    if(x == 0) cout << "Yes" << endl;
    else if((x + y) == N && x - y == 1) cout << "Yes" << endl;
    else if(x <= y) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
s = sum(A)

av = s / 2
x = 0
y = 0

for i in range(N):
  x += A[i]
  
  if x < av < x +A[i+1]:
    
    y = s - x - A[i+1]
    
    if x > y:
      print(A[i+1]-x+y)
      
    else:
      print(A[i+1]-y+x)
  elif x == av:
    print(0)

Measured memory_bytes: 31668
a = "keyence"

b = input()
o = 0
k = len(b)
j = 0
jj = 0
kk = [0 for i in range(8)]
al = 0
if k == 7:
	if a == b:
		print("YES")
	else:
		print("NO")
elif k >= 8:
	for i in range(k):
		if j == 7:
			al = 1
			print("YES")
			break
		if b[i] == a[j] and jj == 0:
			j += 1
		else:
			jj = 1
			o = j
		if jj == 1 and o == 0:
			if b[-7:] == a:
				print("YES")
				break
			else:
				print("NO")
				break
		elif jj == 1:
			if b[-(7-o):] == a[o:]:
				print("YES")
				break
			else:
				print("NO")
				break
else:
	print("NO")



Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string s,t;
    cin>>s>>t;
    ll count =0;
    rep(i,s.size()){
        if(s[i]==t[i])count++;
    }
    cout<<s.size()-count<<endl;

}

Measured memory_bytes: 3916
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    l = [0]*N
    l[0] = p[0]+1
    for i in range(1, N):
        l[i] = l[i-1]+p[i]+1
    ans = l[K-1]
    for i in range(N-K):
        tmp = l[K+i]-l[i]
        if tmp > ans:
            ans = tmp
    print(ans/2)
resolve()

Measured memory_bytes: 71792
#include <bits/stdc++.h>
using namespace std;
#define mps 1000000007
char maps[805][805];
int dis[805][805];
queue <int> xv,yv;
int main()
{
    int x,y,h,w,k,ans=666666;
    cin>>h>>w>>k;
    for(int i=1;i<=h;i++)
    {
        scanf("%s",maps[i]+1);
        for(int j=1;j<=w;j++)
        {
            dis[i][j]=-1;
            if(maps[i][j]=='S')
            {
                x=i;
                y=j;
            }
        }
    }
    xv.push(x);
    yv.push(y);
    dis[x][y]=0;
    while(!xv.empty())
    {
        x=xv.front();
        xv.pop();
        y=yv.front();
        yv.pop();
        int temp=min(min(x-1,h-x),min(y-1,w-y));
        temp=temp/k+(temp%k!=0);
        ans=min(ans,1+temp);
        if(dis[x][y]<k)
        {
            if(dis[x+1][y]==-1 && maps[x+1][y]=='.')
            {
                xv.push(x+1);
                yv.push(y);
                dis[x+1][y]=dis[x][y]+1;
            }
            if(dis[x-1][y]==-1 && maps[x-1][y]=='.')
            {
                xv.push(x-1);
                yv.push(y);
                dis[x-1][y]=dis[x][y]+1;
            }
            if(dis[x][y+1]==-1 && maps[x][y+1]=='.')
            {
                xv.push(x);
                yv.push(y+1);
                dis[x][y+1]=dis[x][y]+1;
            }
            if(dis[x][y-1]==-1 && maps[x][y-1]=='.')
            {
                xv.push(x);
                yv.push(y-1);
                dis[x][y-1]=dis[x][y]+1;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3456
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      s: chars,
      t: chars,
    }

    let mut possibles: Vec<String> = vec![];

    for i in 0..(s.len() - t.len() + 1) {
        let mut ok = true;
        let mut ss = s.clone();
        for j in 0..t.len() {
            if !(s[i+j] == '?' || s[i+j] == t[j]) {
                ok = false;
                break;
            }
            ss[i+j] = t[j];
        }
        if !ok { continue };
        for i in 0..s.len() {
            if ss[i] == '?' { ss[i] = 'a'; }
        }
        possibles.push(ss.into_iter().collect());
    }
    possibles.sort();
    if possibles.len() == 0 {
        println!("{}", "UNRESTORABLE");
    } else {
        println!("{}", possibles[0]);
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int w,x,y,z;
	w = 0;
	z = -1;
	scanf("%d%d" ,&x,&y);
	if(x < y){
		w = x;
		x = y;
		y = w;
	}
	while(z != 0){
		z = x % y;
		x = y;
		y = z;
	}
	printf("%d\n",x);
	return 0;
}



Measured memory_bytes: 2092
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[200011];
int dp[200011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    for (int i=N; i--;) {
	dp[A[i]] = dp[A[i]+1] + 1;
    }
    int ans = *max_element(dp, dp+N+1);
    ans = N - ans;
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>

int n;
int a, b;
int res[2];

int main()
{
	while( 1 ){
		std::cin >> n;
		
		if( !n ) break;
		
		res[0] = res[1] = 0;
		
		while( n-- ){
			std::cin >> a >> b;
		 	if( a == b ){
			 	res[0] += a;
				res[1] += b;
			}
			else if( a > b ){
			 	res[0] += a + b;
			}
			else{
			 	res[1] += a + b;
			}
		}
		
		std::cout << res[0] << " " << res[1] << std::endl;
	}

 	return 0;
}

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

string S;
int K;
int main(){
	cin >> S;
	cin >> K;
	int N = S.size();
	for(int i=0;i<N;i++){
		if(S[i]!='a'){	
			int l = 26 - (S[i]-'a');
			if(l<=K){
				K -= l;
				S[i] = 'a';
			}
		}
	}
	if(K>0){
		K %= 26;
		for(int i=0;i<K;i++){
			S[N-1]++;
		}
	}
	cout << S << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <deque>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
int n;
int ans=0;
int main()
{
  while(1)
    {
      ans=0;
      cin >> n;
      if(!n) break;
      vector<string> steps(n);
      int foots[]={0,0};
      for(int i=0;i<n;i++)
	{
	  cin >> steps[i];
	}
      if(steps[0]=="lu") foots[0]++;
      else if(steps[0]=="ru") foots[1]++;
      for(int i=1;i<n;i++)
	{
	  if(steps[i]=="lu" && foots[0]==0) 
	    {
	      foots[0]=(foots[0]+1)%2;
	      if(foots[1]==1 && steps[i-1]=="ru") ans++;
	    }
	  if(steps[i]=="ru" && foots[1]==0) 
	    {
	      foots[1]=(foots[1]+1)%2;
	      if(foots[0]==1 && steps[i-1]=="lu") ans++;
	    }
	  if(steps[i]=="ld" && foots[0]==1)
	    {
	      foots[0]=(foots[0]+1)%2;
	      if(foots[1]==0 && steps[i-1]=="rd") ans++;
	    }
	  if(steps[i]=="rd" && foots[1]==1)
	    {
	      foots[1]=(foots[1]+1)%2;
	      if(foots[0]==0 && steps[i-1]=="ld") ans++;
	    }
	}
      cout << ans << endl;
    }
  return 0;
}



Measured memory_bytes: 3140
// parameter "input" gets all data
function Main(data) {
  	let input = Number(data)
	if(input>=400 && input<=599){
    	console.log(8)
    }else if(input>=600 && input<=799){
    	console.log(7)
	}else if(input>=800 && input<=999){
    	console.log(6)
	}else if(input>=1000 && input<=1199){
    	console.log(5)
	}else if(input>=1200 && input<=1399){
    	console.log(4)
	}else if(input>=1400 && input<=1599){
    	console.log(3)
	}else if(input>=1600 && input<=1799){
    	console.log(2)
	}else if(input>=1800 && input<=1999){
    	console.log(1)
	}
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    int a, b;
    cin >> a >> b;
    vector<string> arr(2);
    FOR(i, a) arr[0] += to_string(b);
    FOR(i, b) arr[1] += to_string(a);
    sort(arr.begin(), arr.end());
    cout << arr[0] << '\n';
}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int a, b;
	cin >> a >> b;

	if (a < b) {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
		cout << endl;
	} else {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 384
q = int(input())
ll = []
rr = []
for i in range(q):
    l,r = map(int,input().split())
    ll.append(l)
    rr.append(r)

def f(n):
    flag = [True]*(n+1)
    flag[0] = flag[1] = False
    for i in range(2,int(n**0.5)+1):
        if flag[i]:
            x = 2*i
            while x <= n:
                flag[x] = False
                x += i
    return flag

m = max(rr)
j = f(m)
cnt = [0]*(m+1)
for i in range(1,m+1):
    cnt[i] = cnt[i-1]
    if i%2 != 0 and j[i] and j[(i+1)//2]:
        cnt[i] += 1

for i in range(q):
    print(cnt[rr[i]]-cnt[ll[i]-1])

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

int main(){
    int c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    string ans="Yes";
    if((c[1][0]-c[0][0])!=(c[1][1]-c[0][1]) or (c[1][1]-c[0][1])!=(c[1][2]-c[0][2])) ans="No";
    if((c[2][0]-c[0][0])!=(c[2][1]-c[0][1]) or (c[2][1]-c[0][1])!=(c[2][2]-c[0][2])) ans="No";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
X,Y,n=map(x->parse(Int,x),split(readline()))
x=y=0
for i=1:n
	a,b,c=map(x->parse(Int,x),split(readline()))
	if c==1&&x<a
		x=a
	elseif c==2&&X>a
		X=a
	elseif c==3&&y<b
		y=b
	elseif c==4&&Y>b
		Y=b
	end
end
print(max(X-x,0)*max(Y-y,0))


Measured memory_bytes: 116680
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  string s; cin >> s;

  // int n = 30000;
  // string s = "";
  // rep(i, n) {
  //   s += (char)(rand() % 10 + '0');
  // }
  // debug2(n, s);

  set<int> set1, set2, ans;
  for (int i = 0; i < n; i++) {
    int c1 = s[i] - '0';
    if (set1.find(c1) != set1.end()) continue;
    set1.insert(c1);
    for (int j = i + 1; j < n; j++) {
      int c2 = s[j] - '0';
      int m = c1 * 10 + c2;
      if (set2.find(m) != set2.end()) continue;
      set2.insert(m);
      for (int k = j + 1; k < n; k++) {
        int c3 = s[k] - '0';
        ans.insert(m * 10 + c3);
      }
    }
  }
  outl(ans.size());
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(){
	int W,H,N;
	int x,y,a;
	int a1,a2,a3,a4;
	cin >> W >> H >> N;
	a1 = 0;
	a3 = 0;
	a2 = W;
	a4 = H;
	while(cin >> x >> y >> a){
		if(a == 1){
			a1 = max(x, a1);
		}else if(a == 2){
			a2 = min(x, a2);
		}else if(a == 3){
			a3 = max(y, a3);
		}else{
			a4 = min(y, a4);
		}
	}
	cout << max(0, (a2 - a1)) * max(0,(a4 - a3)) << endl;
	return 0;
}
	


Measured memory_bytes: 256
using System;

namespace EDPC
{
    class A2
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            // initialize
            long[] h = new long[N];
            for (int i = 0; i < N; i++)
            {
                h[i] = int.Parse(input[i]);
            }

            // 初期条件
            long[] dp = new long[N];
            for (int i = 0; i < N; i++)
            {
                dp[i] = int.MaxValue;
            }
            dp[0] = 0;

            // 配るDP
            for (int i = 0; i < N - 1; i++)
            {
                dp[i + 1] = Math.Min(dp[i + 1], dp[i] + Math.Abs(h[i + 1] - h[i]));
                if (i < N - 2) dp[i + 2] = Math.Min(dp[i + 2], dp[i] + Math.Abs(h[i + 2] - h[i]));
            }
            Console.WriteLine(dp[N - 1]);
        }
    }
}


Measured memory_bytes: 19680
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
string s;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
    
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};
mint dp[100010][15];
int main()
{
  cin >> s;
  int N=s.size();
  for(int i=0;i<=N;++i){
    for(int j=0;j<13;++j){
      dp[i][j]=0;
    }
  }
  dp[0][0]=1;
  for(int i=0;i<N;++i){
    if(s[i]=='?'){
      for(int j=0;j<13;++j){
	for(int x=0;x<10;++x){
	  dp[i+1][(j*10+x)%13]+=dp[i][j];
	}
      }
    }
    else{
      int num=s[i]-'0';
      for(int j=0;j<13;++j){
	dp[i+1][(j*10+num)%13]+=dp[i][j];
      }
    }
  }
  cout << dp[N][5].x << "\n";
  return 0;
}


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

int main() {
  int a, b, h, m;
  std::cin >> a >> b >> h >> m;
  long double pi=3.1415926535;
  double rad = ((30*h + 0.5*m - 6*m) / 180) * pi;
  double ans = a*a + b*b - 2 * a * b * cos(rad);
  double length = sqrt(ans);
  cout << fixed << setprecision(10) << length <<endl;
}


Measured memory_bytes: 4188
const = 5 * (10 ** 15)
s = gets.chop
k = gets.chop.to_i

num_chars = s.chars.map(&:to_i)

selected = 0
current_number_of_char = 0
i = 0
found = 0

while found == 0 && i <= num_chars.length - 1
	current_number_of_char += num_chars[i] ** const
	
	if k <=  current_number_of_char
		selected = num_chars[i]
		found = 1
	end
	
	i += 1
end

puts selected

Measured memory_bytes: 1788
n, a, b = [int(i) for i in input().split(" ")]

def p2l(x):
    l = []
    for i in range(0, n):
        l = [x % 2] + l
        x = x // 2
    return l

def l2p(x):
    return sum([x[i] * 2**(len(x) - i - 1) for i in range(0, len(x))])

al = p2l(a)
bl = p2l(b)

def gray(a, b):
    if len(a) == 1:
        return [a, b]
    
    for i in range(0, len(a)):
        if a[i] != b[i]:
            break
    ah = a[i]
    bh = b[i]
    del a[i]
    del b[i]
    
    c = [1 - a[0]] + a[1:]
    g1 = gray(a[:], c[:])
    g2 = gray(c[:], b[:])
    g1 = [h[0:i] + [ah] + h[i:] for h in g1]
    g2 = [h[0:i] + [bh] + h[i:] for h in g2]
    return g1 + g2

if sum(al) % 2 != sum(bl) % 2:
    print("YES")
    g = gray(al, bl)
    p = [l2p(gi) for gi in g]
    print(' '.join(map(str, p)))
else:
    print("NO")

Measured memory_bytes: 131848