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

int main()
{
	int n,m;
	cin>>n>>m;
	
	char s[m],c[m];
	char ch[n+1];
	for(int i=1;i<=n;i++)
		ch[i]='*';
	
	for(int i=0;i<m;i++)
		cin>>s[i]>>c[i];
		
		
	for(int i=0;i<m;i++)
	{
		if(s[i]=='1' && c[i]=='0' && n!=1)
		{
			cout<<-1<<endl;
			return 0;
		}
		
		if(ch[s[i]-48]!='*' && ch[s[i]-48]!=c[i])
		{
			cout<<-1<<endl;
			return 0;
		}
		ch[s[i]-48]=c[i];
	}
	
	if(n==1)
		if(ch[1]=='*')
		{
			cout<<0;
			return 0;
		}

	for(int i=1;i<=n;i++)
	{
		if(i==1)
			if(ch[i]=='*')
				ch[i]='1';
		if(i!=1)
			if(ch[i]=='*')
				ch[i]='0';
		cout<<ch[i];
	}
	cout<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B;
    cin >> A >> B;
    cout << max(A + A - 1, max(B + B - 1, A + B)) << endl;
    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  int64 ret = 0;
  for(int i = 1; i <= N; i++) {
    if(i % 3 == 0 || i % 5 == 0) continue;
    ret += i;
  }
  cout << ret << endl;
}



Measured memory_bytes: 3664
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass

def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)
S = set()
n = int(input())
A = list(map(int,input().split()))

for i in range(n):
  ass = prime_factor(A[i])
  la = len(ass)
  ls = len(S)
  S.update(ass)
  if len(S) - ls != la:
    break
else:
  print("pairwise coprime")
  exit()

SetGcd = A[0]
for i in range(n):
  SetGcd = gcd(SetGcd,A[i])
if SetGcd == 1:
  print("setwise coprime")
else:
  print("not coprime")


Measured memory_bytes: 176432
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;
using System.Drawing;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            tree = new long[N].Select(_ => new List<(long v, long w)>()).ToArray();
            for (var i = 0; i < N - 1; ++i)
            {
                var (u, v, w) = Slice3<long>();
                --u; --v;
                tree[u].Add((v, w));
                tree[v].Add((u, w));
            }
            colors = new long[N];
            colors[0] = 0;
            dfs(0, -1);
            foreach (var c in colors)
                WriteLine(c);
        }
        static List<(long v, long w)>[] tree;
        static long[] colors;
        static void dfs(long n, long p)
        {
            foreach (var info in tree[n])
            {
                if (info.v == p) continue;
                if (info.w % 2 == 0)
                    colors[info.v] = colors[n];
                else
                    colors[info.v] = (colors[n] + 1) % 2;
                dfs(info.v, n);
            }
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 60564
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int N = 110, M = 1010;

void solve() {
	int n, m;
	scanf("%d%d", &n, &m);
	int x = (n + 1) / 2, y = x + 1, cnt = m;
	for(int i = 1; i <= m; i++) {
		if(i & 1) {
			printf("%d %d\n", x - cnt, x);
			cnt--;
			x--;
		}
		else {
			printf("%d %d\n", y, y + cnt);
			cnt--;
			y++;
		}
	}
}

int main() {
	//FRE;
	int t;
	solve();
	return 0;
}


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> primes(int x) {
  vector<int> ret;
  if (x % 2 == 0) {
    ret.push_back(2);
    while (x % 2 == 0) x /= 2;
  }
  for (int i = 3; i * i <= x; i += 2) {
    if (x % i) continue;
    while (x % i == 0) x /= i;
    ret.push_back(i);
  }
  if (x != 1) ret.push_back(x);
  return ret;
}
signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> primes_cnt;
  for (auto& x : A) {
    cin >> x;
    for (auto e : primes(x)) {
      primes_cnt[e]++;
    }
  }

  int ma = 0;
  for (auto p : primes_cnt) {
    ma = max(ma, p.second);
  }

  if (ma == N) {
    cout << "not coprime\n";
  } else if (ma > 1) {
    cout << "setwise coprime\n";
  } else {
    cout << "pairwise coprime\n";
  }
}


Measured memory_bytes: 15860
#include<stdio.h>
int main(){
    char s[10+1];
    char t[10+1];
    int a,b;
    char u[10+1];
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    for(int i=0;i<10;i++){
        if(s[i]!=u[i]){
            printf("%d %d\n",a,b-1);
            return 0;
        }else{
            printf("%d %d\n",a-1,b);
            return 0;
        }
    }
}

Measured memory_bytes: 128
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
	auto s = readln().split()[0].to!int();
	if (s==4 || s==2 || s==1) { writeln("4"); return; }
	auto i = 1;
	while(true) {
		if (s == 1) { writeln(i+1); return; }
		i++;
		s = f(s);
	}
}

int f(int n) {
	return n%2 == 0 ? n/2 : 3*n + 1;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long N,P,ans,cur,t=1,cnt[10010],i;string S;
int main()
{
    cin>>S;
    N = S.size();P = 2019;
        cnt[0]=1;
        for(i=N-1;i>=0;i--){
            (cur+=(S[i]-'0')*t)%=P;
            ans+=cnt[cur]++;
            t=t*10%P;
        }
    cout<<ans;
}


Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i=1;i<=N;i++){
    if((int)(to_string(i).size())%2==1)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    boolean res = false;
    double i;
    for(i = 0; i <= 10000; ++i) {
      if( (int) (i * 0.08) == a && (int) (i * 0.1) == b) {
        res = true;
        break;
      }
    }
    if(res) System.out.println((int) i); 
    else System.out.println(-1);
  }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<cmath>
#include<algorithm>
using std::max;
int f[3][105],a[3][105],n;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			f[i][j]=max(f[i-1][j]+a[i][j],f[i][j-1]+a[i][j]);
	printf("%d\n",f[2][n]);
	return 0;
}

Measured memory_bytes: 128
a_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
b_list = []
while True:
    try:
        al = input()
        al = al.lower()
        b_list = b_list + list(al)

    except:
        break

for i in range(len(a_list)):
    print(a_list[i] + " : " + str(b_list.count(a_list[i])))
    
    


Measured memory_bytes: 5580
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#define MAXN 100000
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
map<PII,bool> vis;
set<PII> exist;
int a[MAXN+5],b[MAXN+5];
int dir[9][2]={{-2,-2},{-2,0},{0,-2},{0,0},{-1,-2},{-2,-1},{-1,0},{0,-1},{-1,-1}};
LL ans[10]={};
int main()
{
	int H,W,N;
	scanf("%d %d",&H,&W);
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
		exist.insert(PII(a[i],b[i]));
	}
	LL tot=1LL*(1LL*H-2LL)*(1LL*W-2LL);
	for(int i=1;i<=N;i++)
	{
		int bgx,bgy;
		for(int p=0;p<9;p++)
		{
			bgx=a[i]+dir[p][0];
			bgy=b[i]+dir[p][1];
			if(bgx<=0||bgy<=0||bgx>H||bgy>W)
				continue;
			if(bgx+2<=0||bgy+2<=0||bgx+2>H||bgy+2>W)
				continue;
			if(vis[PII(bgx,bgy)]==true)
				continue;
			LL cnt=0;
			for(int x=bgx;x<=bgx+2;x++)
				for(int y=bgy;y<=bgy+2;y++)
				{
					if(exist.find(PII(x,y))!=exist.end())
						cnt+=1LL;
				}
			vis[PII(bgx,bgy)]=true;
			ans[cnt]+=1LL;
		}
	}
	ans[0]+=tot-vis.size();
	for(int i=0;i<=9;i++)
		printf("%lld\n",ans[i]);
	return 0;
}

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

using namespace std;
#define INF 1e9+1;
typedef long long int ll;

int main()
{
    int n, w;
    cin >> n >> w;
    ll v[n+1];
    int wt[n+1];
    for(int i=0; i<n; i++) cin >> wt[i+1] >> v[i+1];

    //dp array will contain the max weight able to be carried
    ll dp[n+1][w+1] = {};
    
    for(int i=1; i<=n; i++)
    {
        for (int j = 1; j <= w; j++)
        {
              ll a = dp[i-1][j];
              ll b =0;
              if (wt[i] <= j) b = v[i] + dp[i-1][j - wt[i]];
              dp[i][j] = max(a,b);
        }
    }

    cout << dp[n][w] << endl;
}

Measured memory_bytes: 82316
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  double num, total;
  string check;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> num >> check;
    if (check == "BTC"){
      num = num * 380000;
    }
    total = total + num;
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

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

    ll x[n], y[n];
    ll f[n], g[n];
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        f[i] = x[i] - y[i];
        g[i] = x[i] + y[i];
    }

    sort(f, f + n);
    sort(g, g + n);

    ll maxf = f[n - 1];
    ll minf = f[0];
    ll maxg = g[n - 1];
    ll ming = g[0];

    ll ans = max(maxf - minf, maxg - ming);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9880
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll x, y;
    cin >> x >> y;

    if (abs(x - y) <= 1) print("Brown");
    else print("Alice");
    
}


Measured memory_bytes: 3632
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	v := nextFloat64s(n)
	sort.Sort(sort.Float64Slice(v))

	for i := 1; i < n; i++ {
		v[i] = (v[i-1] + v[i]) / 2.0
	}
	puts(v[n-1])
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
    long int n;
    int cnt = 0, min = 20000000;
    scanf("%ld", &n);
    long int data[n];
    for(int i = 0; i < n; i++){
        scanf("%ld", &data[i]);
        if(min >= data[i]){
            cnt ++;
            min = data[i];
        }
    }
    printf("%d\n", cnt);
    return 0;

}

Measured memory_bytes: 1664
n,x = map(int, input().split())

burger = [[1,1]]

for i in range(n):
    burger.append([burger[-1][0]*2+3,burger[-1][1]*2+1])

# レベルn, 下からx段, 食べるパティp枚
def eat(n,x):
    if n==0:
        if x>0:
            return 1
        else:
            return 0
    if x < 1:
        return 0
    if 1 <= x <= 1+burger[n-1][0]:
        return eat(n-1,x-1)
    if x == 2 + burger[n-1][0]:
        return burger[n-1][1]+1
    if x>2+burger[n-1][0]:
        return eat(n-1,x-2-burger[n-1][0])+burger[n-1][1]+1


print(eat(n,x))


Measured memory_bytes: 38384
//AtCoder Beginner Contest 085
//C - Otoshidama

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n,y;
    cin >> n >> y;

    for(int i=0;i<=n;i++){
        int sum1 = 10000*i;
        if(sum1 <= y){
            for(int j=0;j<=n;j++){
                int sum2 = sum1 + 5000*j;
                if(sum2 <= y){
                    int num = (y-sum2)/1000;
                    if(num+i+j==n){
                        cout << i << " " << j << " " << num << endl;
                        return 0;
                    }
                }else{
                    break;
                }
            }
        }else{
            break;
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

int main()
{
	int a, b; cin >> a >> b;

	int sum = max(a, b);
	if (a < b) b--;
	else       a--;

	sum += max(a, b);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    char c;
    cin >>c;
    cout << (('A' <= c && c <= 'Z') ? 'A' : 'a') << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#define N 50
using namespace std;
int main(){
	int n, r, p, c, i, j, card[N+1], memo[N+1];
	while(cin >> n >> r, n){
		for(i = 1; i <= n; i++) card[i] = n - i + 1;
		for(i = 0; i < r; i++){
			cin >> p >> c;
			for(j = 1; j < p; j++) memo[j] = card[j];
			for(j = 1; j <= c; j++) card[j] = card[p + j - 1];
			for(j = 1; j < p; j++) card[c + j] = memo[j];
		}
	cout << card[1] << endl;
	}
	return 0;
}

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

#include <stdio.h>
using namespace std;

int main(void) {
	string deck;
	string after(200, 'a');
	int m;
	while (1) {
		int shuffleNum = 0;
		cin >> deck;
		if (deck == "-") break;
		cin >> m;
		for (int i = 0; i < m; i++) {
			int next;
			cin >> next;
			shuffleNum += next;
		}
		for (int i = 0; i < deck.length(); i++) {
			after[i] = deck[(i + shuffleNum) % deck.length()];
			cout << after[i];
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3120
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [[False]*3 for i in range(3)]

for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                B[j][k] = True

flag = False

for i in range(3):
    if B[i][0] and B[i][1] and B[i][2]:
        flag = True
        break
    if B[0][i] and B[1][i] and B[2][i]:
        flag = True
        break

if B[0][0] and B[1][1] and B[2][2]:
    flag = True

if B[0][2] and B[1][1] and B[2][0]:
    flag = True

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    string a = readln.chomp.split.join;
    int m = readln.chomp.to!int;
    string b = readln.chomp.split.join;
    writeln(a < b ? 1 : 0);
}


Measured memory_bytes: 2492
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
vll cumsum(vll& A){
  vll cum;
  int N=A.size();
  cum.push_back(0);
  for (int i=0;i<N;++i){
    cum.push_back(cum[i]+A[i]);
  }
  return cum;
}
 
//[low, high-1]から探す。
int b_search(vll& cum, int low, int high, ll c){
  int lb=low-1, ub=high;
  while(ub-lb>1){
    int mid=(ub+lb)/2;
    if(cum[mid]>=c){ub=mid;}
    else{lb=mid;}
  }
  return ub;
}
 
int main(){
  int N;cin>>N;
  vll A;
  for (int i=0;i<N;++i){
    ll a;cin>>a;A.push_back(a);
  }
 
  vll cum=cumsum(A);
 
  ll smallest=cum[N];
  //i,i+1の間でまんなかを切る
  for (int i=2;i<N-1;++i){
    ll lc=cum[i];
    ll hc=cum[N]+cum[i];
    int lub=b_search(cum, 1, i+1, lc/2);
    int hub=b_search(cum, i+1, N+1, hc/2);
    ll B=cum[lub];
    ll C=cum[i]-cum[lub];
    ll D=cum[hub]-cum[i];
    ll E=cum[N]-cum[hub];
    ll M=max(B,C);M=max(M,D);M=max(M,E);
    ll m=min(B,C);m=min(m,D);m=min(m, E);
    smallest=min(smallest, M-m);
    if(lub!=1){
      ll B_=cum[lub-1];
      ll C_=cum[i]-cum[lub-1];
      M=max(B_,C_);M=max(M,D);M=max(M,E);
      m=min(B_,C_);m=min(m,D);m=min(m, E);
      smallest=min(smallest, M-m);
    }
    if(hub!=i+1){
      ll D_=cum[hub-1]-cum[i];
      ll E_=cum[N]-cum[hub-1];
      M=max(B,C);M=max(M,D_);M=max(M,E_);
      m=min(B,C);m=min(m,D_);m=min(m, E_);
      smallest=min(smallest, M-m);
      if(lub!=1){
        ll B_=cum[lub-1];
        ll C_=cum[i]-cum[lub-1];
        M=max(B_,C_);M=max(M,D_);M=max(M,E_);
        m=min(B_,C_);m=min(m,D_);m=min(m, E_);
        smallest=min(smallest, M-m);
      }
    }
  }
 
  cout << smallest << endl;
  return 0;
}

Measured memory_bytes: 4848
import sys
import os
from sys import stdin
import math

# stdin = open(os.path.dirname(__file__) + '/input.txt')  # local test
input = stdin.readline
sys.setrecursionlimit(20000000)


N = int(input())
i_6 = math.ceil(math.log(N, 6))
i_9 = math.ceil(math.log(N, 9))

dp = [9999999] * (N + 1)
dp[0] = 0

for i in range(N):
    for j in range(i_6 + 1):
        if (i + 6 ** j) > N:
            break
        if dp[i] < dp[i + 6 ** j]:
            dp[i + 6 ** j] = dp[i] + 1

    for k in range(i_9 + 1):
        if (i + 9 ** k) > N:
            break
        if dp[i] < dp[i + 9 ** k]:
            dp[i + 9 ** k] = dp[i] + 1

print(dp[N])


Measured memory_bytes: 42092
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int mod_pow(int x,int y,int m){
	int res=1;
	while(y>0){
		if(y&1)res=(__int128_t(res)*x)%m;
		y>>=1;x=(__int128_t(x)*x)%m;
	}
	return res;
}
 
bool prime(int n){
	if(n<2||n%2==0)return n==2;
	int d=n-1;while(d%2==0)d>>=1;
	for(int x:{2,325,9375,28178,450775,9780504,1795265022}){
		if(n<=x)break;
		int t=d,y=mod_pow(x,t,n);
		while(t!=n-1&&y!=1&&y!=n-1){
			y=(__int128_t(y)*y)%n;t<<=1;
		}
		if(y!=n-1&&t%2==0)return false;
	}return true;
}
int rho(int n){
	if(n%2==0)return 2;
	int MOD=n;
	auto f=[&](int x){return ((__int128_t)x*x+1)%MOD;};
	auto g=[](int x,int y){
		if(x<y)return y-x;
		return x-y;
	};
	for(int x1=0;;x1++){
		for(int x=x1,y=f(x);;x=f(x),y=f(f(y))){
			int d=gcd(g(y,x),n);
			if(1<d&&d<n)return d;
			if(d==n)break;
		}
	}
}
vector<int>factor(int n){
	if(n==1)return {};
	if(prime(n))return {n};
	int d=rho(n);
	vector<int>res=factor(d);
	for(int i:factor(n/d))res.push_back(i);
	return res;
}

int extGCD(int a,int b,int &x,int &y){
	if(!b){
		x=1;y=0;return a;
	}
	int d=extGCD(b,a%b,y,x);
	y-=a/b*x;
	return d;
}
P CRT(vector<int>b,vector<int>m){
	int r=0,M=1;
	rep(i,len(b)){
		int p,q;
		int d=extGCD(M,m[i],p,q);
		if((b[i]-r)%d)return P(0,-1);
		int tmp=(b[i]-r)/d*p%(m[i]/d);
		r+=M*tmp;
		M*=m[i]/d;
	}
	return P((r%M+M)%M,M);
}
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;N*=2;
	vector<int>v=factor(N);sort(all(v));
	map<int,int>mp;
	for(int i:v)mp[i]++;
	int ans=N/2;
	rep(i,1<<len(mp)){
		int x=1,y=1;
		int j=0;
		for(auto k:mp){
			if(i>>j&1){
				x*=mod_pow(k.first,k.second,inf);
			}else {
				y*=mod_pow(k.first,k.second,inf);
			}
			j++;
		}
		if(x!=1){
			chmin(ans,CRT({x-1,0},{x,y}).first);
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	if(a>b*2){
		cout << a-b*2;
	}
	else{
		cout << 0;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;


// Fermat の小定理を用いた F_mod 上での逆元計算: x^(mod-2), 蟻本p115
ll Inverse(ll x){
    ll res = 1;
    int n = mod - 2;
    while(n > 0){
        if(n & 1){
            res = res * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}


int main() {
    int B,W;
    cin >> B >> W;

    // 明らかに分母を2^nに固定できる
    vector<ll>y(B+W);
    ll AllBlack = 0;
    ll AllWhite = 0;

    // 分母xのmodを計算, 2のi+1乗 = x[i}
    vector<ll>x(B+W);
    x[0] = 2;
    for(int i=1; i<B+W; i++){
        x[i] = x[i-1] * 2;
        x[i] %= mod;
    }

    // iの階乗 = fact[i}
    vector<ll>fact(B+W+1);
    fact[0]=1;
    for(int i=1; i<B+W+1; i++){
        fact[i] = fact[i-1] * i % mod;
    }

    // 分子のmodを計算
    for(int i=0; i<B+W; i++){
        // これがi+1回目の試行
        if(i==0){
            y[i]=1;
        }else{
            y[i]= x[i-1] + AllBlack - AllWhite + mod;
            y[i] %= mod;
        }

        // i+1回目の試行後にAllBlackとAllWhiteの場合の数を更新(全事象の数はx[i})
        // 試行前が黒B+W-i-1個, 白1個の状態の場合の数だけ増えて, これはi_C_W-1
        if(i>=W-1){
            AllBlack = (AllBlack * 2) + (fact[i] * Inverse(fact[W-1] * fact[i- W + 1] % mod));
        }
        AllBlack %= mod;
        // 白も同じく
        if(i>=B-1){
            AllWhite = (AllWhite * 2) + (fact[i] * Inverse(fact[B-1] * fact[i - B + 1] % mod));
        }
        AllWhite %= mod;
    }






    // 分母の逆元を Fermat の小定理を用いて計算
    vector<ll>xInverse(B+W);
    for(int i=0; i<B+W; i++){
        xInverse[i] = Inverse(x[i]);
    }

    // 出力
    ll o;
    for(int i=0; i<B+W; i++){
        o = y[i] * xInverse[i] % mod;
        cout << o << endl;
    }
    return 0;
}

Measured memory_bytes: 8448
#include<iostream>
using namespace std;
int main() {
  int h, w;
  string c;
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    for (int i = 0; i < h; i++) {
      cout << "#";
      if (i == 0 || i == h - 1) c = "#";
      else c = ".";
      for (int j = 0; j < w - 2; j++) cout << c;
      cout << "#" << endl;
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
    double a,b,c,h,m,alfa,beta,delta;
    double PI=3.14159265358;
    cin >> a >> b >> h >> m;
    alfa=30*h+30*(m/60);
    beta=6*m;
    delta=abs(alfa-beta);
    delta=min(delta,360-delta);
    c=sqrt(a*a+b*b-2*a*b*cos(delta*PI/180));
    cout << fixed << setprecision(10) << c;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

//directed graph
vector<int> G[1000];
//hash
string name[1000];

void dfs(int now, int d)
{
    rep(i,d) printf(".");
    cout << name[now] << endl;

    rep(i,G[now].size()) dfs(G[now][i],d+1);
}

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

    int k;
    string m;

    //make root
    cin >>k >>m;
    name[0]=m;

    //make tree
    rep(i,n-1)
    {
        cin >>k >>m;
        name[i+1]=m;
        G[k-1].pb(i+1);
    }

    //answer
    dfs(0,0);

    return 0;
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int a,b;
	cin >> a >> b;
	P(((a*b)%2 == 0 ? "Even" : "Odd"));
}

int main() {
	solve();
	return 0;
}


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


const int MAX = 220000;
int N;
vector<int> tmp;
int val[220000];
vector<int> adj[220000];

int t[550000];
void modify(int p, int value) {
	p += MAX;
	for (t[p] = max(t[p], value); p > 1; p >>= 1)
		t[p >> 1] = max(t[p], t[p ^ 1]);
}
void init(int p, int value) {
	for (t[p += MAX] = value; p > 1; p >>= 1)
		t[p >> 1] = max(t[p], t[p ^ 1]);
}
int query(int l, int r) {
	int ret = 0;
	for (l += MAX, r += MAX; l < r; l >>= 1, r >>= 1) {
		if (l & 1) ret = max(ret, t[l++]);
		if (r & 1) ret = max(ret, t[--r]);
	}
	return ret;
}

map<pll, int> mp;

int dp[220000];
int ans[220000];
void dfs(int nd, int prv = -1) {
	dp[nd] = query(0, val[nd]) + 1;
	modify(val[nd], dp[nd]);
	mp[{dp[nd], val[nd]}]++;
	for (int nxt : adj[nd]) {
		if (prv == nxt) continue;
		dfs(nxt, nd);
	}
	if (--mp[{dp[nd], val[nd]}] == 0)
		if (query(val[nd], val[nd] + 1) == dp[nd]) init(val[nd], 0);
}

void dfs2(int nd, int mx, int prv = -1) {
	ans[nd] = mx;
	for (int nxt : adj[nd]) {
		if (prv == nxt) continue;
		dfs2(nxt, max(mx, dp[nxt]), nd);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> val[i];
		tmp.push_back(val[i]);
	}
	for (int i = 0; i < N - 1; i++) {
		int a, b; cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	sort(tmp.begin(), tmp.end());
	tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());

	for (int i = 0; i < N; i++)
		val[i] = lower_bound(tmp.begin(), tmp.end(), val[i]) - tmp.begin() + 1;

	dfs(0);
	dfs2(0, dp[0]);

	for (int i = 0; i < N; i++) cout << ans[i] << '\n';

	return 0;
}


Measured memory_bytes: 47596
import java.util.Scanner;

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

		int n = sc.nextInt();

		double[] x = new double[n];
		double[] y = new double[n];

		for (int i = 0; i < n; i++) {
			x[i] = sc.nextDouble();
			y[i] = sc.nextDouble();
		}

		double sum = 0;

		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				double distance = Math.sqrt(
						Math.pow(x[i] - x[j], 2) +
								Math.pow(y[i] - y[j], 2));
				sum += distance;

			}

		}

		System.out.println(sum * (2) / n);

	}


}

Measured memory_bytes: 23380
#include<iostream>
#include<set> 
#include<vector>
#include<stack>
#include<string>
#include<ctype.h>
#include<sstream> 
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<cstring> 
using namespace std; 

char farm[105][105];
int H,W;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1}; 
void dfs(int x, int y, char c)
{
	farm[x][y] = 'x';
	for(int i = 0; i < 4; i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(nx >= 0 && nx < W && ny >= 0 && ny < H && farm[nx][ny] == c){
			dfs(nx, ny, c);
		}
	}
}
int main()
{	
	while(cin>>W>>H && (W || H))
	{
		for(int i = 0; i < W; i++){
			for(int j = 0; j < H; j++){
				cin>>farm[i][j];
			}
		}
		int res = 0;
		for(int i = 0; i < W; i++){
			for(int j = 0; j < H; j++){
				if(farm[i][j] != 'x'){
					dfs(i, j, farm[i][j]);
					res++;
				}
			}
		}
		cout<<res<<endl;
	}
	return 0;
 } 
 


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7;
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}
int main(){
  ll A,B;
  cin>>A>>B;
  
  cout<<max(A*B,max(A-B,A+B))<<endl;
}


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

#define N 20000

int main(void)
{
	char str[N];
	int sum=0, i, c1=0, c2=0;
	int s1[N], s2[N], result[N];
	int x, y;
	scanf("%s", str);
	
	for(i=0; i<strlen(str); i++){
		if(str[i]=='\\') s1[c1++]=i;
		else if(str[i]=='/' && c1>0){
			x=s1[--c1];
			y=i-x;
			while(c2>0 && s2[c2-1]>x) y+=result[--c2];
			result[c2]=y;
			s2[c2]=i;
			c2++;
		}
	}
	
	for(i=0; i<c2; i++) sum+=result[i];
	printf("%d\n", sum);
	printf("%d", c2);
	for(i=0; i<c2; i++) printf(" %d", result[i]);
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 2092
// 2011/08/05 Tazoe

#include <iostream>
using namespace std;

struct man{
	int x;
	int y;
	int d;
};

int main()
{
	while(true){
		int W, H;
		cin >> W >> H;
		if(W==0&&H==0)
			break;

		char S[30][30];
		struct man M[900];
		int N = 0;		// ÀHàÉ¢él
		for(int y=0; y<H; y++){
			for(int x=0; x<W; x++){
				cin >> S[y][x];

				if(S[y][x]=='E'||S[y][x]=='N'||S[y][x]=='W'||S[y][x]=='S'){
					M[N].x = x;
					M[N].y = y;
					if(S[y][x]=='E')
						M[N].d = 2;
					else if(S[y][x]=='N')
						M[N].d = 3;
					else if(S[y][x]=='W')
						M[N].d = 0;
					else if(S[y][x]=='S')
						M[N].d = 1;
					N++;
					S[y][x] = '@';		// lª¢é}XÚ
				}
			}
		}

		bool flg = false;
		for(int t=1; t<=180; t++){
			// è@
			for(int i=0; i<N; i++){
				int D = (M[i].d+4-1)%4;
				for(int j=0; j<4; j++){
					if(D==2&&(S[M[i].y][M[i].x+1]=='.'||S[M[i].y][M[i].x+1]=='X'))
						break;
					else if(D==3&&(S[M[i].y-1][M[i].x]=='.'||S[M[i].y-1][M[i].x]=='X'))
						break;
					else if(D==0&&(S[M[i].y][M[i].x-1]=='.'||S[M[i].y][M[i].x-1]=='X'))
						break;
					else if(D==1&&(S[M[i].y+1][M[i].x]=='.'||S[M[i].y+1][M[i].x]=='X'))
						break;
					if(j<3)
						D = (D+1)%4;
					else
						D = M[i].d;	// ü«ðÏ¦È¢
				}
				M[i].d = D;
			}

			// ûpÅ\[gi¼ü«Cìü«Cü«Cìü«j
			for(int i=0; i<N-1; i++)
				for(int j=i+1; j<N; j++)
					if(M[i].d>M[j].d){
						struct man tmp = M[i];
						M[i] = M[j];
						M[j] = tmp;
					}

			// èA
			for(int i=0; i<N; i++)
				if(M[i].d==2&&(S[M[i].y][M[i].x+1]=='.'||S[M[i].y][M[i].x+1]=='X')){
					if(S[M[i].y][M[i].x+1]=='X')
						M[i].d = 9;	// ñíûÉ
					S[M[i].y][M[i].x] = '.';
					M[i].x += 1;
					S[M[i].y][M[i].x] = '@';
				}
				else if(M[i].d==3&&(S[M[i].y-1][M[i].x]=='.'||S[M[i].y-1][M[i].x]=='X')){
					if(S[M[i].y-1][M[i].x]=='X')
						M[i].d = 9;
					S[M[i].y][M[i].x] = '.';
					M[i].y -= 1;
					S[M[i].y][M[i].x] = '@';
				}
				else if(M[i].d==0&&(S[M[i].y][M[i].x-1]=='.'||S[M[i].y][M[i].x-1]=='X')){
					if(S[M[i].y][M[i].x-1]=='X')
						M[i].d = 9;
					S[M[i].y][M[i].x] = '.';
					M[i].x -= 1;
					S[M[i].y][M[i].x] = '@';
				}
				else if(M[i].d==1&&(S[M[i].y+1][M[i].x]=='.'||S[M[i].y+1][M[i].x]=='X')){
					if(S[M[i].y+1][M[i].x]=='X')
						M[i].d = 9;
					S[M[i].y][M[i].x] = '.';
					M[i].y += 1;
					S[M[i].y][M[i].x] = '@';
				}

			// ñíûÌlÍCÀHà©çÁ¦é
			for(int i=0; i<N; i++)
				if(M[i].d==9)
					S[M[i].y][M[i].x] = 'X';

			// ûpÅ\[giñíûÌlðÅãÉj
			for(int i=0; i<N-1; i++)
				for(int j=i+1; j<N; j++)
					if(M[i].d>M[j].d){
						struct man tmp = M[i];
						M[i] = M[j];
						M[j] = tmp;
					}

			// ñíûÌlðCl©ç­
			for(int i=0; i<N; i++)
				if(M[i].d==9){
					N = i;
					break;
				}

			if(N==0){
				cout << t << endl;
				flg = true;
				break;
			}
		}

		if(!flg)
			cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	for (char i = '0'; i <= '9'; i++) {
		for (char j = '0'; j <= '9'; j++) {
			for (char k = '0'; k <= '9'; k++) {
				vector<char>ch(3);
				ch[0] = i;
				ch[1] = j;
				ch[2] = k;
				int m = 0;
				for (int l = 0; l < S.size(); l++) {
					if (ch[m] == S[l])m++;
					if (m == 3) {
						ans++;
						break;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))

if N % 2 == 1:
  for i in range(M):
    print(1 + i, N - i)
else:
  n = N // 2
  c = 1
  for i in range(M - 1, -1, -2):
    print(c, c + i + 1)
    c += 1
  c = n + 1
  for i in range(M - 2, -1, -2):
    print(c, c + i + 1)
    c += 1



Measured memory_bytes: 9220
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int x = ri();

		Console.WriteLine(x == 0 ? 1 : 0);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static BigInteger rb(){return BigInteger.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
	static BigInteger[] rba(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>BigInteger.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 27532
#include<bits/stdc++.h>
using namespace std;
int w,h,x,y,res;
double ans;
int main()
{
    cin>>w>>h>>x>>y;
    if(x*2==w&&y*2==h)res=1;
    ans=w/2.0*h;
    printf("%lf %d\n",ans,res);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int n;cin>>n;
	string s;
	rep(i,40){
		if(n>>i&1){
			s+='1';
			if(i%2==0){
				n-=(1<<i);
			}
			else{
				n+=(1<<i);
			}
		}
		else s+='0';
	}
	while(!s.empty()&&s.back()=='0')s.pop_back();
	reverse(s.begin(),s.end());
	if(s.empty())s="0";
	cout<<s<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[]A = new int[N];
    
    int all = 0;
    int cou = 0;
    for(int i=0; i<N; i++){
        A[i] = sc.nextInt();
        all += A[i];
    }
    for(int i=0; i<N; i++){    
    if(A[i]>=all/4.0/M){
            cou++;
    }
    }
        if(cou>=M){
       	System.out.println("Yes");
        }else{
        System.out.println("No");
    }
}
}


Measured memory_bytes: 35960
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b = readline().rstrip().decode('utf-8').split()

if a == "H":
    print(b)
else:
    if b == "H":
        print("D")
    else:
        print("H")

Measured memory_bytes: 38256
(N, K), As = readlines.map{_1.split.map(&:to_i)}

cs = Array.new(N + 1, 0)
i, xs, ys = 1, [1], []
cs[1] = 1
while cs[i] <= 2
  i = As[i - 1]
  case cs[i]
  when 0; xs << i
  when 1; ys << i
  end
  cs[i] += 1
end
puts K < xs.size ? xs[K] : ys[(K - xs.size)%ys.size]

Measured memory_bytes: 31876
import scala.io.StdIn._

object Main extends App {

  val Array(k, n) = readLine.split(" ").map(_.toInt)

  val points = readLine.split(" ").map(_.toInt)

  val distances = points.zipWithIndex.map { case (pos, idx) =>
      if (idx == 0) (k - points(points.length - 1)) + pos
      else pos - points(idx - 1)
  }

  val maxDis = distances.zipWithIndex.maxBy { case (dis, _) => dis }._1

  println(k - maxDis)
}



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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int n;cin>>n;

    int result = 0;

    VI s(n);
    REP(i, n){
        cin >> s[i];
        result += s[i];
    }

    if(result%10 != 0){
        cout<<result<<endl;
        return;
    }

    SORT_ASC(s);
    REP(i,n){
        if(s[i]%10 != 0){
            cout<<result-s[i]<<endl;
            return;
        }
    }

    cout<<0<<endl;

    

    






	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

const int N = 0;

int main()
{
	string s;
	cin >> s;
	string z;
	
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=',') z+=s[i];
		else z+=" ";
	}
	cout << z;
}

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

using ll = long long;
using ld = long double;

int main()
{
    int n,tmp, fx=0;
    cin >> n;
    tmp=n;
    while(tmp>0)
    {
        fx+=tmp%10;
        tmp/=10;
    }

    if(n % fx == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if(n == 25)
    {
        printf("Christmas\n");
    }
    else if(n == 24)
    {
        printf("Christmas Eve\n");
    }
    else if(n == 23)
    {
        printf("Christmas Eve Eve\n");
    }
    else if(n == 22)
    {
        printf("Christmas Eve Eve Eve\n");
    }
    return 0;
}


Measured memory_bytes: 256
def wantp(lis,n):

    q = []
    while lis[n] != n:
        q.append(n)
        n = lis[n]

    for i in q:
        lis[i] = n

    return n


N,K,L = map(int,input().split())
rp = [i for i in range(N)]
rank = [1 for i in range(N)]
pqlis = []

for i in range(K):

    P,Q = map(int,input().split())
    P -= 1
    Q -= 1

    PP = wantp(rp,P)
    QP = wantp(rp,Q)
    pqlis.append([P,Q])

    if PP != QP:

        if rank[PP] < rank[QP]:
            rp[PP] = QP

        elif rank[QP] < rank[PP]:
            rp[QP] = PP

        else:
            rp[QP] = PP
            rank[QP] += 1

#print (rp)

tp = [i for i in range(N)]
rank = [1 for i in range(N)]


for i in range(L):

    P,Q = map(int,input().split())
    P-=1
    Q-=1
    pqlis.append([P,Q])

    PP = wantp(tp,P)
    QP = wantp(tp,Q)

    #print (PP,QP,PP2,PQ2)

    if PP != QP:

        if rank[PP] < rank[QP]:
            tp[PP] = QP

        elif rank[QP] < rank[PP]:
            tp[QP] = PP

        else:
            tp[QP] = PP
            rank[QP] += 1

dic = {}

for i in range(N):

    p1 = wantp(rp,i)
    p2 = wantp(tp,i)
    string = str(p1) + "," + str(p2)

    if string not in dic:
        dic[string] = 1
    else:
        dic[string] += 1

for i in range(N):

    p1 = wantp(rp,i)
    p2 = wantp(tp,i)
    string = str(p1) + "," + str(p2)

    print (dic[string])

Measured memory_bytes: 131832