akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,f,n) for(ll i=f; i<(n); i++)
int main()
{
  ll ans = -1;
  ll n, k;
  cin >> n >> k;
  vector<ll> a;
  REP(i,0,n){
    ll ins;
    cin >> ins;
    a.push_back(ins);
  }

  REP(i,0,1<<n){
    ll cnt = 0, ue = 0;
    ll mae = a[0]-1;
    REP(j,0,n){
      ll ima = a[j];
      if((i>>j) & 1){
        ue++;
        if(mae>=ima){
          mae++;
          cnt += mae - ima;
        }
      }
      //cout << ima << " ";
      mae = max(mae, ima);
    }
    //cout << ": " << ue <<endl;
    if(ue>=k){
      if(ans==-1)ans = cnt;
      ans = min(ans, cnt);
    }
  }

  cout << ans << endl;
  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper; cin >> end_stoper;

  return 0;
}

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

#define int long long
//typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {
    int a, b, c;
    cin >> a>>b>>c;
    if(a+b+c>=22) cout << "bust" << endl;
    else cout << "win" << endl;
}



Measured memory_bytes: 256
from operator import itemgetter
 
N, M = map(int, input().split())
P = [0] * M
Y = [0] * M
for i in range(M):
    P[i], Y[i] = map(int, input().split())
n = [i for i in range(M)]
 
P, Y, n = zip(*sorted(zip(P, Y, n), key=itemgetter(0, 1)))
 
count = 1
ans = []
ans.append(str(P[0]).zfill(6) + str(count).zfill(6))
 
for i in range(M - 1):
    if P[i + 1] == P[i]:
        count += 1
    else:
        count = 1
    ans.append(str(P[i + 1]).zfill(6) + str(count).zfill(6))
 
n, ans = zip(*sorted(zip(n, ans), key=itemgetter(0)))
 
for i in ans:
    print(i)

Measured memory_bytes: 38396
N = int(input())
A = map(int, input().split())

# AA = [ix, num for ix, num in enumerate(A)]

AA = []
for ix, num in enumerate(A):
    AA.append((ix, num))

AA = sorted(AA, key=lambda x:x[1])

sbuf = ""
for student in AA:
    sbuf+= str(student[0]+1) + " "

print(sbuf)



Measured memory_bytes: 23352
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int W = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
                        System.out.println(Math.max(Math.abs(b-a)-W, 0));
                }
        }
}

Measured memory_bytes: 23764
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func nextIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}


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

    n := nextInt()
    d := nextIntArr(n)
    set := make(map[int]int)

    for _, i := range d {
        _, f := set[i]
        if !f {
            set[i] = i
        }
    }

    fmt.Println(len(set))
}


Measured memory_bytes: 640
N = int(input())

jobs = list(tuple(map(int,input().split())) for _ in range(N))

# starts = sorted((b-a,a) for a,b in jobs)

t = 0
for dt, due in sorted(jobs, key= lambda x: x[1]):
    if t + dt > due:
        print('No')
        break
    else:
        t += dt
else:
    print('Yes')

Measured memory_bytes: 33404
#include <iostream>

using namespace std;

string s[30][30];

int n,m,i,j,x,y ;

int main()
{
    ios_base :: sync_with_stdio(false) ;

    cin >> n >> m ;

    for(i=0; i<n; i++)
    {
        for(j=0; j<m; ++j)
            cin >> s[i][j] ;
    }

    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
            if(s[i][j] == "snuke")
                cout << (char)('A'+j) << i+1;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int a = 0;
    int b = 0;

    scanf("%d %d", &a, &b);

    if (a >= 13){
        printf("%d\n", b);
    } else if(12 >= a && a >= 6){
        printf("%d\n", b/2);
    } else {
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public class Place
	{
		public float Distance {get;set;}
		public int Index {get;set;}
	}
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var p = Input().ToInt();
		var t = p[0];
		var a = p[1];
		var h = Input().ToInt();
		var hn = new Place[n];
		for(int i = 0; i < n; i++)
			hn[i] = new Place() {Index = i+1, Distance = Math.Abs(a - (float)(t - h[i] * 0.006))};
		Array.Sort(hn, (u,v) => (int)(u.Distance*10000-v.Distance*10000));
		Console.WriteLine(hn[0].Index);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 13268
from bisect import bisect_right

n = int(input())
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(range(2, n)):
    for j in reversed(range(1, i)):
        fix = bisect_right(order, order[i]-order[j])
        if j > fix:
            ans += j - fix

print(ans)

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

#define int long long

int N, Z, W, a[2000], memox[2000], memoy[2000];

int dpx(int, int);
int dpy(int, int);

int dpx(int index, int w) {
    if (index == N - 1) {
        return abs(a[N - 1] - w);
    }
    if (memox[index] != -1) {
        return memox[index];
    }
    int ret = abs(a[N - 1] - w);
    for (int i = index; i < N - 1; i++) {
        ret = max(ret, dpy(i + 1, a[i]));
    }
    memox[index] = ret;
    return ret;
}

int dpy(int index, int z) {
    if (index == N - 1) {
        return abs(z - a[N - 1]);
    }
    if (memoy[index] != -1) {
        return memoy[index];
    }
    int ret = abs(z - a[N - 1]);
    for (int i = index; i < N - 1; i++) {
        ret = min(ret, dpx(i + 1, a[i]));
    }
    memoy[index] = ret;
    return ret;
}

signed main() {
    cin >> N >> Z >> W;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    fill(memox, memox + N, -1);
    fill(memoy, memoy + N, -1);
    cout << dpx(0, W) << endl;
    return 0;
}

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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    int x;
    cin >> x;
    cout << 1 - x;
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
s = input()
maxi = 0
for i in range(n):
  left  = s[:i+1]
  right = s[i+1:]
  left = set(list(left))
  right = set(list(right))
  cnt = len(left & right)
  if maxi < cnt:
    maxi = cnt
print(maxi)

Measured memory_bytes: 38384
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <utility>
#define rep(i, n) for(int i = 0; i < n; i++);

using namespace std;

const int INF = 1000000007;
const double PI = acos(-1.0);
typedef long long llong;

const int N = 10000;
int c[1000 + 1][1000 + 1];

int search(string X, string Y)
{
	
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;

	for (int i = 1; i <= m; i++) 
		c[i][0] = 0;
	for (int j = 1; j <= n; j++)
		c[0][j] = 0;

	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (X[i] == Y[j])
				c[i][j] = c[i - 1][j - 1] + 1;
			else
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);

			maxl = max(maxl, c[i][j]);
		}
	}

	return maxl;
}



int main()
{
	string input1, input2;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> input1 >> input2;
		cout << search(input1, input2) << endl;
	}

	return 0;
	

}

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

int main(void) {
  int ans,i,m,a,z,x;
  i=0;
  m=0;
  a=0;
  ans=0;
  char s[1000000];
  char t[1000000];
  scanf("%s",s);
  scanf("%s",t);
  m=strlen(s);
  a=strlen(t);
  for(i=0;i<m;i++)
  {
    if(s[i]!=t[i])
    {
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

ll dfs(const vvi& G, vb& seen, int curr, const int& k, int num) {
    seen[curr] = true;

    // この頂点に使える色数．
    ll ans = k - num;

    // この頂点に親がいるかどうか．
    int p = num >= 1 ? 1 : 0;

    int cnt = 0;
    for (int next : G[curr]) {
        if (seen[next]) { continue; }
        ans = (ans * dfs(G, seen, next, k, 1 + p + cnt++)) % MOD;
    }
    return ans;
}

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

    int n, k;
    cin >> n >> k;

    vvi G(n);
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);
    }

    if (n == 1) {
        cout << k << endl;
        return 0;
    }

    // O(n)
    int s = 0;
    while (G[s].size() != 1) { ++s; }

    // O(n)
    vb seen(n, false);
    cout << dfs(G, seen, s, k, 0) << endl;

    return 0;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 2e5 + 10;

int n, arr[maxr], ans[maxr];
vector<int> adj[maxr];
vector<int> lis;

void dfs(int start, int parent = -1) {
	bool first = false;
	auto itr = lower_bound(lis.begin(), lis.end(), arr[start]);
	int value = -1; int idx = -1;
	if (itr == lis.end()) {
		lis.push_back(arr[start]);
		first = true;
	}
	else {
		idx = itr - lis.begin();
		value = lis[idx];
		lis[idx] = arr[start];
	}
	ans[start] = lis.size();
	for (auto x : adj[start]) {
		if (x == parent)
			continue;
		dfs(x, start);
	}
	if (first && lis.size()) {
		lis.pop_back();
	}
	else {
		lis[idx] = value;
	}
}

int32_t main()
{
	GO;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		adj[a - 1].push_back(b - 1);
		adj[b - 1].push_back(a - 1);
	}
	dfs(0);
	for (int i = 0; i < n; i++)
		cout << ans[i] << endl;

	return 0;
}

//!


Measured memory_bytes: 31940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{		
		int N = Int32.Parse(Console.ReadLine());

		int ans = Int32.MaxValue;
		for(int A = 1; A <= N - 1; A++)
		{
			int B = N - A;
			ans = Math.Min(ans, digitsSum(A) + digitsSum(B));
		}

		Console.WriteLine(ans);
	}

	public static int digitsSum(int x)
	{
		int tmp = x;
		int ans = 0;
		while(tmp > 0)
		{
			ans += tmp % 10;
			tmp /= 10;
		}

		return ans;
	}
}





Measured memory_bytes: 11092
#include <iostream>
#include <cmath>

using namespace std;

#define MAX 250

int parent(int i)
{
    return (int)floor(i / 2);
};
int left(int i)
{
    return i * 2;
}

int right(int i)
{
    return i * 2 + 1;
}

int main ()
{
    int H;
    int A[MAX + 1];

    cin >> H;

    for (int i = 1; i <= H; i++)
    {
        cin >> A[i];
    }

    for (int i = 1; i <= H; i++)
    {
        cout << "node " << i << ":";
        cout << " key = " << A[i] << ", ";

        if (parent(i) > 0)
            cout << "parent key = " << A[parent(i)] <<  ", ";

        if (left(i) <= H)            
            cout << "left key = " << A[left(i)] << ", ";

        if (right(i) <= H)            
        cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;


int main(){
	int a,b;
	
	cin >> a >> b;
	
	if(a != 1 && b != 1)cout << 1<< endl;
	else if(a != 2 && b != 2)cout << 2 << endl;
	else if(a != 3 && b != 3)cout << 3 << endl;
	
	return 0;
}


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


int main(){   
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<bool> ok(n, true);
    rep(i,n) cin >> h[i];
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        if(h[a] <= h[b]) ok[a] = false;
        if(h[b] <= h[a]) ok[b] = false;
    }
    int ans = 0;
    rep(i,n) if(ok[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e15+100))
#define MX ((ll)(4e9+100))
#define ARRS ((ll)(2e6+100))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)
#define LG 21

ll n,m;
ll a[ARRS];
string s;
ll f[ARRS];



int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	if(n==3){
		cout<<"2 5 63";
		return 0;
	}
	if(n==4){
		cout<<"2 5 20 63";
		return 0;
	}
	if(n==5){
		cout<<"12 4 8 3 9";
		return 0;
	}
	ll c=n-2;
	ll a=1,b=1;
	ll s=0;
	for(int i=4; i<=2*n; i++){
		if(c&&(i%2==0||i%3==0))
			c--,s+=i,cout<<i<<" ";
		//cout<<i<<"-"<<b<<endl;
		if(i%2==0)a++;
		else if(i%3==0)b++;
		if(!c)break;

	}
	if(n==19997){
		s+=29997+3;
		cout<<29997<<" "<<3<<endl;
		//cout<<s%2<<" "<<s%3;
		//cout<<s<<endl;
		return 0;
	}
	if(n==19996){
		s+=2+30000;
		cout<<2<<" "<<30000<<endl;
	//cout<<s%2<<" "<<s%3;
		return 0;
	}
	if(a%3!=0&&(a+1)%3!=0)s+=30000,cout<<30000<<" ";
	else s+=2,cout<<2<<" ";
	//cout<<b<<endl;
	if(b%2)s+=29994,cout<<29994;
	else s+=3,cout<<3;

	cout<<endl;
	//cout<<s%2<<" "<<s%3;

}


Measured memory_bytes: 2432
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;
#define NNN_MAX 100010
typedef pair<int,int> P;

int min(int a, int b){
	return (a>b)? b:a;
}

int max(int a,int b){
	return (a>b)? a:b;
}

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

	if(str.size()==1){
		cout << 1 << endl;
		return 0;
	}

	int bits[str.size()];
	rep(i,str.size()){
		bits[i]=str[i];
	}

	int minimum=str.size();
	rep(i,str.size()-1){
		if(bits[i]!=bits[i+1]){
			minimum = min(minimum,max((str.size()-i-1),i+1));
		}
	}

	cout<< minimum << endl;

	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c,n;
    scanf("%d", &n);
    a = n / 100;
    c = n % 100;
    b = c / 10;
    c = n % 10;
    if (a == 7 || b == 7 || c == 7){
        printf("Yes");
    }
    else{
        printf("No");
    }
    // printf("%d %d %d", a, b ,c);
    return 0;
}


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

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

    ll x,k,d;
    cin >> x >> k >> d;


    if (x > 0){
        ll p = x%d;
        ll z = (x-p)/d;
        if (k <= z){
            cout << x-(k*d) << endl;
        }
        else{
            if ((k-z)%2 == 0){
                cout << p << endl;
            }
            else{
                cout << d-p << endl;
            }
        }
    }
    else if (x == 0){
        if (k%2 == 0){
            cout << 0 << endl;
        }
        else{
            cout << d << endl;
        }
    }
    else{
        ll q = x%d;
        ll y = (q-x)/d;
        if (k <= y){
            cout << abs(x+(k*d)) << endl;
        }
        else{
            if ((k-y)%2 == 0){
                cout << q*(-1) << endl;
            }
            else{
                cout << q+d << endl;
            }
        }
    }
    


}

Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

bool avada(int x, int y, int z) {
  return (x + y) > z;
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

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

 int N;cin>>N;
 vector<int> A(N);
 rep(i,N)cin>>A[i];
 int ans = 0;
 for(int i = 0;i < N;i++) {
   for(int j = i+1;j < N;j++) {
     for(int k = j+1;k < N;k++) {
       if(A[i] != A[j] && A[j] != A[k] && A[i] != A[k]) {
         if(avada(A[i], A[j], A[k]) && avada(A[i], A[k], A[j]) &&
            avada(A[k], A[j], A[i])) ans++;
       }
     }
   }
 }

 cout<<ans;


 return 0;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[100005];
int minn=0x3f3f3f3f,maxx=-0x3f3f3f3f;
int main()
{
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    int p=sum/n;
    int p2=p+1;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        sum1+=abs(a[i]-p)*abs(a[i]-p);
        sum2+=abs(a[i]-p2)*abs(a[i]-p2);
    }
    printf("%d",min(sum1,sum2));
}



Measured memory_bytes: 128
// std input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),*  )) => {
        ( $(read_value!($iter, $t)),*  )
    };
    ($iter:expr, [ $t:tt ; $len:expr  ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    input!{
        a: i32,
        b: i32,
        c: i32,
    }
    let mut ans = c - (a - b);
    if ans < 0 {
        ans = 0;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 500000 + 10;
const int INF = ~0u >> 2;
int dp[MAX_N], c[22];

int main() {
    int n, m;
   // freopen("F:\\in.txt", "r", stdin);
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++) {
        scanf("%d", &c[i]);
    }
    fill(dp, dp + n + 1, INF);
    dp[0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < m; j++) {
            if(i >= c[j]) {
                dp[i] = min(dp[i], dp[i - c[j]] + 1);
            }
        }
    }
    printf("%d\n", dp[n]);
    return 0;
}

Measured memory_bytes: 1388
# AOJ 0040 Affine Cipher

def decode(s, a_inv, b)
  byte_a = "a".ord

  if s.is_a?(String)
    words = [s]
  elsif s.is_a?(Array)
    words = s
  else
    raise TypeError
  end

  words.map {|word|
    word.bytes.map {|byte|
      d = byte - byte_a
      # 26 を法とすると
      # F(c) \equiv a * c + b は
      # c \equiv a^{-1} * (F(c) - b) と同値
      ((a_inv * (d - b)) % 26 + byte_a).chr
    }.join
  }.join(" ")
end

A_INV = [1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25]

n = gets.to_i
n.times do
  words = gets.chomp.split
  words_4 = words.select {|word| word.length == 4}

  # 鍵を探す
  a_inv = b = nil
  words_4.each do |word|
    break if a_inv && b

    A_INV.each do |ai|
      break if a_inv && b

      26.times do |b_ai|
        case decode(word, ai, b_ai)
        when "that", "this"
          a_inv, b = ai, b_ai
          break
        end
      end
    end
  end

  puts decode(words, a_inv, b)
end

Measured memory_bytes: 6128
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const long long INF = 1LL<<60;
//const int V = 100001;
int main() {
    int n;
    int w;
    int V = 1;
    cin >> n >> w;
    vector<int> weight(n);
    vector<int> value(n);
    
    rep(i, n) {
        cin >> weight[i];
        cin >> value[i];
        V += value[i];
    }
    vector<vector<long long>> dp(n+1, vector<long long>(V));
    rep(i, n) {
        rep(j, V) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < V; j++) {
            if(j - value[i] >= 0) { 
                dp[i+1][j] = min(dp[i][j], dp[i][j-value[i]] + weight[i]);
            }
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
        }
    }
    long long res = 0;
    for (int i = 0; i < V; i++) {
        if (dp[n][i] <= w) {
            res = i;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 80256
#include<iostream>
#include<algorithm>
#include<climits>

using namespace std;
typedef long long ll;

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

    int M[n][n];
    int D[c][c];

    int x;
    for(int i = 0; i < c; i++){
        for(int j = 0; j < c; j++){
            cin >> x;
            D[i][j] = x;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> x;
            M[i][j] = x;
        }
    }

    int count[3][c];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < c; j++){
            count[i][j] = 0;
        }
    }

    int now;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            now = (i+1+j+1)%3;
            count[now][M[i][j]-1]++;
        }
    }

    // for(int i = 0; i < 3; i++){
    //     for(int j = 0; j < c; j++){
    //         cout << count[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    ll ans = LLONG_MAX;
    for(int i = 0; i < c-2; i++){
        for(int j = i+1; j < c-1; j++){
            for(int k = j+1; k < c; k++){
                // 配色をi,j,kにする
                int colors[3] = {i, j, k};

                // y を xに塗り替える
                do{
                    ll can = 0;
                    for(int x = 0; x < 3; x++){
                        for(int y = 0; y < c; y++){
                            can += (ll)D[y][colors[x]] * (ll)count[x][y];
                        }
                    }
                    ans = min(can, ans);
                }while(next_permutation(colors, colors+3));
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#define REP(i, n) for(int i=0; i<=n; i++)


using namespace std;

int main(){

    int a, b, c, x;
    int total;
    int count = 0;
    cin >> a >> b >> c >> x;

    REP(ai, a){
        REP(bi, b){
            REP(ci, c){
                total = ai*500 + bi*100 + ci*50;
                if(x == total){
                    count++;
                }
            }
        }
    }

    cout << count << endl;

}

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

 int main(){
  ll a , b , c , d ;
  cin >> a >> b >> c >> d ;
  while(1){
      c -= b ;
      if ( c <= 0){
          cout << "Yes" ;return 0;
      }
       a -= d ;
       if ( a <= 0 ){
           cout << "No"; return 0;
       }
  }
     
}

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

public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int[] num = new int[1000000];

		boolean[] nums = new boolean[1000000];

		for (int i = 0; i < nums.length; i++) {
			nums[i] = true;
		}

		nums[0] = false;
		nums[1] = false;

		int p = 0;

		for (int i = 2; i < 1000000; i++) {
			num[p++] = i;
			if (nums[i]) {
				for (int k = i * 2; k < 1000000; k += i) {
					nums[k] = false;
				}
			}
		}

		String s = "";
		while ((s = br.readLine()) != null) {

			int n = Integer.parseInt(s);


			int count = 0;
			for (int k = 2; k <=n; k++) {
				if (nums[k]) {
					count++;
				}
			}
			System.out.println(count);
		}

	}

}

Measured memory_bytes: 29988
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

function unionFind(n){this.a=Array(n+1).fill(-1);}
unionFind.prototype={
  root:function(i){return this.a[i]<0?i:this.a[i]=this.root(this.a[i]);},
  same:function(x,y){return this.root(x)===this.root(y);},
  unite:function(x,y){x=this.root(x);y=this.root(y);if(x===y)return 1;if(this.a[y]<=this.a[x])this.a[y]+=this.a[x],this.a[x]=y;else this.a[x]+=this.a[y],this.a[y]=x;},
  size:function(i){return -this.a[this.root(i)];},
}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), m = next(), k = next();
  var uf = new unionFind(n);
  var map = xArray("[]",n);
  for(var i = 0; i < m; i++){
    var a = next()-1, b = next()-1;
    uf.unite(a,b);
    map[a].push(b);
    map[b].push(a);
  }
  for(var i = 0; i < k; i++){
    var c = next()-1, d = next()-1;
    map[c].push(d);
    map[d].push(c);
  }
  var ans = [];
  for(var i = 0; i < n; i++){
    var t = uf.size(i)-1;
    for(var j = 0; j < map[i].length; j++){
      if(uf.same(i,map[i][j]))t--;
    }
    ans.push(t);
  }
  return ans.join(" ");
}

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

int get_gcd(int a, int b) {
  while (1) {
    if (a < b) swap(a,b);
    a = a % b;
    if (a == 0) break;
  }
  return b;
}

main () {
  int n, x;
  scanf("%d %d", &n, &x);
  vector<int> v(n);
  rep(i,n) scanf("%d", &v[i]);

  //xを原点とする座標系に変換する
  //xより小さい場合は符号反転する
  rep(i,n) {
    v[i] -= x;
    if (v[i] < 0) v[i] *= -1;
  }

  //vのgcdが回答となる
  int gcd = v[0];
  rep(i,n) gcd = get_gcd(gcd, v[i]);
  printf("%d\n", gcd);

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int count = 700;
  if (a[0]=='o') {
    count+=100;
  }
  if (a[1]=='o') {
    count+=100;
  }
  if(a[2] == 'o') {
    count+=100;
  }
  cout << count << endl;
  
}

Measured memory_bytes: 3568
//himanshu manwani
//basic knapsack.. 1D array
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;
ll sqr(ll x){return abs(x) * abs(x);}

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    ll w; cin>>n>>w;
    vl dp(w+1);
    ll val,wg;
    ll g_max = LONG_MIN;
    for(int item =0;item<n;item++)
    {
        cin>>wg>>val;
        for(int WA = w-wg;WA>=0;WA--)                             //weight already - WA
        {
            dp[WA+wg] = max(dp[WA+wg],dp[WA] + val);
            g_max = max(dp[WA+wg],g_max);
        }
    }
    cout << g_max ;
    return 0;
 }


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

using namespace std;

#define ll long long

int main()
{
	
	ll n, m;
	vector<long long> votes;
	ll votes_s;
	ll sum = 0;
	ll contor = 0;
	
	set<ll> nums;
	
	cin >> n >> m;
	
	for(int i = 0 ;i < n ;++i)
	{
		cin >> votes_s;
		nums.insert(votes_s);
		votes.push_back(votes_s);
		sum += votes_s;
	}
	
	//sort(votes.begin(), votes.end(), greater<ll>() );
	
	//for(int i = 0; i < m; ++i)
	//{
	//	if(votes[i] > sum/(4*m))
	//		contor++;
	//}
	
		for(auto x : nums)
		{
			if(x*4*m >= sum)
				contor++;
		}
	
		if(contor >= m)
			cout << "Yes\n";
		else
			cout << "No\n";
	return 0;
}


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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],k,q,u,v,x,y,tc,c,l,r,ans,p,cnt,root[N],sz[N];

char s[N];

int main(){
	scanf("%s",s);
	int z=0;
	int o=0;
	for(int i=0;s[i];i++){
		z+=s[i]=='0';
		o+=s[i]=='1';
	}
	printf("%d\n",min(o,z)*2);
}



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

using namespace std;

int main() {
    int A1, A2, A3, A4, A5, A6, A7, A8, A9;
    int N;
    int b;
    string resultado;
    cin >> A1 >> A2 >> A3;
    cin >> A4 >> A5 >> A6;
    cin >> A7 >> A8 >> A9;
    cin >> N;
    for (int i =0; i<N; i++){
        cin >> b;
        if (b == A1) A1 = 1000;
        else if (b == A2) A2 = 1000;
        else if (b == A3) A3 = 1000;
        else if (b == A4) A4 = 1000;
        else if (b == A5) A5 = 1000;
        else if (b == A6) A6 = 1000;
        else if (b == A7) A7 = 1000;
        else if (b == A8) A8 = 1000;
        else if (b == A9) A9 = 1000;

    }
    if (A1== 1000 && A2==1000 && A3==100) {
        resultado = "Yes";
    }
    else if (A4==1000 && A5==1000 && A6==1000) {
        resultado = "Yes";
    }
    else if (A7==1000 && A8==1000 && A9==1000) {
        resultado = "Yes";
    }
    else if (A1==1000 && A4==1000 && A7==1000) {
        resultado = "Yes";
    }
    else if (A2==1000 && A5==1000 && A8==1000) {
        resultado = "Yes";
    }
    else if (A3==1000 && A6==1000 && A9==1000) {
        resultado = "Yes";
    }
    else if (A1==1000 && A5==1000 && A9==1000) {
        resultado = "Yes";
    }
    else if (A3==1000 && A5==1000 && A7==1000) {
        resultado = "Yes";
    }
    else {
        resultado = "No";
    }
    
    cout << resultado;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define Pii pair<int,int>
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std; 

#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}    


void solve(){
    string s;
    cin>>s;
    int i=0;
    int ans=0;
    while(s[i]){
        if(s[i]=='R'){
            int j=i+1;
            int ct=1;
            while(s[j] and s[j]=='R'){
                j++;
                ct++;
            }
            i=j;
            ans=max(ans,ct);
        }else{
            i++;
        }
    }
    cout<<ans<<'\n';

}

int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
    return 0;
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int n, m; cin >> n >> m;
	int tot = 0;
	mk(arr, n, int);

	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
		tot += arr[i];
	}

	sort(arr, arr + n, greater<int>());

	int mn = (tot + 4 * m - 1) / (4 * m);

	if (arr[m - 1] >= mn)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

fn reads<T>() -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}

fn main() {
    let n: usize = reads()[0];
    let xs: Vec<i64> = reads();

    let mut ss = xs.clone();
    ss.sort();

    let lo = ss[n / 2 - 1];
    let hi = ss[n / 2];

    for x in xs {
        println!("{}", if x <= lo { hi } else { lo });
    }
}


Measured memory_bytes: 10928
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector


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

int N ,M ; cin >> N >> M;

if (N == M) cout << "Yes\n";
else cout << "No\n";


}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n){
        for(int i = 0;i < n;i++)par[i] = i;
    }
    
    int root(int x){
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x,int y){
        if(root(x) == root(y))return;
        par[root(x)] = root(y);
    }
    
    bool same(int x,int y){
        return root(x) == root(y);
    }
};

int main(void){
    int n,m;
    cin >> n >> m;
    
    UnionFind tree(n);
    
    int p[n],x[m],y[m];
    for(int i = 0;i < n;i++){
        cin >> p[i];
        p[i]--;
    }
    for(int i = 0;i < m;i++){
        cin >> x[i] >> y[i];
        x[i]--;y[i]--;
        tree.unite(x[i],y[i]);
    }
    
    int alina = 0;
    for(int i = 0;i < n;i++){
        if(tree.same(i,p[i])){
            tree.unite(i,p[i]);
            alina++;
        }
    }
    cout << alina << endl;
}

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

int main(){
  long n;
  cin >> n;
  
  long m=20000000000;
  
  for(long i=1; i<=sqrt(n); i++){
  	if(n%i==0) m=min(m,(n/i));
  }
  
 ostringstream stream;
  stream << m;
  string str = stream.str();
  int ans = str.size();
    
    cout << ans << endl;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */


ll pm3[100010];
ll pm2[100010];

void pminit(){
    ll p3 = 1;
    ll p2 = 1;
    rep(i, 100010){
        pm3[i] = p3;
        pm2[i] = p2;
        p3 *= 3;
        p2 *= 2;
        p3 %= MOD;
        p2 %= MOD;
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    pminit();
    string L;
    cin >> L;
    ll szL = SZ(L);
    ll ans = 0;
    ll cnt = 0;
    rep(i, szL){
        if(L[i] == '1'){
            ans += pm2[cnt] * pm3[szL-i-1];
            ans %= MOD;
            cnt++;
        }
    }
    ans += pm2[cnt];
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2048
use std::cmp::max;
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c, d) = scan!(usize, usize, usize, usize);
    println!("{}", max(a * b, c * d));
}


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

long long int d[3*1000000 + 2];

int main() {

    int n;

    cin >> n;

    for(int i=0;i<n;i++){
        cin >> d[i];
    }

    bool flag = false;

    int npos = 0;

    while(!flag){

        long long int mj = 0;
        int maxpos=0;

        for(int i=npos;i<=npos+d[npos]/10;i++){
            if(i == n-1){
                flag = true;
                break;
            }
            if(i==npos) continue;
            if(mj/10 + maxpos <= i + d[i]/10){
                mj = d[i];
                maxpos = i;
            }
        }
        if(mj<10){
            break;
        }
        npos = maxpos;

    }

    if (!flag) {
        cout << "no" << endl;
        return 0;
    }

    reverse(d,d+n);


    flag = false;

    npos = 0;

    while(!flag){

        long long int mj = 0;
        int maxpos=0;

        for(int i=npos;i<=npos+d[npos]/10;i++){
            if(i == n-1){
                flag = true;
                break;
            }
            if(i==npos) continue;
            if(mj/10 + maxpos <= i + d[i]/10){
                mj = d[i];
                maxpos = i;
            }
        }
        if(mj<10){
            break;
        }
        npos = maxpos;

    }

    if (!flag) {
        cout << "no" << endl;
    }
    else{
        cout << "yes" << endl;
    }


    return 0;
}

Measured memory_bytes: 5432
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>
#include <numeric>
#include<iomanip>

using namespace std;



int main() {
	int n;
	cin >> n;
	if (n < 100) {
		cout << 0 << endl;
	}
	else {
		int count = 0;
		int k = n;
		while (k >99) {
			k -= 100;
			count++;
		}
		for (int i = 6; i--; i >= 1) {
			while (k >= i && count > 0) {
				k -= i;
				count--;
			}
		}
		if (k == 0) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer> map1 = new HashMap<Integer, Integer>();
		Map<Integer, Integer> map2 = new HashMap<Integer, Integer>();
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				putMap(map1, sc.nextInt());
			} else {
				putMap(map2, sc.nextInt());
			}
		}
		sc.close();

		// 数、値
		int[][] max1 = new int[2][2];
		for (Entry<Integer, Integer> entry : map1.entrySet()) {
			if (max1[0][0] < entry.getValue()) {
				max1[1][0] = max1[0][0];
				max1[1][1] = max1[0][1];
				max1[0][0] = entry.getValue();
				max1[0][1] = entry.getKey();
			} else if (max1[1][0] < entry.getValue()) {
				max1[1][0] = entry.getValue();
				max1[1][1] = entry.getKey();
			}
		}
		int[][] max2 = new int[2][2];
		for (Entry<Integer, Integer> entry : map2.entrySet()) {
			if (max2[0][0] < entry.getValue()) {
				max2[1][0] = max2[0][0];
				max2[1][1] = max2[0][1];
				max2[0][0] = entry.getValue();
				max2[0][1] = entry.getKey();
			} else if (max2[1][0] < entry.getValue()) {
				max2[1][0] = entry.getValue();
				max2[1][1] = entry.getKey();
			}
		}

		if (max1[0][1] != max2[0][1]) {
			System.out.println(n - max1[0][0] - max2[0][0]);
		} else {
			if (max1[1][0] < max2[1][0]) {
				System.out.println(n - max1[0][0] - max2[1][0]);
			} else {
				System.out.println(n - max1[1][0] - max2[0][0]);
			}
		}
	}

	static void putMap(Map<Integer, Integer> map, int i) {
		if (map.containsKey(i)) {
			map.put(i, map.get(i)+1);
		} else {
			map.put(i, 1);
		}
	}
}


Measured memory_bytes: 60968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    public static int Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] buf = Console.ReadLine().Split(' ');

        int Total = 0;
        int Total_sq = 0;
        int x;

        for (int i = 0; i < N; ++i)
        {
            int a = int.Parse(buf[i]);
            Total += a;
            Total_sq += a * a;
        }
        x = (Total * 10) / N;
        if (x < 0)
        {
            x = (x - 5) / 10;
        }
        else
        {
            x = (x + 5) / 10;
        }

        Console.WriteLine(N * x * x - 2 * Total * x + Total_sq);
        return 0;
    }
}


Measured memory_bytes: 2648