akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define sz(x) (int)x.size()
#define aint(v) v.begin(), v.end()
#define x first
#define y second
#define in(x) cin >> x;
#define inde(x) ll (x); cin >> x;
#define rep(ai, j, k) for(ll ai=j; ai<k; ai++)
#define sep(ai, j, k) for(ll ai=j; ai>=k; ai--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inputarr(x,y) for(int ai=0; ai<y; ai++) {cin >> x[ai];}
#define inpprefixarr(arr,y) cin>> arr[0]; for(ll ai=1;ai<y;ai++) {ll temp; cin >> temp; arr[ai]= temp + arr[ai-1];}

#define watch(x) cout << (#x) << " is " << (x) << endl
#define watcharrsz(x) cout << (#x) << " starts:\n"; for(int ai=0;ai<sz(x);ai++) {cout << x[ai]<<" ";} cout << "\n" << (#x) << "ends\n";
#define watcharr(x,n) cout << (#x) << " starts:\n"; for(int ai=1;ai<=n;ai++) {cout << x[ai]<<" ";} cout << "\n" << (#x) << "ends\n";
#define watchg(x,n,y) cout << (#x) << " starts:\n"; for(int ai=0; ai<=n; ai++) {cout << (ai) << ":"; for(int aj=0; aj<x[ai].size();aj++) {cout << x[ai][aj]<< y;} cout << "\n";}cout << "\n"<< (#x) << "ends\n";
#define watch2darr(x,m,n,y) cout << (#x) << " starts:\n"; for(int ai=1;ai<=m;ai++) { for(int aj=1;aj<=n;aj++) {cout << x[ai][aj]<< y;} cout << "\n";}cout << "\n"<< (#x) << "ends\n";

#define print(x,y) cout << (x) << y;
#define printarrsz(x,y) for(int ai=0; ai<sz(x); ai++) {cout << x[ai]<< y;} cout << "\n";
#define printarr(x,n,y) for(int ai=0; ai<n; ai++) {cout << x[ai]<< y;} cout << "\n";
#define print2darr(x,m,n,y) for(int ai=0;ai<m;ai++) { for(int aj=0;aj<n;aj++) {cout << x[ai][aj]<< y;} cout << "\n";}cout << "\n";
#define mod(x) = (x % m + m) % m;

const ll m = (ll)1000000007;
const ll N = 3e6+5;
const ll INF = 1ll<<63; 

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef set<ll> sl;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

typedef priority_queue<pll, vpll, greater <pll> > pqg;
/***************************Code Begins Here *****************************/


void solve()
{
    // Never use x,y here, try to use i,j in loops only
    inde(n);
    ll he[n];
    inputarr(he,n);
    ll ok = 0;
    ll dec=0;
    ll maxx=he[0];
    rep(i,0,n) {
        maxx = max(maxx,he[i]);
        if(maxx - he[i] >= 2) {
            ok = 1;
        }
    }
    if(ok) {
        print("No",endl);
    }
    else {
        print("Yes",endl);
    }
}

signed main()
{
    ios
    ll t=1;
    // cin>>t;

    while(t--)
        solve();

    return 0;
}

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

using namespace std;

int main () {
    int n, t, c = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> t;
        if (i != t) c++;
    }
    cout << (c <= 2 ? "YES" : "NO") << endl;
}

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

int main(void)
{
    int N, M;
    int K;
    int ans[M];
    cin >> N >> M;
    for (int i=0; i<N; i++)
    {
        cin >> K;
        int A[K];
        for (int j=0; j<K; j++)
        {
            cin >> A[j];
            ans[A[j]-1] += 1;
        }
    }
    int correct = 0;
    for (int k = 0; k < M; k++)
    {
        if(ans[k]==N)
        {
            correct += 1;
        }
    }
    cout << correct << endl;

    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {

var inputs = chunk.toString().trim().split('\n').map(Number);
for (var i = 0; i < inputs .length; i++) {
        if (inputs [i] === 0) {
            break;
        }
        console.log('Case ' + (i + 1) + ': ' + inputs[i]);
}


});

Measured memory_bytes: 20696
S=input()

if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int elementaryMatrix(vector<bitset<300> >& mat)
{
    const int n = mat.size();
    const int m = mat[0].size();
    int y = 0;
    int x = 0;
    while(y < n && x < m){
        int tmp = y;
        while(tmp < n && !mat[tmp][x])
            ++ tmp;

        if(tmp < n){
            swap(mat[y], mat[tmp]);
            for(int i=y+1; i<n; ++i){
                if(mat[i][x])
                    mat[i] ^= mat[y];
            }
            ++ y;
        }
        ++ x;
    }
    mat.resize(y);
    return y;
}

const int MOD = 998244353;

long long power(long long a, int b)
{
    long long ret = 1;
    long long tmp = a;
    while(b > 0){
        if(b & 1){
            ret *= tmp;
            ret %= MOD;
        }
        tmp *= tmp;
        tmp %= MOD;
        b >>= 1;
    }
    return ret;
}

int main()
{
    int h, w;
    cin >> h >> w;
    vector<bitset<300> > v(h);
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            int a;
            cin >> a;
            v[i][j] = a;
        }
    }

    int rank = elementaryMatrix(v);
    long long ans = power(2, h+w-1) - power(2, h+w-1-rank);
    ans += MOD;
    ans %= MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	
	int a, b, t;
	int i = 1;
	int sum = 0;

	scanf("%d %d %d", &a, &b, &t);
	while (i * a <= (double)t + 0.5) {
		sum += b;
		i++;
	}
	printf("%d", sum);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef long long ll;
const int N=5005;

using namespace std;

/*struct node
{
	int t,next;
}adj[N<<1];
void add(int s,int t)
{
	adj[++now]=(node){t,head[s]};
	head[s]=now;
}*/
inline int read()
{
	char c;int x;
	while (c=getchar(),c<'0' || c>'9');x=c^'0';
	while (c=getchar(),c>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x;
}
void write(int x)
{
	if (x==0) return;
	write(x/10);
	putchar((x%10)+'0');
}
//void upd(int& x,int y){if (x==-1) x=y;else x=max(x,y);}

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	ll n;cin>>n;
	ll i,j,k;
	for (i=1;i<=3500;i++)
	for (j=i;j<=3500;j++)
	{
		ll b=n*i*j;
		ll a=i*j*4-n*i-n*j;
		if (a>0 && b%a==0){printf ("%lld %lld %lld",i,j,b/a);return 0;}
	}
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

void over_modify(const long i, std::vector<long>& dp, const std::string s){
    for(long j = i+1; s[j] == '1'; j++){
        dp[j] = dp[i];
    }
}

std::vector<long> solve(long n, long m, std::string s){
    std::vector<long> dp(n+1, LINF);
    dp[n] = 0;
    for(long i = n-1; i >= 0; i--){
        if(i+m > n && s[i] == '0'){
            dp[i] = 1;
            over_modify(i, dp, s);
        }else if(s[i] == '0'){
            dp[i] = dp[i+m]+1;
            over_modify(i, dp, s);
        }
    }

    /*
    for(int i = 0; i < dp.size(); i++){
        printf(" %ld", dp[i]);
    }
    printf("\n");
    //*/

    if(dp[0] >= LINF){
        return std::vector<long>(1, -1);
    }
    std::vector<long> ans(dp[0]);
    long index = 0;
    long vis = 0;
    for(long i = 0; i <= n; i++){
        if(s[i] == '0' && dp[i] == dp[vis] - 1){
            ans[index] = i - vis;
            vis = i;
            index++;
        }
    }
    return ans;
}

int main(){
    long n, m;
    scanf("%ld%ld", &n, &m);
    std::string s;
    std::cin >> s;
    std::vector<long> ans = solve(n, m, s);
    for(int i = 0; i < ans.size(); i++){
        printf("%ld ", ans[i]);
    }
    printf("\n");
}


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

int main() {
	char a,b,c,d;
  	cin>>a>>b;
    
  if(a=='H'){
  	if(b=='H'){
    	cout<<"H"<<endl;
    }
    else
      cout<<"D"<<endl;
  }
  else{
  	if(b=='H'){
    	cout<<"D"<<endl;
    }
    else
      cout<<"H"<<endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 1000000
typedef struct{ 
  int p, l, r;
}Node;
Node t[1000000];
int count,h,d[1000000];
void b(int); 
 
int main(){
  int n,id,k,c,l,r;
  cin>>n;
  for(int i=0;i<n;i++) {
    t[i].p=-1;
    t[i].l=-1;
    t[i].r=-1;
  }  
  for(int i=0;i<n;i++){
    cin>>id>>k;
    for(int j=0;j<k;j++){
      cin>>c;
      t[c].p=id;
      if(j==0)t[id].l=c;
      else t[r].r=c;
      r=c;
    }
  }
 
  for(int i=0;i<n;i++){
    b(i);
    d[i]=count;
  }
  for(int i=0;i<n;i++){
    if(t[i].p==-1)
    cout<<"node "<<i<<": parent = "<<t[i].p<<", depth = "<<d[i]<<", root, ";  
    else if(t[i].l==-1)
    cout<<"node "<<i<<": parent = "<<t[i].p<<", depth = "<<d[i]<<", leaf, ";         
    else
      cout<<"node "<<i<<": parent = "<<t[i].p<<", depth = "<<d[i]<<", internal node, ";
    int j=i;
    cout<<'[';
    if(t[j].l!=-1){
      cout<<t[j].l;
      if(t[t[j].l].r==-1) cout<<']'<<endl;
      else cout<< ", ";
        
      j=t[j].l;
      while(t[j].r!=-1){
    cout<<t[j].r;
      if(t[t[j].r].r==-1)cout<<']'<<endl;
      else cout<<", ";
      j=t[j].r;
      }
    }
    else cout<<']'<<endl; 
  }
  return 0;
}
 
void b(int x){
  count=0;
  while(t[x].p>=0){
    x=t[x].p; 
    count++;
  }
}



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

typedef long long ll;

int count_digit(ll num, int dig) {
	num /= 10;
	if (num > 0)
		count_digit(num, ++dig);
	else
		return dig;
}

int main(void) {
	ll N;
	int ans;

	cin >> N;
	ans = 100;
	for (ll A = 1; A * A <= N; ++A) {
		if (N % A != 0)
			continue;
		ll B = N / A;
		ll num = max(A, B);
		ans = min(ans, count_digit(num, 1));
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String s = sc.next();

        int max= 0;
        String ss[]=new String[n];
        for (int i=0;i<n;++i) ss[i]=s.substring(i,i+1);

        int tmp=0;
        for (int i=0;i<n;++i)
        {
            if (ss[i].equals("I")) ++tmp;
            else if (ss[i].equals("D")) --tmp;

            if (max<tmp)
            {
                max = tmp;
            }
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 21716
import java.util.*;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		int[] a = new int[N];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			a[i] = sc.nextInt();
		}
		boolean[][] map = new boolean[H][W];
		for(int i = 0; i < N; i++) {
			if(a[i] == 1) {
				for(int j = 0; j < x[i]; j++) {
					for(int k = 0; k < H; k++) {
						map[k][j] = true;
					}
				}
			} else if(a[i] == 2) {
				for(int j = x[i]; j < W; j++) {
					for(int k = 0; k < H; k++) {
						map[k][j] = true;
					}
				}
				
			} else if(a[i] == 3) {
				for(int j = 0; j < W; j++) {
					for(int k = 0; k < y[i]; k++) {
						map[k][j] = true;
					}
				}
			} else {
				for(int j = 0; j < W; j++) {
					for(int k = y[i]; k < H; k++) {
						map[k][j] = true;
					}
				}
			}
		}
		int sum = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(map[i][j]) sum++;
			}
		}
		System.out.println(H * W -sum);
		
	}
}

Measured memory_bytes: 24532
#include<bits/stdc++.h>
#define ull usigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    ll dp[n+1][m+1];
    dp[0][0]=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
                continue;
            }
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else if(s[i-1]!=t[j-1])
            {
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    ll count=dp[n][m];
    vector<char>v;
    ll a=n,b=m;
   while(a>0 && b>0 && count>0)
   {
       if(s[a-1]==t[b-1])
       {
           v.push_back(s[a-1]);
           a--;
           b--;
           continue;
       }
       else if(dp[a-1][b]>dp[a][b-1])
       a--;
       else
       {
           b--;
       }
       
   }

    for(int i=v.size()-1;i>=0;i--)
    cout<<v[i];


    
    return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};
int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        --x;--y;
        uf.unite(x,y);
    }
    int ans=0;
    rep(i,n)if(uf.find(i)==i)++ans;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
As = list(mapint())
from itertools import accumulate

for _ in range(K):
    lamps = [0]*N
    for i, a in enumerate(As):
        lamps[max(0, i-a)] += 1
        if i+a+1<=N-1:
            lamps[i+a+1] -= 1
    As = list(accumulate(lamps))
    if sum(As)==N**2:
        break
print(*As)

Measured memory_bytes: 196256
n=int(input())
a_list = list(map(int,input().split()))
index_list = []
for i in range(n):
    tmp_list = []
    tmp_list.append(i+1)
    tmp_list.append(a_list[i])
    index_list.append(tmp_list)
index_list.sort(key=lambda x:x[1])
ans_list = []
for j in range(len(index_list)):
    ans_list.append(index_list[j][0])
print(*ans_list)

Measured memory_bytes: 25156
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6

using namespace std;

//2で割る回数の判定
long wareru2 (long n){
    long ans=0;
    for(int i=0;n%2==0;ans++){
        n/=2;
    }
    return ans;
}


int main(){
    long n;
    cin >> n;
    long ans=0;
    for(int i=0;i<n;i++){
        long a;
        cin >> a;
        ans+=wareru2(a);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


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

const int N=200005;


void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {cin>>a[i];
        a[i]--;
    }
    bool visited[n]={0};
    //visited[0]=1;
    int j=0;//int last=0;
    while(!visited[j])
    {
        visited[j]=1;
        //last=j;
        j=a[j];
        k--;
        if(k==0)
        {
            cout<<j+1<<endl;
            return;
        }
    }
    //debug(j);
    int i=a[j],cnt=0;
    while(i!=j)
    {
        cnt++;
        i=a[i];
    }
  //  debug(cnt);
    k=k%(cnt+1);
    while(k)
    {
        j=a[j];
        k--;
    }
    cout<<j+1<<endl;
    
    
    
    
    
}

int32_t main()
{
    IOS;
   
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

int main() {
	string s; cin>>s;
	int n = s.size();
	vector oldv(2019,0);
	ll sum2{};
	for(int i=0; i<n; i++){
		vector newv(2019,0);
		newv.at(s.at(i)-'0')++;
		for(int j=0; j<2019; j++){
			int sum = j*10 + s.at(i)-'0';
			sum %= 2019;
			newv.at(sum) += oldv.at(j);
			
		}
		sum2 += newv.at(0);
		oldv = newv;
	}
	cout << sum2 << endl;
}


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

namespace AtCoder.Abc
{
    class A_167_Registration
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string a = Console.ReadLine();
            string b = Console.ReadLine();

            if (Regex.IsMatch(b, a + "."))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26872
(w, h, x, y, r) = input().split(' ')
w = int(w)
h = int(h)
x = int(x)
y = int(y)
r = int(r)

if 0 + r <= x <= w - r and 0 + r <= y <= h - r:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7696
n, m, X, Y=map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))
x.sort()
y.sort()

Z_start=x[-1]+1
Z_end=y[0]

for z in range(Z_start, Z_end+1):
    if X<z<=Y:
        print("No War")
        exit()

print("War")

Measured memory_bytes: 8984
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

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

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(usize);
    let As = get!(usize | );
    let mut As = As.iter().map(|&x| x == 1).collect::<Vec<_>>();
    let mut left = N >> 1;
    for i in (0..left).rev() {
        for k in 2..(N+1) {
            if k*(i+1) > N {
                break;
            }
            if As[k*(i+1)-1] {
                As[i] = !As[i];
            }
        }
    }
    let mut cnt = 0;
    let mut res = Vec::new();
    for (i, &a) in As.iter().enumerate() {
        if a {
            cnt += 1;
            res.push(i+1);
        }
    }
    println!("{}", cnt);
    for r in res {
        print!("{} ", r);
    }
    println!("");
}


Measured memory_bytes: 7164
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10=1024,X11=2048,X12=4096,X13=8196,X14=16392,X15=32786,X16=65536,X17=131072,X18=262144,X19=524288,X20=1048576;

pair<int,int> f(int a1,int a2,int a3){
    return {a1-a2,a2-a3};
};
int A[3];
void _(){
   int n;
   ll sum = 0;
   cin >> n;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        sum+=t;
    }
    cout << sum-n;
}






int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[(int)1e5 + 100][5];
ll dp[(int)1e5 + 100][5];
int main(){
	int n;
	cin>>n;
	for(int i = 1;i<=n;i++){
		cin>>arr[i][1]>>arr[i][2]>>arr[i][3];
	}
	dp[1][1] = arr[1][1];
	dp[1][2] = arr[1][2];
	dp[1][3] = arr[1][3];
	for(int i = 2;i<=n;i++){
		dp[i][1] = max(dp[i - 1][2], dp[i - 1][3]) + arr[i][1];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][3]) + arr[i][2];
		dp[i][3] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][3];
	}
	cout<<max(max(dp[n][1], dp[n][2]), dp[n][3]);

	return 0;
}

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

int main() {
    //freopen("input1.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i=0; i<n; i++)
        cin >> a[i] >> b[i] >> c[i];
    vector<vector<int>> dp(n, vector<int>(3));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i=1; i<n; i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    return 0;
}

Measured memory_bytes: 9772
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = 3.1415926535897932384626;
const int SIZE = 1 << 17;

long long  gcd(long long  a, long long  b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

int main() {
	long long n, k[100005];
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	long long ans = gcd(k[0], k[1]);
	for (int i = 2; i < n; ++i) {
		ans = gcd(ans, k[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int main()
{
    int n; int d; int x; int day[10000]={}; int count =0;
    cin >>n >>d >>x;
    for (int i=0; i<n; i++)
    {
        cin>> day[i];
    }
   
    if (d-1>=0)
    {
        count=count+n;
    }
    
    for (int i=0; i<n; i++)
    {
        for (int k=1; k<=d; k++)
        {
            if (d-(k*day[i])-1>=0)
            {
                count+=1;
            }
        }
    }
   
    if (d-1<0)
    {
        cout<<x;
    }
    else
    {
        cout<<count+x;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
	int n, a[10], i, j, m;
	while(scanf("%d", &n) != 0){
		if(n == 0) break;
		for(i = 0; i < 10; i++) a[i] = 0;
		for(i = 0; i < n; i++){
			scanf("%d", &m);
			a[m]++;
		}
		for(i = 0; i < 10; i++){
			if(a[i] == 0){
				printf("-");
				
			}else{
				for(j = 0; j < a[i]; j++) printf("*");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 568
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char[] c_array = s.toCharArray();
		Map<Character, Integer> counter = new HashMap<Character, Integer>();
		for (char c : c_array) {
			counter.put(c, counter.get(c) == null?1:counter.get(c) + 1);
		}
		int flag = 0;
		for (char key : counter.keySet()) {
			if (counter.get(key) % 2 != 0) {
				flag = 1;
			}
		}
		if (flag == 1) {
			System.out.println("No");
		}
		else 
			System.out.println("Yes");
	}
}

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

using namespace std;
typedef long long ll;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt = min(a, k), ans = min(a, k);
    if (cnt < k) cnt += min(k - cnt, b);
    if (cnt < k) ans -= k - cnt, cnt = k;
    cout << ans << "\n";
}


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

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  ll n,k;
  cin >> n >> k;
  cout << min(n%k,k - n%k) << endl;
}

Measured memory_bytes: 256
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	string s,t;
	cin>>s>>t;

	int n=s.length();
	int m=t.length();

	int Min=INT_MAX;

	for(i=0;i<=n-m;i++)
	{
		int cnt=0;
		string temp=s.substr(i,m);
		d(temp);
		for(j=0;temp[j];j++)
		{
			if(t[j]!=temp[j])
			{
				cnt++;
			}
		}
		Min=min(Min,cnt);
	}

	cout<<Min<<endl;

}

Measured memory_bytes: 3664
#include<iostream>  
#include<cmath>
#include<string>
#include<stack>
#include<queue> 
#include<algorithm>
#include<stdlib.h> 
#include<ctime>
#include<iomanip>
#include<vector>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	if(a<=b)
		cout<<min(b-a,a);
	else{
		a-=((a-b)/b)*b;
		while(a>b)
			a-=b;
		cout<<min(b-a,a);
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <set>

int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> a(n), deg(n);
  std::set<int> left;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    ++deg[--a[i]];
    left.insert(i);
  }

  int forbid = -1;
  
  auto check = [&](int x) {
    if (x == forbid) return false;
    int y = a[x];
    if (!left.count(y)) {
      if (left.size() == 3) {
        int u = -1, v = -1;
        for (auto &e: left) if (e != x) {
          if (u == -1) u = e;
          else v = e;
        }
        if (a[u] == v && a[v] == u) return false;
      }
      return true;
    }
    if (x == a[y]) {
      if (deg[x] == 1 && deg[y] == left.size() - 1) return false;
    } else {
      int z = a[y];
      if (!left.count(z)) return deg[y] != left.size() - 1;
      if (y != a[z]) return true;
      if (deg[z] == 1 && deg[y] == left.size() - 1) return false;
    }
    return true;
  };

  std::vector<int> b(n, -1);
  for (int i = 0; i < n; ++i) {
    for (auto it = left.begin(); it != left.end(); ++it) {
      if (check(*it)) { b[i] = *it; break; }
    }
    if (b[i] == -1) break;
    forbid = a[b[i]];
    --deg[forbid];
    left.erase(b[i]);
  }
  if (b.back() == -1) puts("-1");
  else {
    for (auto &x: b) printf("%d ", x + 1);
    puts("");
  }
  return 0;
}


Measured memory_bytes: 6656
import itertools
from bisect import bisect_right

num_lst = []
for i in range(10):
    for lst in itertools.product(["3", "5", "7"], repeat=i):
        if ("3" not in lst) or ("5" not in lst) or ("7" not in lst):
            continue
        num_lst.append(int("".join(lst)))
num_lst.sort()

n = int(input())
print(bisect_right(num_lst, n))


Measured memory_bytes: 10148
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)

readTuple4 :: IO (Int, Int, Int, Int)
readTuple4 = do
    [a, b, c, d] <- readInts
    return (a, b, c, d)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

numList :: Int -> Int -> Int -> [[Int]]
numList mini maxi 0 = do
    n <- [mini..maxi]
    pure [n]

numList mini maxi len = do
    n <- [mini..maxi]
    latter <- numList n maxi (len - 1)
    pure $ n : latter

solve :: Int -> Int -> Int -> [(Int, Int, Int, Int)] -> Int
solve n m q points = let
    calcPoint al (a, b, c, d) = if al A.! b - al A.! a == c then d else 0
    calcPoints ax = let
        al :: UA.UArray Int Int
        al = A.listArray (1, n) ax
        in
        sum $ calcPoint al <$> points
    axCandi = numList 1 m  n
    in
    maximum $ calcPoints <$> axCandi

main :: IO ()
main = do
    (n, m, q) <- readTuple3
    points <- replicateM q readTuple4
    print $ solve n m q points


Measured memory_bytes: 6608
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <map>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 90001

using namespace std;

bool check(int a)
{
	auto str = to_string(a);
	
	for (int i = 0; i < str.length() / 2; i++)
	{
		if (str[i] != str[str.length() - 1 - i])
			return false;
	}

	return true;
}

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	int a, b; cin >> a >> b;
	int ret = 0;
	while (a <= b)
	{
		if (check(a))
			ret += 1;
		a += 1;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define y1 Emilia
#define N 400400
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n, m, v, p;

int a[N];


bool good(int x) {
    if (a[x] + m < a[p])
        return false;
    ll res = m * 1ll * (p - 1) + m * 1ll * (n - x);
    for (int i = p; i <= x; ++i)
        res += 1ll * (a[x] + m - a[i]);
    
    return res >= m * 1ll * v;
}

int main() {
    dracarys
    cin >> n >> m >> v >> p;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    
    sort (a + 1, a + n + 1);
    reverse (a + 1, a + n + 1);
    
    int l = 1, r = n, res = -1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (good(mid)) {
            res = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int n;
	int a, b;
	int a_sum, b_sum;
	int i;
	
	while (1){
		a_sum = b_sum = 0;
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &a, &b);
			
			if (a > b){
				a += b;
				b = 0;
			}
			else if (a < b){
				b += a;
				a = 0;
			}
			a_sum += a;
			b_sum += b;
		}
		printf("%d %d\n", a_sum, b_sum);
	}
	
	return (0);
}

Measured memory_bytes: 600
n=int(input())
a=list(map(int,input().split()))
k=0
N=sum(a)
failflag=0
node=1
min1=[]
min2=[]
for i in range(0,n+1):
  node=node*2-a[i]
  if i==0:
    node=1-a[0]
  node=min(node,N)
  min1.append(node+a[i])
  if node<0:
    failflag=1
if failflag==1:
  print(-1)
else:
  current=0
  for i in range(0,n+1):
    current+=a[n-i]
    min2.append(current)
  min2.reverse()
  ans=0
  for i in range(0,n+1):
    ans+=min(min1[i],min2[i])
  print(ans)

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

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

int N, X;

int x[100001];

// 最大公約数の取得
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

signed main(){
	cin >> N >> X;
	int xx;
	REP(i, 0, N) {
		scanf("%d", &xx);
		x[i] = abs(xx - X);
	}
	int ans;
	if(N == 1) ans = x[0];
	else {
		REP(i, 1, N) {
			ans = gcd(x[i - 1], x[i]);
			x[i] = ans;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s, t, s1, s2;
    cin >> s >> t;
    REP(i,s.length()){
        if (i % 2 == 0) s1 += s[i];
        else s2 += s[i];
    }
    int j1 = 0, j2 = 0;
    for (int i=0; i < t.length() && j1 < s1.length() && j2 < s2.length(); i++){
        if (t[i] == s1[j1]) j1++;
        if (t[i] == s2[j2]) j2++;
    }
    if (j1 == s1.length() || j2 == s2.length()) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3148
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

n = int(stdin.readline())
for _ in range(n):
    s = stdin.readline().strip()
    under = int(''.join(sorted(s)))
    upper = int(''.join(sorted(s, reverse=True)))
    print(upper - under)

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

int main() {
  int N, K;
  string S;
  cin >> N >> S >> K;
  
  for (int i = 0; i < N; ++i) {
    if (S[i] != S[K-1])
      S[i] = '*';
  }

  cout << S << endl;
}


Measured memory_bytes: 256
/* Nurgazy Zhandos */

#include <bits/stdc++.h>

#define F first
#define S second

#define pf push_front
#define pb push_back
#define mp make_pair
#define pp pop_back
#define in insert

#define up upper_bound
#define lb lower_bound

#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define sz(a) a.size()

#define nl '\n'

//#define int long long

using namespace std;

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

const int MAX_N = 1e5 + 123;
const int inf = 1e9 + 123;
const ll INF = 1e18 + 123;
const int NN = 2e6 + 123;
const double eps = 1e-9;
const int mod = 1e9 + 7;

/*void random() {
 		unsigned int FOR;
 		asm("rdtsc" : "=A" (FOR));
	srand(FOR);
}*/

inline void fre() {
	#ifdef TEZZY
//	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
	#endif
}

inline void boost() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
}

int rep(int n) {
 	int cnt = 0;

 	while(n) {
 	 	cnt += n % 10;
 	 	n /= 10;
 	}

 	return cnt;
}

main () {
	fre();
	boost();

	int n;
	cin >> n;

	int mn = inf;

	for(int i = 1; i <= n / 2 + 1; i++) {
		mn = min(mn, rep(i) + rep(n - i));
	}
	
	cout << mn;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
K=int(input())

count=0

for a in range(1,K+1):
    for b in range(a,K+1):
        for c in range(b,K+1):
            cal=math.gcd(math.gcd(a,b),c) 
            #print(cal)
            if a!=b and b!=c:
                count+=cal*6
            elif a==b==c:
                count+=cal
            else:
                count+=cal*3
            

print(count)

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

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
const int MOD = 1e9 + 7;


const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

void comInit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll com(int n, int r)
{
    if (n < r)
        return 0;
    if (n < 0 || r < 0)
        return 0;

    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

int hcomb(int n, int r)
{
    return com(n+r-1, r-1);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    comInit();

    int s;
    cin >> s;

    ll ans = 0;
    for(int i=1; s-i*3>=0; i++)
    {
        ans += hcomb(s-i*3, i)%MOD;
        ans += MOD;
        ans %= MOD;
    }

    cout << ans << endl;


    return 0;

}


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

using namespace std;

int main()
{
	int t1;
	t1=1;
	while(t1--)
	{
	

	long long int n,m,i,j,k,sum;
	
	long long int a[300000],dp[300000] {0};
	
	cin>>n;
	
	for(i=0;i<n;i++)
	cin>>a[i];
	
	dp[n-1]=0;
	for(i=n-2;i>=0;i--)
	{
		dp[i]= (dp[i+1]+a[i+1] ) % 1000000007;
		
	}
	
	sum=0;
	for(i=0;i<n-1;i++)
	{
		
		sum= (sum+ (a[i]*dp[i])%1000000007 )%1000000007;
		
	}
	
	cout<<sum<<endl;
	}



}


Measured memory_bytes: 7532
#include <stdio.h>

int A[100][100];
int b[100];

int main(void)
{
int n, m, i, j;
long sum;

scanf("%d %d", &n, &m);

for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
scanf("%d", &A[i][j]);
}
}

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

for (i = 0; i < n; i++)
{
sum = 0L;
for (j = 0; j < m; j++)
{
sum += (long)A[i][j] * (long)b[j];
}
printf("%ld\n", sum);
}

return 0;
}

Measured memory_bytes: 640
#ABK=list(map(int,input().split()))
import datetime

S=input()
comp1=datetime.datetime.strptime(S,"%Y/%m/%d")
comp2=datetime.datetime(2019,4,30,23,59,59)

if comp1<=comp2:
 print("Heisei")
else:
 print("TBD")

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

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)  rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

// using namespace std;

void solve(void)
{
//	std::string str{}; std::cin >> str;
	ull S{}; std::cin >> S;

	constexpr ull MOD = 1'000'000'000ULL;

	typedef std::pair<ull, ull> Pos;
	std::vector<Pos> p(3);
	p[0] = { 0, 0 };
	p[1] = { 1,MOD };
	p[2] = {};

	p[2].second = (MOD - S % MOD) % MOD;
	assert(p[2].second <= MOD);
	p[2].first = (S + p[2].second * p[1].first) / p[1].second;
	assert(p[2].first <= MOD);

	std::for_each(p.begin(), p.end(), [](auto pos) {
		std::cout << pos.first << " " << pos.second << " ";
		});

	std::cout << "\n";

	return;
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);

	solve();

	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
class union_find{
    public:
        int n;
        vector<T> p, rank;

        union_find(int n)
            : n(n), p(n+1, -1), rank(n+1) {}

        int find(int v){
            if(p[v] == -1){
                return v;
            }
            p[v] = find(p[v]);
            return p[v];
        }

        void unite(int u, int v){
            int u_root = find(u);
            int v_root = find(v);

            if(u_root == v_root){
                return;
            }

            if(rank[u_root] < rank[v_root]){
                swap(u_root, v_root);
            }

            if(rank[u_root] == rank[v_root]){
                rank[u]++;
            }

            p[v_root] = u_root;
        }
};

signed main(){
    int n, q;
    cin >> n >> q;

    vector<int> p(n, -1);

    union_find<int> uf(n);
    rep(i, q){
        int com, x, y;
        cin >> com >> x >> y;

        if(com == 0){
            uf.unite(x, y);
        }

        if(com == 1){
            int px = uf.find(x);
            int py = uf.find(y);

            cout << (px == py ? 1 : 0) << endl;
        }
    }

    return 0;
}



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

namespace AtCoder
{
	public class Program
	{
		// ABC105-C
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			long posi = 0, nega = 0, diff = N;

			long[] pattern = new long[64];
			long m = 1;
			for (long i = 0; i < pattern.Length; i++) {
				pattern[i] = m;
				m = (m << 1) | i % 2;
			}

			while (true) {
				if (diff == 0) {
					// 終了
					Console.WriteLine(Convert.ToString(posi + nega, 2));
					return;
				} else if (diff > 0) {
					// 正
					int i = 0;
					while (pattern[i] < diff) {
						i += 2;
					}
					posi += 1L << i;
				} else {
					// 負
					int i = 1;
					while (-1 * pattern[i] > diff) {
						i += 2;
					}
					nega += 1L << i;
				}
				diff = N - (posi + (-1 * nega));
			}
		}
	}
}



Measured memory_bytes: 11220