akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
#define sz(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define ar vector
#define vse(a) a.begin(), a.end()
 
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 
 
using namespace std;
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(15);
    solve();  	
}
 
void solve() {                                                  
	int m, k;
	cin >> m >> k;

	if (m == 1 && k == 0) {
	    cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
	    return;
	}	

	if (m == 1 && k == 1) {
	 	cout << -1 << endl;
	 	return;
	}
	
	int num = 1;
	for (int i = 0; i < m; ++i) {
		num *= 2;
	}	
	num--;

	if (num < k) {
		cout << -1 << endl;
		return;
	}

	for (int i = 0; i <= num; ++i) {
	 	if (i != k) {
	 	 	cout << i << " ";
	 	}
	}
	cout << k << " ";
	for (int i = num; i >= 0; --i) {
	 	if (i != k) {
	 	 	cout << i << " ";
	 	}
	}
	cout << k << endl;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
	"strings"
)

func main() {
	// Code for C - Dubious Document
	var N int
	fmt.Scanf("%d", &N)

	var S string
	count := make([][]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%s", &S)
		count[i] = make([]int, 26)
		for j := 0; j < 26; j++ {
			count[i][j] = strings.Count(S, string('a'+j))
		}
	}

	var min int
	for j := 0; j < 26; j++ {
		min = 100
		for i := 0; i < N; i++ {
			if min > count[i][j] {
				min = count[i][j]
			}
		}
		fmt.Printf("%s", strings.Repeat(string('a'+j), min))
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 1840
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
#input = sys.stdin.readline
#文字列のときはうまく行かないのでコメントアウトすること
sys.setrecursionlimit(2147483647)

def main():
  l = int(input())
  ans = l**3/27
  print(ans)
  

if __name__ == '__main__':
  main()

Measured memory_bytes: 5204
import scala.io.{StdIn => in}

object Main extends App {
  val Array(hh, ww) = in.readLine.split(" ").map(_.toInt)
  val Array(h, w) = in.readLine.split(" ").map(_.toInt)
  val ans = (hh-h) * (ww-w)
  println(ans)
}

Measured memory_bytes: 25528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int N;
    cin >> N;
    int H, temp;
    cin >> temp;
    temp--;
    for (int i = 1; i < N; i++)
    {
        cin >> H;
        if (temp > H)
        {
            cout << "No" << endl;
            return 0;
        }
        temp = (temp < H ? H-1 : H);
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
	ll X, N;
	cin >> X >> N;
	vector<ll> A(N), C(100);
	rep(i, N) cin >> A.at(i);
	sort(A.begin(), A.end());
	rep(i, N) {
		if (A.at(i) > X) {
			C.at(A.at(i) - X)++;
		} else {
			C.at(X - A.at(i)) += 2;
		}
	}
	if (C.at(0) != 2)
		cout << X;
	else {
		for (int i = 1; N; i++) {
			if (C.at(i) == 0) {
				cout << X - i;
				break;
			}
			if (C.at(i) == 1) {
				cout << X - i;
				break;
			}
			if (C.at(i) == 2) {
				cout << X + i;
				break;
			}
		}
	}
}


Measured memory_bytes: 3588
#!/bin/bash

read n
p=$((${#n}/2))
if [ $((${#n}&1)) -eq 0 ]; then
  echo $((9+900*(p/2)+90000*(p/3)))
else
  k=$(((${#n}+1)/2))
  echo $((n-90*(k/2)-9000*(k/3)))
fi


Measured memory_bytes: 376
/**
 *      ABc 63 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 03:29:20 
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S; cin >> S;
    int sizeS = S.size();
    for (char c = 'a'; c <= 'z'; ++c){
        int count = 0;
        for (int i = 0; i < sizeS; ++i) {
            if (S[i] == c){
                ++count;
                if (count >= 2){
                    cout << "no"; return 0;
                }
            }
        }
    }
    cout << "yes";

    return 0;
}


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

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

	vector<int> vec(m);
	for (int i = 0; i < m;i++) {
		cin >> vec.at(i);
	}
	sort(vec.begin(), vec.end());

	if (n < m) {
		vector<int> dif(m - 1);
		for (int i = 0; i < m - 1; i++) {
			dif.at(i) = (vec.at(i+1) - vec.at(i));
		}
		sort(dif.rbegin(), dif.rend());

		int ans = 0;
		for (int i = 0; i < n - 1; i++) {
			ans += dif.at(i);
		}
		cout << vec.at(m - 1) - vec.at(0) - ans << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <limits.h>
#include <algorithm>
 
using namespace std;
 
int cmp_count = 0;
 
 
void merge(int A[],int left,int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1],R[n2+1];
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] =  INT_MAX;
 
    int i = 0, j = 0;
    for(int k = left;k < right; k++){
        if(L[i] <= R[j]){
            A[k] = L[i++];
            cmp_count++;
        }else{
            A[k] = R[j++];
            cmp_count++;
        }
    }
}
 
void mergeSort(int A[],int left,int right){
    if(left+1 < right){
        int mid = (left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}
 
int main(){
    int n;
    scanf("%d",&n);
    int S[n];
    for(int i = 0; i < n; i++) scanf("%d",&S[i]);
 
    mergeSort(S,0,n);
 
    for(int i = 0; i < n-1; i++) printf("%d ",S[i]);
    printf("%d\n",S[n-1]);
    printf("%d\n",cmp_count);
 
}



Measured memory_bytes: 6504
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

def eratos2(n):
	ans = n*(n+1)//2
	#print(ans)
	for i in range(2,n+1):
		#ans += (n+1)//i
		ans += (n//i)*(2*i+(n//i-1)*i)//2
		#print(ans)
	return ans

print(eratos2(readInt()))

Measured memory_bytes: 67648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define vec vector <int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define all(x) x.bg,x.en
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cout<<#x<<" "<<x<<endl;
#define dbga(arr,n) cout<<#arr<<": "; rp(tt,0,n) cout<<tt<<" "<<arr[tt].ff<<" "<<arr[tt].ss<<endl; cout<<endl;
#define mapi map<int,int>
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
const int mod=1e9+7,mex=1e12,md=998244353;
signed main()
{
	fast
	string s;
  	cin>>s;
  	if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int d,x;
}a[100010];
bool cmp(node a,node b)
{
    return a.d<b.d;
//    if (a.x)
}
int main()
{
    int n,m,pos = 0;
    cin>>n>>m;
    for (int i =0;i < n;i ++)
        cin>>a[i].d>>a[i].x;
    sort(a,a + n,cmp);
    priority_queue<int> que;
    int ans = 0;
    for (int i = 1;i <= m;i ++)
    {
        for (int j = pos;j <= n;j ++)
        {
            if (a[j].d == i) que.push(a[j].x);
            else if (a[j].d > i)
            {
                pos = j;
                break;
            }
        }
        //cout<<pos<<endl;
        if (!que.empty())
        {
            ans += que.top();
            que.pop();
        }
    }
    cout<<ans<<'\n';
    return 0;
}
//5 3

//1 4
//2 3
//1 3

//1 2
//2 1



//3 4
//4 3
//4 1
//2 2


Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

double dist(double x1, double y1, double x2, double y2) {  // (x1, y1) と (x2, y2) のユークリッド距離
    return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

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

    vector<double> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }

    double ans = 0;
    rep(i, n) {
        exrep(j, i+1, n-1) {
            ans += dist(x[i], y[i], x[j], y[j]);
        }
    }

    ans = ans*2.0/n;

    exout(ans);
    re0;
}

Measured memory_bytes: 256
/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int t; cin>>t;while(t--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

int main (void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	lli num=7, cnt=0, k;
	
	cin>>k;
	
	while (num%k!=0 && cnt<5000000)
	{
		num=((num*10)+7)%k;
		cnt++;
	}
	
	if (cnt==5000000)
		cnt=-2;
	
	cout<<cnt+1<<endl;

	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(){
    int n;
    int i,j,k;
    int count[4][3][10]={{{}}};
    cin >> n;
    int b,f,r,v;
    for(i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        count[b-1][f-1][r-1]+=v; //入居者カウント
    }
    for(i=0;i<4;i++){ //公社
        for(j=0;j<3;j++){ //階数
            for(k=0;k<10;k++){ //部屋
            cout <<" ";
            cout << count[i][j][k];
            } 
            cout << endl;
        }
        if(i<3)cout << "####################" << endl;
    }
}
    
   



Measured memory_bytes: 3096
N, K = map(int, input().split())
mod = 10**9+7

import math

def combination(a, b):
    minb = min(a-b, b)
    r = 1
    for j in range(1, minb+1):
        r = r * (a-minb+j)//j
    return int(r)

for i in range(1, K+1):
    if N==K and i!=1:
        print(0)
        continue
    must = combination(K-1, i-1)
    if must is None:
        print("K:"+str(K)+", i:"+str(i))
    left_ball = N-K-i+1
    if left_ball < 0:
        print(0)
        continue
    can = combination(left_ball+i, i)
    print((must*can)%mod)


Measured memory_bytes: 44508
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s,t;
  cin >> s >> t;

  int a,b;
  cin >> a >> b;

  string u;
  cin >> u;

  a -= s == u ? 1 : 0;
  b -= t == u ? 1 : 0;

  cout << a << " " << b;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
//
//  main.cpp
//  GridRepainting2
//
//  Created by XsC on 2018/5/5.
//  Copyright © 2018年 夏思聪. All rights reserved.
//

#include <iostream>

const int maxn=60;

char mp[maxn][maxn];
int h,w;

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

bool solve(char ch,int x,int y){
    if(ch=='.')
        return true;
    for(int i=0;i<4;i++){
        if(mp[x+step[i][0]][y+step[i][1]]==ch)
            return true;
    }
    return false;
}

int main(int argc, const char * argv[]) {
    scanf("%d %d",&h,&w);
    getchar();//'enter'
    for(int i=0;i<h;i++){
        scanf("%s",&mp[i]);
    }
    for(int i=1;i<h-1;i++){
        for(int j=1;j<w-1;j++){
            if(!solve(mp[i][j],i,j)){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
#define ll long long
using namespace std;
ll n, m, i, j, k, t;
int x[110],y[110];
int dx[110][110], dy[110][110];
double deg[110][110];
double d[110][110];
double pi=3.1415926535897384626;
double p[110];
double max1=-99999, min1=99999, max2=-99999, min2=99999;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>x[i]>>y[i];
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			dx[i][j]=x[j]-x[i];
			dy[i][j]=y[j]-y[i];
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(j==i) continue;
			deg[i][j]=atan2(dy[i][j],dx[i][j]);
			}
			deg[i][i]=deg[i][(i%n)+1];
		}
	for(i=1;i<=n;i++){
		max1=-99999; min1=99999; max2=-99999; min2=99999;
		for(j=1;j<=n;j++){
			max1=max(max1,deg[i][j]);
			min1=min(min1,deg[i][j]);
		}
		sort(deg[i]+1,deg[i]+n+1);
		for(j=1;j<=n-1;j++){
			max2=max(max2,deg[i][j+1]-deg[i][j]);
			min2=min(min2,deg[i][j+1]-deg[i][j]);
		}
		if(max1-min1<=pi) p[i]=(pi-(max1-min1))/(2*pi);
		else{
			p[i]=(max2-pi)/(2*pi);
		}
		p[i]=max(p[i],0.0);
		printf("%.15lf\n", p[i]);
	}
	return 0;
}

Measured memory_bytes: 384
n = int(input())
a, b, c = [list(map(int, input().split())) for _ in range(3)]
foodSum = sum(b)
for i in range(n - 1):
    if a[i + 1] - a[i] == 1:
        foodSum += c[a[i] - 1]

print(foodSum)


Measured memory_bytes: 3060
# input
k, a, b = map(int, input().split())

ans = 1 + k
if b <= a + 2:
    print(ans)
else:
    if (k - a + 1) % 2 == 0:
        i = a - 1
    else:
        i = a
    ans = 1 + i + ((b - a) * (k - i) // 2)
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m;
    cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

int main(){
  string s,t; cin>>s>>t;
  bool ans=false;
  for(int i=0;i<s.size();i++){
    if(s==t){
      ans=true;
      break;
    }
    s=s.back()+s.substr(0,s.size()-1);
  }
  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

int main(void){
    
   string s; //coffee
   cin >> s;
   
   if(s[2] == s[3] && s[4] == s[5]){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" <<endl;
   }
}

Measured memory_bytes: 3592
//最大公約数
#include <bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t a,int64_t b){
  int64_t c;
  c=a;
  a=max(a,b);
  b=min(c,b);
  c=a;
  while(b > 0){
    a = b;
    b = c % b;
    c = a;
  }
  return a;
}


int main() {
  int64_t a,b;
  cin>>a>>b;
  int64_t c;
  c=gcd(a,b);
  cout<<a*b/c<<endl;
}

Measured memory_bytes: 256
S=input()
s1=int(S[0])
s2=int(S[1])
s3=int(S[2])
s4=int(S[3])
can1=10*s1+s2
can2=10*s3+s4
count=[]
count.append(0)
count.append(0)
if(0<can2 and 13>can2):
    count[0]=1
if(0<can1 and 13>can1):
    count[1]=1
if(count[0]==1 and count[1]==1):
    print("AMBIGUOUS")
elif(count[0]==0 and count[1]==1):
    print("MMYY")
elif(count[0]==1 and count[1]==0):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
import scala.io.StdIn

object Main {
  def main(args:Array[String]){
    var n:Int=StdIn.readInt()
    val s:Int=n%60
    val m:Int=(n-s)%3600/60
    val h:Int=(n-s-m)/3600
    println(h+":"+m+":"+s)
  }
}

Measured memory_bytes: 43648
// to Utils -> L47
// to Rlyeh -> L78
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
#define class struct
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define elif else if
#define echo std::cout <<
#define read std::cin >>
#define fin << '\n'
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define alles(obj) obj.begin(), obj.end()
#define bash push_back
#define makePair std::make_pair
// type-define
#define String std::string
#define Stack std::stack
#define Queue std::queue
#define pQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
typedef long long llong;
typedef bool boolean;
typedef Pair<int,int> Pii;
typedef Vector<int> Vi;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

class hori {

    static llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) {
                ans = ( ans * x ) % mod;
            }
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }

    static llong power ( llong x, llong n ) {
        return power( x, n, 1000000007 );
    }

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

    static llong lcm ( llong x, llong y ) {
        return ( x / gcd(x, y) * y );
    }

    static boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
};

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int d;
        read d;
        echo "Christmas";
        for ( int i = 0; i < 25-d; i++ ) {
            echo " Eve";
        }
        echo std::endl;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, 0, n){
        cin >> a[i];
    } 
    rep(i, 0, n){
        cin >> b[i];
    }
    int ans = 0;
    rep(i, 0, 30){
        vector<int> bb(n);
        rep(j, 0, n){
            bb[j] = b[j] % (1LL << (i + 1));
        }
        int cnt = 0;
        sort(all(bb));
        rep(j, 0, n){
            int aa = a[j] % (1LL << (i + 1));
            cnt += bb.end() - lower_bound(all(bb), (3 << i) - aa);
            cnt += upper_bound(all(bb), (1LL << (i + 1)  ) - 1 - aa) - lower_bound(all(bb), (1LL << i) - aa);
        }
        ans |= (cnt % 2) << i;
    }
    cout << ans << endl;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    rep(i, n - 2)
    {
        string x = s.substr(0, i + 1);
        string y = s.substr(i + 1, n - 1);
        set<char> mem;
        int nowing = 0;
        rep(j, x.size())
        {
            mem.insert(x[j]);
        }
        for (auto a : mem)
        {
            if (y.find(a) != string::npos)
            {
                nowing++;
            }
        }
        if (nowing > count)
        {
            count = nowing;
        }
    }
    c(count);
    return 0;
}

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

int main()
{
  ll n;
  cin>>n;
  ll sum = 0;
  ll arr[n];
  for(ll i=0;i<n;i++)
  {
    ll x;
    cin>>x;
    arr[i]=x;
    sum += x;
  }
  ll p1 = int(sum/n);
  ll p2 = ceil(sum*1.0/n);
  ll ans = 0;
  ll ans1 = 0;
  for(ll i=0;i<n;i++)
  {
    ans += pow(p1-arr[i],2);
    ans1 += pow(p2-arr[i],2);
  }
  cout<<min(ans,ans1);
  return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
long A,B,C,D,E,F,i,j,t,max_water,max_sugar,t1,t2;
double concentration;
vector<long> water,sugar;

inline void solve(){
  cin>>A>>B>>C>>D>>E>>F;
  UP(i,0,F){
    t1=100*A*i;
    if(t1>F)break;
    UP(j,0,F){
      t2=100*B*j;
      if(t2>F)break;
      t=t1+t2;
      if(t<=F)water.pb(t);
      else break;
    }
  }
  UP(i,0,F){
    t1=C*i;
    if(t1>F)break;
    UP(j,0,F){
      t2=D*j;
      if(t2>F)break;
      t=t1+t2;
      if(t<=F)sugar.pb(t);
      else break;
    }
  }
  sort(ALL(water));unique(ALL(water));
  sort(ALL(sugar));unique(ALL(sugar));
  REP(i,(long)water.size()){
    REP(j,(long)sugar.size()){
      if(water[i]+sugar[j]<=F &&
      sugar[j]<=E*water[i]/100){
        if(concentration<=(double)sugar[j]/(water[i]+sugar[j])){
          concentration=(double)sugar[j]/(water[i]+sugar[j]);
          max_water=water[i];
          max_sugar=sugar[j];
        }
      }
    }
  }
  OUT2(max_water+max_sugar,max_sugar);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 2420
// https://atcoder.jp/contests/abc134/tasks/abc134_d

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

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t, ans = 0;
    cin >> n;
    vector<bool> a(n + 1, false), b(n + 1, false);
    for (int i = 1; i <= n; i++) {
        cin >> t;
        if (t == 1) {
            a[i] = true;
        }
    }
    for (int i = n; i >= 1; i--) {
        bool bx = a[i];
        for (int j = i * 2; j <= n; j += i) {
            bx ^= b[j];
        }
        b[i] = bx;
        if (bx) {
            ans++;
        }
    }
    cout << ans << endl;
    for (int i = 1; i <= n; i++) {
        if (b[i]) {
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1152
// :) 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	if (s.length() < 5) {
		cout << "NO\n";
		return 0;
	}
	bool ok = true;
	int i = s.length()-1;
	while (i >= 0) {
		string cur;
		for (int t = 0; t < 5 && i - t >= 0; t++)
			cur = s[i-t] + cur;
		if (cur == "erase" || cur == "dream") {
			i -= 5;
			continue;
		}
		cur = "";
		for (int t = 0; t < 6 && i - t >= 0; t++)
			cur = s[i-t] + cur;
		if (cur == "eraser") {
			i -= 6;
			continue;
		}
		cur = "";
		for (int t = 0; t < 7 && i - t >= 0; t++)
			cur = s[i-t] + cur;
		if (cur == "dreamer") {
			i -= 7;
			continue;
		}
		ok = false;
		break;
	}
	if (i != -1 || !ok) 
		cout << "NO\n";
	else
		cout << "YES\n";
}

Measured memory_bytes: 512
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    count = 0
    for i in range(1, (n - 2) + 1):
        for j in range(i + 1, (n - 1) + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    count += 1
    print(count)

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

void OK(str& t){
	str s = "";
	for(auto c : t){
		if(c == 'R') s += c;
		else {
			if((s.size() > 0) && s.back() == 'S') s.pop_back();
			else s += c;
		}
	}
	t = s;
}

vector<int> Solve(int n, str T){
	int pw = 1;
	for(int i = 0; i < n; i++) pw = 3*pw;

	vector<int> res(pw, 0);
	if(n == 0){
		return res;
	}
	vector<int> rec(pw / 3);
	str T2;
	int nw;
	for(int bt = 0; bt < 3; bt ++){
		T2 = "";
		nw = bt;
		for(auto c : T){
			if(c == 'S'){
				T2 += c;
				if(nw != 0) nw = 3 - nw;
			} else {
				if(nw == 2) T2 += 'R';
				nw = (nw + 1) % 3;
			}
		}
		OK(T2);
		rec = Solve(n - 1, T2);
		for(int i = bt; i < pw; i += 3){
			res[i] = rec[i / 3] * 3 + nw;
		}
	}
	return res;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//str ts = "RSSSR";
	//OK(ts); debug(ts);
	int n;
	cin >> n;
	str T;
	cin >> T;
	vector<int> ans = Solve(n, T);
	for(auto x : ans) cout << x << ' ';
		cout << '\n';
	return 0;
}


Measured memory_bytes: 8148
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint p=1e9+7;
int K=60;

int main(){
  lint N;
  cin>>N;
  lint A[N];
  REP(i,N)cin>>A[i];
  lint q[K];
  REP(i,K)q[i]=0;
  REP(i,N){
    REP(j,K){
      q[j]+=(1 & (A[i]>>j));
      // cerr<<(1 & (A[i]>>j));
    }
    // cerr<<endl;
  }
  // REP(i,K)cerr<<q[i];
  // cerr<<endl;
  lint ans=0;
  REP(i,K){
    lint temp=(N-q[i])*q[i];
    temp%=p;
    REP(j,i){
      temp*=2;
      temp%=p;
    }
    // cerr<<temp<<endl;
    ans+=temp;
    ans%=p;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}

bool prime(int n) {
        if (n == 2) return true;
        if (n == 1 || n == 0 || n % 2 == 0) return false;
        for (int i = 3; i * i <= n; i += 2) {
                if (n % i == 0) return false;
        }
        return true;
}

void _main() {
        int n; cin >> n;
        for (int i = 1; i <= 55'555 && n; i += 5) {
                if (prime(i)) {
                        n--;
                        cout << i << ' ';
                }
        }

}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int x,a,b;
  cin>>x>>a>>b;

  cout<< ( abs(x-a)>abs(x-b) ? 'B' : 'A' )<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < 3; i++) {
    if (S[i] == '9') cout << 1;
    else cout << 9;
  }
  cout << endl;
}


Measured memory_bytes: 3624
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: FT Robot
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 8000;

/* typedef */

typedef vector<int> vi;

/* global variables */

vi vds[2];
int sums[2];
bool dp[2][MAX_N * 2 + 1];

/* subroutines */

/* main */

int main() {
  string s;
  int gx, gy;
  cin >> s >> gx >> gy;

  int n = s.size();
  int t = 0, f = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'F') f++;
    else {
      vds[t].push_back(f), sums[t] += f;
      f = 0;
      t ^= 1;
    }
  }
  if (f > 0) vds[t].push_back(f), sums[t] += f;

  if (abs(gx) > sums[0] || abs(gy) > sums[1]) {
    puts("No");
    return 0;
  }

  int ox = sums[0], maxx = sums[0] * 2 + 1;
  memset(dp[0], false, sizeof(dp[0]));
  dp[0][ox + vds[0][0]] = true;
  int cur = 0, nxt = 1;

  for (int i = 1; i < vds[0].size(); i++) {
    int &dx = vds[0][i];
    if (dx == 0) continue;

    memset(dp[nxt], false, sizeof(dp[nxt]));
    for (int x = 0; x <= maxx; x++)
      if (dp[cur][x]) {
	if (x - dx >= 0) dp[nxt][x - dx] = true;
	if (x + dx <= maxx) dp[nxt][x + dx] = true;
      }
    cur ^= 1, nxt ^= 1;
  }

  if (! dp[cur][ox + gx]) {
    puts("No");
    return 0;
  }

  int oy = sums[1], maxy = sums[1] * 2 + 1;
  memset(dp[0], false, sizeof(dp[0]));
  dp[0][oy] = true;
  cur = 0, nxt = 1;

  for (int i = 0; i < vds[1].size(); i++) {
    int &dy = vds[1][i];
    if (dy == 0) continue;

    memset(dp[nxt], false, sizeof(dp[nxt]));
    for (int y = 0; y <= maxy; y++)
      if (dp[cur][y]) {
	if (y - dy >= 0) dp[nxt][y - dy] = true;
	if (y + dy <= maxy) dp[nxt][y + dy] = true;
      }
    cur ^= 1, nxt ^= 1;
  }

  if (! dp[cur][oy + gy]) {
    puts("No");
    return 0;
  }

  puts("Yes");
  return 0;
}


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


using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	if(a > b*2) {
		cout << a - b*2 << endl;
	} else {
		cout << 0 << endl;
	}
	


	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

#define ll long long int

struct Mod_comb
{
    const long long mod_;
    const int n_;
    std::vector<long long> fac;
    std::vector<long long> rev;
    
    Mod_comb() : Mod_comb(1e6+10, 1e9+7)
    {
    }
    
    long long qpow(long long a, long long b)
    {
        long long ret=1;
        while(b)
        {
            if(b&1)ret=(ret*a)%mod_;
            b>>=1;
            a=(a*a)%mod_;
        }
        return ret;
    }
    
    Mod_comb(int n, long long m) : mod_(m), n_(n), fac(n), rev(n)
    {
        fac.resize(n_+1);
        rev.resize(n_+1);
        fac[0] = 1;
        for(int i=1;i<=n_;++i)
        {
            fac[i]=(fac[i-1]*i)%mod_;
        }
        rev[n_]=qpow(fac[n_],mod_-2);
        for(int i=n_-1;i>=0;--i)
        {
            rev[i]=(rev[i+1]*(i+1))%mod_;
        }
    }
    
    long long C(int n,int m)
    {
        if(m>n)
        {
            return 0;
        }
        return (((fac[n]*rev[m])%mod_)*rev[n-m])%mod_;
    }
};

const int Mod = (int)(1e9 + 7);

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<int> index(n+1);
    fill(index.begin(), index.end(), -1);
    int left = 0;
    int right = 0;
    for(int i = 0;i < n+1;i++)
    {
        cin >> a[i];
        if(index[a[i]] >= 0)
        {
            left = index[a[i]];
            right = i;
        }
        index[a[i]] = i;
    }
    
    Mod_comb total(n+1, Mod);
    for(int k = 1;k <= n + 1;k++)
    {
        auto l = total.C(n+1, k);
        auto rest = total.C(n+1 - (right - left + 1), k-1);
        cout << (l - rest + Mod) % Mod << endl;
    }
    return 0;
}

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

class Base {
public:
	Base() {
		score = 0;
		outNum = 0;
		first = false;
		second = false;
		third = false;
	}
	void hit() {
		if (third) {
			score++;
		}
		third = second;
		second = first;
		first = true;
	}
	void homerun() {
		if (first) {
			first = false;
			score++;
		}
		if (second) {
			second = false;
			score++;
		}
		if (third) {
			third = false;
			score++;
		}
		score++;
	}
	void out() {
		outNum++;
		if (outNum > 2) {
			cout << score << endl;
			score = 0;
			outNum = 0;
			first = false;
			second = false;
			third = false;
		}
	}
	
private:
	int score;
	int outNum;
	bool first;
	bool second;
	bool third;
};


int main() {
	Base base;
	string str;
	int inning;
	int count = 0;

	cin >> inning;

	while (count < inning * 3) {
		char data[10];
		cin >> str;
		if (str == "HIT") {
			base.hit();
		}else if (str == "HOMERUN") {
			base.homerun();
		}
		else if(str == "OUT"){
			base.out();
			count++;
		}
	}
	return 0;
}

Measured memory_bytes: 1208
n = input()
k = int(input())

digit_n = len(n)

# dp[x][j][i]: x:n未満か否か, j:0でない数字の数, i:桁
dp = [[[0] * (digit_n + 1) for _ in range(k+1)] for _ in range(2)]
dp[0][0][0] = 1

for i in range(digit_n):
    m = int(n[i])
    for j in range(k+1):
        dp[1][j][i+1] = dp[1][j][i]
        if j > 0:
            dp[1][j][i+1] += dp[1][j-1][i] * 9
    for j in range(k+1):
        if m == 0:
            dp[0][j][i+1] = dp[0][j][i]
        else:
            dp[1][j][i+1] += dp[0][j][i]
            if j > 0:
                dp[1][j][i+1] += dp[0][j-1][i] * (m-1)
                dp[0][j][i+1] = dp[0][j-1][i]

print(dp[0][k][-1] + dp[1][k][-1])


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

int main()
{
	int n,i,j,cnt,maxv=0;
	char ch;
	string s;
	cin>>n>>s;
	for(i=1;i<n;i++)
	{
		cnt=0;
		for(ch='a';ch<='z';ch++)
		{
			bool left=false,right=false;
			
			for(j=0;j<i;j++)
			if(s[j]==ch) left=true;
			
			for( j=i;j<n;j++)
			if(s[j]==ch) right=true;
			
			if(left && right) cnt++;
		}
		if(cnt>maxv) maxv=cnt;
	}
	cout<<maxv;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
double dp[310][310][310];
int n;

double get(int i, int j, int k){
  if(i==0&&j==0&&k==0) return 0.0;
  if(dp[i][j][k]>=0) return dp[i][j][k];
  double ans = 0.0;
  if(i>0) ans += get(i-1,j,k)*i;
  if(j>0) ans += get(i+1,j-1,k)*j;
  if(k>0) ans += get(i,j+1,k-1)*k;
  ans+=n;
  ans *= 1.0/(i+j+k);
  return dp[i][j][k]=ans;
}

int main(){
  cin >> n;
  int c_1=0,c_2=0,c_3=0;
  rep(i,n){
    int x;
    cin >> x;
    if(x==1) c_1++;
    else if(x==2) c_2++;
    else c_3++;
  }
  rep(i,310){
    rep(j,310){
      rep(k,310){
        dp[i][j][k]=-1.0;
      }
    }
  }
  cout << setprecision(10);
  cout << get(c_1,c_2,c_3);
}

Measured memory_bytes: 233088
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    string s;
    cin >> s;
    string t=s;
    reverse(ALL(t));
    if(t!=s){
        cout << "No";
        return 0;
    }
    int n=(s.size()-1)/2;
    string s1=s.substr(0,n);
    string t1=s1;
    reverse(ALL(t1));
    if(t1!=s1){
        cout << "No";
        return 0;
    }

    string s2=s.substr((s.size()+3)/2-1,n);
    string t2=s2;
    reverse(ALL(t2));
    if(t2!=s2){
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
char a[101];
int  b[101];
int main()
{
	int i,j,len;
	int ok = 1;
	scanf("%s",a);
	len = strlen(a);
	if(len % 2 != 0) ok = 0;
	
	for(i=0 ; i<len ; i++)
		b[a[i] - 'a']++;
	for(i = 0 ; i < 26 ; i++)
	{
		if(b[i] % 2 != 0)
			ok = 0;
	}

	if(ok == 1)
		printf("Yes");
	else
		printf("No");
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int densha=min(a,b);
	int bus=min(c,d);
	int ans=densha+bus;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <queue>
using namespace std;
 
#define int long long
#define INF 1001001001

int arr[200001];
 
int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

int choose2(int n){
	
	return n*(n-1)/2;
}

int32_t main() {
	
 	int N;
 	
 	cin >> N;
 	vector<int> v(N+1);
 	for(int i=1; i<=N; i++){		
 		int tmp;		
 		cin >> tmp;		
 		arr[tmp]++;	
 		v[i] = tmp;
	}
	
	int sum = 0;
	for(int i=1; i<=N; i++){		
		sum += choose2(arr[i]);	
		
	}
    int ans = sum;
    for(int i=1; i<=N; i++){
    	ans = sum;
    	ans -= choose2(arr[v[i]]);	
    	
    	ans += choose2(arr[v[i]]-1);
    	
    	cout << ans << endl;
	}
    
 	
 	
}

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

using namespace std;

class nck {
    vector<long long> inv;
    vector<long long> frac;
    vector<long long> frac_inv;
    int mod;

public:
    nck(int n, int m) {
        inv = vector<long long>(n + 1, 0);
        frac = vector<long long>(n + 1, 0);
        frac_inv = vector<long long>(n + 1, 0);
        mod = m;

        inv[1] = 1;
        frac[0] = frac[1] = 1;
        frac_inv[0] = frac_inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            inv[i] = mod - (inv[mod % i] * (mod / i)) % mod;
            frac[i] = (frac[i - 1] * i) % mod;
            frac_inv[i] = (frac_inv[i - 1] * inv[i]) % mod;
        }
    }

    int calc(int n, int k) {
        return (frac[n] * frac_inv[k] % mod) * frac_inv[n - k] % mod;
    }
};

int main() {
    long long n, m, k;
    cin >> n >> m >> k;

    int mod = 998244353;
    nck nck(n, mod);

    vector<long long> p(n);
    p[0] = m;
    for (int i = 1; i < n; i++) {
        p[i] = (p[i - 1] * (m - 1)) % mod;
    }

    long long res = 0;
    for (int i = 0; i <= k; i++) {
        res = (res + nck.calc(n - 1, i) * p[n - i - 1]) % mod;
    }

    cout << res << endl;
}


Measured memory_bytes: 9528
#include<bits/stdc++.h>
using namespace std;
struct node
{
    double x,y;
}a[8];
int n,v[10],o=1,h[10];
double ans=0;
double f(double x)
{
    return x*x;
}
void cal()
{
    for(int i=2;i<=n;i++)
        ans+=sqrt(f(a[h[i]].x-a[h[i-1]].x)+f(a[h[i]].y-a[h[i-1]].y));
}
void dfs(int x)
{
    if(x==n+1)
        cal();
    else
    {
        for(int i=0;i<n;i++)
        {
            if(v[i])
                continue;
            v[i]=1;
            h[x]=i;
            dfs(x+1);
            v[i]=0;
        }
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        o*=i;
    for(int i=0;i<n;i++)
        scanf("%lf%lf",&a[i].x,&a[i].y);
    dfs(1);
    printf("%lf",ans/o);
    return 0;
}

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

int f[10000010];

inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}

inline void writeln(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
     puts("");
}

signed main(){
    int n=read();
    
    int i,j;    
    int ans=0;
    
    for(i=1;i<=n;i++){
        for(j=1;i*j<=n;j++)
            f[i*j]++;
    }
    
    for(i=1;i<=n;i++)
        ans+=i*f[i];
    
    writeln(ans);
    return 0;
}

Measured memory_bytes: 81740
#include <iostream>
#include <vector>
#include <cmath>
#include <bitset>
 
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    vector<int> var(s.length(), 0);
    //A, B, C, Dに分ける
    for(int i=0; i<s.length(); i++){
        var[i] = atoi(s.substr(i, 1).c_str());
    }
    
    // 3ビットのビット列をすべて列挙する
    for (int tmp = 0; tmp < (1 << 3); tmp++) {
        bitset<3> b(tmp);
        // ビット列を使用した処理
        s.clear();
        int sum=var[0];
        s+= to_string(var[0]);
        
        //3bitのループ
        for(int i=0; i<3; i++){
            //i桁目のbitが0or1を判定
            if(b.test(i)){
                sum=sum-var[i+1];
                s+="-"+to_string(var[i+1]);
            }else{
                sum=sum+var[i+1];
                s+="+"+to_string(var[i+1]);
            }
        }
        
        if(sum==7){
            cout << s + "=7" << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256