akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

int main()
{
    int n;
    cin >> n;
    vector<queue<int>> A(n);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n - 1; j++)
        {
            int a;
            cin >> a;
            --a;
            A[i].push(a);
        }
    }
    // 処理が終了するまで繰り返す
    set<int> lst;
    set<int> empty_index;

    // １回目の試合について確認する
    for (int i = 0; i < n; i++)
    {
        if (lst.count(i))
        {
            continue;
        }
        int a = i;
        int b = A[i].front();
        if (A[b].front() == i && !lst.count(b))
        {
            lst.insert(a);
            lst.insert(b);
            // 一致するものの先頭を削除する
            A[a].pop();
            A[b].pop();
            if (A[a].empty())
                empty_index.insert(a);
            if (A[b].empty())
                empty_index.insert(b);
            // cout << a << ':' << b << endl;
        }
    }
    int cnt = 1;
    // ２回目の試合以降について確認する
    while (true)
    {
        if (empty_index.size() == n)
        {
            cout << cnt << endl;
            return 0;
        }
        // cout << "===" << endl;
        set<int> this_game;

        for (int i : lst)
        {
            // このラウンドで既に試合をした，もしくは試合が残っていない場合
            if (this_game.count(i) || A[i].empty())
            {
                continue;
            }
            int a = i;
            int b = A[i].front();
            if (A[b].front() == i && !this_game.count(b))
            {
                this_game.insert(a);
                this_game.insert(b);
                // 一致するものの先頭を削除する
                A[a].pop();
                A[b].pop();
                if (A[a].empty())
                {
                    empty_index.insert(a);
                }
                if (A[b].empty())
                {
                    empty_index.insert(b);
                }
                // cout << a << ':' << b << endl;
            }
        }
        if (this_game.size() == 0)
        {
            cout << -1 << endl;
            return 0;
        }
        ++cnt;
        lst = this_game;
    }
}


Measured memory_bytes: 8080
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=5e6+10;
const int mod=1e9+7;
int arr[N],iarr[N];
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
map<int,int> mp;
int arr1[1000001],arr2[1000001];

int solve()
{
	int a,b;
	cin>>a>>b;
	cout<<6-(a+b);
}
int32_t main()																																	
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	long long int x,y;
	cin>>x>>y;
	if(x>y){
		cout<<"safe"<<endl;
	}
	else{
		cout<<"unsafe"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int arr[]={500,5};
    int x;
    cin>>x;
    ll sum = 0;
    for(int i=0;i<2;i++)
    {
        // if(x%arr[i])
        // {
            ll tmp = x/arr[i];
            if(arr[i]==500)
                sum+=1000*tmp;
            else
                sum+=arr[i]*tmp;
            x=x%arr[i];
        // }
    }
    cout<<sum<<endl;
    return 0;
}

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

int main(){
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n+1,0);
	REP(i,n){
		cin >> a[i];
	}
	rep(i,n){
		a[i+1] += a[i];
	}
	
	vector<ll> sum;
	for (int i = 1; i <= n; ++i) {
		for (int j = i; j <= n; ++j) {
			sum.push_back(a[j]-a[i-1]);
		}
	}
	
	ll ans = 0;
	
	for (int bit = 40; bit >= 0; --bit) {
		ll temp  = 1;
		rep(j,bit) temp*= 2;
		int count = 0;
		rep(j, n*(n+1)/2){
			if(((ans + temp) & sum[j]) == ans + temp) count++;
		}
		if(count >= k) ans += temp;
	}
	
	cout << ans << endl;
	
    return 0;
}



Measured memory_bytes: 5876
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
    int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
	    cin >> a[i];
	}
	vector<int> b(n);
	for (int i = 0; i < n; ++i) {
	    cin >> b[i];
	}
	auto sorted_a = a;
	sort(all(sorted_a));
	auto sorted_b = b;
	sort(all(sorted_b));
	
	for (int i = 0; i < n; ++i) {
	    if (sorted_a[i] > sorted_b[i]) {
		    cout << "No" << endl;
			return 0;
		}
	}
	map<int, int> cnta;
	for (int x : a) {
		++cnta[x];
		if (cnta[x] > 1) {
		    cout << "Yes" << endl;
			return 0;
		}
	}
	
	map<int, int> cntb;
	for (int x : b) {
		++cntb[x];
		if (cntb[x] > 1) {
		    cout << "Yes" << endl;
			return 0;
		}
	}
	
	for (int i = 1; i < n; ++i) {
	    if (sorted_a[i] <= sorted_b[i - 1]) {
		    cout << "Yes" << endl;
			return 0;
		}
	}
	
	map<int, int> val;
	for (int i = 0; i < n; ++i) {
	    val[a[i]] = b[i];
	}
	
	sort(all(a), [&](int x, int y) {return val[x] < val[y];});
	
	map<int, int> ord;
	for (int i = 0; i < n; ++i) {
	    ord[sorted_a[i]] = i;
	}
	
	auto perm = a;
	for (int i = 0; i < n; ++i) {
	   perm[i] = ord[a[i]];
	}
	int pos = 0;
	vector<bool> used(n, false);
	for (int i = 0; i + 1 < n; ++i) {
	    used[pos] = true;
		pos = perm[pos];
		if (used[pos]) {
		    cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
    return 0;
}


Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,x;
  cin >> n >> x;
  vector<int> m(n);
  int d=100000;
  for(int i=0;i<n;i++){
    cin >> m.at(i);
    x-=m.at(i);
    d=min(d,m.at(i));
  }
  cout << n+x/d << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

// main is...
func main() {
	// IO start
	var n int
	fmt.Scan(&n)

	var listA = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&listA[i])
	}

	ret := 0
	// process start
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			ret += listA[i] * listA[j]
		}
	}
	fmt.Print(ret)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{long long n=0,f=0,p=1,f1=0;
    cin>>n;
    long long a[n];
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        f=1;
   
    }
    if(f==1)
    cout<<0;
    else
    {
        for(long long j=0;j<n;j++)
        {
            if((1000000000000000000/p)<a[j])
            {
                f1=1;
                break;
            }
            else
            p*=a[j];
        }
        if(f1==1)
        cout<<-1;
        else
        cout<<p;
    }
    
}


Measured memory_bytes: 4372
#include<iostream>
#include <math.h>
using namespace std;

int N;

int main(){
    cin >> N;

    int X = double(N) / 1.08;

    int X1 = floor(X * 1.08);

    if (X1 == N){
        // cout << N << endl;
        cout << X << endl;
        // cout << X1 << endl;
        return 0;
    }
    else{
        X++;
        X1 = floor(X * 1.08);
        if (X1 == N)
        {
            cout << X << endl;
            // cout << X1 << endl;
            return 0;
        }
        else{
            // cout << X << endl;
            // cout << X1 << endl;
            cout << ":(" << endl;
        }
    }
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
           
            int N = sc.nextInt();
            int K = sc.nextInt();
            int result = 1;
      
            for (int i=1; i<=N-1; i++){
              result = result*(K-1); 
            }
      
            int C = K*result;
       
            if (N==1) {
                System.out.println(K);
            }
            
            else  {
                System.out.println(C);  
            }
    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main() {
    long long int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
}

Measured memory_bytes: 3620
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}



Measured memory_bytes: 1972
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);
    var S = lines[1].split("");
    var K = Number(lines[2]);

    for (var i = 0; i < N; i++) {
        if (S[K - 1] !== S[i]) { S[i] = "*"; }
    }
    var result ="";
    for (var i = 0; i < N; i++) {
        result = result + S[i];
    }
    console.log(result);
});

Measured memory_bytes: 11596
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)

typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  string s, t;
  cin >> s >> t;

  string ans = "No";
  rep(i, s.size()) {
    if (s == t) {
      ans = "Yes";
      break;
    }
    s = s.back() + s.substr(0, s.size()-1);
    // cout << s << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    string S;
    cin >> S;
    set<char> s;
    REP(i, S.length()) {
        if (!s.emplace(S[i]).second) {
            cout << "no" << endl;
            return 0;
        }
        
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d)
		cout<<"Balanced"<<endl;
	if(a+b>c+d)
		cout<<"Left"<<endl;
	if(a+b<c+d)
		cout<<"Right"<<endl;
		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> a(3);
  for(int i=0; i<3; i++){
    cin >> a[i];
  }
 
  int sum=0;
  for(int j=0; j<3; j++){
    sum = sum + a[j];
  }
  
  if(sum <= 21){
    cout << "win" << endl;
  }
  else{
    cout << "bust" << endl;
  }
  
}


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

int main()
{
  int S, h, m, s;
  cin >> S;

  h = S / 3600;
  S = S % 3600;
  m = S / 60;
  s = S % 60;

  cout << h << ":" << m << ":" << s << endl;

  return 0;
}



Measured memory_bytes: 3080
X, Y = map(int, input().split())

crane = [x for x in range(X+1)]
turtle = [x for x in range(X+1)]

ans = "No"
for c in crane:
    for t in turtle:
        if c + t > X:
            break
        if c*2 + t*4 == Y and c+t == X:
            ans = "Yes"
            
print(ans)

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll,ll> > vpll;
typedef vector< vector<int> > matrix;

#define SET(Ar,val) memset(Ar,val,sizeof(Ar))
#define rep(i,val,n)  for(int i=val;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LMAX LONG_LONG_MAX
#define LMIN LONG_LONG_MIN
#define IMAX INT_MAX
#define IMIN INT_MIN
#define Md 1000000007ll

/*--------------------------------------------------------------------------------------------------------------------------------*/

template <class T> T modpower(T a,T b,T MOD)
{
    T ans=1;
    while(b!=0)
    {
        if(b%2==1)
        ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return ans;
}

void init()
{
    int N;
    ll M;
    cin >> N >> M;
    ll ar[N+5],ps[N+5];
    ps[0] = 0;
    map<ll,int> ma;
    ma[0ll] = 1;
    rep(i,1,N+1)
    {
        cin >> ar[i];
        ps[i] = ar[i] + ps[i-1];
        ps[i]%=M;
        ma[ps[i]]++;
    }
    ll ans = 0,d1,d2;
    for(auto it : ma)
    {
        d1 = it.fi;
        d2 = it.se;
        ans += ((d2*(d2-1ll))/2ll);
    }
    cout << ans ;
}

int main()
{
    clock_t time1 = clock();
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    init();
    clock_t time2 = clock();
    cerr <<"Time: " <<(double)(time2-time1)/CLOCKS_PER_SEC * 100000 <<" seconds" <<endl;
	return 0;
    }


Measured memory_bytes: 5760
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntListN n = map readInt <$> replicateM (fromIntegral n) BS.getLine

checkNum :: [Int] -> [Int] -> [Int]
checkNum (x : xs) ys
  | elem x ys = 1 : checkNum xs ys
  | otherwise = 0 : checkNum xs ys

bingos = [[1, 0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1], [1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 0]]

checkBingo :: [[Int]] -> [Int] -> Int
checkBingo [] ys = 0
checkBingo (xs : xss) ys
  | foldr (+) 0 (zipWith (*) xs ys) == 3 = 1 + checkBingo xss ys
  | otherwise = checkBingo xss ys

main = do
  card <- getIntNList 3
  n <- getInt
  bs <- getIntListN n
  if n < 3 then 
    putStrLn "No"
  else do
    let cardList = checkNum (concat card) bs
    let result = checkBingo bingos cardList
    if result == 0
      then putStrLn "No"
      else putStrLn "Yes"


Measured memory_bytes: 380
#include <stdio.h>

int main(){
	int a,b,c=0,d,i;
	while(1){
		c=0;
	scanf("%d",&a);
		if(a==0){
			return 0;
		}
	for(i=0;i<9;i++){
		scanf("%d",&b);
		c+=b;
	}
	d=a-c;
	printf("%d\n",d);
	}
}
	

Measured memory_bytes: 600
"""
753の数
"""

import sys
sys.setrecursionlimit(100000)
N = int(input())
# seen = [False] * N
"""
1. Gを予め作って探索するパターン
2. Gを作りながら探索するパターン
"""
cnt = 0
def dfs(v):
    global cnt
    # vを訪問済みにする
    # seen[v] = True
    num = "753"
    #グラフ中の次のVについて
    for n in num:
        next_v = v + n
        # 探索打ち切り条件->
        # すでに探索済み or なにかの終了条件に引掛かる
        if int(next_v) > N: continue
        # 見られていない場合、再帰的に探索
        dfs(next_v)
        if "3" in next_v and "5" in next_v and "7" in next_v:
            cnt += 1

dfs("")
print(cnt)	

Measured memory_bytes: 3060
h, w, k = gets.split.map(&:to_i)
c = []
h.times do |hi|
  c << gets.chomp.chars
end

hh = (0...h).to_a
ww = (0...w).to_a

hc = []
(0..h).each do |n|
  hc.concat(hh.combination(n).to_a)
end

wc = []
(0..w).each do |n|
  wc.concat(ww.combination(n).to_a)
end

ans = 0
hc.each do |hci|
  wc.each do |wci|
    tmp = Marshal.load(Marshal.dump(c))
    hci.each do |hi|
      w.times {|wi| tmp[hi][wi] = '.'}
    end
    wci.each do |wi|
      h.times {|hi| tmp[hi][wi] = '.'}
    end
    ans += 1 if tmp.flatten.count('#') == k
  end
end
puts ans


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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    
const long DIVIDE = 1e9+7;

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    
// ****** print functions ****** //
template <class T, class U>
void print_pairs(const vector<pair<T, U>> pairs);
template <class K, class V>
void print_map(const map<K, V> m);


int main() {    
    int x, a;
    cin >> x >> a;
    int ans;
    if(x < a) {
        ans = 0;
    } else {
        ans = 10;
    }
    cout << ans;
    return 0;   
}   

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}

template <class T, class U>
void print_pairs(const vector<pair<T, U>> &pairs) {
    for(int i=0; i<pairs.size(); i++) { 
        cout << "(" << pairs[i].first << ", " << pairs[i].second << ")" << " "; 
    } 
    cout << endl;
}

template <class K, class V>
void print_map(const map<K, V> &m) {
    for(auto it=m.cbegin(); it!=m.cend(); it++) {
        cout << it->first << ": " << it->second << endl;
    }
}


Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod  1000000007
#define PI 2*acos(0.0)
#define maxn 100009

int32_t main()
{
    io;
    string a, b;
    cin>>a>>b;
    int ans = 0;
    for(int i = 0;i < a.size(); i++)
        if(a[i] != b[i])
            ans++;
    cout<<ans;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll n;

vector<ll> num;

void rec(ll d, ll n) {
    if (d > 10) return;

    if (to_string(n).find('3') != string::npos && to_string(n).find('5') != string::npos && to_string(n).find('7') != string::npos) {
        num.push_back(n);
    }

    rec(d + 1, n * 10 + 3);
    rec(d + 1, n * 10 + 5);
    rec(d + 1, n * 10 + 7);
}

int main() {

    cin >> n;

    rec(0, 0);
    sort(num.begin(), num.end());

    ll ans = 0;
    for (ll x : num) {
        if (x <= n) ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int selectionSort(int A[], int N) {
	int res = 0;
	for (int i = 0; i < N; ++i) {
		int minj = i;
		for (int j = i; j < N; ++j)
			if (A[j] < A[minj]) minj = j;
		if (i != minj) swap(A[i], A[minj]), res++;
	}
	return res;
}

int main() {
	int A[100];
	int N; cin >> N;
	for (int i = 0; i < N; ++i) cin >> A[i];
	int ans = selectionSort(A, N);
	for (int i = 0; i < N; ++i) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl << ans << endl;

	return 0;
}


Measured memory_bytes: 3072
h,w,k=map(int,input().split())
c=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
ans=0
for i in range(h):
    a=input()
    for j in range(w):
        c[i][j]=a[j]
for i in range(2**(h+w)):
    for m in range(h):
        for n in range(w):
            d[m][n]=c[m][n]
    for j in range(h):
        if (i >> j)&1:
            for x in range(w):
                d[j][x]="r"
    for j in range(h,w+h):
        if (i >> j)&1:
            for x in range(h):
                d[x][j-h]="r"
    f=0
    for q in range(h):
        for s in range(w):
            if d[q][s]=="#":
                f+=1
            
        
    if f==k:
        ans+=1
print(ans)

        
    
    
    
        
        
    
    
    
    
        


Measured memory_bytes: 74212
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int h,w,k,ans[301][301],sum[301][301];
char c[301][301];
int main(){
    cin>>h>>w>>k;
    for(int i=0;i++<h;)for(int j=0;j++<w;){
        cin>>c[i][j];
        if(c[i][j]=='#')ans[i][j]=k--;
    }
    for(int i=0;i++<h;){
        for(int j=1;j++<w;){
            if(ans[i][j]==0)ans[i][j]=ans[i][j-1];
        }
        for(int j=w;j;j--){
            if(ans[i][j]==0)ans[i][j]=ans[i][j+1];
        }
    }
    for(int j=0;j++<w;){
        for(int i=1;i++<h;){
            if(ans[i][j]==0)ans[i][j]=ans[i-1][j];
        }
        for(int i=h;i;i--){
            if(ans[i][j]==0)ans[i][j]=ans[i+1][j];
        }
    }
    for(int i=0;i++<h;){
        for(int j=0;j++<w;){
            if(j!=1)cout<<" ";
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a[110], b[110], c, m, n, i, x=0;
    cin>>n>>m>>c;
    for(i=0; i<m; i++)
    	cin>>b[i];
    while(n--)
    {
    	int s=0;
    	for(i=0; i<m; i++)
    	{
    		cin>>a[i];
    		s+=(a[i]*b[i]);
    	}
    	if((s+c)>0)
    		x++;
    }
    cout<<x;
}
    	

Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,K;
    cin>>N>>K;
    vll h(N);
    for(ll i=0;i<N;i++){
        cin>>h[i];
    }
    
    sort(h.begin(),h.end());
    
    ll ans=LLMAX;
    for(ll i=0;i+K-1<N;i++){
        if(h[i+K-1]-h[i]<ans)ans=h[i+K-1]-h[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

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

using namespace std;

int main()
{
	int n;
	while(cin >> n)
	{
		if(n == -1) break;
		
		long long ans = 0;
		
		for(int i=0;n>0;i++)
		{
			ans += (n%4)*pow(10,i);
			n /= 4;
		}

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

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
const ll mod2= 998244353;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main(){
    ll n,k,ans=0;
    string s;
    cin>>s;
    if(s[s.length()-1]=='s')cout<<s<<"es";
    else cout<<s<<"s";
    
}



Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>
int main(void){
    char s[101];
    int i,l;
    scanf("%s",s);

    l=strlen(s);

    /*for(i=0;i<l;i++){
        s[i]=='x';
    }*/
    for(i=0;i<l;i++){
        printf("%c",'x');
    }
    return 0;    
}


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

Alice = []
Bob = []

a = list(map(int, input().split()))
a.sort(reverse=True)

if len(a) % 2 == 1:
    a.append(0)

while len(a) > 0:
    Alice.append(a.pop(0))
    Bob.append(a.pop(0))

print(sum(Alice) - sum(Bob))

Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String X = sc.next();

		if (X.equals("Sunny")) {
			System.out.println("Cloudy");
		}else {
			if(X.equals("Cloudy")) {
				System.out.println("Rainy");
			}else{
				System.out.println("Sunny");
			}
		}

	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void) {
	// your code goes here
	int n;
	long a,i,sum,max,min;
	sum = 0;
	
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%ld\n",&a);
		if(i == 0) {max = a; min = a;}
		else{
		if(a > max) max = a;
		if(a < min) min = a;
		}
		sum = sum + a;
	}
	
	printf("%ld %ld %ld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2128
#include <stdio.h>

int main(void) {
  int N, H, W, A, B, materials;
  for (scanf("%d%d%d",&N,&H,&W), materials = 0; N && scanf("%d%d",&A,&B); N--) {
    if (A >= H && B >= W) {
      materials += 1;
    }
  }
  printf("%d",materials);
  return 0;
}

Measured memory_bytes: 128
use std::vec::Vec;
use std::cmp::*;
use::std::collections::VecDeque;


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (n, m) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1])
    };

    let mut g: Vec<Vec<Vec<(usize, usize)>>> = vec![vec![vec![]; 3]; n];
    for _ in 0..m {
      let v: Vec<usize> = read_vec();
      g[v[0] - 1][0].push((v[1] - 1, 1));
      g[v[0] - 1][1].push((v[1] - 1, 2));
      g[v[0] - 1][2].push((v[1] - 1, 0));
    }
    let (s, t) = {
      let v: Vec<usize> = read_vec();
      (v[0] - 1, v[1] - 1)
    };

    match bfs_dist(n, &g, s, t) {
      std::u64::MAX => {println!("-1");},
      n => {println!("{}", n/3);},
    };


}

//単一視点から目的のノードまでの最短距離、ただし全ての辺の重みが等しいグラフに限る
fn bfs_dist(n: usize, g: &Vec<Vec<Vec<(usize, usize)>>>, start: usize, goal: usize) -> u64 {
  let mut visit = vec![vec![false; 3]; n];
  let mut q: VecDeque<(usize, usize)> = VecDeque::new();
  let mut dist = vec![vec![std::u64::MAX; 3]; n];

  //init
  visit[start][0] = true;
  q.push_back((start, 0));
  dist[start][0] = 0;

  while !q.is_empty() {
    let now
     = match q.pop_front() {
        None => (0, 0),
        Some(e) => e,
     };

    if goal == now.0 && now.1 == 0 {
      break;
    }

    for &e in &g[now.0][now.1] {
      if !visit[e.0][e.1] {
          visit[e.0][e.1] = true;
          dist[e.0][e.1] = min(dist[e.0][e.1], dist[now.0][now.1] + 1);
          q.push_back(e);
      }
    }
  }
  return dist[goal][0];
}


Measured memory_bytes: 47356
#include<stdio.h>
int main(void)
{
  int min, max,count=0,i,keta1,keta2,keta4,keta5,num,keta3;
  scanf("%d%d",&min,&max);
  for(i=min; i<=max; i++)
  {
    num=i;
    keta1=num%10;
    num=num/10;
    keta2=num%10;
    num=num/10;
    keta3=num%10;
    num=num/10;
    keta4=num%10;
    num=num/10;
    keta5=num;
    if(keta1==keta5 && keta2==keta4) 
    {
      count++;

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

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

using namespace std;

int func(int k) {
    return (k*(k-1))/2;
}


int main() {
    
    int n,m;
    
    cin>>n>>m;
    
    int ans=0;
    
    if(n>=2) {
        ans+=func(n);
    }
    
    if(m>=2) {
        ans+=func(m);
    }
    
    cout<<ans;
    
    return 0;
}

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

int main(){
    ll N, K; cin >> N >> K;
    map<ll, ll> M;
    for(int i = 0; i < N; i++){
        int a; cin >> a;
        M[a]++;
    }
    vector<ll> V;
    for(auto m : M){
        V.push_back(m.second);
    }
    sort(V.begin(), V.end());
    ll num = V.size()-K;
    if(num <= 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    for(int i = 0; i < num; i++){
        ans += V[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 14964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long 

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

signed main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;++i)
    {
        int s=0;
        for(int j=i;j<n;++j)
        {
            s+=a[j];
            v.push_back(s);
        }
    }
    int ans=0;
    for(int i=50;i>=0;--i)
    {
        int r=((1ll)<<i);
        vector<int> c;
        for(int j=0;j<v.size();++j)
        {
            if((v[j]&r)==r)
            {
                c.push_back(v[j]);
            }
        }
        if(c.size()>=k)
        {
            v.clear();
            for(auto e:c)
            {
                v.push_back(e);
            }
            ans+=r;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 6512
import itertools
n=int(input())
l=[]
for i in range(n):l.append(input()[0])
c=[]
ul=["M","A","R","C","H"]
for i in ul:c.append(l.count(i))
cc=itertools.combinations(c, 3)
ans=0
for i,j,k in cc:ans+=i*j*k
print(ans)

Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
int a[10001],ans,n;
int main()
{
    cin>>n;
    for(int i=1;i<=2*n;i++)
        cin>>a[i];
    sort(a+1,a+1+2*n);
    for(int i=1;i<=2*n;i+=2)
    {
        ans+=a[i];
    } 
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdlib>
#include<string>
#include<sstream>
#include<vector>
#include<iostream>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<algorithm>
using namespace std;

int main(){
  long long N, M;
  vector<int> v;
  cin >> N >> M;

  v.resize(M);
  for(int i=0; i<M; i++) v[i] = 0;

  for(int i=0; i<N; i++) {
    int k;
    cin >> k;

    for(int j=0; j<k; j++) {
      int a;
      cin >> a;
      v[a-1]++;
    }
  }

  int ans = 0;
  for(int i=0; i<M; i++) {
    if(v[i] == N) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict
N = int(input())

c = Counter()
d = defaultdict(bool)

for i in range(1,N+1):
    s = str(i)
    c[(s[0],s[-1])] += 1
    d[(s[0],s[-1])] = True
    
k = list(c.keys())

ans = 0
for i,j in k:
    if d[(j,i)]:
        ans += (c[(i,j)]*c[(j,i)])
        d[(j,i)] = False
print(ans)

Measured memory_bytes: 3316
N,M = map(int, input().split())
Pi, Yi = [],[]

P_years = {}

for i in range(1,M+1):
    P,Y = map(int, input().split())
    Pi.append(P)
    Yi.append(Y)
    if P not in P_years.keys():
        P_years[P] = [(i,Y)]
    else:
        P_years[P].append((i,Y))

cities_order = [-1]*(M+1)
for k in P_years.keys():
    cities = sorted(P_years[k], key=lambda x: x[1])
    for j, city in enumerate(cities):
        cities_order[city[0]] = j+1

for j, p in enumerate(Pi):
    print("{:06}{:06}".format(p, cities_order[j+1]))


Measured memory_bytes: 38348
#include<bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 300005
#define LOG 10
#define M (N-5)
#define inf 1000000000
#define MOD 1000000007
using namespace std;

int main() {

	int n;

	scanf("%d",&n);

	int cnt[3]={0};
	int ans=1;

	for(int i=1;i<=n;i++) {

		int x;

		scanf("%d",&x);

		int t=0;

		for(int j=0;j<3;j++) t+=(cnt[j]==x);

		ans=(ll)ans*t%MOD;

		for(int j=0;j<3;j++) {
			if(cnt[j]==x) {
				cnt[j]++;
				break;
			}
		}

	}

	printf("%d",ans);

}


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

int main(void){
  int n, dim; cin >> n >> dim;
  double x[n][dim];
  for(int i=0; i<n; i++){
    for(int j=0; j<dim; j++){
      cin >> x[i][j];
    }
  }
  
  int sum = 0, count = 0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      for(int k=0; k<dim; k++){
        sum += pow(x[i][k] - x[j][k], 2.0);
      }
      for(int check = 1; check <= sum; check++){
        //root 1になる場合のためにイコールが必要
        if(check * check == sum) count++;
      } 
      sum = 0;
    }
  }
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
 
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define for1(i, n) for (int i = 1; i <= (int)n; i++)
#define forq(i, s, t) for (int i = s; i <= (int)t; i++)
#define ford(i, s, t) for (int i = s; i >= (int)t; i--)
#define all(v) v.begin(), v.end()
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
 
const double EPS = 1e-15;
const double PI = acos(-1.0);
const int MAXN = (int)1000 + 7;
const int INF = (int)1e9 + 7;
const int MOD = (int)1e9 + 7;
const ll P = 239017;
 
#define TASK "cave"
 
int solve();
 
int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("test.txt", "w", stderr);
    double tstart = TIME;
#else
 //   freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
#endif
    solve();
#ifdef _DEBUG
    double tend = TIME;
    cerr << tend - tstart << " s.\n";
#endif
    return 0;
}

int cnt[(int)1e5 + 123];
 
int solve() {
 	int n, x;
 	cin >> n;
 	int ans = 0;
 	for (int i = 0; i < n; i++) {
 		cin >> x;
 		x++;
 		cnt[x-1]++, cnt[x]++, cnt[x+1]++;
 		ans = max(ans, max(cnt[x-1], max(cnt[x], cnt[x + 1])));
 	}
 	cout << ans;
 	return 0;
 }


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int K[6] = {0, 3, 4, 0, 3, 4};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    int T[7];
    rep(i, 7) cin >> T[i];
    ans += T[1] * 2;
    int original[7] = {};
    rep(i, 7) original[i] = T[i];
    rep(i, 3) {
        ans += (T[K[i]] / 2) * 4;
        T[K[i]] -= (T[K[i]] / 2) * 2;
    }
    if (T[0] == T[3] && T[3] == T[4] && T[0] == 1) {
        ans += 6;
    }
    else {
        rep(i, 3) {
            if (T[K[i]] == T[K[i + 1]] && T[K[i]] == 1 && original[K[i + 2]] >= 2) {
                ans += 2;
                break;
            }
        }
    }
    cout << ans / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<cctype>
#include<algorithm>
using namespace std;
typedef set<string>T;
int main()
{
	int i,j,len,x,c;
	string s,t,u,v;
	T S;
	T::iterator p,q;
	while(getline(cin,s))
	{
		for(c=i=0;i<s.size();)
			if(isalpha(s[i]))s[i]=toupper(s[i]),++i;
			else s.erase(i,1);
		len=s.size();
		for(x=0;x<2;++x)
		{
			S.clear();
			for(i=1;i<len-1-x;++i)
			{
				for(j=min(i,len-i-1-x);j>0;--j)
				{
					u=t=s.substr(i-j,2*j+1+x);
					reverse(u.begin(),u.end());
					if(t==u)
					{
						S.insert(t);
						break;
					}
				}
			}
			for(p=S.begin();p!=S.end();)
			{
				for(q=p,++q;q!=S.end();)
				{
					t=*p;
					u=*q;
					i=t.size();
					j=u.size();
					if(i<j)
					{v=u.substr((j+1)/2-(i+1)/2,i);
						if(v==t)
						{	S.erase(p++);
							goto E;
						}
					}
					else if(i>j)
					{
						v=t.substr((i+1)/2-(j+1)/2,j);
						if(v==u)
						{
							S.erase(q++);
							continue;
						}
					}
					++q;
				}
				++p;
E:;
			}
			for(p=S.begin();p!=S.end();++p)
			{
				if(c++)cout<<' ';
				cout<<*p;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 912
n=int(input())
arr=[input() for _ in range(n)]
dic={}
alphabet='abcdefghijklmnopqrstuvwxyz'
for s in arr:
  count=[0]*26
  for i in range(10):
    for j in range(26):
      if s[i]==alphabet[j]:
        count[j]+=1
        break
  count=tuple(count)
  if count not in dic:
    dic[count]=1
  else:
    dic[count]+=1
ans=0
for val in dic.values():
  ans+=val*(val-1)//2
print(ans)

Measured memory_bytes: 120452
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int L, A_in, B_in, M;

typedef vector<long long int> vec;
typedef vector<vec> mat;

// A*B 
mat mul(mat &A, mat &B){
	mat C(A.size(), vec(B[0].size()));
	for(int i = 0; i < A.size(); i++){
		for(int k = 0; k < B.size(); k++){
			for(int j = 0; j < B[0].size(); j++){
				C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
			}
		}
	}
	return C;
}

// A^n 
mat pow(mat A, long long int n){
	mat B(A.size(), vec(A.size()));
	for(int i = 0; i < A.size(); i++){
		B[i][i] = 1;
	}
	while(n > 0){
		if(n & 1){
			B = mul(B, A);
		}
		A = mul(A, A);
		n /= 2;
	}
	return B;
}

long long int pow_n(long long int num, long long int pow_num){
	long long int mod_num = M;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

int main(){
    cin >> L >> A_in >> B_in >> M;
    long long int ans = 0;
    long long int DS = 1;
    for(long long int d = 18; d >= 1; d--){
        long long int n1 = 1;
        for(int i = 0; i < d - 1; i++){
            n1 *= 10;
        }
        long long int n2 = n1 * 10 - 1;
        if(n2 < A_in){
            break;
        }
        long long int p1 = (n1 - A_in) / B_in + ((n1 - A_in) % B_in != 0);
        if(n1 < A_in){
            p1 = 0;
        }
        long long int p2 = (n2 - A_in) / B_in;
        p1 = max(p1, 0LL);
        p2 = min(p2, L - 1);
        //cout << d << " " << p1 << " " << p2 << endl;
        if(p1 > L || p2 < 0 || p2 < p1){
            continue;
        }
		mat P(3, vec(3));
        P[0][0] = pow_n(10, d);
        P[1][0] = 1;
        P[1][1] = 1;
        P[2][1] = 1;
        P[2][2] = 1;
        P = pow(P, p2 - p1 + 1);
        
		mat S(3, vec(1));
		S[0][0] = 1;
        S[1][0] = S[2][0] = 0;
        
		mat res = mul(P, S);
        
        for(int i = 0; i < 3; i++){
            //cout << res[i][0] << endl;
        }
        
        long long int A1 = A_in % M + B_in % M * p1 % M;
        long long int B1 = B_in % M;
		ans += res[1][0] * A1 % M * DS;
        ans %= M;
		ans += res[2][0] * B1 % M * DS;
        ans %= M;
        //cout << A1 << " " << B1 << " " << DS << endl;
        DS *= pow_n(pow_n(10, d), p2 - p1 + 1);
        DS %= M;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)
int main(){
    string S; cin >> S;
    int N = S.size();

    int ans = N;
    rep(i, 0, N-1){
        if(S[i] !=  S[i+1]){
            ans = min(ans, max(i + 1, N - 1 - i));
        }
    }
    cout << ans << endl;
}

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

int main(){
    //入力
    int H,W;
    
    cin >> H >> W;

    vector<vector<char>> C_ori(H,vector<char>(W));

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> C_ori.at(i).at(j);
        }
    }

    //出力
    for(int i=0;i<2*H;i++){
        for(int j=0;j<W;j++){
        cout << C_ori.at(i/2).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,day,rem,ans;
    cin >> n >> day >> rem ; 
    ans = n;
    while (n--){
        int a; cin>>a;
        int h=day/a;
        if (a*h+1>day) h--;
        ans += h;
    }
    cout << ans+rem << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int a,b;cin>>a>>b;
    int c = b-a;
    int x = c*(1+c)/2;
    cout << (x-b) << endl;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        h: usize,
        w: usize,
        a: usize,
        b: usize,
    };
    for r in 0..h {
        for c in 0..w {
            print!(
                "{}",
                match (r < b, c < a) {
                    (true, true) => 0,
                    (true, false) => 1,
                    (false, true) => 1,
                    (false, false) => 0,
                }
            );
        }
        println!();
    }
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-9;
const ll MOD = 1e9 + 7;
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        arr[i]*=-1;
    }
    vector<int>lcs;
    for(int i=0;i<n;i++)
    {
        int ind=upper_bound(lcs.begin(),lcs.end(),arr[i])-lcs.begin();
        if(ind == lcs.size())
            lcs.push_back(arr[i]);
        else
            lcs[ind]=arr[i];
    }
    cout<<lcs.size()<<endl;
    return 0;
}

Measured memory_bytes: 1276
#include <cstdio>

int N;
int A[100000];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) 
        scanf("%d", &A[i]);
    typedef long long ll_t;
    ll_t res = 0;
    int p = 1;
    for (int i = 0; i < N; i++) {
        if (A[i] > p) {
            int x = (A[i] - 1) / p;
            res += x;
        } 
        if (i == 0 || A[i] == p)
            p++;
        //printf("%d %d %lld\n", i, p, res);
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main() {
	char a, b;

	scanf("%s %s",&a,&b);
	
	if (a=='H'&&b=='H') {
		printf("H");

	}
	else if( a == 'D' && b == 'D') {
		printf("H");

	}
	else {
		printf("D");
	}

	return 0;
}


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

using namespace std;

const int N = 100001;
vector<int> g[N];
int n,m;

int f[N];

void enter()
{
    int u,v;
    cin >> n >> m;
    for (int i=0; i<m; i++)
    {
        cin >> u >> v;
        g[u].push_back(v);
    }
}

int F(int u)
{
    if (f[u])
        return f[u];
    f[u] = 1;
    for (int v: g[u])
    {
        f[u] = max(1 + F(v), f[u]);
    }
    return f[u];
}

int main()
{
    enter();
    int r = 0;
    for (int i=1; i<=n; i++)
        r = max(r, F(i));
    cout << r - 1;
    return 0;
}


Measured memory_bytes: 7424
import java.util.Scanner;


public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a+b+c>=22) {
      System.out.println("bust");
    } else {
      System.out.println("win");
    }
  }
}


Measured memory_bytes: 22868