akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    // Your code here!
    int A,count;
    cin >> A;
    count =0;
    for(int i=1;i<=A;i++){
    if(to_string(i).length()%2 !=0)count++;
    }
    
    cout << count;
    
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        char[][] f=new char[h][w];
        for (int i = 0; i < h; i++) {
            f[i]=sc.next().toCharArray();
        }
        UF.init();
        int[] dx={-1,0,1,0};
        int[] dy={0,-1,0,1};
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int p=w*i+j;
                for (int k = 0; k < 4; k++) {
                    int x=j+dx[k];
                    int y=i+dy[k];
                    if(r(h,w,x,y)){
                        if(f[i][j]!=f[y][x]){
                            UF.unite(p,y*w+x);
                        }
                    }
                }
            }
        }
        long[] white=new long[w*h];
        long[] black=new long[w*h];
        long ans=0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int p=i*w+j;
                if(f[i][j]=='.')white[UF.root(p)]++;
                else black[UF.root(p)]++;
            }
        }
        for (int i = 0; i < w*h; i++) {
            ans+=white[i]*black[i];
        }
        out.println(ans);
    }
    static boolean r(int h,int w,int x,int y){
        return 0<=x&&x<w&&0<=y&&y<h;
    }
    static class UF{
        static int size=400*400;
        static int[] par=new int[size];
        //初期化
        static void init(){
            for (int i = 1; i <size ; i++) {
                par[i]=i;
            }
        }
        //根をたどる
        static int root(int x){
            if(par[x]==x){
                return x;
            }else{
                return par[x]=root(par[x]);
            }
        }
        //同じ根をもつか(同じ集合に属するか)判定
        static boolean same(int x,int y){
            return root(x)==root(y);
        }
        //合体
        static void unite(int x,int y){
            x=root(x);
            y=root(y);
            if(x==y)return;
            par[x]=y;
        }
    }
}

Measured memory_bytes: 30564
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
struct UnionFind {
  vi d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y){
    return root(x) == root(y);
  }
  int size(int x){
    return -d[root(x)];
  }
};
int main(){
  int n,m;
  cin >> n >> m;
  vi a(m), b(m);
  rep(i, m){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  vector<ll> ans(m, 0);
  ans[m - 1] = (ll)n * (n - 1) / 2;
  UnionFind tree(n);
  for(int i = m - 1; i > 0; i--){
    if(!tree.same(a[i], b[i])){
      ans[i - 1] = ans[i] - tree.size(a[i]) * tree.size(b[i]);
    }else{
      ans[i - 1] = ans[i];
    }
    tree.unite(a[i], b[i]);
  }
  rep(i, m) cout << ans[i] << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(void)
{
    int N, M;
    int A, B;
    int i, j;
    int count = 0;

    scanf("%d", &N);
    scanf("%d", &M);

    int H[N];
    int keep[N];
    
    for(i = 0; i < N; i++){
      H[i] = 0;
      keep[i] = 0;
    }

  for(j = 0; j < N; j++){
    scanf("%d", &H[j]);
  }

  for(i = 0; i < M; i++){
    scanf("%d", &A);
    scanf("%d", &B);
   if(H[A-1] <= H[B-1]){
       keep[A-1] = 1;
   }
    if(H[A-1] >= H[B-1]){
       keep[B-1] = 1;
   }
  }
  
    for(i = 0; i < N; i++){
        if(keep[i] == 0){
            count += 1;
        }
    }

  printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 2504
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    long long int s;
    cin>>n>>k>>s;
    int count=0;
    for (int i=0;i<n;i++) {
        if (count<k) {
            count++;
            cout<<s;
        } else {
            if (s!=1000000000) {
                cout<<s+1;
            } else {
                cout<<s-1;
            }
        }
        if (i!=n-1) {
            cout<<" ";
        } else {
            cout<<endl;
        }
    }
}

Measured memory_bytes: 1280
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define fill(x, v) memset(x, v, sizeof(x))
#define FER(i,a,b) for(int i=int(a); i< int(b); ++i)
#define IFR(i,a,b) for(int i=int(a); i>=int(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 200005
// #define M 19
 
#define mod 998244353
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF LONG_MAX
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll add(ll a, ll b) { return a+b < mod? a+b : a+b-mod;}
inline ll sub(ll a, ll b) {return a-b < 0? a-b+mod: a-b;}
inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
	return ret;
}

int main(){
	fastio;
	ll n; cin>>n;
	ll x = __gcd(n, 360);
	ll valor = n*360/x;
	cout<<valor/n<<"\n";
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  int N, X, T;
  cin >> N >> X >> T;
  if(N%X==0) cout << N/X * T << endl;
  else cout << N/X * T + T << endl;
}

Measured memory_bytes: 3564
import numpy as np
def main():
  A, B, H, M = map(int, input().split())
  alpha = H/12*2*np.pi+ 2*np.pi/12*M/60
  beta = M/60*2*np.pi
  print(np.sqrt(A**2+B**2-2*A*B*np.cos(alpha-beta)))
if __name__ == '__main__':
  main()

Measured memory_bytes: 27224
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
vector<int> O[10];
P sg[10];
int d[1005][1005]={};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int fi[1005][1005];
int ans[1005][1005]={};
bool graph[55][55];
bool visited[55];
int a[55],b[55];

signed main(){
    int n;cin>>n;
    int num[105];
    int maxi=-1;
    rep(i,n){
        cin>>num[i];
        num[i]+=105;
        maxi=max(maxi,num[i]);
    }
    int mini=inf;
    rep(i,maxi+1){
        int sum=0;
        rep(j,n){
            sum+=(num[j]-i)*(num[j]-i);
        }
        mini=min(mini,sum);
    }
    cout<<mini<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    ll x[n]; cinf (n,x);
    ll ans=1000000000;
  ll d[n];
    for(int i=0;i<n-k+1;i++){
        d[i]=min(labs(x[i+k-1]),labs(x[i]))+labs(x[i+k-1]-x[i]);
        ans=min(ans,d[i]);


    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);

void solve(long long A, long long B, long long M, std::vector<long long> a,
           std::vector<long long> b, std::vector<long long> x,
           std::vector<long long> y, std::vector<long long> c)
{
  lli ans = *min_element(b.begin(), b.end()) + *min_element(a.begin(), a.end());
  rep(i, M)
  {
    chmin(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
  }
  cout << ans << endl;
}

signed main()
{
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> a(A);
  for (int i = 0; i < A; i++)
  {
    scanf("%lld", &a[i]);
  }
  std::vector<long long> b(B);
  for (int i = 0; i < B; i++)
  {
    scanf("%lld", &b[i]);
  }
  std::vector<long long> x(M);
  std::vector<long long> y(M);
  std::vector<long long> c(M);
  for (int i = 0; i < M; i++)
  {
    scanf("%lld", &x[i]);
    scanf("%lld", &y[i]);
    scanf("%lld", &c[i]);
  }
  solve(A, B, M, std::move(a), std::move(b), std::move(x), std::move(y),
        std::move(c));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 4224
A,B=map(float,input().split())
A_min=int(A/8*100)
A_max=int((A+1)/8*100)+1
ans=0
flag=False
if (A+1)*100%8==0:
    A_max=int((A+1)*100/8)
for i in range(A_min,A_max):
    if int(i*0.1)==B:
        ans=i
        flag=True
        break
if int(ans*0.08)!=A:
    ans+=1
if flag:
    print(ans)
else:
    print(-1)

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;
 
#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(c,l,r) for(int c=(l);c<=(r);c++)
 
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
 
using ll = long long;
//#define int ll
 
const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int  dx[]  = {-1,   0,   1,   0,  1, -1, -1,  1};
const int  dy[]  = { 0,   1,   0,  -1,  1, -1,  1, -1};
const char dt[] = {'U', 'R', 'D', 'L'};

void solve() {	
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == 12 and c == 5) {
		cout << "YES";	
	} else if (a + c == 12 and b == 5) {
		cout << "YES";
	} else if (b + c == 12 and a == 5) {
		cout << "YES";
	} else {
		cout << "NO";
	}
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
   	//cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}



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

int main(void){
  int A, B;
  cin >> A >> B;
  if(A == B)
    cout << "Draw" << "\n";
  else if(A == 1)
    cout << "Alice" << "\n";
  else if(B == 1)
    cout << "Bob" << "\n";
  else if(A > B)
    cout << "Alice" << "\n";
  else if(A < B)
    cout << "Bob" << "\n";
  return 0;
}


Measured memory_bytes: 3596
n, q = list(map(int, input().split()))
s = input().strip()
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i:(i + 2)] == "AC" else 0)

for i in range(q):
    l, r = list(map(int, input().split()))
    print(t[r - 1] - t[l - 1])


Measured memory_bytes: 51160
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define maxv 1e5+1
#define inf 4e18
using namespace std;
int main()
{
    ll n,W;
    cin>>n>>W;
    ll val[n+1],wt[n+1];
    vector<vector<ll>>knap(n+1,vector<ll>(maxv,inf));//2d vector with n+1 r and maxv col with value =inf
    //here the answer i.e maxvalue cant be >10^5
    for(ll i=0;i<n;i++)
        cin>>wt[i]>>val[i];
  knap[0][0]=0;
  for(int i=1;i<maxv;i++)
  {
    if(i==val[0]) knap[0][i]=wt[0];
  }
    for(ll i=1;i<n;i++)
    {
        for(ll j=0;j<maxv;j++)
        {
            if (j<val[i])
                knap[i][j]=knap[i-1][j];
            else
                knap[i][j]=min(knap[i-1][j-val[i]] + wt[i],knap[i-1][j]);
        }
    }
    for(ll i=maxv-1;i>=0;i--)//max value cant be greater than maxv coz vi<=10^3 and n<=100
    {
        if(knap[n-1][i]<=W)
        {
            cout<<i;//max value
            break;
        }
    }
}


Measured memory_bytes: 80384
def selectionSort(A,N):
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            v = A[i]
            A[i] = A[minj]
            A[minj] = v
            count += 1
    print(" ".join(map(str,A)))
    print(count)
    
n = int(input())
numlist = [int(x) for x in input().split()]

selectionSort(numlist,n)


Measured memory_bytes: 5604
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	string S;
	cin >> S;
	
	int N = S.size();
	string ans;
	FOR(i, 0, N) {
		if (S[i] == 'B') {
			int L = ans.size();
			if (L > 0) ans.erase(L - 1);
			continue;
		}
		ans += S[i];
	}

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


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

int N, M, Q;
vector<long long> a, b, c, d;

long long score(const vector<int> &A) {
	long long res = 0;
	for (int i = 0; i < Q; ++i) if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
	return res;
}

long long dfs(vector<int> &A) {
	if (A.size() == N) {
		return score(A);
	}
	long long res = 0;
	int prev_last = (A.empty() ? 0 : A.back());
	for (int add = prev_last; add < M; ++add) {
		A.push_back(add);
		res = max(res, dfs(A));
		A.pop_back();
	}
	return res;
}

int main() {
	cin >> N >> M >> Q;
	a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
	for (int q = 0; q < Q; ++q) {
		cin >> a[q] >> b[q] >> c[q] >> d[q];
		--a[q], --b[q];
	}
	vector<int> A;
	cout << dfs(A) << endl;
}


Measured memory_bytes: 3636
from heapq import heappush, heappop

n = int(input())
x = list(map(int, input().split()))

m = int(n/2)-1
x_tmp = sorted(x)

for i in range(n):
    if x[i] <= x_tmp[m]:
        print(x_tmp[m+1])
    else:
        print(x_tmp[m])

Measured memory_bytes: 26284
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  int h,w;
  cin >> h >> w;
  cout << (h-1) * (w-1) << LF;

  return 0;
}



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

def dfs(n, a, b, c):
    if n > N: return 0
    ret = 1 if a and b and c else 0
    ret += dfs(n*10+3, True, b, c) + dfs(n*10+5, a, True, c) + dfs(n*10+7, a, b, True)
    return ret

print(dfs(0, False, False, False))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,a,n) for(ll i=(a); i<(ll)(n); i++)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(v) (v).begin(), (v).end()

int main(void) {
    int A,B,C;
    cin >> A >> B >> C;
    int ans;
    if (A == B) ans = C;
    else if (A == C) ans = B;
    else ans = A;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//include----------------------------------------------------------------------------------------------------------------------
#include <bits/stdc++.h>
 
//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;
 
//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
 
//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;
 
//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos( -1.0 );
 
//global-----------------------------------------------------------------------------------------------------------------------
vector<int> a(10);
 
//function---------------------------------------------------------------------------------------------------------------------
int main() {
    rep( i, 10 ) {
        scanf( "%d", &a[ i ] );
    }
    sort( a.begin(), a.end() );
    ROF( i, 9, 7 ) {
        printf( "%d\n", a[ i ] );
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

ll F(ll a, ll b){
  return max(to_string(a).size(), to_string(b).size());
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll N; cin >> N;
  ll ans = 20;
  for(ll i=1;i*i<=N;i++){
    if(N %i != 0) continue;
    ans = min(ans, F(i, N/i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int S = scanner.nextInt();
        int h = S/3600;
        int m = (S-3600*h)/60;
        int s = S-3600*h-60*m;
        System.out.println(h+":"+ m +":"+ s );
    }
}

Measured memory_bytes: 26072
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

// お気に入りが1のときの回数
fn ans1(aa: &Vec<i64>) -> i64 {
    let n = aa.len();
    let mut last = aa[0];
    let mut cnt = 0;
    for i in 1..n {
        let next = aa[i];
        if last < next {
            // lastとnextの間に1があることはない
            cnt += next - last;
        } else {
            // 必ずお気に入りを押したほうが良い
            cnt += next - 1 + 1;
        }
        last = next;
    }

    cnt
}

fn solve(m: usize, aa: Vec<i64>) -> i64 {
    let n = aa.len();
    let mut last = aa[0] as usize;
    let mut ms = vec![0 as i64; m+2];

    for i in 1..n {
        let next = aa[i] as usize;
        if last < next {
            ms[last+1] += 1;
            ms[next] -= 1;
        } else {
            ms[last+1] += 1;
            ms[m+1] -= 1;
            ms[0] += 1;
            ms[next] -= 1;
        }
        last = next;
    }

    // a_iとa_{i+1}間にxがあるようなi
    let mut acc = vec![0; m+1];
    acc[0] = ms[0];
    for i in 1..m+1 {
        acc[i] = acc[i-1] + ms[i];
    }

//    println!("acc = {:?}", acc);

    let mut ans = vec![0; m+1];
    ans[1] = ans1(&aa);

//    println!("ans1 = {}", ans[1]);

    // a_{i+1} = x であるi
    let mut add1 = vec![0; m+1];
    let mut last = aa[0] as usize;
    for i in 1..n {
        let next = aa[i] as usize;
        if 1 <= next && next < m {
            add1[next+1] += ((next + m - last) % m) as i64 - 1;
        }
        last = next;
    }

    for i in 2..m+1 {
        ans[i] = add1[i] + ans[i-1] - acc[i-1];
    }

//    println!("ans = {:?}", ans);

    let mut min_ = std::i64::MAX;
    for i in 1..m+1 {
        if ans[i] < min_ {
            min_ = ans[i];
        }
    }

    min_
}

fn main() {
    let (_n, m) = parse_line!(usize, usize);

    let aa = parse_vec!(i64);

    println!("{}", solve(m, aa));
}

#[test]
fn solve_test() {
    assert_eq!(solve(6, vec![1,5,1,4]), 5);
    assert_eq!(solve(10, vec![10,9,8,7,6,5,4,3,2,1]), 45);
}


Measured memory_bytes: 10492
using System;

namespace ITP1_8_C
{
    class Program
    {
        static void Main()
        {
            int[] sum = new int[26];
            while(true)
            {
                string sentence;
                if((sentence = Console.ReadLine()) == null) break;
                char[] schar = sentence.ToLower().ToCharArray();
                for(int i = 0; i < schar.Length; i++)
                {
                    if(char.IsLower(schar[i])) sum[schar[i] - 'a']++;
                }
            }
            for(int i = 0; i < sum.Length; i++) Console.WriteLine(((char)('a' + i)) + " : " + sum[i]);
        }
    }
}

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 1; i < (int)c; i++)
#define debug(x) cout << #x << " is " << endl

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

    ll ans = 0;
    rep(i, N + 1)
    {
        if (i % 3 == 0 && i % 5 == 0)
        {
            continue;
        }
        else if (i % 3 == 0)
        {
            continue;
        }
        else if (i % 5 == 0)
        {
            continue;
        }
        else
        {
            ans += i;
        }
    }

    cout << ans << endl;
}


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


int main() {

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i = i + 2) {
        int cnt = 0;
        for (int j = 1; j <= n; j = j + 2) {
            if (i % j == 0) ++cnt;
        }
        if (cnt == 8) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;

int main() {
ll n;
cin >> n;
string s,t;
cin >> s >> t;
string ans="";
rep(i,n){
    ans += s[i];
    ans += t[i];
}
cout << ans << endl;
 }


Measured memory_bytes: 256
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif  
}

int32_t main(){
   boost;
   IO();

   int N; cin>>N;
   int mx=0;
   int a[N];  for(int i=0; i<N; i++) cin>>a[i];

   int ans=0;
   for(int i=0; i<N; i++){
   	mx=max(mx,a[i]);
   	ans+=mx-a[i];
   }
	cout << ans << endl;

   return 0;
}



Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int32_t main(){_
   
   cin>>n;

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

   int bst = inf;
   for (int i = 0; i <= 200; ++i)
   {
      int ans = 0;
      for (int j = 0; j < n; ++j)
      {
         ans += (a[j]-i) * (a[j]-i);  
      }
      if(bst > ans){
         tr(i);
         bst = ans;
      }
   }
   
   cout<<bst;

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<cstdio>
#include<cstring>
#include<string>
int main(){
  char mozi[1001][33],lenm[33],hind[33];
  int len=0,i=0,mozisu,count,max=-1;
  while(scanf("%s",mozi[i])!=EOF){
    len=strlen(mozi[i]);
    for(int j=0;j<len;j++){
      if(mozi[i][j]>='A' && mozi[i][j]<='Z'){
	mozi[i][j]+='a'-'A';
      }
    }
    if(mozisu<len){
     mozisu=len;
      strcpy(lenm,mozi[i]);
    }
    ++i;
  }
  for(int j=0;j<i+1;j++){
    count=0;
    for(int k=j+1;k<i+1;k++){
      if(!strcmp(mozi[j],mozi[k])){
	count++;
      }
    }
    if(max<count){
      max=count;
      strcpy(hind,mozi[j]);
    }
  }
  cout<<hind<<" "<<lenm<<endl;
}

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

int a[34] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main () {
	int n; cin >> n;
	cout << a[n] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
 
class Main {
 
    public static void main (String args[])
    {
      Scanner in = new Scanner(System.in);
        
        int sh = in.nextInt();
        int w=in.nextInt();
        if(w>=sh)System.out.println("unsafe");
        else System.out.println("safe");
    }
}

Measured memory_bytes: 35736
/*
  "I knew I shouldn't have
   gotten out of bed today."
   - Squidward Tentacles
*/
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<numeric>

#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

#include<fstream>
#include<chrono>
using namespace std;
// using namespace __gnu_pbds;

#define int          long long
#define ld           long double
#define pii          pair<int,int>
#define vi           vector<int>
#define maxheap      priority_queue<int>
#define minheap      priority_queue<int,vi,greater<int>>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define brep(i,s,e)  for(int i=s;i>=e;i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define VR46         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int MOD = 1e9+7;
ld EPS = 1e-12;

signed main()
{
    VR46 ofstream out("output.txt");
    // auto start = chrono::high_resolution_clock::now();

    // GANDU TEST CASE BNAKE TEST KRLE
    // OUT OF BOUNDS BHI DEKHLIO CHUTIYE
    int t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        int n;
        string s, t;
        cin>>n>>s>>t;
        string m = "";
        rep(i,0,n-1) m += s[i], m += t[i];
        cout<<m<<endl;
    }

    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout<<"Time taken by function: "<<duration.count()<<" milliseconds"<<endl;

    // *( hsh.find_by_order(k) ) kth smallest, from 0
    // hsh.order_of_key(k) num of ele str less than k
    // change less to less_equal for multiset pbds
}

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

using namespace std;

#define MAX_N 105
#define MAX_K 100005

int n, k, w[MAX_N], v[MAX_N];

long long dp[MAX_N][MAX_K];

long long f_imp(int, int);

long long f(int p, int wh)
{
	if (dp[p][wh] == 0)
		dp[p][wh] = f_imp(p, wh) + 1;
	return dp[p][wh] - 1;
}

long long f_imp(int p, int vl)
{
	if (vl < 0)
		return LONG_LONG_MAX/2;
	if (vl == 0)
		return 0;
	if (p == n - 1)
	{
		if (vl == v[p])
			return w[p];
		else
			return LONG_LONG_MAX/2;
	}
	return min(f(p + 1, vl), f(p + 1, vl - v[p]) + w[p]);
}

int main()
{
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d", w + i, v + i);
	}
	for (int i = n * 1000; i >= 0; i--)
	{
		if (f(0, i) != LONG_LONG_MAX/2 && f(0, i) <= k)
		{
			printf("%d\n", i);
			return 0;
		}
	}
	int err = 0;
	err = 10 / err;
}


Measured memory_bytes: 80000
S = input()[::-1]
devide = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(4):
    devide[i] = devide[i] [::-1]
    
flag = True
i = 0
while i < len(S):
    flag2 = False
    for j in range(4):
        if devide[j] == S[i : i+len(devide[j])]:
            flag2 = True
            i += len(devide[j])
    
    if not flag2:
        flag = False
        break

print('YES' if flag == True else 'NO')

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int N;
    cin >> N;
    int A[N],B[N];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    int ans=0;
    rep(i,N){
        int count=accumulate(A,A+i+1,0)+accumulate(B+i,B+N,0);
        ans=max(ans,count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

unsigned long long conv(int base,const string& fact){
  unsigned long long res = 0;
  unsigned long long digit = 1ULL;
  for(int i = fact.size() - 1; i >= 0; i--){
    if('A' <= fact[i] && fact[i] <= 'Z'){
      res += (fact[i] - 'A' + 10) * digit;
      digit *= base;
    }
    else{
      res += (fact[i] - '0') * digit;
      digit *= base;
    }
  }
  return res;
}

int main(){
  int base;
  string fact;
  while(cin >> base >> fact){
    if(base == 0 && fact == "0") break;
    unsigned long long init = conv(base,fact);
    unsigned long long prime_factor[37] = {};
    for(int i = 2; i <= base; i++){
      while(base % i == 0){
        prime_factor[i]++;
        base /= i;
      }
    }

    unsigned long long res = numeric_limits<unsigned long long>::max();
    for(unsigned long long i = 2; i <= 36; i++){
      if(prime_factor[i] == 0) continue;
      unsigned long long count = 0;
      unsigned long long tmp = init;

      while(tmp > 0){
        count += tmp / i;
        tmp /= i;
      }
      res = min(res,count / prime_factor[i]);
    }

    if(res == numeric_limits<unsigned long long>::max()) res = 0;    
    cout << res << endl;
  }
}

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

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; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int H1, M1, H2, M2, K;

// *********************************************************
int main(){

    // 入力スタンダード
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int l,m;

    l = H2*60 + M2 - H1*60- M1;

    if(l<K){
        cout << 0 <<endl;
    }else{
        cout << l - K <<endl;
    }
    





    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MAX_D = 32;
const int MAX_W = 51;
const int MAX_X = 6;

/*
	yuta1024 さんのコード

*/
int C, D, W, X;	// C: 地域数 (1 ≦ C ≦ 15 ) D: ツアー数（1 ≦ D ≦ 30 ) 
			// W:負担の合計の最大値 (0 ≦ W ≦ 50 )
			// X:ツアー期間中ライブを同じ日に2度以上行える合計日数の上限 ( 0 ≦ X ≦ 5 )
int E[40][40];	// E[i][j] 地域 i で j 日目にライブを行うことで期待される利益 ( 0 ≦ E[i][j] ≦ 1000)
int F[40][40];	// F[i][j] 地域 i で j 日目にライブを行うことで掛かる負担 ( 0 ≦ F[i][j] ≦ 10 )

int dp[MAX_D][MAX_W][MAX_X];

int solve (int d, int w, int x ){
	if (d >= D ) return 0;
	if (dp[d][w][x] != -1 ) return dp[d][w][x];

	int res = solve (d+1, w, x );
	rep (i, C ){
		if (E[i][d] != 0 && w+F[i][d] <= W ){
			res = max (res, solve (d+1, w+F[i][d], x ) + E[i][d] );
			if (x + 1 <= X ){
				int curr_w = w + F[i][d], curr_e = E[i][d];
				for (int j = i-1; j >= 0; j-- ){
					if (E[j][d] == 0 || curr_w + F[j][d] > W ) break;
					curr_w += F[j][d];
					curr_e += E[j][d];
					res = max (res, solve (d+1, curr_w, x+1) + curr_e );
				} // end for

				curr_w = w + F[i][d], curr_e = E[i][d];
				for (int j = i+1; j < C; j++ ){
					if (E[j][d] == 0 || curr_w+F[j][d] > W ) break;
					curr_w += F[j][d];
					curr_e += E[j][d];
					res = max (res, solve (d+1, curr_w, x+1) + curr_e );
				} // end for
			} // end if
		} // end if
	} // end rep

	return dp[d][w][x] = res;
} 

int main()
{
	ios_base::sync_with_stdio(0);
	while (cin >> C >> D >> W >> X, C ){
		memset (E, 0, sizeof (E ) );
		memset (F, 0, sizeof (F ) );
		rep (i, C ) rep (j, D ) cin >> E[i][j];
		rep (i, C ) rep (j, D ) cin >> F[i][j];

		memset (dp, -1, sizeof (dp ) );
		int res = solve (0, 0, 0 );		
		cout << res << endl;
	} // end while

	return 0;
}

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

typedef long long ll;
const int N = 2e5 + 10;
ll n, f[N], s[N], x, ans;

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        f[i] = f[i - 1] + x;
        s[i] = s[i - 1] ^ x;
    }
    int l = 1;
    for (int r = 1; r <= n; r++) {
        for (; f[r] - f[l - 1] != (s[r] ^ s[l - 1]); l++);
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
/*
g++ -std=c++11 -o2 -Wall AGC026A.cpp -o ./out/AGC026A.out
./out/AGC026A.out
*/

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

typedef long long ll;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

constexpr ll INF = 10000000000000000;

int a[105];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int ans = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int i = 0;
  int c = 101;
  while (i + 1 < n) {
    if (a[i] == a[i + 1]) {
      a[i + 1] = c++;
      ++ans;
    }
    ++i;
  }
  cout << ans << "\n";
}


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

int main(){
	int N, K;
	cin >> N >> K;
	
/*	int i, sum=1;
	for(i=0; i<N-2; i++){
		sum *= i;
	}
	
	if(sum < K)	cout << "NO" << endl;
	else		cout << "YES" << endl;
*/
	
	int sum = (N+1)/2;
//	cout << sum << endl;
	
	if(sum < K)	cout << "NO" << endl;
	else		cout << "YES" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int a, b, c;
	int i, divNum = 0;

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

	//i=a??????b?????§??°?????????
	for (i = a;i <= b;i++) {
		//c????´???°??§????????°count???1?¢???????
		if (c%i == 0) {
			divNum++;
		}
	}

	//c????´???°????????°?????????
	printf("%d\n", divNum);

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;




int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (abs(A - B - 1) % 2 == 1)
		cout << "Alice" << endl;
	else
		cout << "Borys" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();

            AtCoderMain at = new AtCoderMain();
            Console.WriteLine(at.ABC081ARun(s1));
            Console.ReadKey();

        }
    }

    public partial class AtCoderMain
    {
        /// <summary>
        /// abc081_a - Placing Marble
        /// https://atcoder.jp/contests/abc081/tasks/abc081_a
        /// </summary>
        /// <param name="p1"></param>
        /// <returns></returns>
        public string ABC081ARun(string p1)
        {
            int cnt = 0;
            for (int i = 0; i < p1.Length; i++)
            {
                if (p1[i] == '1')
                {
                    cnt++;
                }
            }
            return cnt.ToString();
        }
    }
}


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

#define ll long long

using namespace std;

int main(){
	ll n,m,l,i,j,s,k;
	
	cin>>n>>m>>l;
	
	ll a[n+1][m+1],b[m+1][l+1];
	
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=l;j++){
			cin>>b[i][j];
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<l;j++){
			s=0;
			for(k=1;k<=m;k++){
				s+=a[i][k]*b[k][j];
			}
			cout<<s<<" ";
		}
		s=0;
		for(k=1;k<=m;k++){
			s+=a[i][k]*b[k][j];
		}
		cout<<s<<endl;
	}
}


Measured memory_bytes: 3248
let n, m =
  let l =
    (stdin.ReadLine ()).Split(' ') |> Array.map int64
  l.[0], l.[1]

let P = 1000000007L

let ans =
  match abs (n - m) with
  | a when a > 1L -> 0L
  | 0L ->
    [1L .. n]
    |> List.fold (fun acc i -> (acc * i) % P) 1L
    |> (fun x -> 2L * (x * x) % P)
  | 1L ->
    let dogs =
      [1L .. n]
      |> List.fold (fun acc i -> (acc * i) % P) 1L
    let monkeys =
      [1L .. m]
      |> List.fold (fun acc i -> (acc * i) % P) 1L
    (dogs * monkeys) % P

ans |> stdout.WriteLine

Measured memory_bytes: 19536
#include<stdio.h>
int main(){

  int n,i,j;
  int num[50100]={0};
 
  for(i=3;i<50100;i+=2){
    if(num[i]==1)
      continue;
    for(j=3*i;j<50100;j+=i*2)
      num[j]=1;
  }
  while(scanf("%d",&n)!=EOF){
	int i;
	int tmp=2;
	for(i=3;i<n;i+=2)
	  if(num[i]==0)tmp=i;
	printf("%d",tmp);
	if(n%2==0)
	  i=n+1;
	else
	  i=n+2;
	for(;i<50100;i+=2)
	  if(num[i]==0)break;
	printf(" %d\n",i);
  }
  return 0;
}

Measured memory_bytes: 800
x=input()
KUPC=list(0 for i in range(4))
for i in range(len(x)):
    if x[i] == 'K':
        KUPC[0]+=1
    elif x[i] =='U':
        KUPC[1]+=1
    elif x[i] == 'P':
        KUPC[2]+=1
    elif x[i]=='C':
        KUPC[3]+=1
if (KUPC[0]==KUPC[1] and KUPC[1]==KUPC[2] and KUPC[2]==KUPC[3]):
    print(KUPC[0])
else :
    list.sort(KUPC)
    print(KUPC[0])


Measured memory_bytes: 5568
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         int input = sc.nextInt();
         int gohyaku = input / 500;
         int nokori = input % 500;
         int five = nokori / 5;
         System.out.println(gohyaku * 1000 + five * 5);
    }
}


Measured memory_bytes: 21972
#include <stdio.h>
int main()
{
  int x, y, r, n;

  scanf("%d%d",&x,&y);
  if (x < y){
    n = x;
    x = y;
    y = n;
  }
  while (y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  printf("%d\n",x);
  
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
     
using namespace std;
     
#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	all(c)			(c).begin(),(c).end()
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())
#define	endl			'\n'
     
typedef long long		ll;
typedef unsigned long long	ull;
typedef unsigned char	 	byte;
typedef vector<int>		vi;
typedef pair<int, int>		pii;
typedef pair<ll, ll>		pll;
typedef vector<pii>		vpii;
     
const int MX = 3005;

typedef struct _Node {
	int len;
	typedef struct _loc {
		int i,j;
	} loc;
	loc pre;
	int idx;
} Node;

Node dp[MX][MX];

     
int main(int argc, char *argv[])
{
#ifdef	HTRINH_UNIT_TEST
	freopen(argv[1],"r",stdin);
	ifstream cin(argv[1]);
#endif
#if 0
	ofstream cout(argv[2]);
#endif
	ios :: sync_with_stdio(false);
	cin.tie(NULL);

	string s,t;
	cin >> s >> t;
	s = '.'+s;
	t = '#'+t;
	Node x;
	x.len = 0;
	x.pre = {-1,-1};
	x.idx = -1;
	dp[0][0] = x;
	int n = s.length(), m = t.length();
	FOR(i,0,n) {
		x.len = 0;
		x.pre = {-1,-1};
		x.idx = -1;
		dp[i][0] = x;
	}
	FOR(i,0,m) {
		x.len = 0;
		x.pre = {-1,-1};
		x.idx = -1;
		dp[0][i] = x;
	}
	FOR(i,1,n) FOR(j,1,m) {
		if (s[i] == t[j]) {
			x.len = dp[i-1][j-1].len+1;
			x.pre = {i-1,j-1};
			x.idx = i;
			dp[i][j] = x;
		} else {
			if (dp[i-1][j].len >= dp[i][j-1].len) {
				x = dp[i-1][j];
			} else {
				x = dp[i][j-1];
			}
			dp[i][j] = x;
		}
	}
	string ans = "";
	x = dp[n-1][m-1];
	while (x.idx != -1) {
		ans = s[x.idx]+ans;
		int i = x.pre.i;
		int j = x.pre.j;
		x = dp[i][j];
	}

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


Measured memory_bytes: 141184