akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n;
    cin >> n;
    int left = 0,right = n;
    cout << 0 << endl;
    string s;
    cin >> s;
    if(s == "Vacant") return 0;

    string sl,sr;
    sl = s;
    sr = s;
    REP(i,19){
        int out = (right + left) / 2;
        cout << out << endl;
        string ans;
        cin >> ans;
        if(ans == "Vacant") return 0;
        if( (right - left) %2 == 1){
            /// どうせいのはず
            if(ans == sl){
                if( (out - left) %2 == 1) right = out;
                else left = out;
            }
            else{
                if( ( out - left ) %2 == 1){
                    left = out;
                    sl = ans;
                }
                else{
                    right = out;
                    sr = ans;
                }
            }

        }
        else{
            if(ans == sl){
                if( (out - left ) %2 == 1 ){
                    right = out;
                    sr = ans;
                }
                else{
                    left = out;
                    sl = ans;
                }

            }
            else{
                if( (out - left ) %2 == 0 ){
                    right = out;
                    sr = ans;
                }
                else{
                    left = out;
                    sl = ans;
                }

            }
        }
    }

}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int a[n];
  rep(i,n) cin>>a[i];
  
  bool allmx=false;
  while(!allmx && k>0){
    k--;
    int tab[n+1]={};
    rep(i,n){
      tab[max((int)0,i-a[i])]++;
      tab[min(n,i+1+a[i])]--;
    }
    int now=0;
    allmx=true;
    rep(i,n){
      now+=tab[i];
      if(now!=n) allmx=false;
      a[i]=now;
    }
  }
  rep(i,n){
    if(i) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;

  return 0;
}


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
int n=s.length();
int s_int[n];
rep(i,n) s_int[i]=int(s[i]-'0');

int m=pow(2,n-1);
ll total=0;

rep(bit,m){
    vector<int> add_num;
    rep(i,n){
        add_num.pb(s_int[i]);
        if(bit&(1<<i)){
            int k=add_num.size();
            rep(j,k){
            total+=pow(10,k-1-j)*add_num[j];
            }
            add_num.clear();
        }
    }
    int k=add_num.size();
    rep(j,k){
        total+=pow(10,k-1-j)*add_num[j];
        }
}
cout<<total<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Point struct {
	h, w int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	H, W, K := sc.nextInt(), sc.nextInt(), sc.nextInt()
	dp := make([][]int, H+1)
	for i := 0; i < H+1; i++ {
		dp[i] = make([]int, W)
	}
	dp[0][0] = 1
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			var X, Y, Z int
			for bit := 0; bit < 1<<uint(W-1); bit++ {
				ok := true
				for k := 0; k < W-2; k++ {
					// 横棒が並んでいる場合
					if 1<<uint(k)&bit > 0 && 1<<uint(k+1)&bit > 0 {
						ok = false
					}
				}
				if !ok {
					continue
				}
				if j >= 1 && 1<<uint(j-1)&bit > 0 {
					// 左に進む
					X++
				} else if 1<<uint(j)&bit == 0 {
					// 横移動しない
					Y++
				} else if 1<<uint(j)&bit > 0 {
					// 右に進む
					Z++
				}
			}
			if j >= 1 {
				dp[i+1][j-1] += X * dp[i][j]
				dp[i+1][j-1] %= MOD
			}
			dp[i+1][j] += Y * dp[i][j]
			dp[i+1][j] %= MOD
			if j+1 < W {
				dp[i+1][j+1] += Z * dp[i][j]
				dp[i+1][j+1] %= MOD
			}
		}
	}
	fmt.Fprintln(wtr, dp[H][K-1])
}


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

int N;
vector<ll> A;

void solve(){
    vector<ll> minus, plus;
    for(int i = 0; i < N; i++){
        if( A[i] >= 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }
    sort(plus.begin(), plus.end(), greater<ll>());
    sort(minus.begin(), minus.end());
    if(plus.empty()) plus.push_back(minus.back()),minus.pop_back();
    if(minus.empty()) minus.push_back(plus.back()), plus.pop_back();

    vector<pair<ll, ll> > res;
    ll cur = minus.back();
    for(int i = 0; i < plus.size() - 1; i++){
        res.push_back({cur,plus[i]});
        cur -= plus[i];
    }
    res.push_back({plus.back(),cur});
    cur = plus.back() - cur;
    for(int i = 0; i < minus.size()-1; i++){
        res.push_back({cur,minus[i]});
        cur -= minus[i];
    }
    cout << cur << endl;
    for(auto p: res) cout << p.first << " " << p.second << endl;
}

int main(){
    cin >> N; 
    A.resize(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    solve();
}

Measured memory_bytes: 5872
#include <cstdio>
#include <cstring>
char str[1000005];
int main(){
	while(1){
		int n,m,now=0,con=0,ans=0;
	scanf("%d %d",&n,&m);
	if(n==0){
		break;
	}
	scanf("%s",str);
	int leng=strlen(str);
	for(int i=0;i<leng;i++){
		if(str[i]=='O'){
			continue;
		}else{
			now=i;
			while(1){
				if(str[now+1]=='O' && str[now+2]=='I'){
					con++;
					now+=2;
				}else{
					break;
				}
			}
			if(con>=n){
				ans+=(con-n+1);
			}
			con=0;
			i=now;
		}
	}
	printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2008
import sys

N, K = map(int,input().split())
D = list(input().split())
for i in range(N, 100001):
    flg = 1
    cost = str(i)
    digit = len(cost)
    for j in range(digit):
        if cost[j] in D:
            flg = 0
            break
    if flg == 1:
        print(cost)
        sys.exit()
print("error")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(a!=c)cout<<1<<endl;
  else cout<<0<<endl;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

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

int main() {
  int a, b;
  cin >> a >> b;
  
  double mean;
  int mean_int;
  
  mean = (a + b) / 2.0;
  mean_int = mean * 1;
  
  if (mean != mean_int){
    cout << mean_int + 1 << endl;
  }
  else{
    cout << mean << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int64_t N;

void solve(){
    int64_t ans =0;
    for(int64_t i=1;i<=N;i++){
        if(i%3 && i%5){
            ans += i;
        }
    }
    cout << ans << endl;
}

int main(){
    cin >> N;
    solve();
}   

Measured memory_bytes: 3636
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    int count_AB = 0;
    int tail_A = 0;
    int head_B = 0;
    int hB_tA = 0;
    rep(i, N) {
        cin >> S[i];
        auto s = S[i];
        if (s[0] == 'B' && s[s.size() - 1] == 'A')
            hB_tA++;
        else if (s[0] == 'B')
            head_B++;
        else if (s[s.size() - 1] == 'A')
            tail_A++;

        rep(j, s.size() - 1) {
            if (s[j] == 'A' && s[j + 1] == 'B') {
                count_AB++;
            }
        }
    }
    if (hB_tA > 0) {
        count_AB += (hB_tA - 1);
        hB_tA = 1;
    }
    int triple = min(min(hB_tA, tail_A), head_B);
    count_AB += (triple * 2);
    head_B -= triple;
    tail_A -= triple;
    hB_tA -= triple;
    if (hB_tA == 0)
        count_AB += min(tail_A, head_B);
    else if (tail_A == 0)
        count_AB += min(hB_tA, head_B);
    else if (head_B == 0)
        count_AB += min(tail_A, hB_tA);
    cout << count_AB << endl;
    return 0;
}

Measured memory_bytes: 768
import sys
input = sys.stdin.readline
EPS = 10**(-8)
INF = 10**16

N, M = map(int, input().split())
graph = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].add(b-1)

dp = [0]*N
dps = [0]*N
dpl = [0]*N
for n in reversed(range(N-1)):
    for p in graph[n]:
        if dp[p] != -1:
            dps[n] += dp[p]
            dpl[n] += 1
    if dpl[n] > 0:
        dp[n] = dps[n]/dpl[n] + 1
    else:
        dp[n] = -1

Weight = [0]*N
Weight[0] = 1
for n in range(N):
    for p in graph[n]:
        Weight[p] += Weight[n]/dpl[n]

ans = dp[0]
for n1 in range(N):
    if len(graph[n1]) != 1:
        for n2 in graph[n1]:
            newE = (dps[n1]-dp[n2])/(dpl[n1]-1) + 1
            ans = min(ans, dp[0] - Weight[n1]*dp[n1] + Weight[n1]*newE)

print(ans)

Measured memory_bytes: 19140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_1_D
{
	class Program
	{
		static void Main(string[] args)
		{
			int second = int.Parse(Console.ReadLine());

			int hour = second / 3600;
			second = second % 3600;

			int minute = second / 60;
			second = second % 60;

			Console.WriteLine("{0}:{1}:{2}", hour,minute,second);
			
		}
	}
}

Measured memory_bytes: 5628
n = gets.chomp.to_i
line = gets.chomp
line = line.split(" ")
ary = Array.new(n){Array.new(21)}
for i in 0..20
  ary[0][i] = 0
end
ary[0][line[0].to_i] = 1;
for i in 1..n-1
  for j in 0..20
    if j-line[i].to_i >= 0 
      ary[i][j] = ary[i-1][j-line[i].to_i]
    else 
      ary[i][j] = 0
    end
    if j+line[i].to_i <= 20 
      ary[i][j] += ary[i-1][j+line[i].to_i]
    else 
      ary[i][j] += 0
    end
  end
end
puts ary[n-2][line[n-1].to_i]

Measured memory_bytes: 8624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <ctime>

using namespace std;

#define LOCAL 0
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1& arg1){
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1& arg1, Args&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 7;

int main() {
#if LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    int ans = 0, tmp = 0;
    vi a(n); fore(i, 0, n) cin >> a[i];
    fore(i, 0, n - 1) {
        tmp += a[i];
        ans += tmp * a[i + 1];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
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;}
const ll INF = ll(1e18)+1;


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

int n; ll k;
cin >> n >> k;
vl a(n);
rep(i,n) cin >> a[i];
sort(all(a));

ll l = -INF, r = INF;
while(r - l > 1) {
    ll mid = (l+r)/2;
    bool ok = [&]{
        ll cnt = 0;
        rep(i,n) {
            if(a[i] >= 0) {
                int l = -1, r = n;
                while(r - l > 1) {
                    int c = (l+r)/2;
                    if(a[i]*a[c] <= mid) l = c; else r = c;
                }
                cnt += r;
            }
            else {
                int l = -1, r = n;
                while(r - l > 1) {
                    int c = (l+r)/2;
                    if(a[i]*a[c] <= mid) r = c; else l = c;
                }
                cnt += n-r;
            }
            if(a[i]*a[i] <= mid) cnt--;
        }
        cnt /= 2;
        return cnt >= k;
    }();
    if(ok) r = mid; else l = mid;
}

cout << r << endl;
return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;
int n;
long long dp[100010];
long long h[100010];
int main() {
   cin >>n;
   int k;cin>>k;
   for(int i = 0;i<n;i++) cin >> h[i];
   for(int i = 0;i<100010;i++) dp[i] = INF;
   dp[0] = 0;
   for(int i = 0;i<n;i++){
     for(int ki = 1;ki<=k;ki++){
       if(i-ki <0)break;
       chmin(dp[i],dp[i-ki]+abs(h[i]-h[i-ki]));
     }
   }
   cout << dp[n-1];
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 2, 0), sum(n + 2, 0), skip(n + 2, 0);
    for (auto i = 0; i < n + 2; i++) {
        if (i < n) cin >> a[i + 1];
        if (i < n + 1)
            sum[i + 1] = abs(a[i + 1] - a[i]) + sum[i];
        if (i >= 2) skip[i - 1] = abs(a[i] - a[i - 2]);
    }
    for (auto i = 1; i <= n; i++) {
        int64_t ans = skip[i];
        if (i > 1) ans += sum[i - 1] - sum[0];
        if (i < n) ans += sum[n + 1] - sum[i + 1];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4532
n,m=map(int,input().split())
k=[0]*m
a=[0]*m
ans=["x"]*n

for i in range(m):
  k[i],a[i]=map(int,input().split())
  if k[i]==1 and n>2 and a[i]==0:
    print(-1)
    exit()
  
for i in range(m):
  for j in range(m):
    if k[i]==k[j]:
      if a[i]!=a[j]:
        print(-1)
        exit()
        
for i in range(m):
  ans[k[i]-1]=str(a[i])
  
Ans=""
for i in range(n):
  if ans[i]=="x":
    if i==0 and n>=2:
      ans[i]="1"
    else:
      ans[i]="0"
  Ans+=ans[i]

if Ans=="0"*n and n>2:
  print(-1)
  exit()
        
print(int(Ans))

Measured memory_bytes: 3064
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
int n;
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	while(cin>>n){
		
		int counter=0;
		for(int i=0;i<=9;i++){
			for(int k=0;k<=9;k++){
				for(int j=0;j<=9;j++){
					for(int p=0;p<=9;p++){
						if(n==i+k+j+p){
							counter++;
							//break;
					}
				}
			}
		}
	}
		cout<<counter<<"\n";
		
	}
	

	return 0;
}

Measured memory_bytes: 1196
using namespace std;

//#define fileio

#ifndef fileio
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>

typedef long long ll;

#ifdef fileio
ifstream cin;
ofstream cout;
#endif


struct uf {
	vector<int> rt, sz;

	uf(int n) {
		rt.resize(n);
		sz.resize(n);
		for (int i = 0; i < n; i++) {
			rt[i] = i;
			sz[i] = 1;
		}
}

	int id(int x) {
		if (rt[x] == x) return x;
		return rt[x] = id(rt[x]);
	}

	bool join(int x, int y) {
		x = id(x);
		y = id(y);
		if (x == y) return false;
		rt[x] = rt[y];
		sz[y] += sz[x];
		sz[x] = 0;
		return true;
	}
};




int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef fileio
    cin.open("Text.txt");
    cout.open("Output.txt");
#endif

    int n, q;
    cin >> n >> q;
	uf uf(n);
    while (q-- > 0) {
        int x, y, z;
        cin >> x >> y >> z;
        if (x == 0) {
			uf.join(y, z);
        }
        else {
			cout << (uf.id(y) == uf.id(z)) << endl;
        }
    }

}


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

int main() {
    long travel_count;
    long time[travel_count];
    long x_pos[travel_count];
    long y_pos[travel_count];
    int now_xpos = 0;
    int now_ypos = 0;
    int now_time = 0;
    cin >> travel_count;
    for(int i = 0 ; i < travel_count ; i++)
    {
        cin >> time[i] >> x_pos[i] >> y_pos[i];
    }
    for(int i = 0 ; i < travel_count ; i++)
    {
        int need_minimum_travel = abs(x_pos[i] - now_xpos) + abs(y_pos[i] - now_ypos);
        int can_travel_num = time[i] - now_time;

        if(can_travel_num < need_minimum_travel)
        {
            cout << "No" << endl;
            return 0;
        }
        else
        {
            if( (can_travel_num - need_minimum_travel) % 2 == 1 )
            {
                cout << "No" << endl;
                return 0;
            }
        }
        
        now_xpos = x_pos[i];
        now_ypos = y_pos[i];
        now_time = time[i];
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 10624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

// varify : https://onlinejudge.u-aizu.ac.jp/problems/DSL_2_A
template<class Monoid> struct SegmentTree {
private:
    using Func = std::function<Monoid(Monoid, Monoid)>;
    Func F;
    Monoid UNITY;
    int n;
    std::vector<Monoid> node;
public:
    SegmentTree() {}

    SegmentTree(int m, const Monoid &val, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        n = 1; while (n < m) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
        if (val != UNITY) {
            for (int i = 0; i < m; i++) node[i] = val;
            build();
        }
    }

    SegmentTree(const std::vector<Monoid>& v, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        int sz = v.size();
        n = 1; while (n < sz) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
        for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
        build();
    }

    // 最後に build が必要
    void set(int k, const Monoid &x) {
        node[n + k - 1] = x;
    }

    void build() {
        for (int i = n - 2; i >= 0; i--) node[i] = F(node[2 * i + 1], node[2 * i + 2]);
    }

    void update_query(int x, const Monoid &val) {
        if (x >= n || x < 0) return;
        x += n - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) >> 1;
            node[x] = F(node[2 * x + 1], node[2 * x + 2]);
        }
    }

    /*
    // 再帰のためお蔵
    Monoid query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return UNITY;
        if (a <= l && r <= b) return node[k];
        Monoid vl = query(a, b, 2 * k + 1, l, (r - l) / 2 + l);
        Monoid vr = query(a, b, 2 * k + 2, (r - l) / 2 + l, r);
        return F(vl, vr);
    }
    */

    // [a,b)
    Monoid get_query(int a, int b) {
        Monoid L = UNITY, R = UNITY;
        for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = F(L, node[a++ - 1]);
            if (b & 1) R = F(node[--b - 1], R);
        }
        return F(L, R);
    }

    Monoid operator[](int x)const {
        return node[n + x - 1];
    }

    int size() {
        return n;
    }

    void print() {
        for (int i = 0; i < n; i++) {
            std::cout << i << "\t: " << node[n + i - 1] << std::endl;
        }
    }
};

int main() {
    int n, q; cin >> n >> q;
    SegmentTree<ll> seg(n, INT_MAX, [](ll a, ll b) {return min(a, b); }, INT_MAX);
    for (int _ = 0; _ < q; _++) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) {
            seg.update_query(x, y);
        }
        else {
            cout << seg.get_query(x, y + 1) << endl;
        }
    }
    return 0;
}


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

#define MAXN (100010)

int n;
std::vector<int> mat[MAXN];

int dfs(int u){
	std::vector<int> vec;
	for(auto v : mat[u]){
		vec.push_back(dfs(v));
	}
	if(!vec.size()) return 0;
	std::sort(vec.begin(), vec.end());
	for(int i = 0, sz = vec.size(); i < sz; ++ i){
		vec[i] += sz - i;
	}
	std::sort(vec.begin(), vec.end());
	return vec[vec.size() - 1];
}

int main(){
	scanf("%d", &n);
	for(int i = 2; i <= n; ++ i){
		int a;
		scanf("%d", &a);
		mat[a].push_back(i);
	}
	printf("%d\n", dfs(1));
	return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int h,w,n,m;
  cin>>h>>w>>n>>m;
  if(h%n==0&&w%m==0) drop("No");

  cout<<"Yes"<<endl;
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(j) cout<<" ";
      cout<<(i%n==n-1&&j%m==m-1?-1000*n*m+999:1000);
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int A, B, C;
    int x = 0;
    cin >> A >> B >> C;
    if(A%2 == B%2 && C%2 != B%2) {
        A++;
        B++;
        x++;
    }
    else if(A%2 == C%2 && B%2 != C%2) {
        A++;
        C++;
        x++;
    }
    else if(A%2 != B%2 && B%2 == C%2) {
        B++;
        C++;
        x++;
    }
    int a[3];
    a[0] = A;
    a[1] = B;
    a[2] = C;
    sort(a, a+3);
    x += (a[2] - a[1])/2;
    x += (a[2] - a[0])/2;
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3556
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(n: usize, m: usize, a: [i64; m]);
    const MOD: i64 = 1_000_000_007;

    let mut ok = vec![true; n + 1];
    for &i in a.iter() {
        ok[i as usize] = false;
    }

    let mut dp = vec![0i64; n + 10];
    // 閉路を持たないグラフなら、ケツから（次数が0の/前方に依存していないノードから）数え上げたほうが実装が楽
    dp[n] = 1;
    for i in (0..n).rev() {
        if !ok[i] {
            dp[i] = 0;
        } else {
            dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
        }
    }

    println!("{}", dp[0]);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   1e9+7;

int main()
{  fast
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll ans=-2e18;
ans=max(ans,b*c);
ans=max(ans,a*c);
ans=max(ans,b*d);
ans=max(ans,a*d);
cout<<ans;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define w(t)            int t; cin>>t; while(t--)
#define mod 1000000007
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back



int32_t main(){
	ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    string s;
    cin>>s;

    int days = 0;
    for(int i=0;i<3;){
    	if(s[i]=='R'){
    		int temp = 1;
    		i++;
    		while(s[i] != 'S' && i < 3){
    			temp++;
    			i++;
    		}
    		days = max(days,temp);
    	}
    	else{
    		i++;
    	}
    }

    cout<<days;

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
char a[1010][1010];
int main(){
//	freopen("C.in","r",stdin);
	int n,m,A,B;
	int cntA,cntB;
	scanf("%d%d%d%d",&n,&m,&A,&B);
	if(n&1){
		if(A>m/2)
			cntA=m/2,A-=m/2;
		else
			cntA=A,A=0;
	}
	else
		cntA=0;

	if(m&1){
		if(B>n/2)
			cntB=n/2,B-=n/2;
		else
			cntB=B,B=0;
	}
	else
		cntB=0;
	if((A&1)&&(B&1)&&(n&1)&&(m&1)&&A/2+B/2<(n/2)*(m/2)){
		A--,B--;
		for(int i=1;i<n;i+=2){
			for(int j=1;j<m;j+=2){
				if(i+2>=n&&j+2>=m) break;
				if(A>0){
					if(A>=2){
						a[i][j]='<',a[i][j+1]='>';
						a[i+1][j]='<',a[i+1][j+1]='>';
						A-=2;
					}
					else{
						a[i][j]='<',a[i][j+1]='>';
						a[i+1][j]='.',a[i+1][j+1]='.';
						A--;
					}
				}
				else if(B>0){
					if(B>=2){
						a[i][j]='^',a[i+1][j]='v';
						a[i][j+1]='^',a[i+1][j+1]='v';
						B-=2;
					}
					else{
						a[i][j]='^',a[i+1][j]='v';
						a[i][j+1]='.',a[i+1][j+1]='.';
						B--;
					}
				}
				else{
					a[i][j]='.',a[i+1][j]='.';
					a[i][j+1]='.',a[i+1][j+1]='.';
				}
			}
		}
		for(int i=1;i<=(cntA-1)*2;i+=2)
			a[n][i]='<',a[n][i+1]='>';
		for(int i=1;i<=(cntB-1)*2;i+=2)
			a[i][m]='^',a[i+1][m]='v';
		a[n][m-1]='<',a[n][m]='>';
		a[n-2][m-2]='<',a[n-2][m-1]='>';
		a[n-1][m-2]='^',a[n][m-2]='v';
		a[n-2][m]='^',a[n-1][m]='v';
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				if(a[i][j]==0)
					a[i][j]='.';
		printf("YES\n");
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++)
				printf("%c",a[i][j]);
			printf("\n");
		}
		return 0;
	}
	if((A+1)/2+(B+1)/2>(n/2)*(m/2)){
		printf("NO\n");
		return 0;
	}
	for(int i=1;i<n;i+=2){
		for(int j=1;j<m;j+=2){
			if(A>0){
				if(A>=2){
					a[i][j]='<',a[i][j+1]='>';
					a[i+1][j]='<',a[i+1][j+1]='>';
					A-=2;
				}
				else{
					a[i][j]='<',a[i][j+1]='>';
					a[i+1][j]='.',a[i+1][j+1]='.';
					A--;
				}
			}
			else if(B>0){
				if(B>=2){
					a[i][j]='^',a[i+1][j]='v';
					a[i][j+1]='^',a[i+1][j+1]='v';
					B-=2;
				}
				else{
					a[i][j]='^',a[i+1][j]='v';
					a[i][j+1]='.',a[i+1][j+1]='.';
					B--;
				}
			}
			else{
				a[i][j]='.',a[i+1][j]='.';
				a[i][j+1]='.',a[i+1][j+1]='.';
			}
		}
	}
	for(int i=1;i<=cntA*2;i+=2)
		a[n][i]='<',a[n][i+1]='>';
	for(int i=1;i<=cntB*2;i+=2)
		a[i][m]='^',a[i+1][m]='v';
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(a[i][j]==0)
				a[i][j]='.';
	printf("YES\n");
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			printf("%c",a[i][j]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2176
import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort()

P = P[:X]
Q = Q[:Y]

ans = sum(P[:X]) + sum(Q[:Y])

p = P.pop()
q = Q.pop()
r = R.pop()

INF = 10 ** 10


while True:
    m = min(p, q, r)

    if m == r or m == INF:
        break

    if m == p:
        ans += (r - p)

        if P:
            p = P.pop()
        else:
            p = INF
    elif m == q:
        ans += (r - q)

        if Q:
            q = Q.pop()
        else:
            q = INF

    if R:
        r = R.pop()
    else:
        break

print(ans)


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

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int x;
        cin >> x;
        v.push_back(x);
    }

    vector<int> orig = v;
    sort(v.begin(), v.end());

    int mid1 = v[n/2-1], mid2 = v[n/2];

    for(int i=0;i<n;++i){
        if(orig[i] > mid1)cout << mid1;
        else cout << mid2;
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>
#include<queue>
#include<cmath>

using namespace std;

typedef long long int64;

int main(void){
    int64 N,K;
    cin>>N>>K;
    vector<int64> p(N);
    for (int64 i = 0; i < N; i++)
    {
        cin>>p[i];
    }

    sort(p.begin(),p.end());

    int64 ans=0;

    for (int64 i = 0; i < K; i++)
    {
        ans+=p[i];
    }

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

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;int main(){cin.tie(0);ios::sync_with_stdio(false);long long i,a,N,s,A=INT_MAX,l=0,r=0,S[100002]={0};cin>>N>>s;for(i=1;i<=N;i++){cin>>a;S[i]+=S[i- 1]+a;}for(;;){if(S[r]-S[l]>=s){A=min(A,r-l);l++;}else(r++);if(r>N){if(A==INT_MAX)A=0;cout<<A<<endl;return 0;}}}

Measured memory_bytes: 3920
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	int n, w, h;
	cin >> n >> w >> h;
	cout << (n - w + 1) * (n - h + 1) << endl;
}


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

int main(){
  int w,n;
  scanf("%d\n%d",&w,&n);
  int v[w+1],s1,s2;
  for(int i=1;i<=w;i++) v[i]=i;
  for(int i=0;i<n;i++){
    scanf("%d,%d",&s1,&s2);
    swap(v[s1],v[s2]);
  }
  for(int i=1;i<=w;i++) printf("%d\n",v[i]);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n, j = 1, ans = 0;
char s[100005];
int main(){
	scanf("%d", &n);
	scanf("%s", s+1);
	while (j <= n)	{
		ans++;
		while (s[j] == s[j + 1]) j++;
		j++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
from fractions import gcd
n=int(input())
A=list(map(int, input().split()))
#####segfunc######
def segfunc(x,y):
  return gcd(x,y)

def init(init_val):
  #set_val
  for i in range(n):
    seg[i+num-1]=init_val[i]    
  #built
  for i in range(num-2,-1,-1) :
    seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
  k += num-1
  seg[k] = x
  while k:
    k = (k-1)//2
    seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
  if q<=p:
    return ide_ele
  p += num-1
  q += num-2
  res=ide_ele
  while q-p>1:
    if p&1 == 0:
      res = segfunc(res,seg[p])
    if q&1 == 1:
      res = segfunc(res,seg[q])
      q -= 1
    p = p//2
    q = (q-1)//2
  if p == q:
    res = segfunc(res,seg[p])
  else:
    res = segfunc(segfunc(res,seg[p]),seg[q])
  return res

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

ans=-1
init(A)
for i in range(n):
  ans=max(ans, gcd(query(0,i), query(i+1,n)))
  
print(ans)

Measured memory_bytes: 16140
s=input()
n=len(s)
mod=10**9+7
dp=[[0]*2 for _ in range(n)]
dp[0][0]=2
dp[0][1]=1
for i in range(n-1):
  d=int(s[i+1])
  dp[i+1][1]=(3*dp[i][1]+d*dp[i][0])%mod
  dp[i+1][0]=(dp[i][0]+d*dp[i][0])%mod
print(sum(dp[-1])%mod)

Measured memory_bytes: 85368
s = input()
t = input()

sl = list(s)
sl.sort()
tl = list(t)
tl.sort()
tl=tl[::-1]
S="".join(sl)
T="".join(tl)
if S<T:
    ans ='Yes'
else:
    ans = 'No'
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,ans=0;
  cin>>a>>b>>c>>x;
  
  for(int i=0;i<=a;i++){
    for(int m=0;m<=b;m++){
      int n=(x-m*100-500*i)/50;
      if(0<=n&&n<=c) ans+=1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,m,i,j,po,ne,ans=0;
  string p;
  cin >> n;
  vector<string> s(n+3,"");
  for (i=0;i<n;i++) cin >> s.at(i);
  cin >> m;
  vector<string> t(m+3,"");
  for (i=0;i<m;i++) cin >> t.at(i);
  
  for (i=0;i<n;i++){
    po=ne=0;
    p=s.at(i);
    for (j=0;j<n;j++) if (s.at(j)==p) po++;
    for (j=0;j<m;j++) if (t.at(j)==p) ne++;
    if (ans<po-ne) ans=po-ne;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[11][2][2][2][2];
ll solve(vector<int> &nm, int s, int e, int a, int b, int c, int small){
    if(s > e){
        if(a > 0 && b > 0 && c > 0)
        return 1;
        return 0;
    }
    if(dp[s][a][b][c][small] != -1)
        return dp[s][a][b][c][small];
    ll so = 0;
    if(small == 1){
        so += solve(nm, s + 1, e, 1, b, c, small);
        so += solve(nm, s + 1, e, a, 1, c, small);
        so += solve(nm, s + 1, e, a, b, 1, small);
        return dp[s][a][b][c][small] = so;
    }
    if(3 < nm[s])
     so += solve(nm, s + 1, e, 1, b, c, 1);
    if(5 < nm[s])
     so += solve(nm, s + 1, e, a, 1, c, 1);
    if(7 < nm[s])
     so += solve(nm, s + 1, e, a, b, 1, 1);
    if(3 == nm[s])
     so += solve(nm, s + 1, e, 1, b, c, small);
    if(5 == nm[s])
     so += solve(nm, s + 1, e, a, 1, c, small);
    if(7 == nm[s])
     so += solve(nm, s + 1, e, a, b, 1, small);
    return dp[s][a][b][c][small] = so;
}
int main() {
    ll n;
    cin >> n;
    ll sz = 0;
    ll num = n;
    if(n < 357){
        cout << 0;
        return 0;
    }
    vector<int> nm;
    while(num > 0){
        nm.push_back(num % 10);
        num /= 10;
        sz++;
    }
    ll c = 0;
    reverse(nm.begin(), nm.end());
    for(int i = 3; i <= sz; i++){
    memset(dp, -1, sizeof(dp));
    int sm = 0;
    if(i < sz)
    sm = 1;
    c += solve(nm, 0, i - 1, 0, 0, 0, sm);
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d,t,s;
    cin>>d>>t>>s;
    int sum=(t*s);
    if(d<=sum)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3552
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	int x;
	cin>>x;
	if(x<1200)cout<<"ABC"<<endl;
	else cout<<"ARC"<<endl;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

vlli G[100001];
int main() {
    lli n;
    cin1(n);
    lli a[n+1];
    lli b[n+1];
    // 辺のペアに対するインデックス
    // val: 0 〜 n-2
    map<P, lli> m1;
    REP(i,0,n-1) {
        cin2(a[i],b[i]);
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
        m1[P(a[i], b[i])] = i;
    }
    lli k = 0;
    REPE(i,1,n) {
        k = max<lli>(k, G[i].size());
    }

    // 辺のペアに対する色
    map<P, lli> m2;
    REPE(i,1,n) {
        lli cur = 0;
        REP(j, 0, G[i].size()) {
            lli from = i;
            lli to = G[i][j];
            if (m2[P(to, from)]) {
                cur = m2[P(to, from)] % k;
                break;
            }
        }
        REP(j, 0, G[i].size()) {;
            lli from = i;
            lli to = G[i][j];
            if (from > to)
                continue;
            m2[P(from, to)] = cur+1;
            //cout3(cur+1, from, to);
            cur = (cur + 1) % k;
        }
    }
    // インデックス: 色
    lli ans[n];
    REPIT(it, m1) {
        ans[it->second] = m2[it->first];
    }
    cout << k << endl;
    REPE(i,0,n-2) {
        //cout2(a[i], b[i]);
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 24576
#include <stdio.h>

int main()
{
	int n;//輸入的卡片數
	char c;//輸入的字元 
	int i, j, number;//跌代器(i, j)，輸入的數字 
	scanf("%d", &n);
	
	int card[4][13] = {0};
	for(i = 0; i < n ; i++)
	{
		scanf(" %c %d", &c, &number);
		switch(c){
			case'S':
				card[0][number - 1] = 1;
				break;
			case'H':
				card[1][number - 1] = 1;
				break;
			case'C':
				card[2][number - 1] = 1;
				break;
			case'D':
				card[3][number - 1] = 1;
				break;
		}
	}
	for(i = 0; i < 4 ; i++ )
	{
		
		for(j = 0; j < 13 ; j++ )
		{
			if(card[i][j] == 0)
			{
				switch(i){
					case 0:
						printf("S %d\n", j+1);
						break;
					case 1:
						printf("H %d\n", j+1);
						break;
					case 2:
						printf("C %d\n", j+1);
						break;
					case 3:
						printf("D %d\n", j+1);
						break;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2036
package main

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

// S....M....E
// R...RL...LR
func searchRange(text string, start, limit int) (int, int, int) {
	middle := -1

	for i := start; i < limit; i++ {
		if text[i] != 'R' {
			middle = i
			break
		}
	}

	end := limit

	for i := middle; i < limit; i++ {
		if text[i] != 'L' {
			end = i
			break
		}
	}

	return start, middle, end
}

func answer() {
	var text string
	fmt.Scan(&text)
	limit := len(text)

	start := 0
	middle := 0
	end := 0
	firstPrinted := false

	writer := bufio.NewWriter(os.Stdout)

	for end < limit {
		start, middle, end = searchRange(text, start, limit)

		for i := start; i < middle-1; i++ {
			if firstPrinted {
				writer.WriteString(" ")
			}
			writer.WriteString("0")
			firstPrinted = true
		}

		{
			len1 := middle - start
			len2 := end - middle
			count1 := (len1+1)/2 + len2/2
			count2 := len1/2 + (len2+1)/2

			if firstPrinted {
				writer.WriteString(" ")
			}
			writer.WriteString(strconv.Itoa(count1))
			writer.WriteString(" ")
			writer.WriteString(strconv.Itoa(count2))
		}
		firstPrinted = true

		for i := middle + 1; i < end; i++ {
			if firstPrinted {
				writer.WriteString(" ")
			}
			writer.WriteString("0")
			firstPrinted = true
		}
		start = end
		firstPrinted = true
	}

	writer.WriteString("\n")
	writer.Flush()
}

func main() {
	answer()
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int N=2e5;
typedef long long LL;
const LL INF=1e14;
LL n,q,ax,bx,a[N+10];
LL sum=0,f[N+10];
struct bit {
	LL t[N+10];
	void clear() {
		for (int i=1;i<=N;i++) t[i]=INF;
		return;
	}
	int lowbit(int x) {
		return x&(-x);
	}
	void Add(int x,LL va) {
		while (x<=N) {
			t[x]=min(t[x],va);
			x+=lowbit(x);
		}
	}
	LL Query(int x) {
		LL ans=INF;
		while (x>0) {
			ans=min(t[x],ans);
			x-=lowbit(x);
		}
		return ans;
	}
}bit1,bit2;
LL abs(LL x) {
	if (x<0) return -x;
	return x;
}
int main() {
	scanf("%lld%lld%lld%lld",&n,&q,&ax,&bx);
	for (int i=1;i<=q;i++) scanf("%lld",&a[i]);
	bit1.clear();
	bit2.clear();
   	bit1.Add(ax,abs(bx-a[1])-ax);
	bit1.Add(bx,abs(ax-a[1])-bx);
	bit2.Add(n+1-ax,abs(bx-a[1])+ax);
	bit2.Add(n+1-bx,abs(ax-a[1])+bx);
	for (int i=1;i<=N;i++) f[i]=INF;
	f[ax]=min(f[ax],abs(bx-a[1]));
	f[bx]=min(f[bx],abs(ax-a[1]));
	for (int i=2;i<=q;i++) {
		LL now1=bit1.Query(a[i]),now2=bit2.Query(n+1-a[i]);
		now1=now1+a[i];
		now2=now2-a[i];
		now1=min(now1,now2)-abs(a[i]-a[i-1]);
		bit1.Add(a[i-1],now1-a[i-1]);
		bit2.Add(n+1-a[i-1],now1+a[i-1]);
		f[a[i-1]]=min(f[a[i-1]],now1);
		sum+=abs(a[i]-a[i-1]);
	}
	LL ans=INF;
	for (int i=1;i<=n;i++) ans=min(ans,f[i]+sum);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6528
s = input()
n = len(s)

correct_ops = None
def helper(cur, i, ops=[]):
  global correct_ops
  if i == n and cur == 7: 
    correct_ops = ops
    return ops
  if i == n and cur != 7: return []

  if helper(cur+int(s[i]), i+1, ops+["+"]): return ops

  if helper(cur-int(s[i]), i+1, ops+["-"]): return ops

helper(int(s[0]), 1)

res = ""
for i in range(n):
  if i == n-1:
    res += s[i]
  else:
    res += s[i]+correct_ops[i]

print(res+"=7")

Measured memory_bytes: 3064