akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;
ll A[200005], B[200005];

int main()
{
	int N;
	cin >> N;
	ll sum = 0;
	ll min = 1000000001;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i] >> B[i];
		sum += A[i];
		if (A[i] > B[i])
		{
			min = std::min(min, B[i]);
		}
	}

	for (int i = 0; i < N; ++i)
	{
		if (A[i] != B[i])
		{
			break;
		}
		if (i == N - 1)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	cout << sum - min << endl;
	return 0;
}

Measured memory_bytes: 512
#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 a, b;
  cin >> a >> b;
  int t = stoi(a + b);
  
  bool ok = false;
  rep(i,400) {
    if (i*i==t) {
      ok = true;
      break;
    }
  }
  
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("outp.txt","w",stdout);
    #endif
    double t,n,x,i;
    cin>>n>>x>>t;
    double z=ceil(n/x)*t;
    cout<<(ll)z;
}

    


Measured memory_bytes: 3700
#include<stdio.h>

int main()
{
  int c[3][3];
  int i,j;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&c[i][j]);
    }
  }
  if(c[0][0]-c[0][1]!=c[1][0]-c[1][1] || c[0][0]-c[0][1]!=c[2][0]-c[2][1]){
    printf("No");
    return 0;
  }
  if(c[0][2]-c[0][1]!=c[1][2]-c[1][1] || c[0][2]-c[0][1]!=c[2][2]-c[2][1]){
    printf("No");
    return 0;
  }
  if(c[0][0]-c[1][0]!=c[0][1]-c[1][1] || c[0][0]-c[1][0]!=c[0][2]-c[1][2]){
    printf("No");
    return 0;
  }
  if(c[0][0]-c[2][0]!=c[0][1]-c[2][1] || c[0][0]-c[2][0]!=c[0][2]-c[2][2]){
    printf("No");
    return 0;
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int main(void){
  string S;
  cin >> S;

  int flag = 1;
  int i;
  for(i=0; i<S.length(); i+=2)
    if(S[i] == 'L')
      flag = 0;
  for(i=1; i<S.length(); i+=2)
    if(S[i] == 'R')
      flag = 0;

  if(flag == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int dfs(const vector<vecint>& tree, int idx) {
  vecint depths;
  for (auto&& child : tree[idx]) {
    depths.push_back(dfs(tree, child));
  }
  sort(depths);
  int cnt = tree[idx].size();
  int mx = cnt;
  for (auto&& p : index(depths)) {
    mx = max(mx, static_cast<int>(cnt-p.index()+p.value()));
  }
  return mx;
}

int main()
{
  int n;
  cin>>n;
  vector<vecint> children(n);
  for(int i : irange(0, n-1)) {
    int a;
    cin>>a;
    --a;
    children[a].push_back(i+1);
  }
  cout<<dfs(children, 0)<<endl;
  return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int64_t i = 0; i < n; ++i)
using namespace std;

int main() {
  unordered_set<char> u;
  string s;
  cin >> s;
  rep(i, s.size()) u.insert(s[i]);
  if(u.size() == s.size()) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        long N=gl();
        long D=gl();
        
        long ans=0;
        for (int i=0; i<N;i++) {
        	double x=gd();
        	double y=gd();
        	double d=Math.sqrt(x*x+y*y);
        	if(d<=D) {
        		ans++;
        	}
        	
        }

        System.out.println(ans);
//
//        if(N>=30) {
//
//		    System.out.println("Yes");
//        } else {
//        	System.out.println("No");
//
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 60976
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int a[105];
int main(void){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<abs(a[n-1]-a[0])<<endl;
    
    return 0;
}


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


int main()
{
	int len,flag=0;
	char str[1025] = { 0 };

	
	while (scanf("%[^ ,.]%*[ ,.]", str)!=EOF)
	{
		len = strlen(str);
		
		if (len > 2 && len < 7)
		{
			if (flag)
			{
				printf(" ");
			}
			printf("%s", str);
			flag = 1;
		}
	}
	printf("\n");

	return 0;
}


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

if n < 600:
  print(8)
elif 600 <= n and n < 800:
  print(7)
elif 800 <= n and n < 1000:
  print(6)
elif 1000 <= n and n < 1200:
  print(5)
elif 1200 <= n and n < 1400:
  print(4)
elif 1400 <= n and n < 1600:
  print(3)
elif 1600 <= n and n < 1800:
  print(2)
else:
  print(1)

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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int N,M;
    bool t=false;
    cin>>N>>M;
    if(abs(N-M)>1){
        cout<<0<<endl;
        return 0;
    }else if(abs(N-M)==1)t=true;
    ll A=1,B=1;
    REP(i,2,N+1){
        A*=i;
        A%=INF;
    }
    REP(i,2,M+1){
        B*=i;
        B%=INF;
    }
    ll ANS;
    if(t)ANS=A*B%INF;
    else ANS=A*B%INF*2%INF;

    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122

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

void insertionSort(int array[], int n);
void printArray(int array[], int n);


int main(void)
{
	// ????´???°???????????????
	int n;
	scanf("%d", &n);

	// ????´????????´?????????????????????¢?????????????¢????
	int *elements;
	elements = (int *)malloc(n * sizeof(int));
	if (elements == NULL) {
		printf("error: failed to allocate memory space\n");
		return 1;
	}

	// ????´?????????????????´?
	int i;
	for (i=0; i<n; i++) {
		scanf("%d", &elements[i]);
	}

	// ?????\??????????????????
	insertionSort(elements, n);

	free(elements);
	
	return 0;
}


// ?????\?????????
void insertionSort(int array[], int n)
{
	int i, j, v;
	printArray(array, n);
	for (i=1; i<n; i++) {
		v = array[i];
		j = i-1;
		while (j>=0 && array[j]>v) {
			array[j+1] = array[j];
			j--;
		}
		array[j+1] = v;
		printArray(array, n);
	}
}


// ??????????¨???????????????¨???
void printArray(int array[], int n)
{
	int i;
	for (i=0; i<n; i++) {
		printf("%d", array[i]);
		if (i<n-1) putchar(' ');
	}
	putchar('\n');
}


/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp
*/

Measured memory_bytes: 1780
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}

//x未満の要素数を返す二分探索関数
int b_s(vector<int>&vecxx, int xx) {
	if (xx <= vecxx[0]) { //x以下の要素数を返させる時は"<"に変える
		return 0;
	}
	if (vecxx.back() < xx) { //x以下の要素数を返させる時は"<="に変える
		return vecxx.size();
	}
	int aa1 = 0, aa2 = vecxx.size() - 1, aa3;
	while (aa1 + 1 < aa2) {
		aa3 = (aa1 + aa2) / 2;
		if (vecxx[aa3] >= xx) { //x以下の要素数を返させる時は">"に変える
			aa2 = aa3;
		}
		else {
			aa1 = aa3;
		}
	}
	return aa2;
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す

int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	string s, s2;
	cin >> s >> s2;
	rep(i, s.size()) {
		if (s[i] != s2[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}




Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	double W, H;
	double x, y;
	cin >> W >> H >> x >> y;
	cout << W * H / 2<<" ";
	if (x * 2 == W && y * 2 == H) {
		cout << 1;
	}
	else {
		cout << 0;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>
#include <sstream>
#include <bitset>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926535;

class UnionFind {
	std::vector<int> p;

public:
	UnionFind(int n) : p(n, -1) {}

	int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

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

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (p[y] < p[x]) std::swap(x, y);
		if (p[x] == p[y]) --p[x];
		p[y] = x;
		return true;
	}

};

ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}

ll count(ll n, ll k) {
	ll cnt = 0;
	while (true)
	{
		if (n >= k) {
			break;
		}
		cnt++;
		n *= 2;
	}
	return cnt;
}

int main() {
	string S, T;
	cin >> S >> T;
	bool ok = true;

	for (ll i = 0; i < S.size(); i++)
	{
		if (S[i] != T[i]) {
			ok = false;
		}
	}

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

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


signed main(){
  int n,k;cin>>n>>k;
  int l[55];rep(i,n)cin>>l[i];
  sort(l,l+n,greater<int>());
  int ans = 0;
  rep(i,k)ans += l[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint n,m;

void solve(){
  cin >> n >> m;
  llint a;
  llint sum=0;
  for(int i=0;i<m;i++){
    cin >> a;
    sum+=a;
  }

  if(n<sum)cout << -1;
  else cout << n-sum;
  cout << endl;

}

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


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

int main(){
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    int sum=0;
    bool can = false;
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for(int i=0;i<n;i++){
        sum += a.at(i);
        if(sum>=h){
            can = true;
            break;
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 640
def factoring(n):
    """
    This program factorize any number.
    This returns the dictionary of prime factors of the number.(if n=18=2*3**2, this returns {2:1,3:2})
        """
    if n == 0:
        return {0: 1}
    if n == 1:
        return {1: 1}

    # 今回のアルゴリズムについて
    # nが素数でない⇔nは√n以下の素因数を持つ⇒√n以下のすべての素数を列挙して、それでnを割っていってみる。
    #√n以下の素数をすべて書き出すために、エラトステネスの篩を使用する。t以下の素数をすべて列挙するためには√tまでの素数について調べれば十分なので、√nまでの素数を書き出すためには√√nまでの数について真面目に篩をかければいい。

    nOrigin = n
    n = n**0.5
    # n(=√input())以下の素数のリストをエラトステネスにより作成する
    # 素数の位置にはその数が、合成数の位置には-1が格納されているリストを作成
    # 0が格納されているのはまだ確認していない数。
    numlist = [0 for i in range(int(n) + 1)]
    numlist[0] = -1
    numlist[1] = -1

    #√√n以下の数について篩をかけていく
    t = 2
    while t < (n**0.5):
        if numlist[t] == 0:
            numlist[t] = t
            k = 2
            while t * k <= n:
                numlist[t * k] = -1
                k += 1
        t += 1

    #√√nより大きい数で、篩にかからなかった数は素数。
    while t <= n:
        if numlist[t] == 0:
            numlist[t] = t
        t += 1

    #√n以下の数で割っていく。
    result = {}
    for i in numlist:
        if i == -1:
            continue
        j = 0
        while nOrigin % i == 0:
            j += 1
            nOrigin = nOrigin / i
        if j == 0:
            continue
        else:
            result[i] = j

    if int(nOrigin) != 1:
        result[int(nOrigin)] = 1
    return result

n=int(input())

print("{0}: ".format(n),end="")
factors=[]
for i in sorted(factoring(n).items()):
    for j in range(i[1]):
        factors.append(str(i[0]))

print(" ".join(factors))



Measured memory_bytes: 6000
program main
  implicit none
  integer(8) :: n, i, counter(1:200000), pairs
  integer(8), allocatable :: a(:)
  read (*, *) n
  allocate (a(n))
  read (*, *) a(:)

  counter(:) = 0
  do i = 1, n
    counter(a(i)) = counter(a(i)) + 1
  end do

  pairs = 0
  do i = 1, 200000
    pairs = pairs + (counter(i) * (counter(i) - 1)) / 2
  end do

  do i = 1, n
    write (*, "(i0)") pairs - max(0_8, counter(a(i)) - 1)
  end do
end program main


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;

const int INF = INT_MAX;
typedef pair<int, pair<int, int> > Edge; // pair<cost, pair<from, to>>

long long edmonds(vector<Edge> edges, int v, int st){
    vector< pair<int, int> > mins(v, pair<int, int>(INF, -1));
    for(int i = 0; i < (int)edges.size(); i++){
        Edge edge = edges[i];
        mins[edge.second.second] = min(mins[edge.second.second], pair<int,int>(edge.first, edge.second.first));
    }
    mins[st] = pair<int,int>(-1, -1);
    
    vector<int> gr(v, 0);
    vector<bool> tfc(v, false), f(v, false);
    int cnt = 0;
    
    for(int i = 0; i < v ; i++){
        if(f[i]) continue;
        vector<int> ch;
        int cu = i;
        for(; cu !=-1 && !f[cu];){
            f[cu] = true;
            ch.push_back(cu);
            cu = mins[cu].second;
        }
        if(cu != -1){
            bool tfc2 = false;
            for(int j = 0; j < (int)ch.size(); j++){
                gr[ch[j]] = cnt;
                if(ch[j] == cu){
                    tfc[cnt] = true;
                    tfc2 = true;
                }
                if(!tfc2) cnt++;
            }
            if(tfc2) cnt++;
        }
        else for(int j = 0; j < (int)ch.size(); j++, cnt++) gr[ch[j]] = cnt;
    }
    if(cnt==v){
        long long ans = 1;
        for(int i = 0; i < v; i++) ans += mins[i].first;
    return ans;
    }
    long long res = 0;
    for(int i = 0; i < v; i++) if(i != st && tfc[gr[i]]) res += mins[i].first;
    
    vector<Edge> nedges;
    for(int i = 0; i < (int)edges.size(); i++){
        Edge edge=edges[i];
        int fto = edge.second.second, gfr = gr[edge.second.first], gto = gr[edge.second.second];
        if(gfr == gto) continue;
        else if(tfc[gto]) nedges.push_back(make_pair(edge.first - mins[fto].first, pair<int,int>(gfr, gto)));
        else nedges.push_back(make_pair(edge.first, pair<int,int>(gfr, gto)));
    }
    return res + edmonds(nedges, cnt, gr[st]);
}
 
int main(){
    int v, e, r;
    scanf("%d %d %d", &v, &e, &r);
    vector<Edge> es;
    for(int i = 0; i < e; i++){
        int s, t, w;
        scanf("%d %d %d", &s, &t, &w);
        es.push_back(make_pair(w, pair<int, int>(s, t)));
    }
    printf("%d\n", edmonds(es, v, r));
    return 0;
}




Measured memory_bytes: 3680
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

N = int(input())
s = input()

items_list = []

for i in range(10):
    for j in range(10):
        for k in range(10):
            tmp = [str(i), str(j), str(k)]
            items_list.append(tmp)

ans = 0
for pin in items_list:
    cnt = 0
    for i in range(0, len(s), 1):
        if s[i] == pin[cnt]:
            cnt += 1
            if cnt == 3:
                ans += 1
                break

print(ans)

Measured memory_bytes: 66136
# -*- coding: utf-8 -*-
import numpy as np
import math
n = int(input())
res = []
for i in range(int(math.sqrt(n))):
    if n%(i+1) == 0:
        res.append(i+1)
ans = int(math.log10(n/res[-1]) + 1)
print(ans)


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }


int main(void){
  int a,b,t;cin >> a >> b >> t;
  cout << (t/a)*b << endl;
  

  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = "abcdefghijklmnopqrstuvwxyz"
ans = []

while n > 26:
    n -= 1
    tmp = n % 26
    ans.append(tmp)
    n //= 26

ans.append(n-1)

for i in ans[::-1]:
    print(s[i], end="")


Measured memory_bytes: 9184
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=5001;
const ll LINF=100000000000000000;

int main(){
  int N,t=0;
  cin >> N ;
  set<int> tr;
  rep(i,N){
    int a;
    cin >> a ;
    if(a/400>=8) t++;
    else{
      tr.insert(a/400);
    }
  }
  cout << max(int(tr.size()),1) << " " << int(tr.size())+t << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: usize,
        w: usize,
        goods: [(usize, usize); n],
    }

    let v_sum: usize = goods.iter().map(|x| x.1).sum();

    let mut dp = vec![vec![0; v_sum+1]; n+1];
    
    for i in 0..v_sum+1 {
        dp[0][i] = 1<<60;
    }
    
    dp[0][0] = 0;
    

   for i in 1..n+1 {
       for j in 0..v_sum+1 {
           if j >= goods[i-1].1 {
                dp[i][j] = cmp::min(dp[i-1][j], dp[i-1][j-goods[i-1].1] + goods[i-1].0);
           } else  {
               dp[i][j] = dp[i-1][j];
           }
        }
    }


    for i in (0..v_sum+1).rev() {
        if dp[n][i] <= w {
            println!("{}", i);
            break;
        }
    }

}



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

#define int long long

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

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

signed main(){
    int N;
    cin>>N;
    for(int i=0;i<=100;i++)for(int j=0;j<=100;j++){
        if(i*4+j*7==N){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE  505

struct Point{

	double x,y;
};


int N;
double W,H;
int boss[SIZE],height[SIZE];
Point point[SIZE];


int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

void init(){

	for(int i = 0; i < N; i++){

		boss[i] = i;
		height[i] = 0;
	}
}

double calc_dist(Point A,Point B){

	return (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y);
}


bool is_OK(double R){

	init();

	//左端
	for(int i = 1; i <= N-2; i++){

		if(point[i].x < R){
			unite(0,i);
		}
	}

	//右端
	for(int i = 1; i <= N-2; i++){

		if(point[i].x > W-R){
			unite(N-1,i);
		}
	}


	for(int i = 1; i <= N-3; i++){
		for(int k = i+1; k <= N-2; k++){

			if(calc_dist(point[i],point[k]) < 4*R*R){

				unite(i,k);
			}
		}
	}

	return get_boss(0) != get_boss(N-1); //左端と右端が違うグループならOK
}

int main(){

	scanf("%lf %lf %d",&W,&H,&N);

	for(int i = 1; i <= N; i++){

		scanf("%lf %lf",&point[i].x,&point[i].y);
	}

	N += 2;

	double L = 0,R = W,mid = (L+R)/2;
	double ans = 0;

	for(int i = 0; i < 50; i++){

		if(is_OK(mid)){

			ans = mid;
			L = mid+EPS; //より長く

		}else{

			R = mid-EPS; //より短く
		}
		mid = (L+R)/2;
	}

	printf("%.10lf\n",ans);

	return 0;
}





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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    int n, cnt = 0;
    vector<int> a, used;
    cin >> n;
    a.resize(n+2);
    REP(i,n)cin >> a[i+1];
    a[0] = a[n+1] = 0;
    used.push_back(0);
    REP(i,n+1){
        if(a[i]<a[i+1]){
            used.push_back(a[i+1]);
            cnt++;
        }
        else if(a[i]>a[i+1]){
            while(used[used.size()-1]>a[i+1])used.pop_back();
            if(used[used.size()-1]<a[i+1]){
                used.push_back(a[i+1]);
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 4600
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
ll dp2[300000][60]={};
int main() {
	string s;
	cin>>s;
	rep(i,s.size())cout<<"x";
	return 0;
}


Measured memory_bytes: 3968
def solve_sub(t, r, s, p):
    prev = "@"
    res = 0
    win = {
        "r": p,
        "s": r,
        "p": s,
    }
    for c in t:
        if c == prev:
            prev = "@"
            continue
        else:
            res += win[c]
            prev = c
    return res


def main():
    N, K = [int(x) for x in input().split()]
    R, S, P = [int(x) for x in input().split()]
    T = input()

    groups = [""] * K
    for i in range(len(T)):
        groups[i%K] += T[i]
    # print(groups)

    ans = 0
    for g in groups:
        ans += solve_sub(g, R, S, P)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6132
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, r; cin>>n>>r;
    if(r>n/2) r=n-r;
    bool used[300010]={};
    vector<int> v;
    int p[300010];
    for(int i=0; i<n; i++){
        cin>>p[i]; p[i]--;
    }
    for(int i=0; i<n; i++){
        if(!used[i]){
            int c=0;
            int t=i;
            while(!used[t]){
                used[t]=1;
                t=p[t];
                c++;
            }
            v.push_back(c);
        }
    }
    bitset<150001> bs;
    bs[0]=1;
    for(auto x:v){
        bs=bs|(bs<<x);
    }
    if(bs[r]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 6440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
int n,t,zer;
ll z[maxn],f[maxn];
struct node
{
	ll a,b;
}e[maxn];
bool cmp(node x,node y)
{
	return y.a*(x.b+1)<x.a*(y.b+1);
}
int main()
{
//    freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin>>n>>t;
	for(int i=1;i<=35;i++) f[i]=t+1;
	
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		if(x==0) z[++zer]=y+1;
		else e[i-zer].a=x,e[i-zer].b=y;
	}
	n-=zer;
	sort(e+1,e+n+1,cmp);
	sort(z+1,z+zer+1);
	
	for(int i=1;i<=zer;i++)
	{
		z[i]+=z[i-1];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=35;j>=1;j--)
		{
			f[j]=min(f[j],(f[j-1]+1)*(e[i].a+1)+e[i].b);
		}
//		cout<<f[i]<<endl;
	}
	
	ll ans=0;
	for(ll i=0;i<=35;i++)
	{
//		cout<<f[i]<<endl;
		if(f[i]>t) continue;
		int s=0;
		if(zer) s=upper_bound(z+1,z+zer+1,t-f[i])-(z+1);
//		if(s==zer+1) s=zer;
//		if(f[i]+z[s]>t) continue;
		ans=max(ans,i+s);
	}
	cout<<ans<<endl;
	return 0;
}
 

Measured memory_bytes: 6732
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
	    void solve(IO io, PrintWriter out)
	    {
           int i, j;
           long n = io.nextLong();
          long a = io.nextLong();
          long b = io.nextLong();
          
          //out.print((b-a)+" "+((b-a)/2));
          long s=Long.MAX_VALUE;
          if((b-a)%2==0)
          {
            s=(b-a)/2;
          }
          
          long n1 = a-1;
          n1+=((b-a)-1)/2;
          n1+=1;
          long n2 = n-b;
          n2+=(n-(a+n-b+1))/2;
          n2+=1;
            //out.print(n1+" "+n2);
          s=Math.min(s,n1);
           out.print(Math.min(s,n2));
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

vector<long long int> inverse;
vector<long long int> f, f_inverse;

void factorial_Initialize(int max){
    vector<long long int> a(max+1,1);
    inverse = a;
    f = a;
    f_inverse = a;

    for (int i=2; i<=max; i++){
        inverse[i]   = MOD - inverse[MOD % i] * (MOD / i) % MOD;
        f[i]         = f[i-1]         * i          % MOD;
        f_inverse[i] = f_inverse[i-1] * inverse[i] % MOD;
    }
}

long long int nCr(int n, int r){
    if(n < r || r < 0) return 0;
    if (n >= f.size()){
        factorial_Initialize(n);
    }
    return f[n] * f_inverse[r] % MOD * f_inverse[n-r] % MOD;
}

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

    vector<int> a(n);
    set<int> a_set;
    for(int i=0; i<n; i++){
        cin >> a[i];
        a_set.insert(a[i]);
    }
    sort(a.begin(), a.end());

    long long int ans = 0;
    for(int ai : a_set){
        int smaller = lower_bound(a.begin(), a.end(), ai) - a.begin();
        int larger  = a.end() - upper_bound(a.begin(), a.end(), ai);
        int same    = upper_bound(a.begin(), a.end(), ai) - lower_bound(a.begin(), a.end(), ai);
        //cout << smaller << " " << larger << endl;
        for(int i=0; i<=same-1; i++){
            ans += ai * nCr(smaller+i, k-1);
            ans -= ai * nCr(larger+i,  k-1);
            ans = (ans % MOD + MOD) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7808
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int a, b, c;
    
    scanf("%d", &a);
    b = a/3600;
    a = a%3600;
    c = a/60;
    a = a%60;
    
    printf("%d:%d:%d\n", b,c,a);
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

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

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3624
package main

import "fmt"

var ans = 0

func check(y int) {
	a, b, c := false, false, false
	for i := y; i > 0; i /= 10 {
		z := i % 10
		if z == 3 {
			a = true
		} else if z == 5 {
			b = true
		} else if z == 7 {
			c = true
		}
	}
	if a && b && c {
		ans++
	}
	return
}

func rec(x int) {
	check(x)
	if x > n {
		return
	}
	if x*10+3 <= n {
		rec(x*10 + 3)
	}
	if x*10+5 <= n {
		rec(x*10 + 5)
	}
	if x*10+7 <= n {
		rec(x*10 + 7)
	}
	return
}

var n int

func main() {
	fmt.Scan(&n)
	rec(0)
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define  f(i,a,b) for( i=a;i<b;i++) 
#define ll long long int
using namespace std;

int main()
{	
	
	int a,b,c,d;
	string s; cin>>s;

	a = s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
	

	if(a+b+c+d==7) {cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"; return 0;}
	if(a+b+c-d==7) {cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"; return 0;}
	if(a+b-c+d==7) {cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"; return 0;}
	if(a-b+c+d==7) {cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"; return 0;}
	if(a-b-c+d==7) {cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"; return 0;}
	if(a-b+c-d==7) {cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"; return 0;}
	if(a-b-c+d==7) {cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"; return 0;}
	if(a+b-c-d==7) {cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"; return 0;}
	if(a-b-c-d==7) {cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"; return 0;}





			
	
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }


signed main(){
  int n,m,k;
  cin >> n >> m >> k;
  vint A(n);
  vint B(m);
  vint ASUM(n);
  vint BSUM(m);
  rep(i,0,n) cin >> A[i];
  rep(i,0,m) cin >> B[i];
  ASUM[0] = A[0];
  rep(i,1,n) ASUM[i] += ASUM[i-1] + A[i];
  BSUM[0] = B[0];
  rep(i,1,m) BSUM[i] += BSUM[i-1] + B[i];
  int ans = 0;
  rep(i,0,n){
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)BSUM.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    int key = k-ASUM[i];
    if(key >= 0){
      /* ok と ng のどちらが大きいかわからないことを考慮 */
      while (abs(ok - ng) > 1) {
          int mid = (ok + ng) / 2;

          if (BSUM[mid] > key) ok = mid;
          else ng = mid;
      }
      
      if(ans < i+1 + ok) ans = i+1+ ok; 
    }
  }
  int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
  int ok = (int)BSUM.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
  int key = k;
  if(key > 0){
    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (BSUM[mid] > key) ok = mid;
        else ng = mid;
    }
    
    if(ans < ok) ans = ok;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9588
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

if N == X or 0 == X:
    print(0)

else:
    s_cost = 0
    e_cost = 0
    for i in range(0,X):
        if i in A:
            s_cost += 1
    for i in range(X,N):
        if i in A:
            e_cost += 1
    print(min(s_cost,e_cost))

Measured memory_bytes: 3060
import sys
n = int(input())
a = list(map(int,sys.stdin.readline().split()))
q = int(input())
s = sum(a)
cnt = [0]*(10**5+5)
for c in a:
  cnt[c] +=1
for i in range(q):
  b,c = map(int,sys.stdin.readline().split())
  bdif = c-b
  s += cnt[b]*bdif
  cnt[c] += cnt[b]
  cnt[b] = 0
  print(s)

Measured memory_bytes: 20456
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
int a[200001];

int M=0;
int ans[200001];

int main(){
    cin>>N;
    repn(i,N){
        cin>>a[i];
        if(i>N/2){
            ans[i]=a[i];
            if(a[i]==1) M++;
        }
    } 

    repn(i,N/2){
        int sum=0;
        int index=N/2-i+1;
        do{
            sum+=ans[index];
            index+=N/2-i+1;
        }while(index<=N);
        //cout<<i<<' '<<sum<<endl;

        if(sum%2!=a[N/2-i+1]){
            ans[N/2-i+1]++;
            M++;
        }
    }

    cout<<M<<endl;
    repn(i,N){ 
        if(ans[i]==1){
            cout<<i<<' ';
        }
    }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int n;
  cin >> n;
  int BA = 0;
  int A = 0;
  int B = 0;
  int ans = 0;
  rep(i,n){
    string s;
    cin >> s;
    rep(i,s.size()-1){
      if(s[i] == 'A' && s[i+1] == 'B') ans++;
    }
    if(s[0] == 'B' && s[s.size()-1] == 'A') BA++;
    else if(s[0] == 'B') B++;
    else if(s[s.size()-1] == 'A') A++;
  }
  //cout << A << " " <<  B << " " << BA << endl;
  if(BA > 0){
    ans += BA-1; 
      if(A > 0) ans++;
      A--;
      if(B > 0) ans++;
      B--;
  }
  while(A > 0 && B > 0){
    ans++;
    A--;
    B--;
  }
  cout << ans << endl;
} 

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

int digit(int64_t x)
{
  int digits = 0;
  while(x > 0){
    x /= 10;
    digits++;
  }
  
  return digits;
}

int main()
{
  int64_t n;
  cin >> n;
  
  int64_t fmin = digit(n),b = 0;
  int fn = 0;
  for(int64_t a = 1; a*a <= n; a++){
    if( (n % a) != 0){
      continue;
    }
    b = n / a;
   
    fn = max(digit(a),digit(b));
    if(fn < fmin){
      fmin = fn;
    }
  }//for
  
  cout << fmin << endl;
}


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

int main() {
  int i, min_count, temp_count_a = 0, temp_count_b = 0;
  char ch;
  char tiles_color[100001];
  scanf("%s", tiles_color);
  for(i = 0; i < strlen(tiles_color); i++) {
    ch = tiles_color[i] - '0';
    temp_count_a += (i % 2 == 0)? (ch ^ 0x1) : (ch ^ 0x0);
    temp_count_b += (i % 2 == 1)? (ch ^ 0x1) : (ch ^ 0x0);
  }
  min_count = (temp_count_a < temp_count_b)? temp_count_a : temp_count_b;
  printf("%d\n", min_count);
  return 0;
}


Measured memory_bytes: 256
x,y = input().split(" ")
c = ['A','B','C','D','E','F']
nums = [10,11,12,13,14,15]
tr = dict( zip(c,nums) )

if tr[x] > tr[y]:
  print('>')
elif tr[x] < tr[y]:
  print('<')
else:
  print('=')

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

	n := nextInt()
	s := nextStr()

	if n < 3200 {
		fmt.Println("red")
	} else {
		fmt.Println(s)
	}

}

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


Measured memory_bytes: 1772
#include <iostream>
using namespace std;
 
int gcm(int a, int b)
{
  if (a > b)
  {
    int tmp = a;
    a = b;
    b = tmp;
  }
 
  for (int i = 1; ; ++i)
  {
    if (a % i == 0 and b % (a / i) == 0 )
    {
      return a / i;
    }
  }
}
 
int main(void)
{
  int a, b;
  while (cin >> a >> b)
  {
    cout << gcm(a, b) << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int c = Integer.parseInt(line[2]);
		int max = 0;

		max = 10 * a + b + c;
		max = Math.max(max, 10 * b + c + a);
		max = Math.max(max, 10 * c + a + b);

		System.out.println(max);
	}
}

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

int main() {
	string s; cin >> s;
	int res = 0,ans = 0;
	for (int i=0; i<=2; ++i) {
		if (s[i] == 'R') res++;
		else {
			ans = max(ans,res);
			res = 0;
		}
	}
	ans = max(ans,res);
	cout << ans << endl;
}

Measured memory_bytes: 3580
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	ff := make([]int, n)
	pp := make([][11]int, n)

	for i := 0; i < n; i++ {
		for ii := 0; ii < 10; ii++ {
			f := getNextInt(scanner)
			ff[i] |= f << uint(ii)
		}
	}

	for i := 0; i < n; i++ {
		for ii := 0; ii < 11; ii++ {
			pp[i][ii] = getNextInt(scanner)
		}
	}

	x := -(1 << 30)

	for i := 1; i < 1<<10; i++ {
		sum := 0
		for ii := 0; ii < n; ii++ {
			p := 0
			a := ff[ii] & i
			for a > 0 {
				p += 1 & a
				a >>= 1
			}
			sum += pp[ii][p]
		}
		if x < sum {
			x = sum
		}
	}

	fmt.Fprintln(writer, x)
	writer.Flush()
}


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

using namespace std;
int main(){
	long long x,k,d;
	cin>>x>>k>>d;
	if(x>=0){
		long long cnt=x/d;
		if(cnt>k){
			cout<<abs(x-k*d)<<endl;
			return 0;
		}
		x-=cnt*d;
		cnt=k-cnt;
		if(cnt%2==0)cout<<abs(x)<<endl;
		else cout<<min(abs(x+d),abs(x-d));
	}
	else{
		long long cnt=abs(x)/d;
		if(cnt>k){
			cout<<abs(x+k*d)<<endl;
			return 0;
		}
		x+=cnt*d;
		cnt=k-cnt;
		if(cnt%2==0)cout<<abs(x)<<endl;
		else cout<<min(abs(x+d),abs(x-d));
	}
	return 0;
}


Measured memory_bytes: 3620
list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]
list3 = [2]

x, y = map(int, input().split())

if list1.count(x) + list1.count(y) == 2:
    print("Yes")
elif list2.count(x) + list2.count(y) == 2:
    print("Yes")
elif list3.count(x) + list3.count(y) == 2:
    print("Yes")
else:
    print("No")

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

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

    ll ans = 0;

    for(int bit=0; bit<(1<<s.size()-1); bit++){
        ll sum = 0;
        ll cur = s[0] - '0';

        for(int i=0; i<s.size()-1; i++){
            if(bit & (1<<i)){
                sum += cur;
                cur = 0;
            }
            cur = 10*cur+s[i+1] - '0';
        }
        sum += cur;
        ans += sum;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256