akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int h[] = new int[N];
		int ans = 0;
		for(int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
			if(h[i] >= K) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 48848
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cassert>

using namespace std;

const int N = 2e5 + 7;
const int LOG = 25;

int n;
vector<int> adj[N];
int ans;

int dfs(int u, int from) {
	int all = 0, least = 0;
	for (int v : adj[u]) {
		if (v == from) continue;
		int mask = dfs(v, u);
		for (int j = 0; j < LOG; j++) {
			if ((all >> j & 1) && (mask >> j & 1)) {
				least = max(least, j + 1);
			}
		}
		all |= mask;
	}
	assert(least + 1 < LOG);
	for (int i = least; ; i++) {
		if (~all >> i & 1) {
			ans = max(ans, i);
			all ^= (1 << i);
			for (int j = i - 1; j >= 0; j--) {
				if (all >> j & 1) {
					all ^= (1 << j);
				}
			}
			return all;
		}
	}
}

int solve() {
	ans = 0;
	dfs(rand() % n + 1, 0);
	return ans;
}

int main() {
	scanf("%d", &n);
	//n = 1e5;
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int ret = n;
	for (int r = 1; r <= 5; r++) {
		ret = min(ret, solve());
	}
	printf("%d\n", ret);
}


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

int main(){

    int H, W;
    cin >> H >> W;
    vector<vector<char> > a(H, vector<char>(W));
    for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) cin >> a[i][j];

    vector<bool> row(H, false), col(W, false);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(a[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for(int i = 0; i < H; i++){
        if(row[i]){
            for(int j = 0; j < W; j++){
                if(col[j]) cout << a[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>

using namespace std;

void print_current(deque<int> arr, int n) {
  for (int i = 0; i < n - 1; i++) {
    cout << arr[i] << ' ';
  }
  cout << arr[n - 1] << endl;
}

void insertion_sort(deque<int> arr, int n) {
  print_current(arr, n);

  for (int i = 1; i < n; i++) {
    int val = arr[i];
    int j;

    for (j = i - 1; j >= 0 && arr[j] > val; j--) {
      arr[j + 1] = arr[j];
    }

    arr[j + 1] = val;

    print_current(arr, n);
  }
}

int main() {
  int n;
  deque<int> arr;

  cin >> n;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    arr.push_back(tmp);
  }

  insertion_sort(arr, n);

  return 0;
}


Measured memory_bytes: 3068
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <functional>
 
using namespace std;
 
int main() {
    unsigned long long n,a,b;
    cin>>n>>a>>b;
    if (a+b==0){
    cout<<0;
    return 0;
    }
    unsigned long long m=n/(a+b);
    unsigned long long cnt=m*a;
    unsigned long long x=n-m*(a+b);
    if (x<=a){
        cnt+=x;
    }else{
        cnt+=a;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 18
for i in range(N - K + 1):
    left = i
    right = i + K - 1
    tmp = min(abs(x[left]) + abs(x[right] - x[left]), abs(x[right]) + abs(x[left] - x[right]))
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 14380
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)*}
    };
}

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

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

fn main() {
    input!{
        n: usize,
        xs: [i32; n]
    }
    let mut is_even: bool = true;
    for x in 0..n {
        if xs[x] % 2 != 0 {
            is_even = false
        }
    }
    if is_even {
        fn div_cnt(i: Vec<i32>, acc: i32) -> i32 {
            if i.iter().all(|&x| x % 2 == 0) {
                div_cnt(i.iter().map(|&x| x / 2).collect(), acc + 1)
            } else {
                acc
            }
        };
        let ret: i32 = div_cnt(xs, 0);
        println!("{}", ret);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= int(e); ++it)
#define per(it, f, e) for (rint it = (f); it >= int(e); --it)
const int MAXN = 1e5 + 10;
vector<int> edge[MAXN], cycle;
struct DSU {
	int par[MAXN];
	DSU() {
		rep (i, 1, MAXN - 1) {
			par[i] = i;
		}
	}
	inline int find(int x) {
		return par[x] == x ? x : par[x] = find(par[x]);
	}
	inline void marry(int x, int y) {
		par[find(x)] = find(y);
	}
}	Dsu;
int val[MAXN], par[MAXN];
inline void dfs(int u, int valor) {
	val[u] = valor;
	for (auto v : edge[u]) {
		if (v == par[u]) continue;
		par[v] = u;
		dfs(v, -valor);
		val[u] += val[v];
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int le1 = 1, le2 = 1;
	int n, m, u, v;
	cin >> n >> m;
	rep (i, 1, m) {
		cin >> u >> v;
		if (Dsu.find(u) != Dsu.find(v)) {
			Dsu.marry(u, v);
			edge[u].pb(v);
			edge[v].pb(u);
		} else {
			le1 = u, le2 = v;
		}
	}
	dfs(le1, 1);
	if (n == m) {
		for (int u = le2; u; u = par[u]) {
			cycle.pb(val[u]);
		}
        if (cycle.size() & 1) {
			if (val[le1] & 1) {
				cout << -1 << endl;
				return 0;
			}
			for (int u = le2; u; u = par[u]) {
				val[u] -= val[le1] / 2;
			}
        } else {
			if (val[le1]) {
				cout << -1 << endl;
				return 0;
			}
			sort(all(cycle));
			for (int u = le2; u; u = par[u]) {
				val[u] -= cycle[cycle.size() / 2 - 1];
			}
        }
	} else if (val[le1]) {
		cout << -1 << endl;
		return 0;
	}
	lint ans = 0;
	rep (i, 1, n) {
		ans += abs(val[i]);
	}
    cout << ans << endl;
	return 0;
}

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

int main()
{
    string x; cin>>x;
    stack<char> s;

    for(e: x) {
        if (e=='T' and s.size() and s.top()=='S')
            s.pop();
        else
            s.push(e);
    }
    cout<<s.size()<<endl;
}


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

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

  string G[h];
  for (int i = 0; i < h; i++) cin >> G[i];

  const int dy[4] = {-1, 0, 0, 1};
  const int dx[4] = {0, -1, 1, 0};

  bool can = true;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (G[i][j] == '#') {
        bool sharp = false;
        for (int d = 0; d < 4; d++) {
          if (i + dy[d] < 0 || h <= i + dy[d]) continue;
          if (j + dx[d] < 0 || w <= j + dx[d]) continue;
          if (G[i + dy[d]][j + dx[d]] == '#') sharp = true;
        }
        if (sharp == false) can = false;
      }
    }
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
n = int(input())

h = [h for h in map(int, input().split(' '))]

# print(n)
# print(h)

if n == 1:
  print('Yes')
  sys.exit()

for i in range(1, n):
  if h[i] < h[i-1]:
    print('No')
    sys.exit()
  if h[i] == h[i-1]:
    # 一つ前と同じ高さなら下げられない
    continue
  h[i] = max(h[i]-1, 0)
print('Yes')

Measured memory_bytes: 63708
#include <bits/stdc++.h>
using namespace std;
int cel(int a,int b)
{
    return (a/b)+(bool)(a%b);
}
int main()
{
    int n,k,a,i=0;
    for(scanf("%d%d",&n,&k); i<n; ++i) scanf("%d",&a);
    printf("%d\n",cel(n-1,k-1)),exit(0);
}

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

int main() {
	vector<int> num;
	int n, temp, Mix, k;
	cin >> n >> k;
	vector<int> dp(n);

	for (int i = 0; i < n; ++i) {
		cin >> temp;
		num.push_back(temp);
	}
	for (int i = 0; i < n; ++i) {
		Mix = 1e9;
		for (int j = 1; j <= k; ++j) {
			if (i - j < 0) {
				continue;
			} else {
				Mix = min(Mix, dp[i - j] + abs(num[i] - num[i - j]));
				dp[i] = Mix;
			}
		}
	}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 3900
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;
const int maxn=2e5+10;
typedef long long ll;

unordered_map<int,int> mp;
ll s[maxn];

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%lld",&s[i]),s[i]+=s[i-1];
    for(int i=1;i<=n;i++)
        s[i]=(s[i]-i%k+k)%k;
    ll ans=0;
    k=min(k,n+1);
    for(int i=0;i<k;i++){
        ans+=mp[s[i]];
        mp[s[i]]++;
    }
    for(int i=k;i<=n;i++){
        mp[s[i-k]]--;
        ans+=mp[s[i]];
        mp[s[i]]++;
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 10056
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 X = sc.nextInt();
		int[] math = new int[N + 1];
		for (int i = 0; i < M; i++) {
			int x = sc.nextInt();
			math[x]++;
		}
		int route1 = 0;
		int route2 = 0;
		for (int i = (X + 1); i <= N; i++) {
			route1 += math[i];
		}
		for (int i = (X - 1); i >= 0; i--) {
			route2 += math[i];
		}

		if (route1 <= route2) {
			System.out.println(route1);
		} else {
			System.out.println(route2);
		}

		sc.close();

	}

}

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

int Left[MAX/2+2],Right[MAX/2+2];
int cnt;

void merge(int ary[],int n,int left,int mid,int right){
  int i,j,k;
  int n1,n2;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++)Left[i]=ary[left+i];
  for(i=0;i<n2;i++)Right[i]=ary[mid+i];
  Left[n1]=Right[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(Left[i]<=Right[j]){
      ary[k]=Left[i++];
    }
    else{
      ary[k]=Right[j++];
    }
  }
}

void mergesort(int ary[],int n,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergesort(ary,n,left,mid);
    mergesort(ary,n,mid,right);
    merge(ary,n,left,mid,right);
  }
}

int main(){
  int ary[MAX],n,i;
  cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ary[i]);
  }
  mergesort(ary,n,0,n);
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",ary[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}
		



Measured memory_bytes: 5668
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		int result[];
		result = new int[10001];

		for (int x = 1; x <= 100; x++) {
			for (int y = 1; y <= 100; y++) {
				for (int z = 1; z <= 100; z++) {
					int p = (x * x) + (y * y) + (z * z);
					if (p <= 10000) {
						p += (x * y) + (y * z) + (z * x);
						if (p <= 10000) {
							result[p]++;
						}
					}
				}
			}
		}

		for (int i = 1; i <= n; i++) {
			System.out.println(result[i]);
		}
	}
}


Measured memory_bytes: 38832
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

string S[26][26];

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

  ll H, W; cin >> H >> W;
  rep(i,H){
    rep(j,W){
      cin >> S[i][j];
    }
  }

  rep(i,H){
    rep(j,W){
      if(S[i][j] == "snuke"){
	cout << (char)('A'+j) << i+1 << endl;
	return 0;
      }
    }
  }
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

int main(){
	int a[4],b[4];
	int h,bl;
	int i,j;
	while(EOF!=scanf("%d %d %d %d %d %d %d %d",
		&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])){
		h=0;
		bl=0;
		for(i=0; i<4; i++){
			if(a[i]==b[i]){
				h++;
				a[i]=-1;
				b[i]=-1;
			}
		}
		for(i=0; i<4; i++){
			for(j=0; j<4; j++){
				if(a[i]>=0&&b[j]>=0&&a[i]==b[j])bl++;
			}
		}
		printf("%d %d\n",h,bl);
	}


	return 0;
}

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

#define ll long long
#define inf 0x3f3f3f3f 
#define il inline 

#define in1(a) a=read()
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
#define out(a) printf( "%d" , a ) 
#define out_(a) printf( " %d" , a )
#define outn(a) out(a),putchar('\n')

#define I_int int 
inline I_int read() {

    I_int x = 0 , f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    return x * f ;
}
#undef I_int

using namespace std ;

#define N 100010

int n , k ;

vector<int>s[N]; 

int main() {
	in1( n ) ;
	k = -1 ;
	for( int i = 1 ; i < 500 ; i ++ ) 
		if( i * ( i - 1 ) / 2 == n ) { k = i ; break ; }
	if( k == -1 ) { return puts("No"),0; }
	int x = 0 ;
	for( int i = 0 ; i < k ; i ++ ) {
		for( int j = i + 1 ; j < k ; j ++ ) {
			x ++ ;
			s[ i ].push_back( x ) ;
			s[ j ].push_back( x ) ;
		}
	}
	puts("Yes"); outn(k);
	for( int i = 0 ; i < k ; i ++ ) {
		out((int)s[i].size());
		int len = s[ i ].size();
		for( int j = 0 ; j < len ; j ++ ) {
			out_(s[i][j]);
		}
		putchar('\n');
	}
	return 0 ;
}

Measured memory_bytes: 4608
/*
 Shahadat Hossain
 I.C.T Department
 Comilla University
 Session: 2013-2014
 */

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

#define int long long
#define valid(x,y) x>=0 && y>=0 && x<n && y<n
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define ms(a,b) memset(a, b, sizeof(a))
#define eps 1e-5
#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)
#define d(x) cout << #x << " = " << x << endl
#define dd(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define ddd(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl
//fprintf(stdout,"\nTIME: %.3lf sec\n", (double)clock()/(CLOCKS_PER_SEC));
//int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
#define bit(n,k) (((n)>>(k))&1)
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pr(x) {cout << (x) << '\n';  }
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define mask(i) ((1LL<<(i)))
#define endl '\n'
double const PI = acos(-1);
const int INF = 1e18;
const int inf = 1e9;

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int const N = 5e5+10;
//int const M = 1005;
//int const MOD = 998244353;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(10, 20)(rng)



int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a, b;
    cin >> a >> b;
    if((a + b) & 1){
        cout << "IMPOSSIBLE" << endl;
    }
    else{
        cout <<( (a + b) >> 1 )<< endl;
    }
}


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

int main(){
    int A[4];
    for(int i = 0; i < 4; i++) cin >> A[i];
    sort(A, A+4);
    if(A[0]==A[1] && A[2]==A[3])
        cout << "yes" << endl;
    else
        cout << "no" << endl;

    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int num=0;
	char c=' ';
	bool flag=true;
	for(;c>'9'||c<'0';c=getchar())
	if(c=='-')
	flag=false;
	for(;c>='0'&&c<='9';num=num*10+c-48,c=getchar());
	return flag ? num : -num;
}
int A,B;
bool check(int num)
{
	int num1=num%10;
	int num2=num/10000;
	if(num1!=num2)return false;
	num1=num%100/10;
	num2=num/1000%10;
	if(num1!=num2)return false;
	return true;
}
int main()
{
	A=read();
	B=read();
	int ans=0;
	for(int i=A;i<=B;i++)
	{
		if(check(i))
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	int n = fetch<int>();
	auto S = fetch<string>();
	int cnt = 0;

	for(char a = '0'; a <= '9'; ++a) {
		for(char b = '0'; b <= '9'; ++b) {
			for(char c = '0'; c <= '9'; ++c) {
				int cur = 0;
				int ok = 1;

				for(auto& chr: {a, b, c}) {
					while(cur < n && S[cur] != chr) {
						++cur;
					}

					if(cur == n) {
						ok = 0;
						break;
					}

					++cur;
				}

				cnt += ok;
			}
		}
	}

	cout << cnt << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
typedef struct{
  int son[2];//子
  int reach;
  int parent;
  int sibling;
  int degree;
  int height;
}node;

node B[100];
int n,x;

int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<2;j++){
      if(num==B[i].son[j]){
	r=i;
	return r;
      }
    }
  }
  return r;
}

int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}

int sibling(int num){//sibling input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    if(i!=num){
      if(B[num].parent==B[i].parent){
	r=i;
	return r;
      }
    }
  }
  return r;
}
/////////////////////////////////////////////////////////////////////////////
int height(int num,int r,int parent){//height input

  int i,j,deep=0;
  for(i=0;i<n;i++){
    if(deep<B[i].reach){
      for(j=B[i].parent;;j=B[j].parent){
	if(j==num){
	  deep=B[i].reach;
	  break;
	}
	if(B[j].parent==-1)break;
      }
    }
  }
  return deep;
}
///////////////////////////////////////////////////////////////////////////
int main(){
  int i,j,k,a,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    B[i].parent=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d",&a);
    for(j=0;j<2;j++){
      scanf("%d",&k);
      B[a].son[j]=k;
      B[k].parent=a;
      if(k!=-1)count++;    
    }
    B[a].degree=count;
    count=0;
  }
  /* 
  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  */
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
  
  for(i=0;i<n;i++){
    B[i].sibling=sibling(i);
  }
  
  for(i=0;i<n;i++){
    if(B[i].son[0]==-1&&B[i].son[1]==-1)B[i].height=0;
    else B[i].height=height(i,0,B[i].parent)-B[i].reach;
  }
 
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,B[i].parent,B[i].sibling,B[i].degree,B[i].reach,B[i].height);
    if(B[i].parent==-1)printf("root\n");
    else if(B[i].son[0]==-1&&B[i].son[1]==-1)printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define MAX 10001

using namespace std;

int main(void)
{
	int n,m;
	int r,q;
	int i1,i2,i3;
	int t,PCn,STm,s;
	int ts,te;
	int time_;
	int c;
	int check;

	while(1){
		cin >> n >> m;
		if(n+m==0) break;

		vector<pair<int,int> > v[MAX];

		cin >> r;
		for(i1=0;i1<r;i1++){
			cin >> t >> PCn >> STm >> s;
			v[STm].pb(mp(t,s));
			/*if(STm==120) {
				cout << t << " " << s << endl;
			}*/
		}

		cin >> q;
		for(i1=0;i1<q;i1++){
			cin >> ts >> te >> STm;
			vector<int> in(1000,0);
			time_=0;
			c=0;
			int count = 0;
			

			for(i2=540;i2<=te;i2++){
				check=0;
				if(c<v[STm].size()){
					if(v[STm][c].first==i2){
						if(v[STm][c].second==1){
							c++;
							count++;
							//cout << count << " " << i2 << endl;
							if(v[STm][c].first==v[STm][c-1].first){
								i2--;
								check=1;
							}
						}
						else {
							c++;
							count--;
							//cout<<count<<" "<<i2<<endl;
							if(v[STm][c].first==v[STm][c-1].first){
								i2--;
								check=1;
							}
						}
					}
				}
				if(count>0 && check==0) in[i2-540]=1;	
			}
			/*for(i2=623-540,i3=1;i2<=673-540;i2++,i3++){
				cout<<in[i2]<<" "<<i3<<endl;
			}*/

			for(i2=ts-540;i2<te-540;i2++){
				if(in[i2]==1) time_++;
			}

			cout << time_ << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1448
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<ll,ll>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const long double eps = 1e-10;
//const double PI = M_PI; 
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space. */
int main(){
  ll n; cin >> n;
  cout << (n == 5 || n == 7 || n == 3?"YES":"NO") << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

int main()
{
	int x; cin >> x;
	LLONG ans = 0;
	// first, move to the right as much as possible so as not to go beyond x
	int sum = 0;
	for (int i = 1;; ++i)
	{
		sum += i;
		++ans;
		if (sum >= x)
		{
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3560
from fractions import gcd
from math import sqrt


def prime_factorize(n):
    result = []
    for i in range(2, int(sqrt(n)) + 1):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result


A, B = map(int, input().split())
print(len(prime_factorize(gcd(A, B))) + 1)


Measured memory_bytes: 5048
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = 1;
            while (T-- > 0)
            {
                solveOne(in, out);
            }
        }

        private void solveOne(Scanner in, PrintWriter out)
        {
            String S = in.next();
            int cnt = 0;
            int anw = 0;
            for (char c : S.toCharArray())
            {
                if (c == 'R')
                {
                    cnt++;
                } else if (c == 'S')
                {
                    cnt = 0;
                }
                anw = Math.max(anw, cnt);
            }
            out.print(anw);
        }

    }
}



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

const int INF = 1e9;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i=0; i<N; i++) cin >> h[i];
  vector<int> dp(N, INF);
  dp[0] = 0;
  for (int i=1; i<N; i++){
    for (int j=1; j<=K; j++){
      if (i-j<0) break;
      dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#!/usr/bin/env run-cargo-script

#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt;
use std::io::{self, BufWriter, Read, StdinLock, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn solve(mut x: u64, y: u64) -> u32 {
    let mut r = 0;
    while x <= y {
        x *= 2;
        r += 1;
    }
    r
}

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next(), sc.next()));
}

struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                self.bytes
                    .by_ref()
                    .map(Result::unwrap)
                    .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
                    .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
                    .map(&mut f)
                    .collect()
            })
            .collect()
    }
}

trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P =pair<int,int>;

int main(){
    string s;
    cin >> s;
    ll l;
    l=s.size();
    string sx;
    string s2;
    int mx=0;
    rep(i,l){
        s2=s[i];
        if(s2=="x"){
            ++mx;
        }
        else{
            sx=sx+s2;
        }
    }

    ll l2=sx.size();
    int ans=0;
    string s3,s4;

    rep(i,l2/2){
        s3=sx[i];
        s4=sx[l2-1-i];
        if(s3==s4){
            continue;
        }
        else{
            ans=-1;
        }
    }

    //cout << ans << endl;

    if(ans==-1){
        cout << -1 << endl;
    }
    else{
        int ko=0;
        int hi=0,mi=l-1;
        while(hi!=mi){
            s3=s[hi];
            s4=s[mi];
            if(mi-hi==1 and s3==s4){
                break;
            }
            if(s3==s4){
                ++hi;
                --mi;
            }
            else if(s3=="x"){
                ++hi;
                ++ko;
            }
            else{
                --mi;
                ++ko;
            }
        }

        cout << ko << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3892
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n;
		cin>>n;
		map<string,int> d;
		string s[n];
		int m=0;
		FOR(i,0,n)
		{
			cin>>s[i];
			d[s[i]]++;
			m=max(m,d[s[i]]);
		}
		sort(s,s+n);
		FOR(i,0,n)
		{
			if(d[s[i]]==m)
			cout<<s[i]<<'\n';
			d[s[i]]=0;
		}
	}
	return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

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


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

//関数
//main関数
int main() {
    
    
    //入力
    long N;
    cin>>N;
    //計算
    //出力
    if(N==3){
        cout<<"2 5 63"<<endl;
    }else{
        long times=N/8,rem=N%8;
        for(int i=0;i<times;i++){
            cout<<12*i+2<<" "<<12*i+3<<" "<<12*i+4<<" "<<12*i+6<<" "<<12*i+8<<" "<<12*i+9<<" "<<12*i+10<<" "<<12*i+12<<" ";
        }
        if(rem==1) cout<<12*times+6;
        if(rem==2) cout<<12*times+2<<" "<<12*times+4;
        if(rem==3) cout<<12*times+2<<" "<<12*times+4<<" "<<12*times+6;
        if(rem==4) cout<<12*times+2<<" "<<12*times+3<<" "<<12*times+4<<" "<<12*times+9;
        if(rem==5) cout<<12*times+2<<" "<<12*times+3<<" "<<12*times+4<<" "<<12*times+6<<" "<<12*times+9;
        if(rem==6) cout<<12*times+2<<" "<<12*times+3<<" "<<12*times+4<<" "<<12*times+8<<" "<<12*times+9<<" "<<12*times+10;
        if(rem==7) cout<<12*times+2<<" "<<12*times+3<<" "<<12*times+4<<" "<<12*times+6<<" "<<12*times+8<<" "<<12*times+9<<" "<<12*times+10;
    }
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ok = true;
  rep(i,n){
    if(s[i] != s[n - i - 1]){
      ok = false;
      break;
    } 
  }
  rep(i,(n - 1)/2){
    if(s[i] != s[(n - 1)/2 - i - 1] || s[(n + 3)/2 + i - 1] != s[n - 1 - i]){
      ok = false;
      break;
    }
  }
  
  
  if(ok) puts("Yes"); else puts("No");
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;

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

    // x * 1.08 = A
    // x * 1.10 = B
    auto get = [&]()
    {
        // x = 100 / 0.08
        for (int i = 1; i <= 1300; ++i)
        {
            if (((int)(i * 0.08) == A) && ((int)(i * 0.1) == B))
                return i;
        }
        return -1;
    };

    cout << get() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  
  int N;
  scanf("%d",&N);
  std::vector<int > d(N);
  int sum =0;
  int sum2 = 0;
  for(int i=0; i<N; i++){
    scanf("%d",&d[i]);
    sum += d[i];
    sum2 += d[i]*d[i];
  }
  std::cout<<(sum*sum-sum2)/2 << std::endl;
  return 0;
}


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

using namespace std;

long long int l[100];

long long int lucas(int n) {
  if(n == 0) {
    l[0] = 2;
    return 2;
  }
  if(n == 1) {
    l[1] = 1;
    return 1;
  }
  if(l[n] != -1) {
    return l[n];
  }
  l[n] = lucas(n - 1) + lucas(n - 2);
  return l[n];
}

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

  for(int i = 0; i < 100; i++) {
    l[i] = -1;
  }
  
  cout << lucas(n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
int main(){
    string N;
    cin >> N;
    int a = stoi(N);
    int count = 0;
    for(int i = 0; i < N.size(); i++){
        char b = N[i];
        int c = int(b - '0');
        count+=c;
    }
    if(a % count == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3604
def so(l, n, ar):
	if (n < l):
		so(l, n + 1, ar + [True])
		so(l, n + 1, ar + [False])
	elif (n == l):
		global switchOnOff
		switchOnOff.append(ar)
        
switchOnOff = []
n, m = [int(i) for i in input().split()]
denkyus = []
for i in range(m):
	a = [int(j) for j in input().split()]
	denkyus.append(a[1:])
hikaku = [int(i) for i in input().split()]   
so(n, 0, [])

ret = 0
denkyuCnt = [0] * m
for ss in switchOnOff:
	denkyuCnt = [0] * m
	for si, s in enumerate(ss):
		for ji, j in enumerate(denkyus):
			if s and (si + 1) in j:
				denkyuCnt[ji] += 1
	subcnt = 0
	for i, d in enumerate(denkyuCnt):
		if d % 2 == hikaku[i]:
			subcnt += 1
	if subcnt == m:
		ret += 1
print (ret)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int Xor=0;
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N;
    cin>>N;
    while(N--){
        int n,k;
        cin>>n>>k;
        while(n%k){
            int d=n/k;
            int t=n-(k*d);
            t=(t-1)/(d+1)+1;
            n-=t*(d+1);
        }
        Xor^=(n/k);
    }
    cout<<(Xor?"Takahashi\n":"Aoki\n");
    return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
using namespace std;
int main()
{
	int n,flg,h[100000],i;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&h[i]);
	for(i=n-1;i>=1;i--){
		// printf("i=%d h=%d h-1=%d\n",i,h[i],h[i-1]);
		if(h[i]<h[i-1])	h[i-1]-=1;
	}
	flg=0;
	for(i=0;i<n-1;i++){
		if(h[i]>h[i+1])	flg=1;
		// printf("h=%d h+1=%d flg=%d\n",h[i],h[i+1],flg);
	}
	if(flg==1)	printf("No\n");
	else	printf("Yes\n");
	return 0;
}


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

int main() {
    std::string S;
    std::cin >> S;

    if (S[0] != S[2] && S[0] == S[1] && S[2] == S[3])
        std::cout << "Yes\n";
    else if (S[0] != S[1] && S[0] == S[2] && S[1] == S[3])
        std::cout << "Yes\n";
    else if (S[0] != S[1] && S[0] == S[3] && S[1] == S[2])
        std::cout << "Yes\n";
    else
        std::cout << "No\n";
}

Measured memory_bytes: 384
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,M,Q,L[200001],R[200001],p[100001],q[100001],res=0;
  
  cin >> N >> M >> Q;
  REP(i,M)cin >> L[i] >> R[i];
  REP(i,Q)cin >> p[i] >> q[i];
  vector <vector <int> > sum(N+1,vector<int>(N+1,0));
  REP(i,M)sum[L[i]][R[i]]++;
  REP(i,N+1){
    REP(j,N+1){
      if(i == 0 && j == 0)
        continue;
      if(i == 0)
        sum[i][j] += sum[i][j-1];
      else if(j == 0)
        sum[i][j] += sum[i-1][j];
      else
        sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
    }
  }
  REP(i,Q){
    cout << (sum[q[i]][q[i]] - sum[q[i]][p[i]-1] - sum[p[i]-1][q[i]] + sum[p[i]-1][p[i]-1]) << endl;
  }
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 4224
n = int(input())

s = ["".join(sorted(input())) for i in range(n)]
func = [0 for i in range(n)]

for i in range(n):
    if i == 0:
        continue
    func[i] = func[i - 1] + i

counts = {}

for ss in s:
    if ss in counts:
        counts[ss] += 1
    else:
        counts[ss] = 1

count = 0
for v in counts.values():
    count += func[v - 1]

print(count)


Measured memory_bytes: 23880
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a, b;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    b.resize(n);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i] >> b[i];
    }
    ll cur = 0;
    for(auto &i : a) cur += i;
    ll ans = cur;
    cur = 0;
    for(auto &i : b) cur += i;
    ans = min(ans, cur);
    vector <pair <int, int> > all;
    for(int i = 0 ; i < n ; i++){
        all.push_back(make_pair(a[i], i));
        all.push_back(make_pair(b[i], i));
    }
    sort(all.begin(), all.end());
    vector <int> vis(n);
    cur = 0;
    for(int i = 0 ; i < n ; i++){
        cur += all[i].first;
        vis[all[i].second] = 1;
    }
    for(auto &i : vis){
        if(i == 0){
            ans = min(ans, cur);
            finish(ans);
        }
    }
    for(int i = n ; i < 2 * n ; i++){
        ll c = cur;
        c += all[i].first;
        int j = n - 1;
        while(all[j].second == all[i].second) j--;
        c -= all[j].first;
        ans = min(ans, c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3188
//JSD
#include<iostream>
#define ll long long 
using namespace std;
int main(){
	ll n;
	cin>>n;
	ll a[n],sum=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum+=((i%2)?-1:1)*a[i];
	}
	ll dp[n]={0};
	dp[0]=sum;
	for(int i=1;i<n;i++){
		dp[i]=(a[i-1]-dp[i-1]/2)*2;
	}
	for(int i=0;i<n;i++){
		cout<<dp[i]<<" ";
	}
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  double PI = 3.141592653589793238;
  
  double r;
  cin >> r;
  
  cout << fixed << setprecision(10) << 2 * r * PI << '\n';
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#include <numeric>
#include <iterator>
#include <stdio.h>
#define ll long long
#define ull unsigned long long int
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define sz(a) int((a).size())
#define all(a) (a).begin(),(a).end()
#define fr(i,p,n) for(int i=p;i<n;i++)
#define precise cout << std::setprecision(10) << std::fixed;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
ll M=1000000007;
//ll M=  998244353;
typedef pair<int, int> pairs;

int main()
{
    fastio; precise;
    int T=1;
    //cin>>T;
    while(T--){
        string s,t,ans="";
        cin>>s>>t;
        int n=s.length(),m=t.length();
        int L[n+1][m+1];
        fr(i,0,n+1){
        fr(j,0,m+1){
        if(i==0||j==0) L[i][j]=0;
        else if(s[i-1]==t[j-1]) L[i][j]=1+L[i-1][j-1];
        else L[i][j]=max(L[i-1][j],L[i][j-1]);
        }
        }
        int a=L[n][m];
        int i=n,j=m;
        while(i>0&&j>0){
            if(s[i-1]==t[j-1]){
                ans+=s[i-1];
                i--; j--;
            }
            else if(L[i-1][j]>L[i][j-1]) i--;
            else j--;
        }
        reverse(all(ans));
        cout<<ans<<endl;

    }
     return 0;
}


Measured memory_bytes: 38800
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int[3];
    
    for(int i=0;i<3;i++){
      a[i] = sc.nextInt();
    }
    
    if(a[0]<=a[1]*a[2]){
      System.out.println("Yes");
    }else{
       System.out.println("No");
    }
  }
}

Measured memory_bytes: 27012
#include<bits/stdc++.h>
using namespace std;
int main(){
    int K,ans1=0,ans2=0,ans3=0;
    cin >> K;
    for(int a=1; a<=K; a++){
        ans1+=a;
    }
    for(int a=2; a<=K; a++){
        for(int b=1; b<a; b++){
            ans2+=gcd(a,b);
        }
    }
    int ab;
    for(int a=3; a<=K; a++){
        for(int b=2; b<a; b++){
            ab=gcd(a,b);
            for(int c=1; c<b; c++){
                ans3+=gcd(ab,c);
            }
        }
    }
    cout << ans1+6*ans2+6*ans3;
    return 0;
}

Measured memory_bytes: 3624
from collections import Counter
n = int(input())
V = list(map(int,input().split()))
E = []
O = []
for i,v in enumerate(V):
    if i%2==0:
        O.append(v)
    else:
        E.append(v)

cO = Counter(O).most_common(); cO.append((-1,0))
cE = Counter(E).most_common(); cE.append((-1,0))
if cO[0][0]==cE[0][0]: 
    ans = min(n-cO[0][1]-cE[1][1], n-cO[1][1]-cE[0][1])
else:
    ans = n-cO[0][1]-cE[0][1]
print(ans)

Measured memory_bytes: 25960