akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define bits(n) __builtin_popcount(n)

void solve()
{
    string s;
    cin>>s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
    cout<<"3\n";
    else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R'))
    cout<<"2\n";
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
    cout<<"1\n";
    else
    {
        cout<<"0\n";
    }    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

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

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>

#pragma comment(linker, "/STACK:336777216")  

using namespace std;

const int MAXN = 100000 + 10;

int N;
char S[MAXN];

void Work()
{
	scanf("%s", S);
	N = strlen(S);
	int Ans = 0;
	int L = 0, R = N - 1;
	while (L < R)
	{
		if (S[L] == S[R])
		{
			L ++;
			R --;
			continue;
		}
		if (S[L] == 'x')
		{
			L ++;
			Ans ++;
			continue;
		}
		if (S[R] == 'x')
		{
			R --;
			Ans ++;
			continue;
		}
		printf("-1\n");
		return;
	}
	printf("%d\n", Ans);
}

int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
#define lp(k,a) for(int k=1;k<=a;k++)
#define lp0(k,a) for(int k=0;k<a;k++)
#define lpn(k,n,a) for(int k=n;k<=a;k++)
#define lpd(k,n,a) for(int k=n;k>=a;k--)
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d %d",&a,&b)
#define ll long long
#define MAX 100000

using namespace std;

char s[10];

int main()
{
    //freopen("in.txt","r",stdin);
    cin>>s;
    if(s[0]==s[2])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,k; cin >> a >> b >> k;
    if(k <= a) cout << a-k << " " << b << endl;
    else if(k <= a+b) cout << 0 << " " << b - (k-a) << endl;
    else cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    vector<int> left,right;
    rep(i,n){
        if(i%2!=n%2){
            left.push_back(a[i]);
        }else{
            right.push_back(a[i]);
        }
    }
    reverse(left.begin(),left.end());
    rep(i,left.size()){
        cout << left[i] << " ";
    }
    rep(i,right.size()){
        cout << right[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3956
#include <iostream>

using namespace std;
class UFT {
public:
    UFT(int n) : tree {new int[n]}, r {new int[n]}, s {n} {
        int* p = tree;
        int i = 0;
        while(i != s){
            *(p++) = i++;
        }
    };
    int parent(int v){
        if(tree[v] == v){
            return v;
        }
        return tree[v] = parent(tree[v]);
    };
    void unite(int x, int y){
        if(same(x, y)){
            return;
        }
        int px = parent(x);
        int py = parent(y);
        int rx = r[px];
        int ry = r[py];
        if(rx > ry){
            tree[py] = px;
        } else if(rx < ry){
            tree[px] = py;
        } else {
            tree[px] = py;
            ++r[py];
        }
    };
    bool same(int x, int y){
        return parent(x) == parent(y);
    }
    void print(){
        for(int i = 0; i < s; ++i){
            cout << tree[i] << ' ';
        }
        cout << endl;
    }
private:
    int* tree;
    int* r;
    int s;
};

int main(){
    ios_base::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    UFT uft = UFT(n);
    int com, x, y;
    for(int i = 0; i < q; ++i){
        cin >> com >> x >> y;
        if(com == 0){
            uft.unite(x, y);
        } else {
            cout << (uft.same(x, y) ? "1" : "0") << endl;
        }
    }
}

Measured memory_bytes: 1268
#include <iostream>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c,d;
  cin >> a;
  cin >> b;
  if(a==b){
    cout <<"Draw" <<endl; 
    return 0;
  }
  
  if(a==1){
 	cout <<"Alice" <<endl; 
    return 0;
  }
  if(b==1) {
    cout <<"Bob" <<endl; 
    return 0;
  }
  if(a>b){
	
  	cout << "Alice"<<endl;
  }else{
	cout << "Bob"<<endl;
  }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<algorithm>
using namespace std;
int main(){
  int n,m;
  bool judge = true;
  stack<bool> st;
  cin >> n;
  cin >> m;
  for(int i=0;i<m;i++) st.push(1);
  int a,b,ma = m;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    for(int j=0;j<a;j++) st.push(1);
    for(int j=0;j<b;j++){
      if(st.empty()) judge = false;
      else st.pop();
    }
    ma = max(ma,(int)st.size());
  }
  cout << ( judge ? ma : 0 ) << endl;
}

Measured memory_bytes: 1204
using System;
using static System.Console;

namespace abc176
{
    class Program
    {
        static int[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            if (line.Length == 1 && string.IsNullOrEmpty(line[0]))
            {
                return new int[0];
            }
            var numList = new int[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = int.Parse(line[i]);
            }
            return numList;
        }
        static void Main()
        {
            var n = int.Parse(ReadLine());
            var aList = ReadNumList();

            var total = 0L;
            var max = 0;
            foreach (var a in aList)
            {
                if (max < a)
                {
                    max = a;
                }
                else
                {
                    total += max - a;
                }
            }
            WriteLine(total);
        }
    }
}


Measured memory_bytes: 46216
N,Y=map(int,input().split())
ans=-1,-1,-1
for i in range(N+1):
    for j in range(N+1-i):
            if 1<=N<=2000 and 10000*i+5000*j+1000*(N-i-j)==Y:
                ans=i,j,N-i-j
print(*ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    vector <vector<long long>>act(3,vector<long long>(n));
    for(long long i = 0; i < n; i++){
        cin >> act[0][i];
        cin >> act[1][i];
        cin >> act[2][i];
    }
    vector <vector<long long>>dp(3,vector<long long>(n,0));
    for(long long i = 0; i < 3; i++){
        dp[i][0]=act[i][0];
    }
    for(long long i = 1; i < n; i++){
        dp[0][i]=max(dp[1][i-1],dp[2][i-1])+act[0][i];
        dp[1][i]=max(dp[0][i-1],dp[2][i-1])+act[1][i];
        dp[2][i]=max(dp[0][i-1],dp[1][i-1])+act[2][i];
    }

    long long ans = 0;
    for(long long i = 0; i < 3; i++){
        ans = max(ans,dp[i].back());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8564
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007


int main() {
    char b;
    cin >> b;
    if (b == 'A') cout << 'T' << endl;
    else if(b == 'T') cout << 'A' << endl;
    else if(b == 'G') cout << 'C' << endl;
    else cout << 'G' << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>//本当は必要なヘッダファイルだけインクルードするべきです
using namespace std;//本当は個別にusingするか変数や関数ごとにstd::をつけるべきです
//本当は関数内に宣言し明示的に初期化するべきです
string w,t;
map<string,int>cnt;
int main(void){
  cin>>w;
  while(cin>>t){
    if(t=="END_OF_TEXT")break;
    transform(t.begin(),t.end(),t.begin(),::tolower);
    cnt[t]++;
  }
  cout<<cnt[w]<<endl;
  return 0;
}



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

int main()
{
   string s;cin>>s;int n=s.size();string ss="";
   for(int i=0;i<n;i++){
    if(s[i]=='B'&&i!=0){ss=ss.substr(0,ss.size()-1);}
    else if(s[i]=='1'||s[i]=='0'){ss+=s[i];}
   }
   cout<<ss;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string LCS_string(string S, string T){
	vector<vector<int>> dp(S.size() + 1, vector<int>(T.size() + 1, 0));
	for (int i = 0; i < S.size(); i++){
		for (int j = 0; j < T.size(); j++){
			if (S[i] == T[j]){
				dp[i + 1][j + 1] = dp[i][j] + 1;
			} else {
				dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}
	string ans;
	int i = S.size();
	int j = T.size();
	while (dp[i][j] > 0){
		if (dp[i - 1][j] == dp[i][j]){
			i--;
		} else if (dp[i][j - 1] == dp[i][j]){
			j--;
		} else {
			i--;
			j--;
			ans += S[i];
		}
	}
	reverse(ans.begin(), ans.end());
	return ans;
}
int main(){
  string s, t;
  cin >> s >> t;
  cout << LCS_string(s, t);
}

Measured memory_bytes: 35584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		//標準入力取得インスタンス生成
		Scanner sc = new Scanner (System.in);
		
		//とる枚数
		int takeCard = sc.nextInt();
		int[] arrayCard = new int[takeCard];
		int box = 0;
		
		//Alice合計
		int sumAlice = 0;
		//Bob合計
		int sumBob = 0;
		
		if(takeCard >= 1 && takeCard <= 100) {
			
			//取ったカードの枚数だけ、配列に格納
			for(int i = 0; i < takeCard; i++) {
				arrayCard[i] = sc.nextInt();
			}
			
			//arrayCardを大きい順にソート
			for(int i = 0; i < arrayCard.length; i++) {
				for(int j = i; j < arrayCard.length; j++) {
					if(arrayCard[i] < arrayCard[j]) {
						box = arrayCard[i];
						arrayCard[i] = arrayCard[j];
						arrayCard[j] = box;	
					}
				}
			}
			
			//
			for(int i = 0; i < arrayCard.length; i++) {
				if((i == 0) || (i % 2 == 0)) {
					sumAlice += arrayCard[i];
				}else {
					sumBob += arrayCard[i];
				}
			}
			
			//答え
			int ans = sumAlice - sumBob;
			//標準出力
			System.out.println(ans);
			
		}else {
			System.out.print("制約NG");
		}
		
	    // Scannerインスタンスをクローズ
	    sc.close();
	}

}


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


string s;
string t[4]={"dream","dreamer","erase","eraser"};

int mem[100005];

int check(int x){
  if(x==(int)s.size()){
    return 1;
  }
  if(mem[x]!=-1)
    return mem[x];
  
  int res=0;

  for(int i=0;i<4;i++){
    if( x+(int)t[i].size() > (int)s.size() )continue;
    if( s.substr( x, t[i].size() ) != t[i] )continue;
    if( check(x+t[i].size() ) == 1 ){
      res=1;
      break;
    }
  }
  return mem[x]=res;
}

bool solve(){
  if(check( 0 ) ==1)return true;
  return false;
}
int main(){
  memset(mem,-1,sizeof(mem));
  cin>>s;
  cout<< (solve()?"YES":"NO") <<endl;
  return 0;
}


Measured memory_bytes: 2816
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
        c: usize,
        d: usize,
        e: usize,
    }

    let mut time = vec![];
    time.push(ceil(n, a));
    time.push(ceil(n, b));
    time.push(ceil(n, c));
    time.push(ceil(n, d));
    time.push(ceil(n, e));

    let ans = time.iter().copied().max().unwrap() + 4;

    println!("{}", ans);
}

fn ceil(x: usize, y: usize) -> usize {
    if x % y != 0 {
        x / y + 1
    } else {
        x / y
    }
}

Measured memory_bytes: 2136
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,a,b;
  char s[LIMIT1];
  
  scanf("%lld %lld %lld",&n,&a,&b);
  if((b-a)%2==0){
    result = (b-a)/2;
  }else{
    result = min(a-1,n-b)+1+(b-a-1)/2;
  }
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 128
#ABC073
N,T = map(int, input().split())
t = list(map(int, input().split()))
time = 0
for i in range(N-1):
    if t[i+1] - t[i]>T:
        time += T
    else:
        time += t[i+1] - t[i]
time += T

print(time)

Measured memory_bytes: 25196
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	string s; cin >> s;
	ll cnt0 = 0, cnt1 = 0;
	REPC(i, s) {
		if (i == '0')++cnt0; else ++cnt1;
	}
	cout << min(cnt0, cnt1) * 2 << endl;
}

Measured memory_bytes: 512
#include <iostream>

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

	int h[100010];
	bool bad[100010] = {0};

	for (int i = 0; i < n; ++i) {
		std::cin >> h[i];
	}

	int x, y;
	while (m--) {
		std::cin >> x >> y;
		--x;
		--y;

		if (h[x] >= h[y])
			bad[y] = true;
		if (h[y] >= h[x])
			bad[x] = true;
	}

	int ans = n;
	for (int i = 0; i < n; ++i)
		if (bad[i])
			--ans;


	std::cout << ans;
}

Measured memory_bytes: 4092
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c,d,n;
    string s,s1,s2;
    cin >> a >> b >> c;   
    if( a+b >= c)
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
} 

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


namespace Test1 {

    


    class ClassMain {


        static int tileN = 0;

        public static int iro(int x, int y){
            if (y > (tileN + 1) / 2) { y = tileN + 1 - y; }
            if (x > (tileN + 1) / 2) { x = tileN + 1 - x; }
            if (x < y) { return (x - 1) % 3 + 1; }
            else { return (y - 1) % 3 + 1; }
        }



        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = int.Parse(line);
                if (n == 0) { break; }
                tileN = n;
                int m = int.Parse(Console.ReadLine());
                for (int i = 0; i < m; i++) {
                    int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    Console.WriteLine(iro(ints[0], ints[1]));
                }
                break;


            }
        }

        
    }

    

    
}

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

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

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

x=gcd(A[0],A[1])

for i in A[2:]:
    x = gcd(x,i)

print(x)

Measured memory_bytes: 14224
import math

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
li=list(range(1,n+1))
def f(id,i):
    idd = li.index(id)
    li.pop(li.index(id))
    ar = n - 1 - i
    return idd * math.factorial(ar)

sum1=1
sum2=1
for i in range(n):
    sum1+=f(p[i],i)
li=list(range(1,n+1))
for i in range(n):
    sum2+=f(q[i],i)
print(abs(sum1-sum2))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	int a=read(),b=read();
	cout<<max(a+b,max(a-b,a*b));
}

Measured memory_bytes: 256
n,m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

ac = [0] * (n+1)
pena = [0] * (n+1)
for p,s in ps:
    p = int(p)
    if ac[p] == 0:
        if s == "WA": pena[p] += 1
        else: ac[p] = 1
ans = [0,0]
for i in range(1,n+1):
    if ac[i] == 1:
        ans[0] += 1
        ans[1] += pena[i]
print(" ".join(map(str, ans)))

Measured memory_bytes: 31876
import sys
class BinaryTree:
    def __init__(self):
        self.root = None
    def b_insert(self,x):
        if self.root is None:
            self.root = Node(x)
            return
        node = None
        root = self.root
        while root is not None:
            node = root
            if x == root.data:
                return
            elif x < root.data:
                root = root.left
            else:
                root = root.right
        if node is None:
            # print("center",x)
            node = Node(x)
        elif node.data < x:
            # print("right",x)
            node.right = Node(x)
        else:
            # print("left",x)
            node.left = Node(x)
    def b_inorder(self):
        return inorder(self.root)
    def b_preorder(self):
        return preorder(self.root)
         
class Node:
    def __init__(self,x):
        self.data = x
        self.left = None
        self.right = None
             

def inorder(node):
    nodelist = []
    if node.left:
        nodelist += inorder(node.left)
    nodelist += [node.data]
    if node.right:
        nodelist += inorder(node.right)
    return nodelist
def preorder(node):
    nodelist = [node.data]
    if node.left:
        nodelist += preorder(node.left)
    if node.right:
        nodelist += preorder(node.right)
    return nodelist
 
line = sys.stdin.readline()
bfs = BinaryTree()
 
for temp in sys.stdin:
    if temp[0] == 'i':
        command,num = (n for n in temp.split(" "))
        bfs.b_insert(int(num))
    else:
        print("",end=" ")
        print(*bfs.b_inorder())
        print("",end=" ")
        print(*bfs.b_preorder())

Measured memory_bytes: 117928
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = (a), i_len = (b); i < i_len; ++i)

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    REP(i, 0, dy) cout << 'U' ;
    REP(i, 0, dx) cout << 'R' ;
    REP(i, 0, dy) cout << 'D' ;
    REP(i, 0, dx) cout << 'L' ;
    cout << 'L';
    REP(i, 0, dy + 1) cout << 'U';
    REP(i, 0, dx + 1) cout << 'R';
    cout << 'D';
    cout << 'R';
    REP(i, 0, dy + 1) cout << 'D';
    REP(i, 0, dx + 1) cout << 'L';
    cout << 'U';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <limits.h>

using namespace std;

class Graph{
    int V;
    list<int> *adj;
    bool isCyclicUtil(int v, bool visited[], bool *rs);
  public:
    Graph(int V);
    void addEdge(int v, int w);
    bool isCyclic();
};

Graph::Graph(int V){
  this -> V = V;
  adj = new list<int>[V];
}

void Graph::addEdge(int v, int w){
  adj[v].push_back(w);
}

bool Graph::isCyclicUtil(int v, bool visited[], bool *recStack){
  if(visited[v] == false){
    visited[v] = true;
    recStack[v] = true;
    list<int>::iterator i;
    for(i = adj[v].begin(); i != adj[v].end(); ++i){
      if(!visited[*i] && isCyclicUtil(*i, visited, recStack)) return true;
      else if (recStack[*i]) return true;
    }
  }
  recStack[v] = false;
  return false;
}

bool Graph::isCyclic(){
  bool *visited = new bool[V];
  bool *recStack = new bool[V];
  for(int i = 0; i < V; i++){
    if(isCyclicUtil(i, visited, recStack)) return true;
  }
  return false;
}

int main(){
  int num_v = 0, num_e = 0;
  cin >> num_v >> num_e;

  Graph g(num_v);

  int s = 0, t = 0;
  for(int i = 0; i < num_e; i++){
    cin >> s >> t;
    g.addEdge(s,t);
  }

  if(g.isCyclic()) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}



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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


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

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}



set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}


// int power(int x, unsigned int y, int p)
// {
// 	int res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }
// Graph------------------------------------------------------------------------
bool cmp(pii a, pii b)
{
	return a.ff < b.ff;
}

int32_t main()
{
	FIO;
	// c_p_c();
// --------------------------------------------------
	int k, s;
	cin >> k >> s;

	int ans = 0;
	for (int x = 0; x <= k; x++)
		for (int y = 0; y <= k; y++)
		{
			int z = s - x - y;

			if (z >= 0 and z <= k)
				ans++;
		}


	cout << ans << endl;

}





Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
	int H,W;
	cin >> H >> W;
	for(int i=0; i<W+2; i++) cout << '#';
	cout << endl;
	for(int i=0; i<H; i++){
		cout << '#';
		for(int j=0; j<W; j++){
			char c;
			cin >> c;
			cout << c;
		}
		cout << '#' << endl;;
	}
	for(int i=0; i<W+2; i++) cout << '#';
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<string, int> mp;
#define ll long long

int main() {
    int n;
    cin >> n;
    int a[100];
    int c = 0;
    rep(i, n) {
        int b;
        cin >>b;
        c += b;
      if(i==0)a[i]=b;
      else a[i]=a[i-1]+b;
    }
    int jg = c / n;
    int k = 1000;
    rep(i, n) {
        int kk = 0;
        if ((a[i] - (i + 1)*jg) < 0) {
            kk = a[i] / (i + 1);
            if (k > kk)k = kk;
        }
      
 }
  
  if(k==1000)cout<<jg<<endl;
  else  cout << k << endl;
    return 0;
}


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

int main(){
    int h, w, n, a;
    cin >> h >> w >> n;

    vector<int> line;
    for(int i = 1; i <= n; i++){
        cin >> a;
        for(int j = 0; j < a; j++)  line.push_back(i);
    }

    for(int begin = w; begin < h*w; begin += 2*w)   reverse(line.begin()+begin, line.begin()+begin+w);
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(j)   cout << " ";
            cout << line[i*w + j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

int main() {
	string s;
	cin >> s;
	set<char> chars;
	for (ll i = 0; i < s.length(); ++i) {
		chars.insert(s[i]);
	}
	if (chars.size() == 1) {
		cout << 0 << endl;
		return 0;
	}

	ll res = 100, times;
	for (auto key = chars.begin(); key != chars.end(); ++key) {
		string str = s;
		bool flag = true;
		times = 1;

		while (flag) {
			string vacant;
			flag = false;
			for (ll i = 0; i < str.length() - 1; ++i) {
				if (str[i] == *key || str[i + 1] == *key) {
					vacant += *key;
				}
				else {
					vacant += str[i];
					flag = true;
				}
			}
			if (flag) {
				str = vacant;
				times++;
			}
		}
		res = min(res, times);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
// selection sort alg
// input integer elements, output sorted elements and number of change operations
#include<iostream>
void SelectionSort(int*,int);
int main(){
  int cnt=0, N, min, tmp;
  std::cin >> N;
  int A[N];
  for(int i=0; i<N; i++) std::cin >> A[i];
  // for(int i=0; i<N-1; i++){
  //   min = i;
  //   for(int j=i+1; j<N; j++) if(A[min] > A[j]) min = j;
  //   if(i != min){
  //     tmp = A[i], A[i] = A[min], A[min] = tmp;
  //     cnt++;
  //   }
  // }
  SelectionSort(A,N);
  return 0;
}
void SelectionSort(int *S, int N){
  int cnt=0,tmp;
  for(int i=0,min; i<N-1; i++){
    min = i;
    for(int j=i; j<N; j++) if(S[j] < S[min]) min = j;
    if(S[i] != S[min]) tmp = S[i], S[i] = S[min], S[min] = tmp, cnt++;
  }
  for(int i=0; i<N; i++) std::cout << S[i] << (i < N-1 ? " " : "\n");
  std::cout << cnt << "\n";
}

Measured memory_bytes: 3104
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for i := 0; i < 26; i++ {
		if 4*i == n {
			fmt.Println("Yes")
			return
		}
		for j := 0; j < 15; j++ {
			if 7*j == n {
				fmt.Println("Yes")
				return
			}
			if 4*i+7*j == n {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define f first
#define s second
 
#define pb push_back
#define mp make_pair
 
#define ll long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
 
using namespace std;
 
const int MAXN = (int) 2e5 + 10;
const int INF = (int) 2e9 + 7;
 
 
 
int main() {
    #ifdef sony
        freopen("input.txt", "r", stdin);
    #endif // sony
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy";
    else if (s == "Cloudy") cout << "Rainy";
    else cout << "Sunny";
    return 0;
}

Measured memory_bytes: 256
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()

n,m = get_ints()
if n==1:
    Arr = ['0']
    mydict = dict()
    flag = 0
    for i in range(m):
        s,x = get_ints()
        if s in mydict and mydict[s]!=x:
            flag = 1
        else:
            mydict[s] = x
        Arr[s-1] = str(x)
    if flag==1:
        print(-1)
    else:
        print(''.join(Arr))
else:
    Arr = ['1']+['0']*(n-1)
    mydict = dict()
    flag = 0
    for i in range(m):
        s,x = get_ints()
        if s in mydict and mydict[s]!=x:
            flag = 1
        else:
            mydict[s] = x
        Arr[s-1] = str(x)
    if flag==1 or Arr[0]=='0':
        print(-1)
    else:
        print(''.join(Arr))


Measured memory_bytes: 38384
#include <iostream>
#include <string>

int main()
{
	std::string str;
    std::cin >> str;
	if (str.size() == 0 || 3 < str.size())
	{
		std::cout << "input error.\n";
		return -1;
	}

	// 連続で雨だった日数を出力する。
	int continuousRainyDay = 0;
	int ind = str.find("R");
	if (ind != std::string::npos)
	{
		continuousRainyDay = 1;
	}

	ind = str.find("RR");
	if (ind != std::string::npos)
	{
		continuousRainyDay = 2;
	}

	ind = str.find("RRR");
	if (ind != std::string::npos)
	{
		continuousRainyDay = 3;
	}

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


Measured memory_bytes: 3620
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let s = Array.fold_left (+) 0 a in

    let rec loop i dist df =
        if i = n then df else
            if abs (a.(i) * n - s) < dist then loop (i + 1) (abs (a.(i) * n - s)) i
                                          else loop (i + 1) dist df
    in
    loop 0 max_int 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <bitset>

int main(){
    std::string str;
    std::cin >> str;

    std::vector<int> s(4, 0);
    for(int i = 0; i < 4; ++i){
        s.at(i) = str.at(i) - 48;
    }

    std::string ops(3, '#');
    int i = 0;
    while(i < 8){
        int result = s.at(0);
        std::bitset<3> bs(i);
        for(int j = 0; j < 3; ++j){
            if(bs[2 - j]){
                result += s.at(j + 1);
                ops.at(j) = '+';
            }else{
                result -= s.at(j + 1);
                ops.at(j) = '-';
            }
        } 

        if(7 == result){
            break;
        }

        ++i;
    }

    std::cout << str.at(0);

    for(int i = 0; i < 3; ++i){
        std::cout << ops.at(i) << str.at(i + 1);
    }

    std::cout << "=7" << std::endl;

    return 0;
}

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

using namespace std;

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;Y--;

    int A[N][N];
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            A[i][j] = abs(j-i);
        }
    }

    int ans[N-1];
    fill(ans, ans+N-1, 0);
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            int t1 = A[i][X] + 1 + A[Y][j];
            int t2 = A[i][Y] + 1 + A[X][j];
            int l = min(A[i][j], t1);
            l = min(l, t2);
            ans[l-1]++;
        }
    }
    for(int i=0; i<N-1; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 15872
N,K,Q = map(int,input().split())

A = [K]*N
C = [0]*N

for r in range(Q):
  correct = int(input())
  C[correct-1] = C[correct-1] + 1

for i in range(N):
  A[i] = A[i] - Q + C[i]
  
  if A[i] > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 8520
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  while(1){
    int n,m,k;
    cin>>n>>m>>k;
    if(!n)break;
    vector<double> prob(n*m+1);
    REP(i,m) prob[i+1] = 1.0/m;
    REP(i,n-1) {
      vector<double> sum(n*m+2);
      partial_sum(begin(prob),end(prob),begin(sum)+1);
      vector<double> nprob(n*m+1);
      REP(j,n*m+1) {
        nprob[j] = (sum[j] - sum[max(0,j-m)])/m;
      }
      prob.swap(nprob);
    }
    double ept = 0.0;
    REP(i,n*m+1) {
      ept += max(1, i-k) * prob[i];
    }
    cout << setprecision(10) << fixed << ept << endl;
  }
  return 0;
}

Measured memory_bytes: 1336
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp34 {
    class Program {
        static void Main(string[] args) {
            var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Array.Sort(A);

            Console.WriteLine(A[2] - A[0]);

        }

    }
}


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

const int mod = 2019;

int main() {
  ll l, r;
  cin >> l >> r;
  if (r - l >= 2019) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1001001001;
  for (ll i = l; i <= r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      ans = min(ans, (i * j) % mod);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define M 1000003

int main() {
	map<int, int> qu;
	int p, q, r, c, s, t;
	bool cycle;
	while(cin >> p >> q) {
		qu.clear(); c = 0; cycle = true;
		while(qu.count(p)==0) {
			qu[p] = c++; p*=10;
			r = p/q;
			cout << r;
			if(r>0) {
				p %= q;
				if(p==0) {
					cycle = false;
					break;
				}
			}
		}
		cout << endl;
		if(cycle) {
			s = qu[p]; t = c;
			for(int i=0; i<s; ++i) cout << " ";
			for(int i=s; i<t; ++i) cout << "^";
			cout << endl;
		}
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    ll c = __gcd(a, b);
    int sol = 0;
    for (ll i = 2; i * i <= __gcd(a, b); ++i)
    {
        if (c % i == 0)
        {
            while (c % i == 0)
                c /= i;
            sol++;
        }
    }
    cout << sol + 1 + (c != 1);
}


Measured memory_bytes: 256
import fractions


def solute(n, a):
    gcd_left = [0]
    gcd_right = [0]
    for i in range(n):
        gcd_left.append(fractions.gcd(gcd_left[i], a[i]))
        gcd_right.append((fractions.gcd(gcd_right[i], a[-(i+1)])))
    gcd_right = gcd_right[::-1]

    ans = []
    for i in range(n):
        ans.append(fractions.gcd(gcd_left[i], gcd_right[i+1]))
    return max(ans)


n = int(input())
a = [int(x) for x in input().split()]
print(solute(n, a))

Measured memory_bytes: 16124
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 4000000000000000000LL
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int d[10][10];
int H,W;
int main(){
	cin >> H >> W;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin >> d[i][j];
		}
	}
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				chmin(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			int a;
			cin >> a;
			if(a==-1)continue;
			ans += d[a][1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	public static int getGcd(int a, int b) {
		if (a == b)
			return b;
		int bigger = Math.max(a, b);
		int smaller = Math.min(a, b);
		int modded = bigger % smaller;
		if (modded == 0)
			return smaller;
		return getGcd(smaller, bigger % smaller);
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		
		int result = getGcd(a, b);
		System.out.println(result);
	}
}


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

int main(void){
    
while(true){
    int n,m;
    int kakaku[1000000];
    cin >> n >> m ;
    if(n==0&&m==0)break;
    
    for(int i=0;i<n;i++){
        cin >> kakaku[i];
    }
        int ans=-1;
        for (int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if (i!= j ){
                 if(kakaku[i]+kakaku[j] <= m)
                     ans=max(ans, kakaku[i]+ kakaku[j]);
            }
         }
}
        if(ans==-1)
            cout << "NONE" << endl;
        else
            cout << ans << endl;
    
    }
    return 0;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)
#define maxx 1000001
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    FASTIO
    int s;
    cin>>s;
    ll dp[s];
    dp[0]=1;dp[1]=dp[2]=0;
    for(int i=3;i<=s;i++)
        dp[i]=(dp[i-1]+dp[i-3])%mod;
    cout<<dp[s]%mod<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[101],b[101],c[204];
    int i,n;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    a[i]='\0';
    for(i=0;i<n;i++)
    {
        cin>>b[i];
    }
    b[i]='\0';
   // cout<<a<<"  "<<b<<endl;
    int j=0;
    for( i=0;i<n;i++,j=j+2)
    {
        c[j]=a[i];
        c[j+1]=b[i];
        //cout<<"cj="<<c[j]<<"  "<<"j+1="<<c[j+1]<<endl;
        //j=j+2;
    }
    c[n*2]='\0';
    cout<<c<<endl;

    return 0;
}


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

const int maxn = 20;
char s[maxn];
long long dp[maxn][maxn * 10];
long long fc[maxn];
int d[maxn], cnt[maxn];

long long dfs(int p, int z, int n, int s, long long pr, long long pd) {
    // printf("dfs p = %d z = %d n = %d s = %d pr = %lld pd = %lld\n", p, z, n, s, pr, pd);
    if (pd > pr) return 0LL;
    if (p == n) {
        if (s != 0) return 0LL;
        if (pd < pr) {
            long long res = fc[n];
            for (int i = 0; i < 10; ++i) res /= fc[cnt[i]];
            return res;
        }
        vector<int> cc(cnt, cnt + 10);
        long long res = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < d[i]; ++j) {
                if (cc[j] > 0) {
                    --cc[j];
                    long long add = fc[n - i - 1];
                    for (int k = 0; k < 10; ++k) add /= fc[cc[k]];
                    res += add;
                    ++cc[j];
                }
            }
            if (cc[d[i]] == 0) break;
            --cc[d[i]];
        }
        return res;
    }
    long long res = 0;
    for (int i = z; i < 10; ++i) {
        if (s - (n - p) * i < 0) break;
        ++cnt[i];
        res += dfs(p + 1, i, n, s - i, pr, pd * (i + 1));
        --cnt[i];
    }
    return res;
}

int main() {
    scanf("%s", s);
    int n = strlen(s);
    for (int i = 0; i < n; ++i) d[i] = s[i] - '0';
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < maxn * 10; ++j) {
            for (int k = 0; k < 10; ++k) {
                if (j + k < maxn * 10) {
                    dp[i + 1][j + k] += dp[i][j];
                }
            }
        }
    }
    int sum = accumulate(d, d + n, 0);
    long long ans = 0;
    for (int i = 0; i < sum; ++i) ans += dp[n][i];
    
    long long pr = 1LL;
    for (int i = 0; i < n; ++i) pr *= (d[i] + 1);

    fc[0] = 1;
    for (int i = 1; i < maxn; ++i) fc[i] = fc[i - 1] * i;
    printf("%lld\n", ans + dfs(0, 0, n, sum, pr, 1LL));
    return 0;
}




Measured memory_bytes: 3232
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

ans = 0

# bit全探索
for i in range(2 ** N):
    switch_list = [0] * N
    flag = True     # 一つでも電球とスイッチの条件を満たさないならFalseにする
    for j in range(N):
        if i & (1 << j):    # 0 or 1 を調べるためのループ
            switch_list[j] = 1
    for k in range(M):  # 電球kについて
        on_swtich = 0
        for s in range(ks[k][0]):   # 繋がっているks[k][0]個のスイッチの状態を調べる
            if switch_list[ks[k][s+1] - 1] == 1:
                on_swtich += 1
        if on_swtich % 2 == p[k]:
            pass
        else:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 3064
import itertools

n, m = map(int, input().split())

path = [[False] * n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

ans = 0

# 頂点を並び替える順列を生成してループ
for i in itertools.permutations(range(n), n):
    # 頂点1が始点
    if i[0] == 0:
        # 生成した順列の中をさらにループ
        for j in range(n):
            # n - 1 まで続いたら条件を満たすパスが存在する
            if j == n - 1:
                ans += 1
                break
            # i[j] から i[j + 1] に行くパスがなければ終了
            if not path[i[j]][i[j + 1]]:
                break

print(ans)


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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll x; cin >> x;
    ll curr = 100;
    ll ans = 0;
    while(curr < x) {
        ans++;
        ll add = curr / 100;
        curr += add;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.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;
  
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

ans=0
cntA=0
cntK=0
n,k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
        for j in range(i+1,n):
                if a[i] > a[j]:
                        cntA += 1

for i in range(n):
        for j in range(n):
                if a[i] > a[j]:
                        cntK += 1

print((cntA*k+k*(k-1)*cntK//2)%(10**9+7))

Measured memory_bytes: 41836
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string n;
	cin >> n;
	if (n == "a" || n == "i" || n == "u" || n == "e" || n == "o"){
		cout << "vowel" << endl; }
	else{ cout << "consonant"<<endl; }
	return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
s = [input()for _ in range(h)]
dp = [[10**8]*(w+1) for _ in range(h+1)]
dp[0][0] = 0
for i in range(h):
    for j in range(w): 
        if s[i][j] == '.':
            if i+1 < h and s[i+1][j] == '#':dp[i+1][j] = min(dp[i+1][j],dp[i][j]+1)
            else:dp[i+1][j] = min(dp[i+1][j],dp[i][j])
            if j+1 < w and s[i][j+1] == '#':dp[i][j+1] = min(dp[i][j+1],dp[i][j]+1)
            else:dp[i][j+1] = min(dp[i][j+1],dp[i][j])
        else:
            dp[i+1][j]  = min(dp[i+1][j] ,dp[i][j])
            dp[i][j+1] = min(dp[i][j+1],dp[i][j])

            
        
ans = dp[h-1][w-1]
if s[0][0] == '#':ans += 1
print(ans)

Measured memory_bytes: 3188
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

double div2prob(int num, int threshold){
  int num2 = num;
  int count= 0;
  while(num2<threshold){
     num2 *= 2;
     count++;
  }
  //cout << "num: " << num << ", count: " << count << endl;
  return 1.0/(double)pow(2, count);
}

int main(void){
  int N, K;
  cin >> N >> K;
  double proba = 0.0;
  rep_s(i, 1, N+1){
     proba += 1.0/(double)N*div2prob(i, K);
  }
  cout << setprecision(12) << proba << endl;
}


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

int main(){
  string S, T;
  cin >> S >> T;
  int ans = 1001;
  for (int i=0; i<S.size()-T.size()+1; i++) {
    int ok = 0;
    for (int j = 0; j < T.size(); j++) {
      if (S[i + j] == T[j]) {
        ok++;
      }
    }
    ans = min(ans, (int)T.size() - ok);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632