akhauriyash/Code-Regression huggingface dataset:
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

type drink struct {
	price int
	num   int
}

type drinkList []drink

func (d drinkList) Len() int {
	return len(d)
}

func (d drinkList) Swap(i, j int) {
	d[i], d[j] = d[j], d[i]
}

func (d drinkList) Less(i, j int) bool {
	return d[i].price < d[j].price
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	M := io.NextInt()

	d := make(drinkList, N)
	for i := 0; i < N; i++ {
		d[i].price = io.NextInt()
		d[i].num = io.NextInt()
	}
	sort.Sort(d)
	res := 0
	for _, v := range d {
		if M >= v.num {
			M -= v.num
			res += v.num * v.price
		} else {
			res += M * v.price
			break
		}
	}
	io.PrintLn(res)
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;



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

  ll ans = 0;
  ll p = 1;
  while (p <= h){
    ans += p;
    p *= 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char **argv)
{
    int X;
    std::cin >> X;

    int n_500 = X / 500;
    int n_5 = (X % 500) / 5;

    std::cout << ((n_500) * 1000 + (n_5) * 5) << std::endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <gmpxx.h>

using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

ll gcd(ll a,ll b){
    if(b) return gcd(b,a%b);
    else return a;
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
//ll f(ll x,ll c,ll d){
//    ll res = x;
//    res -= x/c;
//    res -= x/d;
//    res += x/lcm(c,d);
//    return res;
//}

class CAntiDivision {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll a,b,c,d;
	    in>>a>>b>>c>>d;
	    auto f = [c,d](ll x){ return x-(x/c)-(x/d)+(x/lcm(c,d));};
	    out<<f(b)-f(a-1)<<endl;



	}
};


int main() {
	CAntiDivision solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

//最大公約数
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
//最小公倍数
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B;
  cin >> A >> B;
  cout << lcm(A, B) << endl;
}


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

string S; bool p[10009];

int main() {
	cin >> S;
	bool OK = true;
	if (S[0] != 'A') { OK = false; }p[0] = true;
	int cnt = 0; for (int i = 2; i < S.size() - 1; i++) { if (S[i] == 'C') { cnt++; p[i] = true; } }
	if (cnt != 1) OK = false;
	for (int i = 0; i < S.size(); i++) {
		if (p[i] == false && S[i] >= 'A' && S[i] <= 'Z') OK = false;
	}

	if (OK == true) cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}

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

void solve() {
	long long n, k;
	cin >> n >> k;
	vector<int> nums(n), lol(n);
	map<int, int> m;
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
		nums[i]--;
	}
	int cur = 0, last;
	for (last = 0; !m.count(cur); last++) {
		m[cur] = last;
		lol[last] = cur;
		cur = nums[cur];
	}
	int bef = m[cur], loop = last - m[cur];
	if (k >= bef) k = (k - bef) % loop + bef;
	cout << lol[k] + 1 << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 13948
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 1e5+10;
int a[N];
int main(){
    string s1;
    cin >> s1;
    int n = s1.size();
    for(int i=0;i<n;++i)    cout << 'x';
    cout << '\n';




    return 0;
}

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

using namespace std;

int main(){
	int a[4] = {6000, 4000, 3000, 2000}, b, c;
	for (int i = 0; i < 4; i++){
		scanf("%d%d", &b, &c);
		printf("%d\n", a[b-1]*c);
	}
return 0;
}

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


using namespace std;


const int MOD = 1e9 + 7;
const int N = 1e5;
const long long INF = 1e9;


int main() {
  	long long a, b;
  	cin >> a >> b;
  	long long g = __gcd(a, b);
  	int ans = 1;
  	for (int i = 2; 1ll * i * i <= g; i++) {
    	if (g % i == 0) {
          	ans++;
         	while (!(g % i))
              	g /= i;
        }
    }
  	if (g > 1)
      	ans++;
  	cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int c,a,n,q;
int main(){
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>c>>a>>n;
        int cnt=0;
        while(1){
            if(n>0&&a>0&&c>0){
                cnt++;n--;a--;c--;
            }else if(a>0&&c>1){
                cnt++;a--;c-=2;
            }else if(c>2){
                cnt++;c-=3;
            }else break;
        }
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e18+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    map<ll,ll> m;
    rep(i,0,n){
        cin >> a[i];
        m[a[i]]++;
    }
    ll ans = 0;
    for(auto x: m){
        if(x.first>x.second) ans+= x.second;
        else if(x.first<x.second) ans += (x.second-x.first);
    }
    cout << ans << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int A, B;
  cin >> A >> B;
  int ans = max(A+B, max(A - B, A * B));
  cout << ans << endl;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n,m;
	cin>>n>>m;
	
	int f=1,b=n;
	while (m--){
		if ((b-f)*2==n || (b-f)*2==n-2) f++;
		cout<<f<<" "<<b<<endl;
		f++,b--;
	}
}


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


def p(m,n):
    a = 1
    for i in range(n):
        a = a*(m-i)
    return a

def p_mod(m,n,mod):
    a = 1
    for i in range(n):
        a = a*(m-i) % mod
    return a

def c(m,n):
    return p(m,n) // p(n,n)

def c_mod(m,n,mod):
    return (p_mod(m,n,mod)*pow(p_mod(n,n,mod),mod-2,mod)) % mod


for i in range(1,K+1):
    print((c_mod(N-K+1,i,mod) * c_mod(K-1,i-1,mod)) % mod)

Measured memory_bytes: 43504
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N) {
        // ll a,b;
        // printf("%d.%d")
        // A[i] = (ll)(a * 1e9);
        std::string s;
        std::cin >> s;

        std::string g;  // 小数点以下を取り出したもの
        if (std::count(s.begin(), s.end(), '.') != 0) {
            while (s.back() != '.') {
                g.push_back(s.back());
                s.pop_back();
            }
            s.pop_back();
            std::reverse(g.begin(), g.end());
        }
        while ((int)g.length() < 9) g.push_back('0');

        // 整数に変換
        A[i] = std::stoi(s) * 1000000000LL + std::stoi(g);
    }
    vector<int> t(N), f(N);
    vector<vector<ll>> v(20, vector<ll>(20,0));
    REP(i, N){
        while((A[i]%2)==0){
            t[i]++;
            A[i] /= 2;
        }
        while((A[i]%5)==0){
            f[i]++;
            A[i] /= 5;
        }
        v[t[i]>18?18:t[i]][f[i]>18?18:f[i]]++;
    }
    ll ans = 0;
    REP(i, 20)REP(j, 20){
        REP(x, 20)REP(y, 20){
            if(i+x>=18 && j+y>=18){
                if(i==x && j==y && v[i][j] > 0) ans += v[i][j] * (v[x][y]-1);
                else ans += v[i][j] * v[x][y];
            }
        }       
    }
    pr(ans/2);

}

Measured memory_bytes: 6412
/*
    When you are not practicing someone else is,
    and the day u meet them u will Lose.

    So, all you need is Practice, Practice and Practice.
*/
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
/**********************************************************************************/



const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>n>>x>>y;
    
    
    n=ceil(n*1.0/x);
    
    cout<< y*n<<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll N, M;
    cin >> N >> M;

    priority_queue<ll> que;
    for (int i = 0; i < N; i++) {
        ll A;
        cin >> A;
        que.push(A);
    }

    ll q;
    for (int i = 0; i < M; i++) {
        q = que.top(); que.pop();
        que.push(q / 2);
    }

    ll ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 1400
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int h, w; cin >> h >> w;
	vector<string> s(h); rep(i, h)cin >> s[i];
	ll res = 0;
	int d[] = { 0,1,0,-1 };
	vector<vector<bool>> passed(h, vector<bool>(w));
	rep(i, h)rep(j, w)
	{
		if (s[i][j] == '.' || passed[i][j])continue;
		passed[i][j] = true;
		queue<pair<int, int>> q;
		q.push(make_pair(i, j));
		ll B = 1, W = 0;
		while (!q.empty())
		{
			int x, y;
			tie(x, y) = q.front();
			q.pop();
			rep(k, 4)
			{
				int nx = x + d[k];
				int ny = y + d[k ^ 1];
				if (nx < 0 || h <= nx || ny < 0 || w <= ny)continue;
				if (passed[nx][ny])continue;
				if (s[x][y] != s[nx][ny])
				{
					q.push(make_pair(nx, ny));
					passed[nx][ny] = true;
					if (s[nx][ny] == '.')++W;
					else ++B;
				}
			}
		}
		res += B * W;
	}
	cout << res << endl;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll N;
  cin>>N;
  string S;
  cin>>S;
  ll ans=1;
  
  for(ll i=1;i<N;i++){
    if(S[i]!=S[i-1]){
      ans++;
    }
  }
cout<<ans<<endl;
}

      

Measured memory_bytes: 512
X = int(input())
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
for i in range(X,10**6+1):
    if is_prime(i):
        print(i)
        exit()

Measured memory_bytes: 3060
#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 << "Left" << endl;
  }else if(A + B == C + D){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 3588
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld;

const ll inf=1e18;
const int N=1e5+100;
vector<ii>gfo[N];
priority_queue<ii,vector<ii>,greater<ii>>pq;

void dijkstra(int s,vector<ll>&dist){
	For(i,0,sz(dist))dist[i]=inf;
	dist[s]=0;
	pq.push({0,s});
	while(!pq.empty()){
		ii data=pq.top();
		pq.pop();
		int d=data.ff;
		int u=data.ss;
		if(d>dist[u])continue;
		for(ii v:gfo[u]){
			if(dist[u]+v.ss<dist[v.ff]){
				dist[v.ff]=dist[u]+v.ss;
				pq.push({dist[v.ff],v.ff});
			}
		}
	}
}

const int mod=1e9+7;
vector<int>adj[3][N];
vector<ii>ctm[N];
bool vst[N];
ll dp[3][N];
int in[N];

void build(int s,int n,int id){
	memset(in,0,sizeof(in));
	For(i,0,n)for(int v:adj[id][i])in[v]++;
	queue<int>q;	
	q.push(s);
	dp[id][s]=1;
	
	//cout<<"inicio build"<<endl;
	//For(i,0,n)trace(in[i]);
	
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int v:adj[id][u]){
			//trace(v);
			in[v]--;
			//trace(in[v]);
			dp[id][v]+=dp[id][u];
			if(dp[id][v]>=mod)dp[id][v]-=mod;
			if(in[v]==0)q.push(v);
		}
	}

	//For(i,0,n)trace(dp[id][i]);

}



int main(){	
	int n,m;cin>>n>>m;
	int s,t;cin>>s>>t;
	s--,t--;
	For(i,0,m){
		int u,v,d;cin>>u>>v>>d;
		u--,v--;
		gfo[u].pb({v,d});
		gfo[v].pb({u,d});
	}
	vector<ll>d1(n),d2(n);
	dijkstra(s,d1);
	dijkstra(t,d2);

	//For(i,0,n)cout<<d1[i]<<" ";
	//cout<<endl;
	//For(i,0,n)cout<<d2[i]<<" ";
	//cout<<endl;

	if(d1[t]==-1){
		cout<<"0"<<endl;
		return 0;
	}
	For(u,0,n)if(d1[u]!=-1){
		for(ii v:gfo[u]){
			if(d1[u]+v.ss==d1[v.ff]){
				if(d1[u]+d2[v.ff]+v.ss!=d1[t])continue;
				adj[0][u].pb(v.ff);
				adj[1][v.ff].pb(u);
				ctm[u].pb(v);
			}
		}
	}

	//For(u,0,n){
	//	trace(u);
	//	for(int v:adj[1][u])cout<<v<<" ";
	//	cout<<endl;
	//}

	memset(vst,false,sizeof(vst));
	build(s,n,0);
	memset(vst,false,sizeof(vst));
	build(t,n,1);
	
	ll ans=dp[0][t];
	ans=(ans*ans)%mod;
	//trace(dp[0][t]);
	//trace(ans);
	For(i,0,n)if(d1[i]+d2[i]==d1[t]){
		if(d1[i]!=d2[i])continue;
		//trace(i);
		ll val=(dp[0][i]*dp[1][i])%mod;
		ans-=(val*val)%mod;
		if(ans<0)ans+=mod;
	}

	//trace(ans);

	For(u,0,n){
		for(ii par:ctm[u]){
			int v=par.ff;
			ll w=par.ss;
			ll dif=abs(d1[u]-d2[v]);
			if(dif<w){
				ll val=(dp[0][u]*dp[1][v])%mod;
				ans-=(val*val)%mod;
				if(ans<0)ans+=mod;
			}
		}
	}


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


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);

    for (int i = 0; i < N;i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    cout << A.at(N-1)-A.at(0) << endl;
}


Measured memory_bytes: 256
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import numpy as np


def create_graph(N, edge_pairs, is_bi_dir=False):
    in_vs, out_vs, weights = [], [], []
    for s, t, w in edge_pairs:
        in_vs.append(s)
        out_vs.append(t)
        weights.append(w)
        if is_bi_dir:
            in_vs.append(t)
            out_vs.append(s)
            weights.append(w)
    return csr_matrix((weights, (in_vs, out_vs)), shape=(N, N), dtype=np.int64)


N, M, L = map(int, input().split())
edge_pairs = []
for _ in range(M):
    s, t, w = map(int, input().split())
    edge_pairs.append((s-1, t-1, w))
graph = create_graph(N, edge_pairs, True)
dist = floyd_warshall(graph, directed=False)
edge_pairs = []
for i in range(N):
    for j in range(i+1, N):
        if dist[i][j] <= L:
            edge_pairs.append((i, j, 1))
graph = create_graph(N, edge_pairs, True)
dist = floyd_warshall(graph, directed=False)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    ans = dist[s-1][t-1]
    if np.isinf(ans):
        print(-1)
    else:
        print(int(ans - 1))


Measured memory_bytes: 24688
#include<iostream>
using namespace std;
main()
{
	string s;cin>>s;
	int n=s.size();
	int m=0,a[3];
	for(int i=0;i<n;)
	{
		a[0]=a[1]=a[2]=0;
		while(i<n&&s[i]!='J')i++;
		while(i<n&&s[i]=='J')a[0]++,i++;
		if(s[i]!='O'||i==n)continue;
		while(i<n&&s[i]=='O')a[1]++,i++;
		if(s[i]!='I'||i==n)continue;
		while(i<n&&s[i]=='I')a[2]++,i++;
		if(a[0]>=a[1]&&a[2]>=a[1])m=max(m,a[1]);
	}
	cout<<m<<endl;
}

Measured memory_bytes: 3964
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {
  string s; cin >> s;
  if( s[0] != 'A' ){
    cout << "WA" << endl;
    return 0;
  }
  int c = 0;
  int cnt = 0;
  for(int i=1; i<s.size(); i++){
    if( s[i] == 'C' && 2 <= i && i <= s.size()-2) c++;
    if( 'a' <= s[i] && s[i] <= 'z' ) cnt++;
  }

  if( c == 1 && cnt + 1 + c == s.size() ){
    cout << "AC" << endl;
  }else cout << "WA" << endl;

  return 0;
}




//


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

int main() {

	int n, x, y, z;
	int a[100], b[100], c[100];

	cin >> n;

	cin >> x;
	for(int i = 0; i < x; i++)
		cin >> a[i];

	cin >> y;
	for(int i = 0; i < y; i++)
		cin >> b[i];

	cin >> z;
	for(int i = 0; i < z; i++)
		cin >> c[i];

	sort(a, a + x);
	sort(b, b + y);
	sort(c, c + z);

	int p = 0, q = 0, r = 0, m = 0;

	for(int i = 1; i <= n; i++){
		if(b[q] == i && c[r] == i){
			m++;
			q++;
			r++;
			if(a[p] == i)
				p++;
		}
		else if (a[p] != i && b[q] != i && c[r] == i){
			m++;
			r++;
		}
		else{
			if(a[p] == i)
				p++;
			if(b[q] == i)
				q++;
			if(c[r] == i)
				r++;
		}
	}

	cout << m << endl;

	return 0;
}


Measured memory_bytes: 3168
import numpy as np
N , M = map(int,input().split())
L = []
R = []
for i in range(M):
	L_M = list(map(int,input().split()))
	L.append(L_M[0])
	R.append(L_M[1])
print(max(0,(min(R) - max(L) + 1)))

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

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int a, b;
	cin >> a >> b;
	if (1 <= a && a <= 9 && 1 <= b && b <= 9) { cout << a * b << endl; }
	else { cout << -1 << endl; }
	return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/23/20 23:55:06
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,m; cin>>n>>m;
  struct Trans {
    int t;
    ll s;
  };
  constexpr ll INF = 1e18;
  cerr<<INF<<endl;
  vector<Trans> graph[n];
  for (int i = 0; i < m; i++) {
    int u,v,s; cin>>u>>v>>s; u--; v--;
    graph[u].push_back({v,s});
    graph[v].push_back({u,s});
  }
  vector<pair<ll,ll>> ranges(n, {INF,INF});
  auto dfs = [&ranges, &graph](auto& f, int s, ll w, bool odd) {
    if (odd) {
      if (ranges[s].first != INF) {
        return ranges[s].first == w;
      } else {
        ranges[s].first = w;
      }
    } else {
      if (ranges[s].second != INF) {
        return ranges[s].second == w;
      } else {
        ranges[s].second = w;
      }
    }
    for (auto [t,ts]:graph[s]) {
      if (!f(f, t, ts-w, !odd)) return false;
    }
    return true;
  };
  if (dfs(dfs, 0, 0, true)) {
    ll inf=1, sup=INF;
    for (auto [l,h]:ranges) {
      if (l!=INF and h!=INF) {
        if ((h-l)%2==1) {
          inf = INF;
          sup = 0;
          break;
        } else {
          auto t = (h-l)/2;
          inf = max(inf, t);
          sup = min(sup, t);
        }
      }
      if (l!=INF) {
        inf = max(inf, 1-l);
      }
      if (h!=INF){
        sup = min(sup, h-1);
      }
    }
    cout << max(0ll, sup-inf+1) << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 18744
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

const int INF = 10000;

int main()
{
	for (int i = 1; i <= 10000; i++) {
		int t;
		cin >> t;
		cout << "Case " << i << ": " << t << endl;
	}

	return 0;
}



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

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

typedef long long ll;
using namespace std;

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

  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll a, b, c;

  // REP(i, K) {
  //   a = A;
  //   b = B;
  //   c = C;
  //   A = b + c;
  //   B = c + a;
  //   C = a + b;
  // }

  // cout << A << ":" << B << ":" << C << endl;

  // cout << A - B << endl;

  a = A;
  b = B;
  c = C;
  if (K == 0) {
    if (A - B <= 1e18) {
      cout << A - B << endl;
    } else {
      cout << "Unfair" << endl;
    }
    return 0;
  }

  if (K == 1) {
    A = b + c;
    B = c + a;
    C = a + b;

    if (A - B <= 1e18) {
      cout << A - B << endl;
    } else {
      cout << "Unfair" << endl;
    }
    return 0;
  }

  if (K % 2 == 0) {
    A = (2 * K - 2) * a + (2 * K - 2 - 1) * b + (2 * K - 2 - 1) * c;
    B = (2 * K - 2 - 1) * a + (2 * K - 2) * b + (2 * K - 2 - 1) * c;
    C = (2 * K - 2 - 1) * a + (2 * K - 2 - 1) * b + (2 * K - 2) * c;
  } else {
    --K;
    A = (2 * K - 2) * a + (2 * K - 2 - 1) * b + (2 * K - 2 - 1) * c;
    B = (2 * K - 2 - 1) * a + (2 * K - 2) * b + (2 * K - 2 - 1) * c;
    C = (2 * K - 2 - 1) * a + (2 * K - 2 - 1) * b + (2 * K - 2) * c;
    a = A;
    b = B;
    c = C;
    A = b + c;
    B = c + a;
    C = a + b;
  }

  if (A - B <= 1e18) {
    cout << A - B << endl;
  } else {
    cout << "Unfair" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import math
# N, K = map(int, input().split(' '))
N = int(input())
run = [list(map(str, range(1, 10)))]
l = 0
count = 9
stop = 10**5
while(1):
    if count > stop:
        break
    nextrun = []
    for i in run[l]:
        if i[-1] == '0':
            nextrun.append(i+'0')
            nextrun.append(i+'1')
        elif i[-1] == '9':
            nextrun.append(i+str(int(i[-1])-1))
            nextrun.append(i+str(int(i[-1])))
        else:
            nextrun.append(i+str(int(i[-1])-1))
            nextrun.append(i+str(int(i[-1])))
            nextrun.append(i+str(int(i[-1])+1))
    run.append(nextrun)
    count += len(nextrun)
    l += 1

newrun = []
for i in run:
    newrun.extend(i)
print(newrun[N-1])


Measured memory_bytes: 19188
s = input()

res = [0 for i in range(2019)]
res[0] += 1

resten = 1
ressum = int(s[-1])
res[ressum] += 1

for i in range(2, len(s)+1):
    resten = (resten*10)%2019
    ressum = (int(s[-i])*resten + ressum)%2019
    res[ressum] += 1

ans = 0
for i in range(2019):
    ans += res[i]*(res[i]-1)//2
print(ans)

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

int larger(int a, int b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}

template <typename T>
class Vec {
 public:
  Vec(size_t i) { data = new T[i]; }
  ~Vec() { delete[] this->data; }
  T* operator[](size_t i) { return &this->data[i]; }

 private:
  T* data;
};

int main() {
  int k, n;

  cin >> k >> n;

  int sum = 0;
  int mx = 0;
  Vec<int> v(n);
  int pre = 0;
  for (size_t i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    *v[i] = ai;
    mx = larger(mx, ai - pre);
    pre = ai;
  }
  mx = larger(mx, k + *v[0] - *v[n - 1]);

  cout << (k - mx) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 ll dp[20010] ;
 int main(){
ll h,n ; cin>>h>>n ;
vector<P> A(n) ;
rep(i,n) cin>>A[i].fi>>A[i].se ;
dp[0]=0 ;
rep2(i,1,20005){
  ll now=INF ;
  rep(j,n){
   if(i-A[j].fi>=0){
    chmin(now,dp[i-A[j].fi]+A[j].se) ;
   }
  }
  dp[i]= now ;
}
ll ma= 0 ;
rep(i,n) chmax(ma,A[i].fi) ;
ll ans=INF ;
rep2(i,h,h+ma) chmin(ans,dp[i]) ;
cout<<ans<<endl ; 
   return 0 ;
}



Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<'='<<x<<' '
typedef long long ll;
typedef pair<int,int> pi;

const ll INF = 1e18+7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N; cin >> N;
    vector<ll> A(N+5);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> ps(N+5), ss(N+5);
    for (int i = 0; i < N; i++) {
		if (!i) ps[i] = A[i];
		else ps[i] = ps[i-1] + A[i];
	}
	for (int i = N-1; i >= 0; i--) {
		if (i == N-1) ss[i] = A[i];
		else ss[i] = ss[i+1] + A[i];
	}
	ll ans = INF;
	for (int i = 0; i < N-1; i++) {
		ans = min(abs(ps[i]-ss[i+1]),ans);
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 4992
function main(input){
  const a = parseInt(input.split("\n")[0],10);
  const b = parseInt(input.split("\n")[1],10);
  const c = parseInt(input.split("\n")[2],10);
  const d = parseInt(input.split("\n")[3],10);
  const e = parseInt(input.split("\n")[4],10);
  const k = parseInt(input.split("\n")[5],10);
  if(e-a>k){
    console.log(":(");
  }else{
    console.log("Yay!");
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

bool cheak(int n){
  if(n / 100){
    if(n/100 == n%100/10 && n%100/10 == n % 10) return true;
    if(n / 100+1 == n%100/10 && n%100/10+1 == n % 10) return true;
  }
  else{
    if( n/10 == n % 10) return true;
  }
  return false;
}
set<int> ans;
bool Solve(vector<int> v, bool f){
  bool ans = false;
  int sum = 0;
  REP(i,1,10){
    sum += v[i];
  }
  if(sum == 0){
    return true;
  }
  auto v2 = v;
  bool fail = true;
  REP(i,1,10){
    //?????????
    if(v[i] >= 2 && !f){
      v[i]-= 2;
      ans |= Solve(v,true);
      v = v2;
      fail = false;
    }
    //????????????
    if(v[i] >= 3){
      v[i]-=3;
      ans |= Solve(v,f);
      v = v2;
      fail = false;
    }
    //????????????
    if(i < 8 && v[i] && v[i+1] && v[i+2]){
      --v[i];
      --v[i+1];
      --v[i+2];
      ans |= Solve(v,f);
      v = v2;
      fail = false;
    }
  }
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin>>s){
    vector<int> v(10,0);
    vector<int> v2;
    rep(i,13){
      v[s[i]-'0']++;
    }
    REP(i,1,10){
      if(v[i] < 4) v2.pb(i);
    }
    ans.clear();
    auto v3 = v;
    rep(i,v2.size()){
      v = v3;
      v[v2[i]]++;
      if(Solve(v,false)) ans.insert(v2[i]);
    }
    if(ans.size() != 0){
      for(auto it = ans.begin(); it != ans.end(); ++it){
        if(it != ans.begin()) cout << " ";
        cout << *it;
      }
      cout << endl;
    }
    else cout << 0 <<endl;
  }
  return 0;
}

Measured memory_bytes: 3196
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	s, _ := r.nextString(), r.nextString()
	r.Scan(true)
	a, b := r.nextInt(), r.nextInt()
	r.Scan(true)
	u := r.nextString()

	if strings.Compare(u, s) == 0 {
		a--
	} else {
		b--
	}
	fmt.Fprintln(stdout, a, b)
}


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

int main(){
    int H,W;
    cin >>H>>W;
    vector<vector<char>>vec(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >>vec.at(i).at(j);
        }
    }
    for(int i=0;i<=W+1;i++){
        cout <<'#';
    }
    cout <<endl;
    for(int i=0;i<H;i++){
     cout <<'#';
     for(int j=0;j<W;j++){
         cout<<vec.at(i).at(j);
     }
     cout<<'#'<<endl;
    }
    for(int i=0;i<=W+1;i++){
        cout <<'#';
    }
    cout <<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int n; cin >> n;
    vector<int> h(n,0);
    rep(i,0,n) cin >> h[i];
    vector<int> cur(n,0);

    int ans = 0;
    int flag = 0;

    while(1){
        flag = 0;
        for(int i=0;i<n;i++){
            if(cur[i] < h[i]){
                cur[i]++;
                flag++;
            }else{
                flag = 0;
            }
            if(flag == 1) ans++;
        }
        int ok = 0;
        for(int i=0;i<n;i++)
            if(cur[i] == h[i])
                ok++;
        if(ok == n) break;
    }

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



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


int calc_digit(long long n){
	stringstream ss;
	ss << n;
	return ss.str().size();
}
int main(void){
	long long n;cin >> n;
	long long a=1;
	int res=calc_digit(n);
	while(true){
		if(a> (long long)(sqrt(n)) ) break;
		if(n%a==0){
			res=min(res,(max(calc_digit(a),calc_digit(n/a))));
		}
		a++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
	int n,count=0;
	std::cin>>n;

	std::vector<int> v(n);

	for (int& x : v) {
		std::cin >> x;
	}

	std::sort(v.begin(), v.end());

	std::reverse(v.begin(), v.end());

	for (int i = 0; i < v.size(); i++) {
		for (int j = i + 1; j < v.size(); j++) {
			for (int k = j + 1; k < v.size(); k++) {
				if (v[i] < v[j] + v[k]) {
					count++;
				}
			}
		}
	}

	std::cout<<count<<std::endl;
	return 0;
}

Measured memory_bytes: 256
MOD = 1000000007
N = int(input())
S1 = list(input())
S2 = list(input())

if S1[0] == S2[0]:
    ans = 3
    tmp = True #直前が縦
    j = 1 #次に見始めるところ
else:
    ans = 6
    tmp = False
    j = 2

while j < N:
    if S1[j] == S2[j]: #縦に並んでいる時
        if tmp: #縦が連続の時
            ans *= 2
        else: #直前が横
            ans *= 1
        tmp = True
        j += 1
    else: #横に並んでいる時
        if tmp: #縦-->横のとき
            ans *= 2
        else: #横が連続の時
            ans *= 3
        tmp = False
        j += 2
    ans %= MOD

print (ans)


Measured memory_bytes: 3064
n = int(input())
S = []
P = []
for i in range(n):
    tmp_S, tmp_P = input().split()
    S.append(tmp_S)
    P.append(int(tmp_P) * -1)
index = [i for i in range(1, n+1)]

ZIP = zip(S, P, index)
ZIP = sorted(ZIP)
S, P, index = zip(*ZIP)

for i in range(n):
    print(index[i])

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
#define mod 1000000007
#define eps 1e-10
using namespace std;
struct node
{
    int m,d,h,min,st,v;
};
node re[1002];
int vis[1002];
int ans[1002];
int cal(int h1,int min1,int h2,int min2)
{
    return h2*60+min2-(h1*60+min1);
}
main()
{
    int n;
    while(scanf("%d",&n),n)
    {
        int m,d,h,min,v;
        char st;int ma=0;
        memset(vis,0,sizeof(vis));
        memset(ans,0,sizeof(ans));
        for(int i=1;i<=n;i++)
        {
            scanf("%d%*c%d%d%*c%d%*c%c%d",&m,&d,&h,&min,&st,&v);
            ma=max(ma,v);
            re[i].m=m;re[i].d=d;re[i].h=h;re[i].min=min;re[i].v=v;
            if(st=='I') re[i].st=1;else re[i].st=0;
        }
        int cm=re[1].m,cd=re[1].d,f=0;
        for(int i=1;i<=n;i++)
        {
            if(cm==re[i].m&&cd==re[i].d)
            {
                if(re[i].v!=0&&re[i].st==1) vis[re[i].v]=i;
                if(re[i].v!=0&&re[i].st==0) if(vis[re[i].v]!=0&&f!=0)
                {
                    int u=vis[re[i].v];//cout<<i<<" "<<u<<endl;
                    ans[re[i].v]+=cal(re[u].h,re[u].min,re[i].h,re[i].min);
                    vis[re[i].v]=0;
                }
                if(re[i].v!=0&&re[i].st==0)  vis[re[i].v]=0;
                if(re[i].v==0&&re[i].st==1)
                {
                    f=i;
                    for(int j=1;j<=ma;j++) if(vis[j]!=0)
                    {
                        re[vis[j]].h=re[i].h;re[vis[j]].min=re[i].min;
                    }
                }
                if(re[i].v==0&&re[i].st==0)
                {
                    f=0;
                    for(int j=1;j<=ma;j++) if(vis[j]!=0)
                    {
                        ans[j]+=cal(re[vis[j]].h,re[vis[j]].min,re[i].h,re[i].min);
                    }
                }


            }
            else
            {
                memset(vis,0,sizeof(vis));
                cm=re[i].m;cd=re[i].d;i--;
            }
        }
        int an=0;
        for(int i=1;i<=ma;i++)
        an=max(an,ans[i]);
        printf("%d\n",an);
    }
}

Measured memory_bytes: 1220
#include<stdio.h>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
int n,r[200005],i,_max,_min;
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&r[i]);
    _max=r[2]-r[1];
    _min=r[1];
    for(i=2;i<=n;i++)
    {
        _max=max(r[i]-_min,_max);
        _min=min(r[i],_min);
    }
    printf("%d\n",_max);
    return 0;
}



Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,v,j;
	cin >> n;
	vector<int> num(n);
	for (int i = 0; i < n; i++) {
		cin >> num.at(i);
		printf("%d", num.at(i));
		if (i != n - 1)cout << ' ';
		else cout << endl;
	}

	for (int i = 1; i < n; i++) {
		v = num.at(i);
		j = i - 1;
		while (j >= 0 && num.at(j) > v) {
			num.at(j + 1) = num.at(j);
			j--;
		}
		num.at(j + 1) = v;

		for (int k = 0; k < n; k++) {
			printf("%d", num.at(k));
			if (k != n - 1)cout << ' ';
			else cout << endl;
		}
	}
}


Measured memory_bytes: 3236