akhauriyash/Code-Regression huggingface dataset:
/*
#include<rabbit>;
using blueHulkStress;
using AceOfSpades;
*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
const int dx[] = {1,-1,0,0,1,-1,1,-1};
const int dy[] = {0,0,1,-1,1,-1,-1,1};
const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};


int main(int argc, char const *argv[])
{
	
	
	int x,y;cin>>x>>y;
	std::vector<string> v(x);
	rep(i,x)cin>>v[i];
	sort(all(v));
	for(auto i:v)cout<<i;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	int N, T;
	cin >> N >> T;
	int m = INF;
	REP(i, N) {
		int c, t;
		cin >> c >> t;
		if (t <= T) m = min(m, c);
	}
	if (m == INF) cout << "TLE\n";
	else cout << m << "\n";
	
	return 0;
}



Measured memory_bytes: 256
# 包除原理, cとdの最小公倍数, b-aではなく b-(a-1)に注意 

def gcd(x, y):
  if x > y:
    return gcd(y, x)
  while x != 0:
    x, y = y % x, x
  return y
def lcm(x, y):
  return (x*y)//gcd(x, y)

a, b, c, d = map(int, input().split())
bx = b - (b//c + b//d - b//lcm(c, d))
ax = (a-1) - ((a-1)//c + (a-1)//d - (a-1)//lcm(c, d))
print(bx-ax)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            ans = max(ans, abs(a[i]-a[j]));
        }
    }
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
 
using namespace std;

int main(){
    vector<int> S;
    int a, b, c;
    cin >> a >> b >> c;

    S.push_back(a);
    S.push_back(b);
    S.push_back(c);

    sort(S.begin(),S.end());

    int ans = (S[2] - S[1]) + (S[1] - S[0]);

    cout << ans << endl; 

    return 0;
    
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,ll md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    int n;
    cin>>n;
    vi a(n);
    f(i,0,n)cin>>a[i];
    f(i,0,n){
        if(a[i]%2==0){
            if(a[i]%3!=0 and a[i]%5!=0){
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

MOD = 10**9+7
def pow(a, b):
    res = 1
    while b:
        if b & 1: res = res * a % MOD
        a = a**2 % MOD
        b >>= 1
    return res

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = set(A)
    
    m = max(B)+1    
    prime = {i:i for i in range(m)}
    is_prime = [False] * m
    
    for i in range(2, int(m**0.5)+1):
        if is_prime[i]: continue
        is_prime[i] = True
        
        for j in range(2*i, m, i):
            if not is_prime[j]: prime[j] = i
            is_prime[j] = True
            
    from collections import Counter
    
    count = Counter()
            
    for a in A:
        c = Counter()
        while a > 1:
            n = prime[a]
            c[n] += 1
            a //= n
        for k, v in c.items(): count[k] = max(count[k], v)
            
    x = 1
    for k, v in count.items(): x = x * k**v % MOD
    
    ans = 0
    for a in A: ans += x * pow(a, MOD-2) % MOD
    
    print(ans%MOD)

if __name__ == '__main__':
    main()        


Measured memory_bytes: 99992
def hitoketame3(num):
    if num % 10 == 3:
        return True
    else:
        return False

n = int(input())
for i in range(1, n+1):
    x = i
    if x % 3 == 0:
        print(" {0}".format(i),end="")
        continue
    if hitoketame3(x) == True:
        print(" {0}".format(i),end="")
        continue
    while x != 0:
        x = x // 10
        if hitoketame3(x) == True:
            print(" {0}".format(i),end="")
            break
print("")

Measured memory_bytes: 8016
def slove():
    import sys
    import bisect
    import collections
    import fractions
    import heapq
    import itertools
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    ks = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    p = list(map(int, input().rstrip('\n').split()))
    a_cnt = 0
    for v in itertools.product([True, False], repeat=n):
        b = True
        for j, vv in enumerate(ks):
            cnt = 0
            for i in range(vv[0]):
                if v[vv[i+1]-1]:
                    cnt += 1
            if cnt % 2 != p[j]:
                b = False
                break
        if b:
            a_cnt += 1
    print(a_cnt)


if __name__ == '__main__':
    slove()


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

good = [True] * N
for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1

    if H[A] == H[B]:
        good[A] = good[B] = False
    else:
        good[B if H[A] - H[B] > 0 else A] = False

print([x for x in good if x].__len__())


Measured memory_bytes: 19980
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int g=0,p=0,w=0,l=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='g'){
      if(p<g){
        p++;
        w++;
      }else {
        g++;
      }
    }else {
      if(p<g){
        p++;
      }else {
        g++;
        l++;
      }
    }
  }
  cout << w - l << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> sunu(N, 0);
  rep(i, K){
  int d;
    cin >> d;
    rep(j, d){
    int num;
      cin >> num;
      sunu[num-1] ++;
    }
  }
  int ans=0;
  rep(i, N){
  if(sunu[i]==0)
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
using namespace std;
int main(){ 
    int d11,d12,d13,d21,d22,d23,d31,d32,d33,cn;
    cin >> d11 >> d12 >>d13 >>d21 >> d22 >> d23 >> d31 >> d32 >> d33 >> cn;
    vector<int> list(cn);
    int tmp;
    int e11 =0;
    int e12 = 0;
    int e13 = 0;
    int e21 = 0;
    int e22 = 0;
    int e23 = 0;
    int e31 = 0;
    int e32 = 0;
    int e33 = 0;
    for (int i = 0; i < cn; i++) {
        cin >> tmp;
        if (tmp == d11) {
            e11 = 1;
        }
        if (tmp == d12) {
            e12 = 1;
        }
        if (tmp == d13) {
            e13 = 1;
        }
        if (tmp == d21) {
            e21 = 1;
        }
        if (tmp == d22) {
            e22 = 1;
        }
        if (tmp == d23) {
            e23 = 1;
        }
        if (tmp == d31) {
            e31 = 1;
        }
        if (tmp == d32) {
            e32 = 1;
        }
        if (tmp == d33) {
            e33 = 1;
        }
    }
    //横
    if (e11 == 1 and e12 == 1 and e13 == 1) {
      cout << "Yes";
    }else if (e21 == 1 and e22 == 1 and e23 == 1) {
      cout << "Yes";
    }else if (e31 == 1 and e32 == 1 and e33 == 1) {
      cout << "Yes";
    } else if (e11 == 1 and e21 == 1 and e31 == 1) {
        //縦
      cout << "Yes";
    } else if (e12 == 1 and e22 == 1 and e32 == 1) {
      cout << "Yes";
    } else if (e13 == 1 and e23 == 1 and e33 == 1) {
      cout << "Yes";
    } else if (e11 == 1 and e22 == 1 and e33 == 1) {
    //斜め
      cout << "Yes";
    } else if (e31 == 1 and e22 == 1 and e13 == 1) {
      cout << "Yes";
    } else {
      cout << "No";
    }
}

Measured memory_bytes: 256
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e6+10;
	
	char str[N];
	
	void main()
	{
		set<int> st;int n=qread();fo(i,1,n){ int now=qread();if(st.count(now)) gg2();st.insert(now); }puts("YES");
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

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

typedef long long int ll;
int main(){
    ll N,Y;
    cin >> N >> Y;
    ll x,y,z;
    for(int i = 0;i < min(Y/10000 + 1,N+1);i++){
        for(int j = 0;j < min((Y - 10000*i)/5000 + 1,N-i + 1);j++){
            if(i * 10000 + j * 5000 + (N-i-j) * 1000 == Y){
                x = i,y = j,z = N-i-j;
                cout << x << ' ' << y << ' ' << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

import math

lst = [_ for _  in range(1,n+1)]

i = 1
lst = [_ for _  in range(1,n+1)]
for _ in p:
    idx = lst.index(_)
    i += math.factorial(len(lst)) // len(lst) * idx
    lst.remove(_)

pans = i

i = 1
lst = [_ for _  in range(1,n+1)]
for _ in q:
    idx = lst.index(_)
    i += math.factorial(len(lst)) // len(lst) * idx
    lst.remove(_)

qans = i

ans = abs(pans - qans)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,a,b);
	OUT((b%a?b-a:a+b))BR;
  
  return 0;
}


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

using namespace std;

bool can_devide(const vector<int> &vec);

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

    vector<int> vec(n);
    for (int i = 0; i < n; ++i)
        cin >> vec[i];

    int count = 0;
    while (can_devide(vec)) {
        for (int i = 0; i < n; ++i)
            vec[i] /= 2;
        ++count;
    }
    cout << count << '\n';
}

bool can_devide(const vector<int> &vec)
{
    for (int i = 0; i < vec.size(); ++i) {
        if (vec[i] % 2 != 0)
            return false;
    }
    return true;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a+b==c || a+c==b || b+c==a)
            System.out.println("Yes");
        else
        System.out.println("No");
    }
}

Measured memory_bytes: 21716
import sys,collections
input = sys.stdin.readline

N = int(input())
a =list(map(int,input().split()))

if sum(a) == 0:
    print('Yes')
    exit()

if N%3 != 0:
    print('No')
    exit()    

ac = collections.Counter(a)

if len(ac) == 2 and ac[0] ==N/3:
    print('Yes')
    exit()


if len(ac) != 3 :
    print('No')
    exit()
else:
    lk1,lk2,lk3 = ac.keys()
    lv1,lv2,lv3 = ac.values()
if lv1 == lv2 ==lv3:
    if lk1^lk2 == lk3:
        print('Yes')
    else:
        print('No')
else:
    print('No')
    exit()

Measured memory_bytes: 20412
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    
    while(1){
        int d,e;
    
        scanf("%d",&d);
        scanf("%d",&e);
    
        if(d==0 && e==0)break;
    
        double res = 1000000;
        for(long double i=0;i<d;i++){
            long double j=d-i;
            if(abs(sqrt(pow(i,2)+pow(j,2))-e)<res)res = abs(sqrt(pow(i,2)+pow(j,2))-e);
        }
        
        
        printf("%.10f\n",res);
    }

    return 0;
}



Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,count=0;
  cin>>a>>b>>c>>d;
  while(a>0 && c>0){
    if(count%2==0){
      c -= b;
      count++;
    }
    else{
      a -=d;
      count++;
    }
  }
  if(0<a)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

using ll = long long;
using ldb = long double;

#define forn(i, x, n) for (int i = x; i < (int)(n); ++i)
#define forcin(a, n) for (int i = 0; i < n; cin >> a[i], ++i)
#define forb(i, x, n) for (int i = (int)(x); i >= n; --i)
#define mmax(a, b, c) max(a, max(b, c))
#define mmin(a, b, c) min(a, min(b, c))
#define pb push_back
#define mp make_pair

const int N = 100500 * 3;
const long double eps = 1e-11;

int a[N], b[N];
pair<int, int> c[N];

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

    forn(i, 0, n) {
        cin >> a[i] >> b[i];
        c[i] = mp(a[i], 1);
        c[i + n] = mp(b[i], 0);
    }

    sort(c, c + 2 * n);
    int dmg = 0;
    int cnt = 0;
    forb(i, 2 * n - 1, 0) {
        if (c[i].second == 0) {
            ++cnt;
            dmg += c[i].first;
        } else {
            cnt += (h - dmg) / c[i].first + ((h - dmg) % c[i].first ? 1 : 0);
            dmg = h + 1;
        }

        if (dmg >= h) {
            cout << cnt;
            return 0;
        }
    }
}


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

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

    vector<int> A(3);

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

    int K;
    cin >> K;

    int a = *max_element(A.begin(), A.end());

    int ans = 0;

    for(int i = 0; i < 3; i++) {
        if(A[i] == a) {
            ans += A[i] * pow(2, K);
            a = 0;
        }
        else ans += A[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    n = int(input())
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    #s = input()
    print(ceil(n/1000)*1000-n)

Measured memory_bytes: 63200
#include <iostream>
using namespace std;
int main()
{
	int D, N;
	cin >> D >> N;
	if (D == 0)
	{
		if (N != 100)
		{
			cout << N;
		}
		else
		{
			cout << 101;
		}
	}
	else if (D == 1)
	{
		if (N != 100)
		{
			cout << N * 100;
		}
		else
		{
			cout << N * 101;
		}
	}
	else
	{
		if (N != 100)
		{
			cout << N * 10000;
		}
		else
		{
			cout << N * 10100;
		}
	}

	return 0;

}

Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <limits>
#include <iomanip>
 
int main()
{
    long long a{};
    double b{};
    std::cin >> a >> b;
    //std::cout << std::setprecision(std::numeric_limits<double>::max_digits10) << b * 100 << std::endl;
    std::cout << a * std::llround(b * 100) / 100 << std::endl;
    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  ll N;
  cin >>N;
 unordered_map<string,long long> mp;
  
  rep(i,N) {
string s;
    cin >>s;
    sort(all(s));
    mp[s]++;
  }
  ll ans=0;
  for(auto p:mp) {
    ans +=(p.second*(p.second-1))/2;
  }
  
  cout<<ans<<endl;
}
    
    
  

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

//auto mod int

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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++() {
      if ((x++) >= mod) x-= mod;
      return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator--() {
      if ((x += mod-1) >= 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;
  }

  // for prime mod
  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;
  }
};

int main(){
    int n;
    cin >> n;
    map<pair<ll,ll>,P> mp; //第一象限の座標ペア->0,180ずれの数、90,-90ずれの数
    int zero = 0;
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        if ( a==0 && b==0) {
            zero++;
            continue;
        }
        ll c = __gcd(abs(a),abs(b));
        a /= c;
        b /= c;
        if(b<0) a*=-1, b*=-1;
        if(b==0 && a<0) a*=-1;
        bool rot90 = (a<=0);
        if(rot90){
            ll tmp = a;
            a = b; b=-tmp;
        }
        if(rot90) mp[{a,b}].second++;
        else mp[{a,b}].first++;
    }
    
    mint ans = 1;
    for (auto p : mp){
        mint now = 2;
        int fi = p.second.first;
        int se = p.second.second;
        //cout << fi << " " << se << "!" << endl;
        ans *= (now.pow(fi)-1) + (now.pow(se)-1) + 1;
    }
    ans-=1;
    ans += zero;
    cout << ans.x << endl;
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int l;
  cin>>l;
  int k=0;
  for(int j=1; j<=l; ++k) j<<=1;
  int n=k--;
  vector<pair<pair<int,int>,int>> e;
  for(int i=k-1; i>=0; --i) {
    while(i>=0 and (1<<i & l) == 0) --i;
    if(i<0) break;
    int mask=(1<<i+1)-1;
    int v=l&~mask;
    e.emplace_back(make_pair(1,n-i),v);
  }
  //e.emplace_back(make_pair(1,n),l);
  cout<<n<<' '<<(int)e.size()+(n-1)*2<<'\n';
  for(int i=1; i<n; ++i) {
    cout<<i<<' '<<i+1<<" 0\n";
    cout<<i<<' '<<i+1<<' '<<(1<<(n-1-i))<<'\n';
  }
  for(auto p:e) {
    cout<<p.first.first<<' '<<p.first.second<<' '<<p.second<<'\n';
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define N 100000
#define MOD 1000000007
#define INF 1000000000

int main()
{
        int n, m;
        cin >> n >> m;
        string a[8];
        for(int i = 0; i < n; i++){
                cin >> a[i];
        }

        queue<pii> q;
        q.push(mp(0, 0));
        map<pii, int> used;
        while(!q.empty()){
                pii cur = q.front();
                q.pop();
                pii turn1 = cur;
                turn1.first++;
                used[cur] = 1;
                pii turn2 = cur;
                turn2.second++;



                pii turn3 = cur;
                turn3.first--;
                pii turn4 = cur;
                turn4.second--;

                if(turn3.first >= 0 && a[turn3.first][turn3.second] == '#' && !used[turn3] || turn4.second >= 0 && a[turn4.first][turn4.second] == '#' && !used[turn4]){
                        cout << "Impossible";
                        return 0;
                }

                if(cur.first == n - 1 && cur.second == m - 1){
                        break;
                }

                if(!(turn1.first < n && a[turn1.first][turn1.second] == '#' && turn2.second < m && a[turn2.first][turn2.second] == '#')){
                        if(turn1.first < n && a[turn1.first][turn1.second] == '#'){
                                q.push(turn1);
                                used[turn1] = true;
                        }
                        else if(turn2.second < m && a[turn2.first][turn2.second] == '#'){
                                q.push(turn2);
                                used[turn2] = true;
                        }
                        else{
                                cout << "Impossible";
                                return 0;
                        }
                }
                else{
                        cout << "Impossible";
                        return 0;
                }
        }

        cout << "Possible";
        return 0;
}


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

int main() {
  int N, T, A;
  cin >> N >> T >> A;

  vector<int> H(N);
  rep(i, N) cin >> H[i];

  vector<double> t(N);
  rep(i, N) {
    t[i] = T - H[i] * 0.006;
  }

  int ans = 0;
  double d = abs(A - t[0]);
  rep(i, N) {
    double tmp = abs(A - t[i]);
    if (tmp < d) {
      d = tmp;
      ans = i;
    }
  }

  ans++;

  cout << ans << endl;
}

Measured memory_bytes: 256
N, M, X = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
Z = [0] * N
for a in A:
    Z[a] = 1
lower = 0
for i in range(0, X+1):
    lower += Z[i]
higher = 0
for i in range(X, N):
    higher += Z[i]
print(min(lower,higher))

Measured memory_bytes: 3064
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N, K = mi()
    h = [ii() for _ in range(N)]
    h.sort()
    print(min(h[i+K-1]-h[i] for i in range(N-K+1)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 50392
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;
#define int long long
const int N = (int) 1e6 + 5, mod = (int) 0;
int pre[N], suf[N], ord[N], ax[N], ay[N], az[N];
int cmpzy(int x, int y) { return ay[x] + az[y] > ay[y] + az[x]; }
struct cmpxz {
	bool operator () (int a, int b) { return mp(ax[a] + az[b], a) > mp(ax[b] + az[a], b); }
};
struct cmpxy {	
	bool operator () (int a, int b) { return mp(ax[a] + ay[b], a) > mp(ax[b] + ay[a], b); }
};
int32_t main() {
	int nx, ny, nz;
	cin >> nx >> ny >> nz;
	int n = nx + ny + nz;
	for (int j = 0; j < n; ++j) {
		cin >> ax[j] >> ay[j] >> az[j];
		ord[j] = j;
	}
	sort(ord, ord + n, cmpzy);
	{
		set<int, cmpxy> st;
		int sum = 0;
		for (int pref = 0; pref < n; ++pref) {
			st.insert(ord[pref]);
			sum += ay[ord[pref]];
			if (pref >= ny) {
				auto cur = *(st.begin());
				st.erase(st.begin());
				sum += ax[cur] - ay[cur];
			}
			pre[pref] = sum;
		}
	}
	{
		set<int, cmpxz> st;
		int sum = 0;
		for (int s = n - 1; s >= 0; --s) {
			st.insert(ord[s]);
			sum += az[ord[s]];
			if (n - s > nz) {
				auto cur = *(st.begin());
				st.erase(st.begin());
				sum += ax[cur] - az[cur];
			}
			suf[s] = sum;
		}
	}
	int res = -1e18;
	for (int split = ny - 1; split < n - nz; ++split) {
		res = max(res, pre[split] + suf[split + 1]);
	}
	cout << res << endl;
}







Measured memory_bytes: 19712
from collections import deque
MOD = 10**9 + 7
N, K = map(int, input().split())
G = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
U = [0]*N
P = [0]*N
que = deque([0])
U[0] = 1
P[0] = -1
ans = K
while que:
    v = que.popleft()
    c = 0
    for w in G[v]:
        if U[w]:
            continue
        U[w] = 1
        que.append(w)
        P[w] = v
        c += 1
    s = 0
    if P[v] != -1:
        s = 2
    else:
        s = 1
    for i in range(c):
        ans = ans * (K-s-i) % MOD
print(ans)

Measured memory_bytes: 24592
#include <bits/stdc++.h>
using namespace std;
bool sudah[1000010];
vector<vector <int> > node;
void cek(int x)
{
	sudah[x]=1;
	int i;
	for(i=0;i<node[x].size();i++)
	{
		if(sudah[node[x][i]]==0)
		{
			cek(node[x][i]);
		}
	}
}
int main()
{
	int n,k;
	cin>>n>>k;
	node.resize(n+10);
	while(k--)
	{
		int a,b,c;
		cin>>a>>b>>c;
		node[a].push_back(b);
		node[b].push_back(a);
	}
	int x;
	int ans=0;
	for(x=1;x<=n;x++)
	{
		ans+=(!sudah[x]);
		if(sudah[x]==0)
		{
			cek(x);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 35
#define INF 1e9
#define F first
#define S second
typedef pair<double,int> pdi;
typedef pair<int,int> pii;
typedef pair<pdi,pii> State;
 
struct Edge{
  int to,d,c;
  Edge(int to,int d,int c) : to(to),d(d),c(c) {}
};
 
int N,M,s,g;
vector<Edge> G[MAX];
 
double dijkstra(){
  priority_queue<State,vector<State>,greater<State> > Q;
  Q.push(State(pdi(0,s),pii(1,N)));
  double Time[MAX][MAX][MAX];
  fill(Time[0][0],Time[0][0]+MAX*MAX*MAX,INF);   
  Time[s][1][N] = 0;
 
  while(!Q.empty()){
    State p = Q.top(); Q.pop();
    int v = p.F.S, vel = p.S.F;
    if(Time[v][vel][p.S.S] < p.F.F) continue;

    if(v == g && vel == 1){
      return Time[g][1][p.S.S];
    }
 
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      for(int j = -1 ; j <= 1 ; j++){
        if(vel+j <= 0) continue;
        if(Time[v][vel][p.S.S] == 0 && j){
          continue;
        }
        Edge e = G[v][i];
        if(e.to == p.S.S) continue;
        double t = (double)e.d/(vel+j);
        if(vel+j <= e.c && 
           Time[v][vel][p.S.S] + t < Time[e.to][vel+j][v]){
          Time[e.to][vel+j][v] = Time[v][vel][p.S.S] + t;
          Q.push(State(pdi(Time[e.to][vel+j][v],e.to),pii(vel+j,v)));
        }
      }
    }
  }
  return INF;
}
 
int main(){
  int x,y,d,c;
  while(cin >> N >> M, N){
    for(int i = 0 ; i < MAX ; i++){
      G[i].clear();
    }
    cin >> s >> g; s--; g--;
    for(int i = 0 ; i < M ; i++){
      cin >> x >> y >> d >> c;
      x--; y--;
      G[x].push_back(Edge(y,d,c));
      G[y].push_back(Edge(x,d,c));
    }
    double res = dijkstra();
    if(res == INF){
      cout << "unreachable" << endl;
    }else{
      printf("%.8f\n",res);
    }
  }
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

struct UFT{
  int * p;
  
  UFT(int N):p(new int[N]){fill(p,p+N,-1);}  
  ~UFT(){delete[] p;}  
  int par(int a)   { if( p[a] >= 0 ){ p[a] = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a) == par(b); }
  void unite(int a, int b){
    a = par(a);  b = par(b);
    if( a == b ) return;
    if( size(a) < size(b) )a^=b^=a^=b;
    p[a] -= size(b);
    p[b] = a;
  }
};


int main(){
  UFT uft(300000);
  int n; cin >> n;
  int m; cin >> m;
  for(int i = 0; i < m; ++i){
    int a,b; cin >> a >> b;
    uft.unite(a, b);
  }
  int ans = 0;
  for(int i = 1; i <= n; ++i){
    ans = max(ans,uft.size(i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4080
using System;
using System.Collections.Generic;
using System.Linq;

namespace Kanazawa
{
    public static class Kaga
    {
        public static void Main()
        {
            var n = Cint();
            var a = CintA();
            var b = CintA();
 
            var count = 0L;
 
            Loop(n, i =>
            {
                if (b[i] >= a[i])
                {
                    count += a[i];
                    b[i] -= a[i];
                    a[i] = 0;
                }
                else
                {
                    count += b[i];
                    a[i] -= b[i];
                    b[i] = 0;
                }
 
                if (b[i] >= a[i + 1])
                {
                    count += a[i + 1];
                    b[i] -= a[i + 1];
                    a[i + 1] = 0;
                }
                else
                {
                    count += b[i];
                    a[i + 1] -= b[i];
                    b[i] = 0;
                }
            });
 
            Cout(count);
        }
        
        #region Input and Output

        private static readonly List<string> Buffer = new List<string>();

        private static string Cin()
        {
            ReadBuffer();

            var str = Buffer.First();
            Buffer.RemoveAt(0);

            return str;
        }

        private static IEnumerable<string> CinA() => Console.ReadLine()?.Split();
        private static int Cint() => int.Parse(Cin());
        private static int[] CintA() => CinA().Select(int.Parse).ToArray();
        private static void Cout(object obj) => Console.WriteLine(obj);

        private static void ReadBuffer()
        {
            if (Buffer.Any()) return;

            var line = Console.ReadLine();
            if (line != null && line.Contains(' '))
            {
                Buffer.AddRange(line.Split());
            }
            else
            {
                Buffer.Add(line);
            }
        }

        #endregion
        #region Loops

        private static void Loop(int count, Action<int> action) => Loop(0, count, action);
        private static void Loop(int init, int count, Action<int> action, int step = 1)
        {
            for (var i = init; i < count + init; i += step)
            {
                action(i);
            }
        }

        #endregion
    }
}


Measured memory_bytes: 36444
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 505;
int n, dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1};
long long mat[N][N], pri[N << 2];

bool check_prime (int p) {
	for (int i = 2; i * i <= p; i++) {
		if (p % i == 0) return false;
	}

	return true;
}

long long gcd (long long x, long long y) {
	if (x < y) swap(x, y);
	while (x % y) {
		long long r = x % y;
		x = y, y = r;
	}
	return y;
}

long long lcm (long long x, long long y) {
	return (x / gcd(x, y)) * y;
}
int main () {
	scanf("%d", &n);
	for (int i = 2, j = 0; j < (n << 2); i++) {
		if (check_prime(i)) pri[++j] = i;
	}

	set<long long> s;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if ((i + j) % 2 == 0) {
				mat[i][j] = pri[i + j >> 1] * pri[(j - i) / 2 + (n + 1) / 2 + n];
				s.insert(mat[i][j]);
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if ((i + j) % 2 == 1) {
				long long div = mat[i][j] = 1;
				for (int k = 0; k < 4; k++) {
					int x = i + dx[k], y = j + dy[k];
					if (1 <= x && x <= n && 1 <= y && y <= n) div = lcm(div, mat[x][y]);
				}
				mat[i][j] += div;
				while (s.count(mat[i][j])) mat[i][j] += div;
				s.insert(mat[i][j]);
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) printf("%lld ", mat[i][j]);
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 16896
#include <iostream>

#

using namespace std;

int main() {
    long long a;
    cin >> a;
    if (a < 10) {
        cout << a << endl;
    } else {
        int flag = 0;
        if ((a + 1) % 10 == 0) {
            flag = 1;
        }
        int y;
        int count = 0;
        while (a > 9) {
            a /= 10;
            count++;
        }
        if (flag != 1) { y = a - 1; }
        else {
            y=a;
        }

        cout << 9 * count + y << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i, n) for (ll i = 0; i < (n); i++)
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false); 
  ll N; cin >> N;
  vector<ll> A(N);

  rep(i, N) {
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<ll>());

  ll sum = 0;
  for (ll i = 0; i < N - 1; i++) {
    sum += A[(i + 1) / 2];
  }

  cout << sum << endl;
}


Measured memory_bytes: 4764
def main():
    import sys
    input = sys.stdin.buffer.readline
    from itertools import permutations
    from math import hypot
    N = int(input())
    XY = [[int(i) for i in input().split()] for j in range(N)]
    ans = 0
    for p in permutations(range(N)):
        for i in range(N-1):
            ans += hypot(XY[p[i+1]][0] - XY[p[i]][0],
                         XY[p[i+1]][1] - XY[p[i]][1])
    for i in range(1, N+1):
        ans /= i
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  long long  A,B;
  long long N;
  int min = 100000;
  int a = 0;
  int b = 0;
  cin >> N;
  double rN = sqrt(N);
  for(int i = 1; i <= rN; i++){
    if(N%i == 0){
      A = i;
      B = N/A;
      while(A>0){
        A /= 10;
        a++;
      }
      while(B>0){
        B /= 10;
        b++;
      }
      if(min > max(a,b)) min = max(a,b);
      a = 0;
      b = 0;
    }
  }
  cout << min <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
string s;

int main() {
    cin >> n >> s;
    n %= 26;
    for (auto &ch:s) {
        ch += n;
        if (ch > 'Z') ch = ch - 'Z' + 'A' - 1;
    }

    cout << s << endl;

    return 0;
}


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

using namespace std;
#define M 110

int main(){
  int N, cnt=0, a[M], i;
  cin >> N;
  for (i = 0; i < N; i++)
    cin >> a[i];
  sort(a, a+N);
  cout << abs(a[0] - a[N-1]) << endl;
  return 0;
}


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

ranges = [tuple(map(int,input().split())) for _ in range(N)]
A = sorted(a for a,b in ranges)
B = sorted(b for a,b in ranges)
if N % 2 == 0:
    a = A[N//2-1]+A[N//2]
    b = B[N//2-1]+B[N//2]
    print(b-a+1)
else:
    a = A[N//2]
    b = B[N//2]
    print(b-a+1)

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

int main( void ) {
    
    string str;
    cin >> str;
    
    for( int i = 0; i < str.length(); i ++ ) {
        for( int j = i + 1; j < str.length(); j ++ ) {
            if( str[i] == 'C' && str[j] == 'F' ) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def main():
    n=int(input().rstrip())

    ans=0

    for a in range(1,n):
        for b in range(1,n):
            if a*b>=n:break
            ans+=1
    print(ans)

if __name__=="__main__":main()

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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int K = S.size();
    ll mod = 1e9+7;
    
    vector<ll> from1(K+5, 0), from2(5, 0);
    from1[K] = 1;
    from2[0] = 1;
    
    for (int z = 0; z < N; z++) {
        vector<ll> to1(z+K+5, 0), to2(min(z+5, N/2+5), 0);
        from1[0] %= mod;
        to1[1] += from1[0] * 3;
        for (int i = 1; i <= z+K; i++) {
            from1[i] %= mod;
            if (i != K) {
                to1[i-1] += from1[i];
                to1[i+1] += from1[i]*2;
            }else {
                to1[i-1] += from1[i];
                to1[i+1] += from2[0] + (from1[i]+mod-from2[0])%mod*2;
                to1[i] += from2[0];
            }
        }
        
        to2[0] = (from2[0]+from2[1])%mod;
        for (int i = 1; i <= min(z+2, N/2+3); i++) {
            to2[i] += (from2[i+1] + from2[i-1]*2)%mod;
        }
        
        swap(from1, to1);
        swap(from2, to2);
    }
    
    cout << from1[0]%mod << endl;
    
    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%d\n",a);
using namespace std;
int n;
int l,r,sum=0;
int a[100050];
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
bool check(int x)
{
	bool f; f=true;
	for (int i=2;i<=x-1;i++) {
	  if (i*i>x) break;
	  if (x%i==0) {
	    f=false;
	    break;
	  }
    }
    if (f) return true;
    return false;
}
int main()
{ 
    a[3]=1; a[4]=1; sum=1;
	for (int i=5;i<=100000;i++) {
	  if (i%4==1) {
	      if (check(i)&&check((i+1)/2)) sum++;
	  }
	  a[i]=sum;
    }
    n=read();
    for (int i=1;i<=n;i++) {
      l=read(),r=read();
      out(a[r]-a[l-1]);
    }
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    map<ll, ll> dic;
    ll ans = 0;
    rep(i,N) {
        int a; cin >> a;
        dic[a]++;
        ans += a;
    }

    int Q; cin >> Q;
    while (Q--) {
        ll b,c; cin >> b >> c;
        ll val = dic[b];
        ans -= b*val; 
        dic.erase(b);
        dic[c] += val;
        ans += c*val;
        cout << ans << ln;
    }

}

Measured memory_bytes: 7536
use std::io;
use std::io::Read;

fn main(){
    let mut stdin = io::stdin();
    let mut lines = String::new();
    let _ = stdin.read_to_string(&mut lines);
    let vec = lines.lines().collect::<Vec<&str>>();
    let x :usize = vec[0].trim().parse().unwrap();
    let n1 = (x / 11) * 2;
    let n2 = if x % 11 == 0 {
        0
    } else if x % 11 <= 6 {
        1
    } else {
        2
    };
    println!("{}", n1 + n2);
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(ll i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i,n){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    string ans;
    rep(i,n){
        ans += s[i];
    }
    cout << ans << endl;
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
	int n, k, h[110000];
	cin >> n >> k;
	fori(n) cin >> h[i];
	int r = 0;
	fori(n) { r += (h[i] >= k); }
	cout << r;
	return 0;
}

Measured memory_bytes: 640