akhauriyash/Code-Regression huggingface dataset:
A, B = [int(x) for x in input().split()]

def common_divisors(a, b):
    cd = []
    n = min(a, b)
    m = max(a, b)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if m % i == 0:
                cd.append(i)
            if i != n // i and m % (n//i) == 0:
                cd.append(n//i)
    return cd

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def sieve(n):
    prime = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime


cd = common_divisors(A, B)
#prime = sieve(max(cd))

def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if i*i > n:
            break
        if n % i == 0:
            return False
    return True

#print(cd)
#print(max(cd))
#print(prime)

ans = 1 # 1は絶対入る
for a in cd:
    if is_prime(a):
        ans += 1

print(ans)


Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

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

  vector <int> A(26);
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      char a; cin >> a;
      int num = a - 'a';
      A[num]++;
    }
  }
  sort(A.begin(), A.end(), greater<int>());

  int cnt2 = 0, cnt1 = 0;
  for (int i = 0; i < 26; i++){
    if (A[i] == 0){
      break;
    }else{
      if (A[i] % 2 != 0){
        cnt1 ++;
        A[i]--;
      }
      if(A[i] % 4 != 0){
        cnt2 ++;
        A[i] -= 2;
      }
    }
  }
  
  bool ans;
  if (H % 2 != 0 && W % 2 != 0){
    int h = H / 2, w = W / 2;
    if (cnt1 == 1 && cnt2 <= h + w){
      ans = true;
    }else{
      ans = false;
    }
  }else if(H % 2 == 0 && W % 2 == 0){
    if (cnt1 == 0 && cnt2 == 0){
      ans = true;
    }else{
      ans = false;
    }
  }else{
    int band;
    if (H % 2 != 0) band = W / 2;
    else band = H / 2;
    if (cnt1 == 0 && cnt2 <= band){
      ans = true;
    }else{
      ans = false;
    }
  }
  
  if (ans == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  

  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(x) setprecision(x)<<fixed
#define ss second
#define fori(v) for(lli i=0; i<v; i++)
#define forj(v) for(lli j=0; j<v; j++)
#define fork(v) for(lli k=0; k<v; k++)
#define forl(v) for(lli l=0; l<v; l++)
#define fort(v) for(lli t=0; t<v; t++)
#define forz(v) for(lli z=0; z<v; z++)
#define lli long long int
#define MAX 100004
#define double long double
#define ch 51
#define max_bit 20
#define pb push_back
#define magic 3
lli inf = pow(10,16);
lli modulo = pow(10,9)+7;
double eps = 1e-11;
ifstream in;
ofstream out;
//#define cin in
//#define cout out
void deal(){
	int a,b;
	cin>>a>>b;
	if(a+b == 15)
		cout<<'+';
	else if(a*b==15)
		cout<<'*';
	else
		cout<<'x';
}
int main() {
//	cin.open("i.txt");
//	cout.open("o.txt");
//	while(1)
	
	deal();
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {

	int n,k;
	int d[10];
	cin >> n >> k;
	int i;
	for (i = 0; i < k; i++) {
		cin >> d[i];
	}
	int x,j;
	int flag;
	for (i = n; i < 99999; i++) {
		x = i;
		flag = 0;
		while (x > 0) {
			for (j = 0; j < k; j++) {
				if ((x % 10) == d[j]) {
					flag = 1;
					break;
				}
			}
			if (flag == 1)break;
			x = (x - (x % 10)) / 10;
		}
		if (flag == 0) {
			cout << i << endl;
			return 0;
		}
	}



}

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

//prime judge function
int is_prime(int x){
        if (x==2) return 1;
        if (x<2 || x%2==0) return 0;
        for (int i = 3; i*i <= x; i+=2){
        if (x%i==0) return 0;
        }
        return 1;
}

int main() {
        int A[10001], N;
        cin >> N;
        int cnt = 0;
        for (int i=0;i<N;i++) {
        cin >> A[i];
        cnt += is_prime(A[i]);
        }

        cout << cnt << endl;
        return 0;
}

Measured memory_bytes: 3076
import math
def main():
    a = []
    for _ in range(5):
        b = int(input())
        a.append([b % 10, b])
    
    a.sort()
    result = 0
    f = 1
    for i in a:
        if i[0] != 0:
            if f:
                result += i[1]
                f = 0
            else:
                result += (i[1]//10 + 1) * 10

        else:
            result += i[1]
    
    print(result)


if __name__ == "__main__":
    main()

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 2e5;
char a[(MAXN << 1) + 5], b[MAXN + 5];
int n, m, nx[(MAXN << 1) + 5][26];

int main(){
	scanf("%s%s", a + 1, b + 1);
	n = strlen(a + 1), m = strlen(b + 1);
	for (register int i = 1; i <= n; ++i) a[n + i] = a[i];
	for (register int i = 0; i < 26; ++i) nx[n << 1][i] = -1;
	for (register int i = (n << 1) - 1; ~i; --i){
		for (register int j = 0; j < 26; ++j) nx[i][j] = nx[i + 1][j];
		nx[i][a[i + 1] - 'a'] = i % n + 1;
	}
	int k = 0, s = 0;
	for (register int i = 1; i <= m; ++i)
		if (~nx[k][b[i] - 'a']){
			if (nx[k][b[i] - 'a'] <= k) ++s;
			k = nx[k][b[i] - 'a'];
		}
		else return printf("-1\n"), 0;
	printf("%lld\n", 1ll * s * n + k);
	return 0;
}

Measured memory_bytes: 22784
def inv_gcd(a, b):
    a = (a + b) % b
    if a == 0:
        return (b, 0)
    s, t = b, a
    m0, m1 = 0, 1
 
    while t:
        u = s // t
        s -= t * u
        m0 -= m1 * u
 
        tmp = s
        s = t
        t = tmp
        tmp = m0
        m0 = m1
        m1 = tmp
    
    if m0 < 0:
        m0 += b // s
    return (s, m0)
 
 
def crt(r, m):
    n = len(r)
    r0, m0 = 0, 1
 
    for i in range(n):
        r1, m1 = (r[i] + m[i]) % m[i], m[i]
 
        if m0 < m1:
            m0, m1 = m1, m0
            r0, r1 = r1, r0
        
        if m0 % m1 == 0:
            if r0 % m1 != r1:
                return (0, 0)
            continue
        
        g, im = inv_gcd(m0, m1)
 
        u1 = m1 // g
        if (r1 - r0) % g:
            return (0, 0)
        
        x = (r1 - r0) // g % u1 * im % u1
 
        r0 += x * m0
        m0 *= u1
        if (r0 < 0):
            r0 += m0
        
    return (r0, m0)


def divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  divisors.sort()
  return divisors


# print(divisors(z))

z=int(input())


ans = z-1 if z%2 else 2*z-1
for i in divisors(2*z):
  y=2*z//i
  if y == 1:
    continue
  a=[0,-1]
  b=[i,y]
  rem, mod = crt(a, b)
  #print(rem)
  #print(mod)
  if rem == mod == 0:
      continue
  ans = min(ans, rem)

print(ans if z-1 else 1)

Measured memory_bytes: 69872
using System;

class Program
{
    static void Main()
    {
            long i,total=0,max,min;
            string kazu = Console.ReadLine();
            string inp = Console.ReadLine();
            string[] data = inp.Split(' ');
            max = long.Parse(data[0]);
            min = long.Parse(data[0]);
            for (i = 0; i < long.Parse(kazu); i++)
            {
                total = total + long.Parse(data[i]);
                if (max < long.Parse(data[i]))
                {
                    max = long.Parse(data[i]);
                }
                if (min > long.Parse(data[i]))
                {
                    min = long.Parse(data[i]);
                }
            }
            Console.WriteLine("{0} {1} {2}", min, max, total);
    }
}


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

int main(){
  long long n;
  long long a; // blue
  long long b; // red
  long long ans;

  long long q;
  long long amari;

  cin >> n >> a >> b;

  if (n < (a+b) || a == 0){ // 割っちゃダメ || そもそも青がない
    if (n >= a){
      ans = a;
      cout << ans << endl;
      return 0;
    } else {
      ans = n;
      cout << ans << endl;
      return 0;
    }
  } else {
    q = n / (a+b); // n の中に何セット入るか
    amari = n % (a+b);
  }

  if(amari) { // 余りがあったら
    if (amari > a) {
      amari -= (amari - a);
    }
    ans = q * a + amari;
  } else {
    ans = q * a; // 余りなしだったので
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e6+5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	vector<ll> A(N + 1);
	for (int i = 0; i <= N; i++) {
		cin >> A[i];
	}

	vector<pair<ll, ll>> le(N + 1);
	le[N].first = A[N], le[N].second = A[N];
	for (int i = N - 1; i >= 0; i--) {
		le[i].first = A[i] + (le[i + 1].first + 1) / 2;
		le[i].second = A[i] + le[i + 1].second;
		//printf("le[%d].first=%lld le[%d].second=%lld\n", i, le[i].first, i, le[i].second);
	}

	vector<ll> dp(N + 1);
	bool flag = true;
	if (le[0].first <= 1 && 1 <= le[0].second) dp[0] = 1;
	else flag = false;

	ll cnt = 0;	
	for (int i = 1; i <= N && flag; i++) {
		//printf("i=%d \n", i);
		if (2 * (dp[i - 1] - A[i - 1]) < le[i].first) {
			flag = false;
		}
		dp[i] = min(2 * (dp[i - 1] - A[i - 1]), le[i].second);
		cnt += dp[i];
		//printf("dp[%d]=%lld\n", i, dp[i]);
	}

	if (!flag)cout << -1 << endl;
	else cout << cnt + 1 << endl;
}



Measured memory_bytes: 6376
#include<bits/stdc++.h>
using namespace std;
int main()
{
  const int mod = 1e9 + 7;
  int n;
  cin >> n;
  long long ans = 1;
  vector<int> p(n + 1);
  for (int i = 2; i <= n; i++) {
	int s = i;
	int t = 2;
	while (s >= t * t) {
	  if (s % t == 0) {
		p[t]++;
		s /= t;
	  }
	  else {
		t++;
	  }
	}
	p[s]++;
  }
  for (int i = 2; i <= n; i++) {
	ans = ans * (p[i] + 1) % mod;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
a=[]
i=0
a.append(int(input()))
while(True):
    if(a[i]%2==0):
        b=a[i]//2
        if(b in a):
            print(i+2)
            exit()
        else:
            a.append(a[i]//2)
            i+=1
    else:
        b=3*a[i]+1
        if(b in a):
            print(i+2)
            exit()
        else:
            a.append(3*a[i]+1)
            i+=1

Measured memory_bytes: 3064
// Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		int cnt[10];
		for(int i=0; i<10; i++){
			cnt[i] = 0;
		}

		for(int i=0; i<n; i++){
			int ice;
			cin >> ice;

			cnt[ice]++;
		}

		for(int i=0; i<10; i++){
			if(cnt[i]==0){
				cout << '-' << '\n';
			}
			else{
				for(int j=0; j<cnt[i]; j++){
					cout << '*';
				}
				cout << '\n';
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(v,a) for(auto &v:a)
#define fi first
#define se second
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(a) a.begin(),a.end()
int re(){int x=0; char c; bool neg=false;while(c!='-'&&(c<'0'||'9'<c)) c=getchar();if (c=='-'){neg=true; c=getchar();}while ('0'<=c && c<='9'){x=x*10+c-'0';c=getchar();}if (neg) x=-x;return x;}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int ran(int l, int r) {return l+rng()%(r-l+1);}
typedef long long ll;
const int N=100010;
int n,k;
int a[N],f[N];
bool dd[N];
queue<int> q;
void bfs()
{
    while (!q.empty())
    {
        int u=q.front(); q.pop();
        forinc(i,1,k) if (u+i<=n && f[u+i]>f[u]+abs(a[u]-a[u+i]))
        {
            f[u+i]=f[u]+abs(a[u]-a[u+i]);
            if (!dd[u+i]) dd[u+i]=true,q.push(u+i);
        }
    }
}
int main()
{
    //freopen("frog1.inp","r",stdin);
    cin>>n>>k;
    forinc(i,1,n) cin>>a[i];
    memset(f,127,sizeof(f));
    f[1]=0; q.push(1); dd[1]=false;
    bfs();
    cout<<f[n];
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;
int main(){
    int n;
    string s,t;
    cin >> n >> s >> t;
 //   char key=t[0];
    int reg=s.size();
    for(int i=0;i<s.size();i++){
        if(s[i]==t[0]){
            bool h=true;
            if(s.size()-i>n){
                continue;
            }
            for(int j=0;j<s.size()-i;j++){
             //   cout<<i+j<<endl;
                if(s[i+j]!=t[j]){
                    h=false;
                    break;
                }
                
            }
            if(h){
                reg=i;
                break;
            }
        }
    }
   // cout<<reg<<endl;
    cout<<max(n,(reg+(int)t.size()))<<endl;
    
}

Measured memory_bytes: 256
import math
a, b, c = map(int, input().split())
s = a * b * math.sin(math.radians(c)) * 0.5
L = a + b + (a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(c))) ** 0.5
h = s / a * 2
print(s)
print(L)
print(h)


Measured memory_bytes: 5724
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

// array pointer = *a, num of element = n, key key
int lower_bound(int *a, int n, int key){
    int ng, mid, ok;
    ng = -1, ok = n-1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (key <= a[mid]){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if (a[ok] >= key)return ok;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]) % mod;
        }
    }
}*/
long long mod = 1000000007;

//x ^ n
long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}




int main(void){
    int hinarray[4] = {0};
    char s;
    char colors[4] = {'P', 'W', 'G', 'Y'};
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf(" %c", &s);
        for (int j = 0; j < 4; j++){
            if (colors[j] == s){
                hinarray[j] = 1;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 4; i++){
        if (hinarray[i] == 1) ans++;
    }
    if (ans == 4) printf("Four\n");
    else if (ans == 3)printf("Three\n");


    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e18 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  string s,t,ss,tt;
  cin >> ss;
  cin >> tt;
  int n = ss.size(), m = tt.size();

  vector<vector<int> > dp(3001, vector<int>(3001,0)), pre(dp);
  // dp[i][j] = s1...si, t1...tjまでのLCS
  // vectorのコピーコンストラクタ -> 同じ要素数を確保
  
  s = '+' + ss; // s[0] != t[0] and s[i] != t[0] and s[0] != t[i]
  t = '*' + tt;

  for (int si = 1; si <= n; ++si) {
    for (int ti = 1; ti <= m; ++ti) {
      if (s[si] == t[ti]) {
        dp[si][ti] = dp[si-1][ti-1] + 1;
        pre[si][ti] = 1;
      } else if (dp[si-1][ti] > dp[si][ti-1]) {
        dp[si][ti] = dp[si-1][ti];
        pre[si][ti] = 2;
      } else {
        dp[si][ti] = dp[si][ti-1];
        pre[si][ti] = 3;
      }
    }
  }

  // cout << dp[n][m] << endl;
  // 復元
  string ans = "";
  int i = n, j = m;
  while (i >= 1 and j >= 1) {
    if (pre[i][j] == 1) {
      ans += s[i];
      i--, j--;
    } else if (pre[i][j] == 2) {
      i--;
    } else {
      j--;
    }
  }
  reverse(ans.begin(), ans.end());
  for (auto itr : ans) {
    cout << itr;
  } END;
}


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

using namespace std;

const int maxn = 16;

int n;
long long int a[maxn][maxn], dp[1<<maxn], sum[1<<maxn];

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

	for (int mask = 0; mask < (1<<n); mask++){
		vector<int> v;
		for (int j = 0; j < n; j++)
			if ((1<<j) & mask)
				v.push_back(j);
		
		for (int j = 0; j < v.size(); j++){
			for (int k = 0; k < j; k++){
				sum[mask] += a[v[j]][v[k]];
			}
		}
	}

	for (int mask = 0; mask < (1<<n); mask++){
		for (int msk = mask; msk > 0; msk = mask&(msk-1)){
			dp[mask] = max(dp[mask], sum[msk] + dp[mask^msk]);
		}
	}

	cout << dp[(1<<n)-1] << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>              
using namespace std;                 
using ll = long long;               
using vl = vector<ll>;              
using vvl = vector<vl>;            
using pll = pair<ll,ll>;                 
using vb = vector<bool>;                 
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      
const double eps = 1e-9;                 
#define sz(c) ll((c).size())             
#define all(c) begin(c),end(c)           
#define mp make_pair                     
#define mt make_tuple                    
#define pb push_back                     
#define eb emplace_back                  
#define xx first                         
#define yy second                       
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)       
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)
#define DB(X) ({ if(1) cerr << "DB: " << (#X) << " = " << (X) << endl; })

int main() { 
  ios::sync_with_stdio(false); 
  ll n;
  cin >> n;
  ll a[n];
  FOR(i,0,n){
    cin >> a[i];
    a[i]--;
  }
  ll res = 0;
  FOR(i,0,n){
    if(a[i] > i && a[a[i]] == i) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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 <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;

  ll ans = 0;
  rep(i, N + 1) {
    if (i == 0) {
      continue;
    }
    string s = to_string(i);
    if (s.size() % 2 == 1) {
      ans++;
    }
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ss second
#define ff first
#define all(a) a.begin(), a.end()
#define All(a) a.rbegin(), a.rend()
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.precision(10), cout << fixed
int main()
{
     ios;
     string s;
     int n;
     cin >> n >> s;
     if (n < 3200)
          cout << "red";
     else
          cout << s;
     return 0;
}

Measured memory_bytes: 3648
n,C,*H=map(int,open(0).read().split());p=[0];P=[0]
for i in range(1,n):
 h=H[i];f=lambda I:p[P[I]]+H[P[I]]*(H[P[I]]-2*h)
 while len(P)>1and f(0)>f(1):P.pop(0)
 p+=[f(0)+h*h+C];h=0;P+=[i]
 while len(P)>2and(H[P[-2]]-H[P[-3]])*(f(-2)-f(-1))>(H[i]-H[P[-2]])*(f(-3)-f(-2)):P.pop(-2)
print(p[-1])

Measured memory_bytes: 27104
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <cstdlib>
using namespace std;
 
int main () {
	int n,i;
	int a,b,c,d,f,g,a1,a2;
	cin >> a >> b >> c >> d >> f >> g ;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a1 >> a2;
		if((a1==a&&a2==b)||(a1==f&&a2==a)||(a1==g&&a2==f)||(a1==b&&a2==g)) cout << c << endl;
		else if((a1==b&&a2==a)||(a1==a&&a2==f)||(a1==f&&a2==g)||(a1==g&&a2==b)) cout << d << endl;
		else if((a1==c&&a2==b)||(a1==f&&a2==c)||(a1==d&&a2==f)||(a1==b&&a2==d)) cout << g << endl;
		else if((a1==b&&a2==c)||(a1==c&&a2==f)||(a1==f&&a2==d)||(a1==d&&a2==b)) cout << a << endl;
		else if((a1==a&&a2==d)||(a1==c&&a2==a)||(a1==g&&a2==c)||(a1==d&&a2==g)) cout << b << endl;
		else if((a1==d&&a2==a)||(a1==a&&a2==c)||(a1==c&&a2==g)||(a1==g&&a2==d)) cout << f << endl;
	}
}
	

Measured memory_bytes: 1160
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Len = sc.nextInt();

		String data[] = new String[N];
		for (int i = 0; i < data.length; i++) {
			data[i] = sc.next();
		}
		for (int i = 0; i < data.length; i++) {
			for (int j = data.length -1; i < j; j--) {
				if(0 >data[j].compareTo(data[j -1])){
					data = change(data, j, j-1);
				}
			}
	}
		StringBuilder str = new StringBuilder();
		for (String s : data) {
			str.append(s);
		}

		System.out.println(str);
		sc.close();
	}
	static String[] change(String[] s, int a, int b){
		String temp;
			temp = s[a];
			s[a] = s[b];
			s[b] = temp;
		return s;
	}
}


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

using ll=long long; 

void solve(){
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int cnt=0;
	for(int i=0; i<=a; i++){
		for(int j=0; j<=b; j++){
			for(int k=0; k<=c; k++){
				if(x==500*i+100*j+50*k){
					cnt++;
				}
			}
		}
	}
	cout<<cnt<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxn = 200100;
const int mod = 1e9 + 7;
long long power(long long x, long long k)
{
	long long ans = 1;
	while(k)
	{
		if(k & 1)
			(ans *= x) %= mod;
		k >>= 1;
		(x *= x) %= mod;
	}
	return ans;
}
int B, W, n;
long long fac[maxn], inv[maxn];
long long C(int x, int y)
{
	if(y < 0 || x < y)
		return 0;
	return fac[x] * inv[x - y] % mod * inv[y] % mod;
}
long long p[maxn], q[maxn];
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> B >> W;
	n = B + W;
	fac[0] = 1;
	for(int i = 1; i <= n; i ++)
		fac[i] = fac[i - 1] * i % mod;
	inv[n] = power(fac[n], mod - 2);
	for(int i = n - 1; i >= 0; i --)
		inv[i] = inv[i + 1] * (i + 1) % mod;
	p[0] = q[0] = 0;
	for(int i = 1; i <= n; i ++)
	{
		cout << (1 - p[i - 1] + q[i - 1] + mod) * power(2, mod - 2) % mod << endl;
		p[i] = (p[i - 1] + C(i - 1, B - 1) * power(power(2, i), mod - 2)) % mod;
		q[i] = (q[i - 1] + C(i - 1, W - 1) * power(power(2, i), mod - 2)) % mod;
	}
	return 0;
}


Measured memory_bytes: 8448
#include<iostream>
using namespace std;
int main(){
  
	int H,W;
	cin>>H>>W;
	while(W!=0||H!=0){
		for(int i=1;i<=W;i++){
			cout<<"#";
				if(i==W){
					cout<<endl;
				}
		}
		for(int a=1;a<=H-2;a++){
			cout<<"#";
				for(int b=1;b<=W-2;b++){
					cout<<".";
				}
			cout<<"#"<<endl;
		}
		for(int d=1;d<=W;d++){
			cout<<"#";
				if(d==W){
					cout<<endl;
				}
		}
		cout<<endl;
		cin>>H>>W;
	}
				
	return 0;
}

Measured memory_bytes: 1152
N = input()
d = []
try :
  while True:
    a = input()
    if a :
      d.append(a)
    else :
      break
except EOFError:
  pass
c = 0
import copy
e = copy.copy(d)
for i in e :
  x = d.pop(0)
  if x not in d: 
    c += 1
print(c)

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

# In[18]:


N, M = map(int,input().split()) 
ab = [list(map(int,input().split())) for i in range(N)]
cd = [list(map(int,input().split())) for i in range(M)]


# In[20]:


ans = []
for i in range(len(ab)):
    ans.append(1)
    dist_min = abs(cd[0][0] - ab[i][0]) + abs(cd[0][1] - ab[i][1])
    for j in range(len(cd)):
#         print(cd[j], ab[i])
        dist = abs(cd[j][0] - ab[i][0]) + abs(cd[j][1] - ab[i][1])
#         print(dist)
        if dist < dist_min:
            dist_min = dist
            ans[-1] = j+1
#     print(ans)

for i in range(N):
    print(ans[i])


# In[ ]:






Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int _0v0_=1000;
int ma[510][510],n,m,h,w;
int main(){
	scanf("%d%d%d%d",&n,&m,&h,&w);
	if(n%h==0&&m%w==0){printf("No");return 0;}
	printf("Yes\n");
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)ma[i][j]=_0v0_;
	for(int i=1;i<=n/h;i++)for(int j=1;j<=m/w;j++)ma[i*h][j*w]=-(h*w-1)*_0v0_-1;
	for(int i=1;i<=n;i++){for(int j=1;j<=m;j++)printf("%d ",ma[i][j]);printf("\n");}
	return 0;
}

Measured memory_bytes: 2560
//嘘っぽい
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

typedef vector<int> Edges;
typedef vector<Edges> Graph;

int INF = 1e+9;
int n, m;
Graph g, rg;
int dist1[1000][1000];
int prev1[1000][1000];
int dist2[1000][1000];
int prev2[1000][1000];

void bfs(Graph &g, int start, int dist[], int prev[]) {
	int n = g.size();
	int i;
	typedef tuple<int, int, int> T;
	queue<T> que;
	
	rep(i, n) dist[i] = INF;
	rep(i, n) prev[i] = -1;
	
	que.push(T(0, start, -1));
	while (!que.empty()) {
		T now = que.front();
		int cst = get<0>(now);
		int v = get<1>(now);
		int bv = get<2>(now);
		que.pop();
		
		if (dist[v] <= cst) continue;
		dist[v] = cst;
		prev[v] = bv;
		
		rep(i, g[v].size()) {
			int nv = g[v][i];
			if (dist[nv] <= cst + 1) continue;
			que.push(T(cst + 1, nv, v));
		}
	}
}

int main() {
	int i, j;
	
	cin >> n >> m;
	g.resize(n);
	rg.resize(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		rg[b].push_back(a);
	}
	
	rep(i, n) bfs(g, i, dist1[i], prev1[i]);
	rep(i, n) bfs(g, i, dist2[i], prev2[i]);
	
	int mind = INF;
	int pi, pj;
	rep(i, n) {
		rep(j, n) {
			if (i == j) continue;
			int d = dist1[i][j] + dist2[j][i];
			if (mind > d) {
				mind = d;
				pi = i;
				pj = j;
			}
		}
	}
	if (mind == INF) { cout << -1 << endl; return 0; }
	
	vector<int> ans;
	int v = pj;
	while (v != pi) {
		ans.push_back(v);
		v = prev1[pi][v];
	}
	
	v = pi;
	while (v != pj) {
		ans.push_back(v);
		v = prev2[pj][v];
	}
	
	cout << ans.size() << endl;
	rep(i, ans.size()) { cout << ans[i] + 1 << endl; }
	return 0;
}

Measured memory_bytes: 16000
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
		public static void main(String[] args) {
			int di[]=new int[6];
			for(int i=0;i<6;i++) di[i]=scan.nextInt();
			int a=scan.nextInt();
			List<Integer>list=new ArrayList<Integer>();
			for(int i=0;i<a;i++) {
				int b=scan.nextInt();
				int c=scan.nextInt();
				int basyo1=0,basyo2=0;
				for(int j=0;j<6;j++) {
					if(di[j]==b)basyo1=j;
					if(di[j]==c)basyo2=j;
				}
				switch(basyo1) {
				case 0:
					switch(basyo2) {
					case 1:list.add(di[2]);break;
					case 2:list.add(di[4]);break;
					case 3:list.add(di[1]);break;
					case 4:list.add(di[3]);break;
					}
					break;
				case 1:
					switch(basyo2) {
					case 0:list.add(di[3]);break;
					case 2:list.add(di[0]);break;
					case 3:list.add(di[5]);break;
					case 5:list.add(di[2]);break;
					}
					break;
				case 2:
					switch(basyo2) {
					case 0:list.add(di[1]);break;
					case 1:list.add(di[5]);break;
					case 4:list.add(di[0]);break;
					case 5:list.add(di[4]);break;
					}
					break;
				case 3:
					switch(basyo2) {
					case 0:list.add(di[4]);break;
					case 1:list.add(di[0]);break;
					case 4:list.add(di[5]);break;
					case 5:list.add(di[1]);break;
					}
					break;
				case 4:
					switch(basyo2) {
					case 0:list.add(di[2]);break;
					case 2:list.add(di[5]);break;
					case 3:list.add(di[0]);break;
					case 5:list.add(di[3]);break;
					}
					break;
				case 5:
					switch(basyo2) {
					case 1:list.add(di[3]);break;
					case 2:list.add(di[1]);break;
					case 3:list.add(di[4]);break;
					case 4:list.add(di[2]);break;
					}
					break;
				}
			}
			for(int i=0;i<list.size();i++) {
				System.out.println(list.get(i));
			}
		}
		public static int[] dice(int d[],char ch) {
			int d1=d[0];//上
			int d2=d[1];//前
			int d3=d[2];//右
			int d4=d[3];//左
			int d5=d[4];//奥
			int d6=d[5];//下
			int a[]=new int[6];
			switch(ch) {
			case'S':
				a[0]=d5;
				a[1]=d1;
				a[2]=d3;
				a[3]=d4;
				a[4]=d6;
				a[5]=d2;
				break;
			case'W':
				a[0]=d3;
				a[1]=d2;
				a[2]=d6;
				a[3]=d1;
				a[4]=d5;
				a[5]=d4;
				break;
			case'E':
				a[0]=d4;
				a[1]=d2;
				a[2]=d1;
				a[3]=d6;
				a[4]=d5;
				a[5]=d3;
				break;
			case'N':
				a[0]=d2;
				a[1]=d6;
				a[2]=d3;
				a[3]=d4;
				a[4]=d1;
				a[5]=d5;
				break;
			
			}
			return a;
		}
}


Measured memory_bytes: 26244
a,b=gets.chomp.split.map(&:to_i)
puts "100 100"

g = []
50.times do
    g << ['#'] * 100
end
50.times do
    g << ['.'] * 100
end

a-=1
b-=1
flag = false
1.step(49,2) do |i|
    1.step(99,2) do |j|
        flag = true and break if a == 0
        g[i][j] = '.'
        a -= 1
    end
    break if flag == true
end
flag = false
51.step(99,2) do |i|
    1.step(99,2) do |j|
        flag = true and break if b == 0
        g[i][j] = '#'
        b -= 1
    end
    break if flag == true
end

0.upto(99) do |i|
    puts g[i].join("")
end


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

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<mint>> dp(h+1, vector<mint>(w, 0));
	dp[0][0] = 1;
	rep(i,h){
		rep(j,w){
			rep(k,(1<<(w-1))){
				bool ok = true;
				rep(l,w-2){
					if((k>>l) & 1 && (k>>(l+1) & 1)) ok = false;
				}
				if(ok){
					if(j-1 >= 0 && (k>>(j-1)) & 1){
						dp[i+1][j-1] += dp[i][j];
					}
					else if(j <= w-2 && (k>>j) & 1){
						dp[i+1][j+1] += dp[i][j];
					}
					else{
						dp[i+1][j] += dp[i][j];
					}
				}
			}
		}
	}
	cout << dp[h][k-1].x << endl;
	return 0;
}


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

using namespace std;


int main()
{
    long long A;
    double a =0;
    cin >> A;
    A = (A * A * A);

    a = (double)A / 27.0; 
    cout << fixed << setprecision(12) << a << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int bridge[100]={};
    int c[100],d[100];
    for(int i=1;i<b+1;i++){
        cin>>c[i]>>d[i];
        bridge[c[i]]++;
        bridge[d[i]]++;
    }
    for(int i=1;i<a+1;i++){
        cout<<bridge[i]<<endl;
    }
    return 0;
}

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


int main()
{ 
  ll n,k;
  cin>>n>>k;
  set<ll > s;
  for(int i=0;i<k;i++)
  {   ll d;
      cin>>d;
      for(int j=0;j<d;j++)
      {
        ll x;
        cin>>x;
        s.insert(x);
      }
  }
  ll ans=0;
  for(int i=1;i<=n;i++)
  {
      if(count(s.begin(),s.end(),i)==0)
        ans++;
  }
 cout<<ans;
return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

ll dp[100010];

int main(void){
    ll n;
    cin>>n;
    for(ll i=0;i<100010;i++)dp[i]=i;
    for(ll i=0;i<=n;i++){
        dp[i]=i;
        if(i>=1)dp[i]=min(dp[i],dp[i-1]+1);
        for(ll j=6;j<=i;j*=6){
            dp[i]=min(dp[i],dp[i-j]+1);
        }
        for(ll j=9;j<=i;j*=9){
            dp[i]=min(dp[i],dp[i-j]+1);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}



Measured memory_bytes: 1024
import math

N = int(input())
records = {}

for i in range(N):
    l = ''.join(sorted(input()))
    records.setdefault(l, 0)
    records[l] += 1

count = 0
for v in records.values():
    if v == 1:
        continue
    else:
        count += math.comb(v, 2)

print(count)

Measured memory_bytes: 22284
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    auto a = readln.chomp.split.map!(to!int).array;

    auto b = readln.chomp.split.map!(to!int).array;
    
    long ans = 0;
    foreach (i, e; b) {
        int now = min(a[i], b[i]);
        ans += now;
        a[i] -= now;
        b[i] -= now;
        
        now = min(a[i+1], b[i]);
        ans += now;
        a[i+1] -= now;
        b[i] -= now;
    }
    
    ans.writeln;
}

Measured memory_bytes: 9708
/*************************************************************************
    > File Name: a.cpp
    > Author: samcompu
    > Mail: admin@samcompu.com
    > Created Time: 2018年05月05日 星期六 20时13分13秒
************************************************************************/

#include<bits/stdc++.h>

using namespace std;
/*Constant*/

/*Class*/

/*Variable*/

/*Declare*/

int main() {
  int a;
  int b;
  scanf("%d%d", &a, &b);
  if (a <= b) printf("%d\n", a);
  else printf("%d\n", a - 1);
  return 0;
}

/*Define*/



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

a_end = 0
b_start = 0
a_b = 0
cnt = 0

for _ in range(n):
    s = input()
    cnt += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        a_b += 1
        continue
    if s[0] == "B":
        b_start += 1
    if s[-1] == "A":
        a_end += 1

if a_end == 0 and b_start == 0:
    tmp = max(a_b - 1, 0)
else:
    tmp = min(a_end,  b_start) + a_b
print(cnt + tmp)

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

using namespace std;

typedef long long 		ll;
typedef vector<ll> 		vll;
typedef pair<ll,ll> 	pll;
typedef vector<pll> 	vpll;
typedef vector<int> 	vi;
typedef pair<int,int> 	pii;
typedef vector<pii> 	vpii;

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define per(i,a,b) 		for(int i=a;i>=b;i--)
#define fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				printf("yaha aya\n")
#define debug(x,y)		printf("%d %d\n",x,y)

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

int main(void)
{
	int n;cin>>n;
	int dp[n][3];
	rep(i,0,n-1) cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
	rep(i,1,n-1)
	{
		dp[i][0] += max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] += max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] += max(dp[i-1][0],dp[i-1][1]);
	}
	int ans = max(dp[n-1][2],max(dp[n-1][0],dp[n-1][1]));
	cout<<ans<<"\n";
}

Measured memory_bytes: 1408
# nikkei2019-qualC - Different Strokes
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(N))
    a = sorted(A, key=sum, reverse=1)
    ans = sum(i for i, j in a[::2]) - sum(j for i, j in a[1::2])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 22144
n, m = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(n)] #n行にmつずつ入力される整数
ans_li = list(range(1, m+1))
for l in li:
    ans_li = set(ans_li) & set(l[1:])
print(len(ans_li))

Measured memory_bytes: 38484
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;




int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll l,r,mn,g,h,p,q,r1,r2,ans;
    sfl(l),sfl(r);
    if(r-l>2019){
        printf("0\n");
    }
    else{
        ll mn=INF;
        for(ll i=l;i<=r;i++){
            for(ll j=i+1;j<=r;j++){
                ll val =(i*j)%2019;
                mn = min(mn,val);
            }
        }
        pfl(mn);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    ll p=ceil(sqrt(n-1));
    ll cnt=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            if(n-(i*j)>0)
               {

                cnt++;
                //cout<<i<<" "<<j<<" "<<(n-(i*j))<<"\n";
               }
               if(i*j>=n)
                break;
        }
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 3196
def buble_sort(seq):
    l = len(seq)
    cnt = 0
    for i in range(l):
        for j in range(i+1, l)[::-1]:
            if seq[j] < seq[j-1]:
                seq[j], seq[j-1] = seq[j-1], seq[j]
                cnt += 1
    return seq, cnt


n = int(input())
a = list(map(int, input().split()))
sorted_a, num_swap = buble_sort(a)
print(' '.join(map(str, sorted_a)))
print(num_swap)

Measured memory_bytes: 7712
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
int a[12],x;
int main()
{
	for(int i=1;i<=4;i++)scanf("%d",&x),x<10?a[x]=1:0;
	if(a[1]&&a[7]&&a[4]&&a[9])return puts("YES"),0;
puts("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
    
#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
//#define int long long int
    
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_mset = tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
    
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
//const ll INFLL = (ll)1e17;
const int MAXN = 3123;
const double pi = 3.14159265359;
const double eps = 0.00000001;
 
int dp[MAXN][MAXN];
ii link[MAXN][MAXN];
bool flag[MAXN][MAXN];

int main() {
    $
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            int x = dp[i - 1][j - 1] + (s[i - 1] == t[j - 1]);
            int y = dp[i][j - 1];
            int z = dp[i - 1][j];
            if (x >= max(y, z)) {
                dp[i][j] = x;
                link[i][j] = {i - 1, j - 1};
                flag[i][j] = s[i - 1] == t[j - 1];
            } else if (y >= max(x, z)) {
                dp[i][j] = y;
                link[i][j] = {i, j - 1};
            } else {
                dp[i][j] = z;
                link[i][j] = {i - 1, j};
            }
        }
    }
    string ans;
    ii cur(n, m);
    while (cur.F && cur.S) {
        if (flag[cur.F][cur.S]) {
            ans += s[cur.F - 1];
        }
        cur = link[cur.F][cur.S];
    }
    reverse(all(ans));
    cout << ans << endl;
}

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

using namespace std;
typedef  long long ll;
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll d=c-a-b;
	if (d>0 && 4*a*b<d*d) {cout<<"Yes";}
	else {cout<<"No";}
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int dp[1005][1005];
int main(){
	string s1,s2;
	cin>>s1;
	cin>>s2;
	s1 = ' '+s1;
	s2 = ' '+s2;
	for(int i=1;i<=s1.length();i++){
		dp[i][0] = i;
	}
	for(int j=1;j<=s2.length();j++){
		dp[0][j] = j;
	}
	
	for(int i=1;i<=s1.length();i++){
		for(int j=1;j<=s2.length();j++){
			if(s1[i] == s2[j]){
				dp[i][j] = dp[i-1][j-1];
			}else{
				dp[i][j] = min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
			}
		}
	}
	cout<<dp[s1.length()][s2.length()]<<endl;
}


Measured memory_bytes: 7128
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
const double PI = acos(-1.0);
const double  EPS = 1e-11;
typedef long long ll;
//freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
int main()
{
	
	int a, b, x;
	cin >> a >> b >> x;
	if (x < a||x>(a+b))
	{
		cout << "NO\n";
		return 0;
	}
	if (x - a <= b)
	{
		cout << "YES\n";
		return 0;
	}


	return 0;
}

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

int main() {
  int a, b;
  while (cin >> a >> b) {
    int count = 0;
    int ans = a + b;
  
    while (ans >= 1) {
      count++;
      ans /= 10;
    }
    // cout << a << "," << b << "," << count << endl;
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <map>

using namespace std;

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

	string S, T;
	cin >> S >> T;

	int A, B;
	cin >> A >> B;

	string U;
	cin >> U;

	map<string, int> ball;

	ball[S] = A;
	ball[T] = B;
	ball[U]--;

	cout << ball[S] << " " << ball[T];

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    double pi=3.14159265;
    double rad;
    rad=sc.nextDouble();
    double cir;
    cir=2*pi*rad;
    System.out.printf("%.2f" ,cir);
  }
} 

Measured memory_bytes: 37428