akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long INF = 1e7;
const long long N = 1e6 + 7;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;

ll T = 1, n, m, b, ans, a, cnt;
string s;
vector < ll > v, v1;
set< char > st;
int main(){
    TIME
    cin >> n >> a >> b;
    cnt = a + b;
    ans = n / cnt;
    cout << ans * a + min( n % cnt, a );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Maxn 200007
char s[Maxn],a[Maxn];
int n;
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    int m=0;
    for (int i=1;i<=n;i++)
        if (s[i]!='C') a[++m]=s[i];
        else if (m>0&&a[m]=='B') a[m]='D';
        else a[++m]=s[i];
    long long ans=0LL;
    int tmp=0;
    for (int i=m;i;i--)
        if (a[i]=='A') ans+=tmp;
        else if (a[i]=='D') ++tmp;
        else tmp=0;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4132
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

ll n,sum,ave,ans,ans1 = 0,ans2 = 0,ans3 = 0;
cin >> n;
vi v(n);
repll(i,n) cin >> v[i];
sum = accumulate(v.begin(),v.end(),0);
ave = sum / n;

repll(i,n) ans1 += pow((v[i]-ave),2);
repll(i,n) ans2 += pow((v[i]-ave-1),2);

ans = min(ans1,ans2);
cout << ans << endl;

//////////////////////////////////////////////////////
return 0;}

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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, W;
    cin>>n>>W;
    vector<int> w(n+1), v(n+1);
    vector<vector<long long int>> dp(n+1, vector<long long int> (W+1, 0));
    for(int i = 1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    for(int i = 1;i<=n;i++)
    {
        for(int j = 1;j<=W;j++)
        {
            if(j - w[i] >= 0)
            {
                dp[i][j] = max(dp[i-1][j - w[i]] + v[i], dp[i-1][j]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W]<<"\n";
    return 0;
}

Measured memory_bytes: 83124
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    
    int N;
    cin >> N;
    vector<int> ans(N, 0);
    
    for (int i = 0; i < N - 1; i++) {
        int X;
        cin >> X;
        ans[X-1]++;
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, X, Y; cin >> N >> X >> Y;
  X--; Y--;
  vector<int> line(N - 1, 0);
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      if(i <= X && j < Y) {
        int k = min(j - X, Y - j + 1) + X - i - 1;
        line.at(k)++;
      } else if(i <= X && Y <= j) {
        int k = j - i - (Y - X);
        line.at(k)++;
      } else if(X < i && Y <= j) {
        int k = min(i - X + 1, Y - i) + j - Y - 1;
        line.at(k)++;
      } else if(i > X && j < Y) {
        int k = min(1 + (Y - j) + (i - X), j - i);
        line.at(k - 1)++;
      } else {
        line.at(j - i - 1)++;
      }
    }
  }
  for(int i = 0; i < line.size(); i++) {
    cout << line.at(i) << endl;
  }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
if n%2==1:
  for i in range(m):
    print(n-i-1,i+1)
else:
  cnt=1
  for i in range(m):
    if i%2==0:
      print(n//4-i//2,n//4-i//2+cnt)
    else:
      print(n//2+n//4-i//2,n//2+n//4-i//2+cnt)
    cnt+=1


Measured memory_bytes: 9260
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,e,f,g,h;
	scanf("%d/%1d%1d/%1d%1d",&a,&e,&f,&g,&h);
	printf("%d/",a+1);
	printf("%d%d/",e,f);
	printf("%d%d",g,h);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	c := 0

	for i := 2; i < n; i++ {
		c ^= a[i]
	}

	x := (a[0] + a[1] - c) / 2
	c0, c1 := 0, 0

	for i := 0; i < 50; i++ {
		b := 1 << i
		if x&b != 0 {
			c0 += b
			c1 += b
		}
	}

	for i := 49; i >= 0; i-- {
		b := 1 << i
		if x&b == 0 {
			if c&b != 0 {
				if a[0] >= c0+b {
					c0 += b
				} else {
					c1 += b
				}
			}
		}
	}

	if c0 == 0 || a[0]-c0 < 0 || a[0]+a[1] != c0+c1 || c0^c1 != c {
		fmt.Fprintln(wr, -1)
	} else {
		fmt.Fprintln(wr, a[0]-c0)
	}

}


Measured memory_bytes: 1784
// <------------- Template -----------------------> //


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(2);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 
 
typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5]; 

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m, k;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //

ll factor(ll x) {
	vll f;
	for(ll i=1;i*i<=x;i++) {
		if(x%i == 0) {
			f.pb(i);
			f.pb(x/i);
		}
	}

	ll n = f.size();
	//DISP(f);
	return to_string(f[n-1]).length();
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n ;
	cout<<factor(n);
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 6096
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+1;
vector<int> es[L];
int N,u,v;
vector<int> st;
bool dfs(int r,int p){
	st.push_back(r);
	if(r==u){
		return true;
	}
	for(int e:es[r]){
		if(e==p)continue;
		if(dfs(e,r)){
			return true;
		}
	}
	st.pop_back();
	return false;
}
int dfs2(int r,int p){
	int d=0;
	for(int e:es[r]){
		if(e==p)continue;
		d=max(d,dfs2(e,r)+1);
	}
	return d;
}
int main() {
	cin >> N >> u >> v;
	for(int i=1;i<N;i++){
		int A,B;
		cin >> A >> B;
		es[A].push_back(B);
		es[B].push_back(A);
	}
	dfs(v,0);
	int r=(st.size()+1)/2;
	//cerr << r << ", " << st[r] << endl;
	//cerr << dfs2(st[r],st[r-1]) << endl;
	int d=r+dfs2(st[r],st[r-1]);
	cout << d-1 <<endl;



	return 0;
}



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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int n;
  vector<int> x(2*123456 + 1, 0);
  for(int i = 2; i < sqrt(x.size()); i++){
    if(x[i] == 0){
      for(int j = 2*i; j <= x.size(); j += i){
        x[j] = 1;
      }
    }
  }
  while(cin >> n, n){
     int ans = 0;
     for(int i = n + 1; i <= 2*n; i++){
      if(x[i] == 0)ans++;
     }
     cout << ans << endl;
  }
}

Measured memory_bytes: 3632
N, K, Q = gets.split.map(&:to_i)

data = Array.new(N, 0)

Q.times do
  data[gets.to_i - 1] += 1
end

data.each do |d|
  if K + d - Q > 0
    puts 'Yes'
  else
    puts 'No'
  end
end


Measured memory_bytes: 3196
#C - Energy Drink Collector(ABC121)
N,M=map(int, input().split())
X=[]
for i in range(N):
    a,b=map(int, input().split())
    X.append([a,b])
X.sort()
ans=0
i=0
while M>0:
    if M>=X[i][1]:
        ans+=X[i][1]*X[i][0]
        M-=X[i][1]
        i+=1
    else:
        ans+=X[i][0]*M
        break
print(ans) 

Measured memory_bytes: 20056
#include<set>
#include<deque>
#include<queue>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
void solve(int R,int ans[]){
	int W,H,X,Y,i,j,a,x,y,l;
	tuple<int,int,int> t;
	vector<vector<int>> lev;
	vector<vector<int>> floa;//false->????????¢?´¢???????????????true ?????\?????????
	priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>> que;//???????????????
	scanf("%d %d %d %d",&W,&H,&X,&Y);
	lev.resize(H+2);
	floa.resize(H+2);
	for(i=0;i<H+2;i++){ lev[i].resize(W+2);floa[i].resize(W+2); }
	for(i=0;i<H+2;i++){
		for(j=0;j<W+2;j++){
			floa[i][j]=0;
		}
	}
	for(i=0;i<W+2;i++){ lev[0][i]=big; }
	for(i=1;i<H+1;i++){
		lev[i][0]=big;
		for(j=1;j<W+1;j++){ scanf("%d",&a);lev[i][j]=a; }
		lev[i][W+1]=big;
	}
	for(i=0;i<W+2;i++){ lev[H+1][i]=big; }
	que.push(mt(1,Y,X));floa[Y][X]=1;
	if(R>W*H){
		for(i=W*H+1;i<=R;i++){
			ans[i]=big;
		}
		R=W*H;
	}
	for(i=1;i<=R;i++){
		t=que.top();
		l=get<0>(t);
		y=get<1>(t);
		x=get<2>(t);
		que.pop();
		if(floa[y+1][x]==0){ floa[y+1][x]=1;que.push(mt(lev[y+1][x],y+1,x)); }
		if(floa[y-1][x]==0){ floa[y-1][x]=1;que.push(mt(lev[y-1][x],y-1,x)); }
		if(floa[y][x+1]==0){ floa[y][x+1]=1;que.push(mt(lev[y][x+1],y,x+1)); }
		if(floa[y][x-1]==0){ floa[y][x-1]=1;que.push(mt(lev[y][x-1],y,x-1)); }
		ans[i]=max(l,ans[i-1]);
	}
	return;
}
bool Q(void){
	int ans=big,i,R;
	static int keia[100001]={0};//1????????????????????§i????¨?????????????????????????????¨???¬??????
	static int keib[100001]={0};//2???)ry
	scanf("%d",&R);
	if(R==0){
		return false;
	}
	solve(R,keia);
	solve(R,keib);
	for(i=0;i<=R;i++){
		ans=min(ans,keia[i]+keib[R-i]);
	}
	printf("%d\n",ans);
	return true;
}
int main(void){while(Q()){}return 0;}

Measured memory_bytes: 5472
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,ans=0;
    cin>>n;
    ll arr[10][10]={};
    for(i=1;i<=n;i++){
        ll temp=i;
        while(1){
            if(temp/10==0)
                break;
            temp/=10;
        }
        arr[i%10][temp]+=1;
    }
    for(i=1;i<=n;i++){
        ll temp=i;
        while(1){
            if(temp/10==0)
                break;
            temp/=10;
        }
        ans+=arr[temp][i%10];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *		author:  zvm
 *		created: 28.09.2020 10:18:12
**/

#include <bits/stdc++.h>

using namespace std ;

const int mxN = 16001 ;

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

	string s ;
	cin >> s ;
	
	int x, y ;
	cin >> x >> y ;

	int n = s.size();
	vector<vector<int>> move(2);

	int dir = 0, steps = 0 ;
	for( int i = 0 ; i < n ; ++i ) {
		if( s[i] == 'T' ) {
			move[dir].push_back(steps);
			steps = 0 ;
			dir ^= 1 ;
		}
		else {
			steps++ ;
		}
	}
	move[dir].push_back(steps);

	int N = move[0].size();
	int M = move[1].size();
	
	bitset<mxN> dpx, dpy ;

	dpx[n+move[0][0]] = true ;
	dpy[n] = true ;

	for( int i = 1 ; i < N ; ++i ) {
		dpx = (dpx<<move[0][i]) | (dpx>>move[0][i]) ;
	}
	for( int i = 0 ; i < M ; ++i ) {
		dpy = (dpy<<move[1][i]) | (dpy>>move[1][i]) ;
	}

	cout << ( dpx[n+x] && dpy[n+y] ? "Yes" : "No" ) << endl ;
}


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

int main() {
  std::string x(3, ' ');
  scanf("%s", &x[0], x.size());
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (x[i] == '1') cnt++;
  }
  printf("%d", cnt);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	c -= b;
	
	if(c > a) printf("dangerous\n");
	else if(c > 0) printf("safe\n");
	else printf("delicious\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

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


ll a[3];
int main(){
	REP(i,3){
		cin>>a[i];
		if(a[i]%2==0){
			cout<<0<<endl;
			return 0;
		}
	}
	sort(a,a+3);
	cout<<a[0]*a[1]<<endl;
	return 0;
}
			

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double r;
	double n, m;
	
	scanf("%lf", &r);
	
	m = r * r * 3.141592653589;
	n = r * 2 * 3.141592653589;
	
	printf("%f %f\n", m, n);
	
	return (0);
	
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

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

ll A,B,C,D;

int main()
{
	scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
	if(A == C || B == D){
		printf("0\n");
		return 0;
	}

	ll g = gcd(abs(A - C),abs(B - D));
	ll x = abs(A - C) / g,y = abs(B - D) / g;

	printf("%lld\n",(x + y - 1) * g);

	return 0;
}


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

using namespace std;
typedef long long ll;
const int N=1e6+10;
int a[N];
int b[N];
int s[N];
int vis[N];
map<int,int> mp;
const int maxn=1e6+10;
int prime[maxn];      //就是个素数表
bool sf[maxn];        //判断这个数是不是素数，sf[i]中的i是从1到maxn的数
void sushu(){         //核心 欧拉筛代码
    int num=0;        //num 用来记筛到第几个质数
    memset(sf,true,sizeof(sf));
    for(int i=2;i<=maxn;i++){          //外层枚举1~maxn
        if(sf[i]) prime[++num]=i;      //如果是质数就加入素数表
        for(int j=1;j<=num;j++){       //内层枚举num以内的质数
            if(i*prime[j]>maxn) break; //筛完结束
            sf[i*prime[j]]=false;      //筛掉...
            if(i%prime[j]==0) break;   //避免重复筛
        }
    }
   // cout<<num<<endl;
    sf[1]=false;
    sf[0]=false;  //1 0 特判
}

int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
int main()
{
    memset(vis,0,sizeof(vis));
    sushu();
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) b[i]=a[i];
    memset(s,0,sizeof(s));
    int flag=0;
    for(int i=1;i<=n;i++){
            if(flag) break;
        for(int j=1; ;j++){
            if(prime[j]*prime[j]>a[i]) break;

            if(a[i]%prime[j]==0){
                if(mp[prime[j]]){
                    flag=1;
                    break;
                }
                mp[prime[j]]=1;
                while(a[i]%prime[j]==0){

                a[i]/=prime[j];

                }
            }

            if(a[i]==1) break;
        }
        if(a[i]!=1){
            if(mp[a[i]]){
                flag=1;
                break;
            }
            mp[a[i]]=1;
        }

    }
    if(flag==0){
        cout<<"pairwise coprime"<<endl;
    }
    else{
            for(int i=1;i<=n;i++) a[i]=b[i];
            int ans=a[1];
            for(int i=2;i<=n;i++){
                ans=gcd(ans,a[i]);
            }
            if(ans==1) cout<<"setwise coprime"<<endl;
            else cout<<"not coprime"<<endl;
    }

}



Measured memory_bytes: 20428
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N);
	int m_index = 0;
	int M_index = 0;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		if (v[m_index] > v[i]) {
			m_index = i;
		}
		if (v[M_index] < v[i]) {
			M_index = i;
		}
	}
	vector<pair<int, int>>ans;
	if (abs(v[m_index]) < abs(v[M_index])) {
		ans.push_back({ M_index + 1,N });
		ans.push_back({ M_index + 1,N });
		for (int i = 2; i <= N; i++) {
			ans.push_back({ N,N });
			ans.push_back({ N,i });
		}
	}
	else {
		ans.push_back({ m_index + 1,1 });
		ans.push_back({ m_index + 1,1 });
		for (int i = N - 1; i >= 1; i--) {
			ans.push_back({ 1,1 });
			ans.push_back({ 1,i });
		}
	}
	cout << ans.size() << endl;
	for (auto i : ans) {
		cout << i.first << " " << i.second << endl;
	}
	return 0;
}

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

int main()
{
  int i,j,k;
  int X;
  int syou;
  int amari;

  scanf("%d",&X);
  syou = X/100;
  amari = X%100;
  
  if( amari > (5*syou) ){
    printf("0\n");
    //return 0;
  }
  else{
    printf("1\n");  
  }
  
  
  return 0; 
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cassert>

using namespace std;

struct edge { int to, cost; };
typedef pair<int, int> P;

const int MAX_V = 10000;
const int INF = 1 << 28;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

int prim(){
	int res = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	for(int s = 0;s < V; ++s) {
		if(d[s] != INF) continue;
		d[s] = 0;
		que.push(P(0, s));
		while(!que.empty()){
			P p = que.top(); que.pop();
			int v = p.second;
			if(d[v] < p.first) continue;
			d[v] = -1;
			res += p.first;
			for(int i=0;i<G[v].size();i++){
				edge e = G[v][i];
				if(d[e.to] > e.cost){
					d[e.to] = e.cost;
					que.push(P(e.cost, e.to));
				}
			}
		}
	}
	return res;
}

int main(){
	int E;
	cin >> V >> E;
	for(int i=0;i<E;i++){
		int s, t, w;
		cin >> s >> t >> w;
		assert(0 <= s && s < V);
		assert(0 <= t && t < V);
		G[s].push_back((edge){t, w});
		G[t].push_back((edge){s, w});
	}
	cout << prim() << endl;
	return 0;
}

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

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

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    long long i, j, k, n, m, t, x, y, z, s=0, c=0, l;
    cin >> n;
    int a[2][n];
    for(i=0; i<2; i++)
    {
        for(j=0; j<n; j++)
            cin >> a[i][j];
    }
    for(i=0; i<n; i++)
    {
        c=0;
        for(j=0; j<=i; j++)
            c+=a[0][j];
        for(j=i; j<n; j++)
            c+=a[1][j];
        if(c>s)
            s=c;
    }
    cout << s << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int a[3010];
    cin >> N;
    rep(i,0,N){
        cin >> a[i];
    }
    ll ans = 0;
    rep(i,0,N){
        ans += a[i];
    }
    ans -= N;
    print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
ll C, D, W, X;
ll E[16][31], F[16][31];
ll memo[31][51][6];
const int dx[] = {-1, 1};
 
ll solve(ll d, ll w, ll x)
{
    if (d == D) return 0;
 
    ll &res = memo[d][w][x];
    if (res != -1) return res;
   
    res = 0;
    res = max(res, solve(d+1, w, x));
 
    for (int i = 0; i < C; i++) {
        if (w + F[i][d] <= W && E[i][d] != 0) {
            res = max(res, solve(d+1, w + F[i][d], x) + E[i][d]);      
        }    
    }
 
    if (x+1 <= X) {
        for (int i = 0; i < C; i++) {
            for (int j = 0; j < 2; j++) {
                ll nx = i, cost = 0, f = 0;
                while (1) {
                    if (nx < 0 || nx >= C || E[nx][d] == 0) break;
                    f += F[nx][d];
                    cost += E[nx][d];
                    if (w + f <= W) {
                        res = max(res, solve(d+1, w + f, x+1) + cost);
                    }
                    nx += dx[j];
                }
            }   
        }
    }
    return res;
}
 
int main()
{
    while (cin >> C >> D >> W >> X, C) {
        for (int i = 0; i < C; i++) {
            for (int j = 0; j < D; j++) {
                cin >> E[i][j];
            }
        }
 
        for (int i = 0; i < C; i++) {
            for (int j = 0; j < D; j++) {
                cin >> F[i][j];
            }
        }
 
        memset(memo, -1, sizeof(memo));
     
        ll res = solve(0, 0, 0);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

vector<int> subset_sum(vector<int> &a, vector<int> &m, int K) {
    vector<int> dp(K + 1, -1);
    dp[0] = 0;
    for (int i = 0; i < a.size(); ++i) {
        for (int j = 0; j <= K; ++j) {
            if (dp[j] >= 0) dp[j] = m[i];
            else if (j < a[i] || dp[j - a[i]] <= 0) dp[j] = -1;
            else dp[j] = dp[j - a[i]] - 1;
        }
    }
    return dp;
}

void _main() {
    int N, R;
    cin >> N >> R;
    vector<int> P(N), used(N, 0);
    REP (i, N) {
        cin >> P[i];
        P[i]--;
    }
    map<int, int> mp;
    REP (i, N) if (!used[i]) {
        vector<int> v(1, P[i]);
        while (v.back() != i) {
            used[v.back()] = 1;
            v.push_back(P[v.back()]);
        }
        if (v.size() > 1) mp[v.size()]++;
    }
    if (R > N - R) R = N - R;
    if (mp.size() == 0) {
        cout << "Yes" << endl;
    } else {
        int sum = 0;
        vector<int> a, m;
        for (auto p : mp) {
            a.push_back(p.first);
            m.push_back(p.second);
            sum += a.back() * m.back();
        }
        auto dp = subset_sum(a, m, R);
        int tmp = 0;
        for (int i = R; i > 0; --i) if (dp[i] >= 0) {
            tmp = i;
            break;
        }
        cout << (sum - tmp <= N - R ? "Yes" : "No") << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 11548
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    cin >> a >> b;
    int dif = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] < b[i]) {
            dif += (b[i] - a[i]) / 2;
        } else {
            dif -= (a[i] - b[i]);
        }
    }
    cout << (dif >= 0 ? "Yes" : "No") << endl;
}


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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							 \
			cout.tie(0);
#define PI 3.141592654

using namespace std;

using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 9;

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; }return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
void add(ll& x, ll v) { x = (x + v) % MOD; if (x < 0) x += MOD; }
//ll f[500005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }


void test_case() {

}


int main() {
	fastio;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	ll a;
	string b;
	cin >> a >> b;
	b.erase(b.end() - 3);
	ll c = (ll)stoi(b);
	cout << a * c / 100;
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cmath>

using namespace std;

int main(void){
    long long p[60]={0};
    long long n,a;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        for(int j=0;j<60;j++){
            p[j]+=a%2;
            a=a/2;
        }
    }
    long long ans=0;
    for(int i=0;i<60;i++){
        long long ind=1;
        for(int j=0;j<i;j++){
            ind=(ind*2)%(long long)(1000000007);
        }
        ans=(ans+(p[i]*(n-p[i])%(long long)(1000000007))*ind)%(long long)(1000000007);
    }
    cout << ans;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            T = [L[i], L[j], L[k]]
            T.sort()
            if T[0] != T[1] and T[1] != T[2]:
                if T[2] < T[0]+T[1]:
                    ans += 1
print(ans)


Measured memory_bytes: 68216
use std::cmp::max;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize);
    parse!(it, a: [i64; n]);
    let mut memo = vec![vec![0, 0]; n];
    fn get(memo: &mut Vec<Vec<i64>>, i: usize, n: usize, pat: usize, a: &Vec<i64>) -> i64 {
        if memo[i][pat] != 0 {
            return memo[i][pat];
        }
        match (n - i, pat) {
            (2, 0) => return max(a[i], a[i + 1]),
            (3, 0) => return max(a[i], max(a[i + 1], a[i + 2])),
            (3, 1) => return a[i] + a[i + 2],
            (4, 0) => return max(get(memo, i + 2, n, 0, a) + a[i], a[i + 1] + a[i + 3]),
            _ => (),
        }
        if (n - i) % 2 == 1 {
            if pat == 1 {
                let ret = get(memo, i + 2, n, 1, a) + a[i];
                memo[i][pat] = ret;
                ret
            } else {
                let ret = max(
                    get(memo, i + 2, n, 0, a) + a[i],
                    get(memo, i + 3, n, 0, a) + a[i + 1],
                );
                let ret = max(ret, get(memo, i + 2, n, 1, a));
                memo[i][pat] = ret;
                ret
            }
        } else {
            let ret = max(
                get(memo, i + 2, n, 0, a) + a[i],
                get(memo, i + 3, n, 1, a) + a[i + 1],
            );
            memo[i][pat] = ret;
            ret
        }
    }
    println!("{}", get(&mut memo, 0, n, 0, &a));
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 24508
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;

const int maxn = 1<<19;
int N, Q, V[maxn], W[maxn];
int depth[maxn];
ll dp[550][100001];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> V[i] >> W[i];
        depth[i] = depth[i/2] + 1;
    }
    for (int i = 1; i <= N; i++) {
        if (depth[i] > 9) break;
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = dp[i/2][j];
            if (W[i] <= j) dp[i][j] = max(dp[i][j],dp[i/2][j-W[i]]+V[i]);
            if (j) dp[i][j] = max(dp[i][j],dp[i][j-1]);
        }
    }
    cin >> Q;
    while (Q--) {
        int v, L; cin >> v >> L;
        if (depth[v] <= 9) {
            cout << dp[v][L] << '\n';
        }
        else {
            vector<pair<int,int>> vv;
            do {
                vv.push_back({V[v],W[v]});
                v /= 2;
            } while (depth[v] > 9);
            int n = vv.size();
            ll ans = 0;
            for (int i = 0; i < (1<<n); i++) {
                ll val = 0, wt = 0;
                for (int j = 0; j < n; j++) {
                    if (i & (1<<j)) {
                        val += vv[j].first;
                        wt += vv[j].second;
                    }
                }
                if (wt > L) continue;
                ans = max(ans,dp[v][L-wt]+val);
            }
            cout << ans << '\n';
        }
    }
}


Measured memory_bytes: 405980
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int K;
  cin >> K;

  vector<int> cnt(K+1);

  int now = 0;
  REP(i, K+10){
    now *= 10;
    now += 7%K;
    now %= K;

    if(now == 0){
      cout << i+1 << "\n";
      return 0;
    }
  }

  cout << -1 << "\n";

  return 0;
}


Measured memory_bytes: 11116
# -*- coding: utf-8 -*-
# 入力
a, b = map(int, input().split())

# 処理

# 前月までは必ず１日ずつある
ans = a - 1
# 当月はその日付が月以上ならばあったことになる
if b >= a:
    ans += 1

# 出力
print("{}".format(ans))


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,h,w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << "\n";

    return 0;
}

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



using namespace std;


int main()
{

   long long int a,r1;
   double b,r2;
    cin>>a;
    r1=a/2;
    r2=(double)a/2;
    if(r1==r2)
    {
        cout<<r1*r1;
    }
    else
    {
        cout<<((r1+1)*r1);
    }



    return 0;
}


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

int main(){
    int N,M,X,Y; cin >> N >> M >> X >> Y;
    int A,B;
    int ans=0;
    int maxA=-1e9;
    int minB=1e9;
    rep(i,N){
        cin >> A; maxA=max(A,maxA);
    }
    rep(i,M){
        cin >> B; minB=min(B,minB);
    }
    for (int i=X+1; i<=Y; i++){
        if(i>maxA && i<=minB) ans=1;
    }
    if(ans==1) cout <<"No War";
    else cout << "War";

    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn=2e5+100;
int st[maxn][70],a[maxn];
int n,pos=1;
ll m;
void bz(){
	int len=log2(m);
	for(int i=1;i<=n;i++) st[i][0]=a[i];
	for(int i=1;i<=len;++i){
		for(int j=1;j<=n;++j){
			st[j][i]=st[st[j][i-1]][i-1];
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;++i) cin>>a[i];
	bz();
	for(int i=0;i<64;i++){
		if(1&(m>>i)){
			pos=st[pos][i];
		}
	}
	cout<<pos<<endl;
}


Measured memory_bytes: 58776
n = int(input())
a = list(map(int, input().split()))

d = {}
for x in a:
    if x in d:
        d[x] += 1
    else:
        d[x] = 1

d = sorted(d.items())

m = len(d)

if m == 1:
    print(d[0][1])
    exit()
elif m == 2:
    if d[1][0] - d[0][0] <= 2:
        print(d[0][1] + d[1][1])
    else:
        print(max(d[0][1], d[1][1]))
    exit()

ans = d[0][1]
if d[1][0] == d[0][0] + 1:
    ans += d[1][1]
r = d[m-1][1]
if d[m-2][0] == d[m-1][0] - 1:
    r += d[m-2][1]
ans = max(r, ans)

for i in range(1, m-1):
    r = d[i][1]
    if d[i-1][0] + 1 == d[i][0]:
        r += d[i-1][1]
    if d[i+1][0] - 1 == d[i][0]:
        r += d[i+1][1]
    ans = max(ans, r)


print(ans)



Measured memory_bytes: 15520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, count = 0;
  cin >> A >> B;
  
  string num_to_str;
  for (A; A <= B; A++) {
    num_to_str = to_string(A);
    if ((num_to_str[0] == num_to_str[4]) &&
        (num_to_str[1] == num_to_str[3])) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
S = input()
S_rvs = S[::-1]
N = len(S)
left = int((N-1)/2)
right = int((N+3)/2-1)

if S == S_rvs and S[:left] == S_rvs[right:] and S[right:] == S_rvs[:left]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
S = input()
N = len(S)
slist = []
solvelist = []
for i in range(N):
    slist.append(S[i])

solvelist.append(S[0])
for i in range(N-1):
    if slist[i] == slist[i + 1]:
        pass
    else:
        solvelist.append(S[i+1])

ans = len(solvelist) - 1

print(ans)

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

int main() {
  string s,t;
  cin >> s >> t;
int ans=0;
  for(int i=0;i<s.length();i++){
      if(s[i]!=t[i]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3916
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0001
 */
#include <iostream>
#include <vector>
#include <algorithm>
#define COUNT 10

using namespace	std;

int
main()
{
	vector<int> heights(COUNT);
	for (int i = 0; i < COUNT; i++) {
		cin >> heights[i];
		cin.ignore();
	}
	sort(heights.begin(), heights.end(), greater<int>());
	for (int i = 0; i < 3; i++)
	  cout << heights[i] << endl;
	return 0;
}

Measured memory_bytes: 3116
n = input()
km = int(input())
dp1 = [[0] * (4) for _ in range(len(n) + 1)]
dp2 = [[0] * (4) for _ in range(len(n) + 1)]
dp1[0][0] = 1
for i in range(len(n)):
    for j in range(4):
        if n[i] == '0':
            dp1[i + 1][j] += dp1[i][j]
            dp2[i + 1][j] += dp2[i][j]
        else:
            dp2[i + 1][j] += dp1[i][j]
            dp2[i + 1][j] += dp2[i][j]
        if j < 3:
            for k in range(1, ord(n[i]) - ord('0')):
                dp2[i + 1][j + 1] += dp1[i][j]
            if n[i] != '0':
                dp1[i + 1][j + 1] += dp1[i][j]
            for k in range(1, 10):
                dp2[i + 1][j + 1] += dp2[i][j]
print(dp1[len(n)][km] + dp2[len(n)][km])


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
#include <climits>
using namespace std;

typedef long long ll;
#define pb push_back

#define rep(i, n) for (int i=0;i<(n);++i)
#define rep2(i, s, n) for (int i=s;i<(n);++i)
#define rev(i, n) for (int i=(n);i>0;--i)
#define INF (1e9+1e9)

int main() {
    int h,w; cin>>h>>w;
    vector<string> S(h);

    rep(i,h) {
        string s;cin>>s;
        S[i] = s;
    }

    rep(i,h) {
        rep(j,w) {
            if (S[i][j] == '#') continue;
            else {
                int cnt = 0;
                rep2(k,-1,2) rep2(l,-1,2) {
                        if (k==0 && l==0) continue;
                        if (i+k<0 || i+k>=h) continue;
                        if (j+l<0 || j+l>=w) continue;
                        if(S[i+k][j+l] == '#') cnt++;
                }
                S[i][j] = to_string(cnt)[0];
            }
        }
        cout << S[i] << endl;
    }
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) { cin >> a[i]; }
  for (int i = 0; i < n; i++) { cin >> b[i]; }
  for (int i = 0; i < n - 1; i++) { cin >> c[i]; }
  int ans = accumulate(b.begin(), b.end(), 0);
  for (int i = 0; i < n - 1; i++) {
    if (a[i + 1] - a[i] == 1) ans += c[a[i] - 1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int m,x;
    
    while(1){
        cin >> m >> x;
        if(m==0 and x==0){
            break;
        }else{
            int count = 0;
            for(int i=1;i<=x/3 and i<=m;i++){
                for(int j=i+1;j<=(x-i)/2 and i<=m;j++){
                    int k;
                    k = x - (i + j);
                    if(j<k and k<=m) count++;
                }
            }
            cout << count << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
const ll mod = 1e9+7;
int a[maxn];

int main()
{
    int n;
    while(cin>>n){
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        bool flag = true;
        int high = a[0];
        for(int i=1;i<n;i++){
            if(high-1 > a[i]) {
                flag = false;
                break;
            }
            else{
                high = max(high, a[i]);
            }
        }
        if(flag){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 640
_ = input()
s = input()
ans = 0
for i in range(len(s)):
  s1 = set(s[:i])
  s2 = set(s[i:])
  c = 0
  for j in s1:
    if j in s2:
      c = c + 1
    ans = max(c, ans)
    
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
	string a; cin>>a;
	if(a=="SUN") cout<<'7'<<endl;
	if(a=="SAT") cout<<'1'<<endl;
	if(a=="FRI") cout<<'2'<<endl;
	if(a=="THU") cout<<'3'<<endl;
	if(a=="WED") cout<<'4'<<endl;
	if(a=="TUE") cout<<'5'<<endl;
	if(a=="MON") cout<<'6'<<endl;
}

Measured memory_bytes: 256
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)
 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(i, a, b) for(ll i = a; i <= b; i++)
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define rrep(i, b, a) for(ll i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
const ll INF = 1e18L + 5;
ll res[1003][1003];

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll n, m;
    cin >> n >> m;
    char mat[n][m];
    rep(i, 0, n) rep(j, 0, m) cin >> mat[i][j];
    if(mat[0][0] != '#') res[1][0] = 1;
    
    repp(i, 1, n) repp(j, 1, m) if(mat[i - 1][j - 1] != '#') res[i][j] = (res[i][j - 1] + res[i - 1][j])%MOD;
    cout << res[n][m];
}

Measured memory_bytes: 9088
import math
while(1):
    [a,b]=[int(x) for x in raw_input().split()]
    if a==0:
        break
    else:
        anum=[]
        bnum=[]
        ruinmin=10000**2*3
        for i in range(1,101):
            if a%i==0 and math.sqrt(a)>=i:
                anum.append([i,a/i])
            if b%i==0 and math.sqrt(b)>=i:
                bnum.append([i,b/i])
        for apair in anum:
            for bpair in bnum:
                abset=sorted(apair+bpair)
                ruin=(abset[1]-abset[0])**2+(abset[2]-abset[1])**2+(abset[3]-abset[2])**2
                ruinmin=min(ruinmin,ruin)
        print ruinmin# your code goes here

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        string b = cin.nextString();
        if (b == "A")
        {
            Console.WriteLine("T");
        }
        if (b == "T")
        {
            Console.WriteLine("A");
        }
        if (b == "C")
        {
            Console.WriteLine("G");
        }
        if (b == "G")
        {
            Console.WriteLine("C");
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092