akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    Vec<u32> A(9);
    for (int i = 0; i < 9; i++)
        cin >> A[i];
    u32 N;
    cin >> N;
    bool B[9] = { false };
    for (int i = 0; i < N; i++) {
        u32 b;
        cin >> b;
        for (int j = 0; j < 9; j++) {
            if (A[j] == b) {
                B[j] = true;
                break;
            }
        }
    }
    bool bingo = false;
    for (int i = 0; i < 3; i++) {
        if (B[i * 3] && B[i * 3 + 1] && B[i * 3 + 2]) bingo = true;
        if (B[i] && B[i + 3] && B[i + 3 * 2]) bingo = true;
    }
    if (B[0] && B[4] && B[8]) bingo = true;
    if (B[2] && B[4] && B[6]) bingo = true;
    cout << (bingo? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
int main(){
ll x,k,d;
cin>>x>>k>>d;
  x=abs(x);
  ll ans;
 /* x-dk>=0 よりx>=dk でx/d<=k */
if(x/d >=k){
	ans=x-d*k;
}
  else {
  	ll e=x/d;
    k-=e;
    x-=e*d;
    if(k%2==1) x=abs(x-d);
    ans=x;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=100005;
const double EPS=1e-6;
const int MOD=1e9+7;

long long dp[SIZE][13];

int main(){
	/*main function start*/
	string s;
	cin>>s;
	int n=s.size();
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		if(s[i-1]!='?'){
			int num=s[i-1]-'0';
			for(int j=0;j<13;j++){
				int k=(j*10+num)%13;
				dp[i][k]+=dp[i-1][j];
				dp[i][k]%=MOD;
			}
			continue;
		}
		for(int j=0;j<13;j++){
			for(int k=0;k<10;k++){
				int l=(j*10+k)%13;
				dp[i][l]+=dp[i-1][j];
				dp[i][l]%=MOD;
			}
		}
	}
	printf("%lld\n",dp[n][5]);
	return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <bitset>
using namespace std;
typedef bitset<64> b64;
int main(){
	b64 b;
	int q,a,x;
	for(cin>>q;q--;){
		cin>>a;
		if(a==0)cin>>x,cout<<b[x]<<endl;
		if(a==1)cin>>x,b[x]=1;
		if(a==2)cin>>x,b[x]=0;
		if(a==3)cin>>x,b[x]=b[x]^1;
		if(a==4)cout<<b.all()<<endl;
		if(a==5)cout<<b.any()<<endl;
		if(a==6)cout<<b.none()<<endl;
		if(a==7)cout<<b.count()<<endl;
		if(a==8)cout<<b.to_ulong()<<endl;
	}
}



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

int main(void)
{
    long long N;
    cin >> N;
    vector<long long> A(N);
    long long S = 0;
    map<long long,long long> mp;
    for(long long i = 0; i < N; i++){
        cin >> A[i];
        S += A[i];
        mp[A[i]]++;
    }
    long long Q;
    cin >> Q;
    vector<long long> B(Q),C(Q);
    for(long long i = 0; i < Q; i++) cin >> B[i] >> C[i];
    for(long long i = 0; i < Q; i++){
        long long s = mp[B[i]];
        S -= B[i]*s;
        S += C[i]*s;
        mp[C[i]] += s;
        mp[B[i]] = 0;
        cout << S << endl;
    }
}

Measured memory_bytes: 11248
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n;
        while(true){
            n = sc.nextInt();
            if(n == 0){
                break;
            }

            int[] score = new int[n];
            int sum_1=0;
            for(int i=0;i<n;i++){
                score[i] = sc.nextInt();
                sum_1 += score[i];
            }

            
            double ave,sum_2=0,sd;
            ave = (double)sum_1/n;
            for(int i=0;i<n;i++){
                sum_2 += Math.pow((score[i]-ave),2);
            }
            sd = Math.sqrt((double)sum_2/n);
            System.out.printf("%.5f\n",sd);
        }
    }
}



Measured memory_bytes: 31560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	int ans = (n + x - 1) / x * t;
	cout << ans << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
//scanf("%lld",&a);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector<long long>v,u;
    pair<long long, long long>n;
    set<string>y;
    long long a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r=0,z,m,h,p;
    string t,s,x,q;
    double w;
    cin>>a>>b>>c>>d;
    while(d--){
        if(a>=b){
            b*=2;
        }
        else{
            c*=2;
        }
    }
    if(a<b&&b<c){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3628
a = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = "War"

for i in range(a[2]+1,a[3]+1):
  if max(x)<i<=min(y):
    z = "No War"
else:
  print(z)


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

#define MAX 101
#define NON -1

int *d,*f,*stack;
char *color;
int time,n;
int top;

struct Data{
	int num;
	struct Data *next;
};

struct Data *data;

void Make_list(void);
struct Data* New_list(void);
void DFS(void);
void DFS_visit(int);
void Push(int);
void Pop(void);
int Next(int);

int main(void){
	int i;
	
	scanf("%d",&n);

	d=(int*)malloc(sizeof(int)*(n+1));
	f=(int*)malloc(sizeof(int)*(n+1));
	stack=(int*)malloc(sizeof(int)*n);
	color=(char*)malloc(sizeof(char)*(n+1));
	data=(struct Data*)malloc(sizeof(struct Data)*(n+1));

	for(i=1;i<=n;i++) Make_list();

	DFS();

	for(i=1;i<=n;i++){
		printf("%d %d %d\n",data[i].num,d[i],f[i]);
	}

	free(d);
	free(f);
	free(stack);
	free(color);
	free(data);

	return 0;
}


void Make_list(void){
	int edg,ver,num;
	int i;
	struct Data *new,*work;

	scanf("%d",&ver);
	scanf("%d",&edg);

	data[ver].num=ver;
	data[ver].next=NULL;

	work=&data[ver];

	for(i=0;i<edg;i++){
		work->next=New_list();
		work=work->next;
	}
}


struct Data* New_list(void){
	struct Data *new;

	new=(struct Data*)malloc(sizeof(struct Data));

	scanf("%d",&new->num);
	new->next=NULL;

	return new;
}


void DFS(void){
	int i;

	time=0;
	top=0;
	
	for(i=0;i<n;i++) stack[i]=-1;

	for(i=1;i<=n;i++) color[i]='w';

	for(i=1;i<=n;i++){
		if(color[i]=='w') DFS_visit(i);
	}

}


void DFS_visit(int u){
	int v;

	Push(u);

	color[u]='g';

	d[u]=++time;

	while(top!=0){
		u=stack[top-1];
		v=Next(u);

		if(v!=-1){
			Push(v);
			color[v]='g';
			d[v]=++time;
		}
		else{
			Pop();
			color[u]='b';
			f[u]=++time;
		}
	}

}


void Push(int u){
	stack[top]=u;
	top++;
}


void Pop(void){
	top--;
	stack[top]=NON;
}


int Next(int u){
	struct Data *work;

	work=&data[u];

	while(work->next != NULL){
		if(color[work->next->num]=='w') return work->next->num;

		work=work->next;	
	}

	return -1;	
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n; cin >> n;
    map<ll,ll> mp;
    ll res=0;
    mp[0]=1;
    rep(i,n){
        int a; cin >> a;
        res+=a;
        mp[res]++;
    }
    ll ans=0;
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        ll x=itr->se;
        ans+=x*(x-1)/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12800
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert (int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        // printf("yeah");
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder (Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder (Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main () {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 26776
#include <bits/stdc++.h>
using namespace std;
int a[10];
bool dfs(int d, int l, int r){
    if(d == 10) return true;
    if(a[d] > l && dfs(d + 1, a[d], r))
      return true;
    if(a[d] > r && dfs(d + 1, l, a[d]))
       return true;
    return false;
}
int main(){
    int n;
    cin >> n;
    for(int k = 0; k < n; k++){
        for(int i = 0; i < 10; i++)
          cin >> a[i];
        if(dfs(0, 0, 0))
          puts("YES");
        else
          puts("NO");
    }
    return 0;
}

Measured memory_bytes: 1116
/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

// -----------------------------------------------------------------------

const ll maxn = 2010;

ll n, L[maxn], R[maxn], C[maxn];
string S;
vi g[maxn];

void dfs(ll x, ll par) {
    C[x] = S[x] == '1';
    R[x] = 0;
    L[x] = 0;
    ll val = 0;
    for (auto y : g[x]) if (y != par) {
        dfs(y, x);
        C[x] += C[y];
        R[x] += R[y] + C[y];
        if (L[x] < L[y] + C[y]) {
            L[x] = L[y] + C[y];
            val = R[y] + C[y];
        }
    }
    L[x] = max(R[x] % 2, L[x] - (R[x] - val));
}
    
int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n >> S;
    fori (i, n - 1) {
        ll a, b; cin >> a >> b; --a, --b;
        g[a].eb(b), g[b].eb(a);
    }
    ll ans = INF;
    fori (i, n) {
        dfs(i, -1);
        if (L[i] == 0) {
            smin(ans, R[i]);
        }
    }
    cout << (ans == INF ? -1 : ans / 2) << '\n';

}


Measured memory_bytes: 512
// 2012/12/13 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int W[10];
	for(int i=0; i<10; i++){
		cin >> W[i];
	}

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

	sort(W, W+10);
	sort(K, K+10);

	cout << W[9]+W[8]+W[7] << ' ' << K[9]+K[8]+K[7] << '\n';

	return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  int n; cin >> n;
  int k = (n+999)/1000;
  cout << k*1000-n << endl;
}


Measured memory_bytes: 3632
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define vi vector<ll>
#define pii pair<ll,ll>
#define bc __builtin_popcountll
#define vvi vector<vi> 
#define vpii vector<pair<ll,ll>>
#define mll unordered_map<ll,ll>
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define fo(i,a,b) for(i=a;i<=b;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()-->returns an iterator to the k-th largest element (counting from zero)
//X.order_of_key()-->the number of items in a set that are strictly smaller than our item.
struct cmp
{
	bool operator() (ll a,ll b){
		return (a>b);
	}
};
ll ceil(const ll &a, const ll &b)
{
    if(a%b == 0)
        return a/b;
    return a/b +1;
}
ll mod=1000000007;
const ll N=100005;
int main()
{
fast;
    ll n;
    cin>>n;
    n--;
    ll sum=0;
    f1(i,n)
    {
        sum+=(n/i);
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>

using namespace std;

class Dice{
private:
  int D1;
  int D2;
  int D3;
  int D4;
  int D5;
  int D6;

public:
  Dice(int d1,int d2,int d3,int d4,int d5,int d6){
  D1=d1;
  D2=d2;
  D2=d2;
  D3=d3;
  D4=d4;
  D5=d5;
  D6=d6;
  }

  void roll(char dire){
  int dd1=D1;
  int dd2=D2;
  int dd3=D3;
  int dd4=D4;
  int dd5=D5;
  int dd6=D6;
  
  if(dire=='E')
    {
    D1=dd4;
    D3=dd1;
    D4=dd6;
    D6=dd3;
    }
  if(dire=='N')
  {
    D1=dd2;
    D2=dd6;
    D5=dd1;
    D6=dd5;
  }
  if(dire=='S')
  {
    D1=dd5;
    D5=dd6;
    D6=dd2;
    D2=dd1;
  }
  if(dire=='W')
  {
    D1=dd3;
    D3=dd6;
    D6=dd4;
    D4=dd1;
  }
  
  }
  
  int ue(){
  return D1;
  }
  
  int light(int up,int mae){
    int i;
    int j;
    int k;
      for(i=0;i<4;i++)
      {
      roll('E');
     for(j=0;j<4;j++)
     {
      roll('S');
     for(k=0;k<4;k++)
     {
        roll('E');
        
        if(up==D1 && mae==D2)
          return D3;
     }
     }
    }
  }
  
  
};

int main()
{
  int di[6]={};
  int i;
  int q;
  int up;
  int mae;
  
  for(i=0;i<6;i++)
    cin >> di[i];
    
  Dice dice1(di[0],di[1],di[2],di[3],di[4],di[5]);
  
  cin >> q;
  
  for(i=0;i<q;i++)
  {
    cin >> up >> mae;
    cout << dice1.light(up,mae) <<"\n";
  }
}

Measured memory_bytes: 1160
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a )
        cout << b << " " << c << " " << a << endl;
    else if(c >= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else cout << c  << " " << b << " " << a << endl;
    
}


Measured memory_bytes: 3108
#include<map>
#include<set>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int main() {
	scanf("%d",&n);
	if(n<1200) puts("ABC");
	else  if(n<2800) puts("ARC");
	else puts("AGC");
}

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

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


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

int main() {
  int N;
  cin >> N;
  
  int temp = N % 10;
  switch(temp){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
      
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
      
    case 3:
      cout << "bon" << endl;
      break;
  }
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    string T;
    cin >> T;
    int N = T.size();
    for_(i,0,N) if (T[i] == '?') T[i] = 'D';
    cout << T << endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	double r,tmp;
	cin>>n>>r>>tmp;
	vd x(n),y(n);
	for(int i=0;i<n;i++) cin>>x[i]>>y[i];
	double cs=cos(tmp/180*pi);
	const int M=10000;
	vector<vvd> dp(M,vvd(n,vd(n,inf)));
	for(int i=1;i<n;i++) dp[1][0][i]=sqrt((x[i]-x[0])*(x[i]-x[0])+(y[i]-y[0])*(y[i]-y[0]));
	for(int i=1;i<M-1;i++){
		bool B=0;
		for(int j=0;j<n;j++) for(int k=0;k<n;k++) if(dp[i][j][k]<inf-eps){
			for(int l=0;l<n;l++) if(l!=k){
				double x1=x[l]-x[k],y1=y[l]-y[k];
				double x2=x[k]-x[j],y2=y[k]-y[j];
				if((x1*x2+y1*y2)/sqrt(x1*x1+y1*y1)/sqrt(x2*x2+y2*y2)>cs){
//					cout<<j<<' '<<k<<' '<<l<<' '<<syosu(9)<<(x1*x2+y1*y2)/sqrt(x1*x1+y1*y1)/sqrt(x2*x2+y2*y2)<<' '<<cs<<endl;
					dp[i+1][k][l]=min(dp[i+1][k][l],dp[i][j][k]+sqrt(x1*x1+y1*y1));
					if(dp[i+1][k][l]<r) B=1;
				}
			}
		}
		if(!B) break;
	}
	int res=0;
	for(int i=0;i<M;i++) for(int j=0;j<n;j++) for(int k=0;k<n;k++) if(dp[i][j][k]<r){
//		cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<endl;
		res=i;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 42736
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  vector<ll> x(3), y(3);
  REP(i,3) cin >> x[i] >> y[i];
  //平行移動
  FOR(i,1,3){
    x[i] -= x[0]; y[i] -= y[0];
  }
  x[0] = 0; y[0] = 0;
  //S = 面積/2
  ll S = abs(x[1]*y[2] - x[2]*y[1]);  

  //辺の長さの2乗
  vector<ll> a(3);
  REP(i,3){
    ll dx = x[(i+1)%3] - x[i];
    ll dy = y[(i+1)%3] - y[i];
    a[i] = dx*dx + dy*dy;
  }
  //最大辺**2 = a[0]
  sort(ALL(a),greater<>());
  //平方根とる
  vector<double> b(3);
  REP(i,3) b[i] = sqrt(a[i]);

  cout << fixed << setprecision(15);
  cout << (double) (1.0*b[0]*S)/(b[0]*(b[0]+b[1]+b[2])+2*S) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
 
int main(){
    int n;
    cin>>n;
    int odd = n/2;
    int even = n-odd;
    cout<<odd*even<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int m1,m2,d1,d2,flag=0;;
  cin>>m1>>d1>>m2>>d2;
  
    if(m2!=m1){
	flag=1;
    }
  if(flag==1)
    cout<<1<<endl;
  else
    cout<<0<<endl;
  return 0;
}

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

using namespace std;

int main()
{
    int N,i,j,flag = 0;

    scanf("%d",&N);

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

        if(((4*i) + (7*j)) == N){

              flag = 1;
        }
    }
    }

    if(flag == 1){

        printf("Yes\n");
    }

    else{

        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n;
    cin>>n;
    if(n<105) cout<<0;
    else if(n<135) cout<<1;
    else if(n<165) cout<<2;
    else if(n<189) cout<<3;
    else if(n<195) cout<<4;
    else cout<<5;
}

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 (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    int n;
    cin>>n;
    cout<<(10000-n)%1000<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int MOD = 1e9 + 7;
#define INF ((1<<30)-1)
#define LINF (1LL<<30)


ll dp[3100][3100];
int a[3100];
int main() {
    int N;
    cin >> N;
    rep(i,N) cin >> a[i];
    rep(i,N) dp[i][i] = 0;

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

            if ((N-len)%2 == 0){
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
            }

            else{
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);
            }
        }

    }
    cout << dp[0][N] << endl;
}

Measured memory_bytes: 73984
#include <iostream>
#define W 0
#define B 1
using namespace std;

int n;
int m;
int p;
int cou;
int dy[]={0, -1, -1, -1, 0, -1, -1, -1, 0, -1, -1, -1, 0};
int dx[]={1, 1, 0, -1, 1, 1, 0, -1, 1, 1, 0, -1, 0};
int dz[]={0, 0, 0, 0, 1, 1, 1, 1, -1, -1, -1, -1, 1};
int hantei(int, int, int, int);
class peg{
public:
  int ball[400];
};
peg data[7][7];

main(){
  while(1){
    cin >> n >> m >> p;
    if(n==0 && m==0 && p==0) break;

    for(int a=0;a<n;a++){
      for(int b=0;b<n;b++){
	for(int c=0;c<=p;c++){
	  data[a][b].ball[c]=-1;
	}
      }
    }

    int ans=0;
    int win=-1;
    bool end=false;
    for(cou=0;cou<p;cou++){
      int x, y;
      cin >> x >> y;
      if(end) continue;
      x--;
      y--;
      if(cou%2==0){
	for(int j=0;;j++){
	  if(data[y][x].ball[j]==-1){
	    int tmp;
	    data[y][x].ball[j]=B;
	    //printf("%d %d %d %d\n", x, y, j, B);
	    tmp=hantei(x, y, j, B);
	    //printf("%d\n", tmp);
	    if(tmp>=m){
	      win=B;
	      ans=cou+1;
	    }
	    break;
	  }
	}
      }
      else{
	for(int j=0;;j++){
	  if(data[y][x].ball[j]==-1){
	    int tmp;
	    data[y][x].ball[j]=W;
	    //printf("%d %d %d %d\n", x, y, j, W);
	    tmp=hantei(x, y, j, W);
	    //printf("!%d\n", tmp);
	    if(tmp>=m){
	      win=W;
	      ans=cou+1;
	    }
	    break;
	  }
	}
      }
      if(win!=-1) end=true;
    }
    if(win==W){
      printf("White %d\n", ans);
    }
    else if(win==B){
      printf("Black %d\n", ans);
    }
    else{
      printf("Draw\n");
    }
  }
  return 0;
}

int hantei(int x, int y, int z, int col){
  int max=-1;
  for(int i=0;i<13;i++){
    int tx=x, ty=y, tz=z;
    int count=0;
    while(1){
      if((tx<0 || tx>=n) || (ty<0 || ty>=n) || tz<0) break;
      if(data[ty][tx].ball[tz]!=col) break;
      count++;
      tx+=dx[i];
      ty+=dy[i];
      tz+=dz[i];
    }
    //printf("@%d ", count);
    tx=x-dx[i];
    ty=y-dy[i];
    tz=z-dz[i];
    while(1){
      if((tx<0 || tx>=n) || (ty<0 || ty>=n) || tz<0) break;
      if(data[ty][tx].ball[tz]!=col) break;
      count++;
      tx+=-1*dx[i];
      ty+=-1*dy[i];
      tz+=-1*dz[i];
    }
    //printf("%d\n", count);
    if(max<count) max=count;
  }
  return max;
}

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

int main() {
	int n, tmp;
	list<int> a;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> tmp;
		if (i % 2) a.push_front(tmp);
		else a.push_back(tmp);
	}
	for (int i = 0; i < n; ++i) {
		if (n % 2) {
			cout << a.back();
			a.pop_back();
		}
		else {
			cout << a.front();
			a.pop_front();
		}
		cout << ' ';
	}
}

Measured memory_bytes: 8448
fun main(args: Array<String>) {
    val x = readLine()!!.toInt()

    println (
    when {
        x < 600 -> 8
        x < 800 -> 7
        x < 1000 -> 6
        x < 1200 -> 5
        x < 1400 -> 4
        x < 1600 -> 3
        x < 1800 -> 2
        else -> 1
    }
    )
}


Measured memory_bytes: 34452
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
#define MOD 1000000007
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){

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

	int x;
	cin>>x;
	cout<<!x<<endl;
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {
	string tenki[3] = { "Sunny","Cloudy","Rainy" };
	string S;
	cin >> S;

	if (S == tenki[0]) {
		cout << tenki[1] << endl;
	}
	else if (S == tenki[1]) {
		cout << tenki[2] << endl;
	}
	else if (S == tenki[2]) {
		cout << tenki[0] << endl;
	}


}

Measured memory_bytes: 256
def main():
    N = int(input())
    ans = 0
    if N >= 10:
        ans += 9
    else:
        ans += N
    if N >= 1000:
        ans += 900
    else:
        ans += max(N-99, 0)
    if N >= 100000:
        ans += 90000
    else:
        ans += max(N-9999, 0)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String x = sc.next();
            
            if(x.equals("0")) break;
            
            int sum = 0;
            for(int i = 0; i < x.length(); i++){
                sum += Character.getNumericValue(x.charAt(i));
            }

            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26436
#include<stdio.h>
int main(void)
{
  long p=1,n,a,i,t=1000000000000000000;
	double m=1;
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    p*=a;
    m*=a;
  }
  if(p>t||m>t){
    printf("-1\n");
  }
  else{
    printf("%lld\n",p);
  }
  return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
    double N ;
    cin >> N ;
    vector<vector<double>> data(N,vector<double>(2,0));
    rep(i,N) cin >> data[i][0] >> data[i][1] ;
    double k = 0 ;
    double ans = 0 ;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            double p = data[i][0] - data[j][0] ;
            double q = data[i][1] - data[j][1] ;
            ans += pow(pow(p,2.0) + pow(q,2.0), 0.5);
            k++ ; 
        }
    }
    cout << fixed << setprecision(10) << ans / k * (N - 1) << endl;
}

Measured memory_bytes: 256
dict = {}

while True:
	try:
		a,b = map(str,raw_input().split())
	except EOFError:
		break
	
	if a in dict:
		dict[a].append(int(b))
	else:
		dict[a] = [int(b)]
	
for var in dict:
	dict[var].sort()

dic = list(dict.keys())
dic.sort()

for var in dic:
	print var
	for i in xrange(len(dict[var])):
		print dict[var][i],
	print 

Measured memory_bytes: 6236
N, K, Q = map(int, input().split())
ans_r = [K - Q] * N
cor = list(map(int, [input() for i in range(Q)]))
for i in cor:
    ans_r[i - 1] += 1
for i in ans_r:
    if i <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 14232
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string data[3] = {"Alice", "Bob", "Draw"};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

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

    string ans;
    if(A == 1 && B == 1){
        ans = data[2];
    }
    else if(A == 1){
        ans =  data[0];
    }
    else if(B == 1){
        ans = data[1];
    }
    else if(A == B){
        ans = data[2];
    }
    else if(A > B){
        ans = data[0];
    }
    else {
        ans = data[1];
    }
    cout << ans << endl;

    return 0;
};

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

int main(){
  int N;
  uint64_t ans=0;
  cin >> N;
  for(int i=1; i<=N; i++){
    if(i%3!=0 && i%5!=0) ans += i;
  }
  cout  << ans << endl;
  return 0;
}


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

const int N=2000005;
const long long int mod=1e9+7;
long long int f[N],inv[N],p[N],q[N],ans=0;

long long int modpow(long long int x, long long int n){
    long res=1;
    for(; n>0; n>>=1) {
        if (n&1) res=res*x%mod;
        x=x*x%mod;
    }
    return res;
}

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n=s.length();
	f[0]=p[0]=q[0]=1;
	for(int i=1;i<=n+k;i++) f[i]=f[i-1]*i%mod;
	inv[n+k]=modpow(f[n+k],mod-2);//逆元はmod-2乗すればいいことが知られている
	for(int i=n+k;i>=1;i--) inv[i-1]=inv[i]*i%mod;
	for(int i=1;i<=k;i++) p[i]=p[i-1]*25%mod,q[i]=q[i-1]*26%mod;
	for(int i=0;i<=k;i++){
		ans += p[k-i]*q[i]%mod*f[n+k-i-1]%mod*inv[n-1]%mod*inv[k-i]%mod;
        ans %=mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 51104
N = int(input())
S = input()

Rs = 0
Gs = 0
Bs = 0
for il in S:
    if il == 'R':
        Rs += 1
    if il == 'G':
        Gs += 1
    if il == 'B':
        Bs += 1
num = 0
for i in range(N):
    for step in range(1, N):
        j = i + step
        k = i + 2*step
        if k > N - 1:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            num += 1
print(Rs*Gs*Bs - num)


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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e15);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n, q;
std::string s, ts, ds;
int main()
{
	std::cin >> n >> q;
	std::cin >> s;

	for (int i = 0; i < q; ++i) {
		char t, d;
		std::cin >> t >> d;
		ts += t;
		ds += d;
	}

	int l = 0, r = n - 1;
	for (int i = q - 1; i >= 0; --i) {
		if (ds[i] == 'L') {
			if (ts[i] == s[l])
				++l;
			if (r < n - 1 && ts[i] == s[r + 1])
				++r;
		}
		else {
			if (l > 0 && ts[i] == s[l - 1])
				--l;
			if (ts[i] == s[r])
				--r;
		}
	}

	std::cout << std::max(0, r - l + 1) << std::endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

string solve()
{
    ll ans = 0;
    string S;
    cin >> S;
    ll a1 = stoi(S.substr(0,2));
    ll a2 = stoi(S.substr(2,2));

    if (1 <= a1 && a1 <= 12) {
        if (1 <= a2 && a2 <= 12) {
            return "AMBIGUOUS";
        } else{
            return "MMYY";
        }
    } else {
        if (1 <= a2 && a2 <= 12) {
            return "YYMM";
        } else{
            return "NA";
        }
    }
}

int main()
{
    do {
        cout << solve() << endl;
    } while (DEBUG);
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    const ll mod=1000000007;
    auto add=[&](ll &a,ll b){a=(a+b)%mod;};
    vector<vector<ll>> one(n+1,vector<ll>(n+1,0));
    one[0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            add(one[i+1][j+1],2*one[i][j]);
            add(one[i+1][max(0,j-1)],one[i][j]);
        }
    }
    ll res=one[n][s.size()];
    for(int i=0;i<(int)s.size();i++) res=(res*(mod+1)/2)%mod;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 197888
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0]==s[1] or s[1]==s[2] or s[2]==s[3]){
    cout << "Bad\n";
  }else{
    cout << "Good\n";
  }
  return 0;
}

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

namespace AtCoder119A
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            //int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split('/');
            int y = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            int d = int.Parse(input[2]);
            // 文字列の入力
            //string s = Console.ReadLine();
            if (y >= 2020)
            {
                Console.WriteLine("TBD");
            }
            else if (y == 2019)
            {
                if (m >= 5)
                {
                    Console.WriteLine("TBD");
                }
                else
                {
                    Console.WriteLine("Heisei");
                }
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll n;cin>>n;
  ll ans = n;
  for(ll i = 1; n >= i * i; ++i) {
    if(n % i)continue;
    ll b = n/i;
    ll tmp = max(digit(b),digit(i));
    ans = min(ans,tmp);
  }
  print(ans);
  return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100010;

int n, m;
int x[N], v[N];

int main() {


  scanf("%d%d", &n, &m);
  if (n >= m) {
    puts("0");
  } else {
    for (int i = 1; i <= m; ++i) {
      scanf("%d", &x[i]);
    }
    sort(x + 1, x + m + 1);
    for (int i = 1; i < m; ++i)
      v[i] = x[i + 1] - x[i];
    nth_element(v + 1, v + m - n, v + m);
    printf("%d\n", accumulate(v + 1, v + m - n + 1, 0));
  }

  return 0;
}


Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
  LL res=1;
  for(;b;b>>=1,a=a*a%_MOD){
    if(b&1)res=res*a%_MOD;
  }
  return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << " # ";
  err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
  ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
  Solve();
  return 0;
}

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

const int M=1e7+5;
int pw[M],f[M],prime[M],isprime[M],ss;
void Solve(){
  pw[1]=1;
  for(int i=2;i<M;i++) {
    if(!isprime[i]) {
      pw[i]=2;f[i]=1;
      prime[++ss]= i;
    }
    for(int j=1;j<=ss && prime[j]*i<M; j++) {
      isprime[prime[j]* i] =1;
      if(!(i%prime[j])) {
        pw[prime[j]*i]=pw[i]/(f[i]+1)*(f[i]+2);
        f[prime[j]*i]=f[i]+1;
        break;
      }
      pw[prime[j]*i]=2*pw[i];
      f[prime[j]*i]=1;
    }
  }
  int n;
  cin>>n;
  LL ans=0;
  rep(i,1,n){
    ans+=(LL)i*pw[i];
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 123432
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
INF = 1<<60

def resolve():
    R, C = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(10)]

    for k in range(10):
        for i in range(10):
            for j in range(10):
                nc = C[i][k] + C[k][j]
                if nc < C[i][j]:
                    C[i][j] = nc

    A = [list(map(int, input().split())) for _ in range(R)]
    ans = [sum([C[x][1] if x!=-1 else 0 for x in a]) for a in A]
    print(sum(ans))

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3444
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int a[] = new int[n];
            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans += Integer.parseInt(in.next()) - 1;
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 25556
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string s) {
    int[] ww = new int[s.length]; // [0, i] を全て白にするコスト
    int[] bb = new int[s.length]; // [i, $] を全て黒にするコスト
    int cost = 0;
    for (int i = 0; i < s.length; i++) {
        if (s[i] == '#') cost++;
        ww[i] = cost;
    }

    cost = 0;
    for (int i = cast(int)s.length-1; i >= 0; i--) {
        if (s[i] == '.') cost++;
        bb[i] = cost;
    }

    int ans = min(ww[$-1], bb[0]);
    for (int i = 0; i < s.length; i++) {
        // [0, i] を白、[i+1, $-1] を黒にするコスト
        int c = ww[i] + (i + 1 < s.length ? bb[i + 1] : 0);
        ans = min(ans, c);
    }
    return ans;
}

void main() {
    readint;
    string s = read!string;
    int ans = calc(s);
    writeln(ans);
}


Measured memory_bytes: 4220
#include<stdio.h>
#include<stdlib.h>
int main()
{
	char str[256],*p,*np;
	while(fgets(str,256,stdin),str[0]!='0')
	{
		int s=0,l,c1=0;
		for(p=str;;)
		{
			l=strtol(p,&np,10);
			if(p==np)break;
			p=np;
			s+=(l<10?l:10);
			c1+=(l==1);
		}
		while(s<=11&&c1)s+=10,--c1;
		printf("%d\n",(s>21?0:s));
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.util.stream.*;

public class Main {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    char[] s = in.nextLine().toCharArray();
    if (s[0] != s[1] && s[1] != s[2] && s[2] != s[3]) {
      System.out.println("Good");
    } else {
      System.out.println("Bad");
    }
  }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);
    static int MOD = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int k = scanner.nextInt();
        long ans = 0;
        for (long i = 1; i < m; i++)
            ans = (ans + i * (m - i) % MOD * n % MOD * n % MOD) % MOD;
        for (long i = 1; i < n; i++)
            ans = (ans + i * (n - i) % MOD * m % MOD * m % MOD) % MOD;
        for (long i = 2; i < k; i++)
            ans = ans * (n * m - i) % MOD * powAndMod(i - 1, MOD - 2) % MOD;
        System.out.println(ans);
    }

    static long powAndMod(long a, long b) {
        if (b == 0)
            return 1;
        if ((b & 1) == 1)
            return a * powAndMod(a, b - 1) % 1000000007;
        return powAndMod(a * a % 1000000007, b / 2);
    }
}

Measured memory_bytes: 23508
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n;
    cin >> n;
    int odd = 0;
    int even = 0;
    int tmp;
    rep(i,n) {
        cin >> tmp;
        if (tmp % 2 == 0)
            even++;
        else
            odd++;
    }

    int all = pow(3,n);
    int ans = all - pow(2,even);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256