akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int solve(int n, int c[], int w[]) {
    int total[1000][1000];
    int min_count[1001];
    for (int left = 0; left < n; ++left) {
        total[left][left] = w[left];
        for (int right = left + 1; right < n; ++right) {
            total[left][right] = -1;
        }
    }
    for (int i = 0; i < n + 1; ++i) {
        min_count[i] = n;
    }
    for (int width = 1; width < n; ++width) {
        for (int left = 0; left + width < n; ++left) {
            int right = left + width;
            if (total[left + 1][right] >= 0 && total[left + 1][right] <= c[left]) {
                total[left][right] = total[left + 1][right] + w[left];
            } else if (total[left][right - 1] >= 0 && total[left][right - 1] <= c[right]) {
                total[left][right] = total[left][right - 1] + w[right];
            }
        }
    }
    min_count[0] = 0;
    for (int left = 0; left < n; ++left) {
        for (int right = 0; right < n; ++right) {
            if (total[left][right] < 0) {
                continue;
            }
            min_count[right + 1] = min(min_count[right + 1], min_count[left] + 1);
        }
    }
    return min_count[n];
}

int main() {
    int n;
    int c[1000], w[1000];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> c[i] >> w[i];
    }
    cout << solve(n, c, w) << endl;
    return 0;
}

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
int main(){
    char s[4];
    cin >> s;
    if(s[1]==s[2]){
        if(s[0]==s[1]||s[2]==s[3]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        if(a >= b + c){
            System.out.println(0);
        } else {
            System.out.println(c-(a-b));
        }
    }

}



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

ans = 0
first = sum(list(range(K)))
end = sum(list(range(N, N-K, -1)))
for i in range(K, N+2):
  if i != K:
    first += (i-1)
    end += (N-i+1)
  ans += (end - first + 1)

print(ans % (10**9 + 7))


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

vector<int> G[100000];
int color[100000];
int group[100000];

void dfs(int v, int c, int g, bool& b) {
	if(color[v] != -1) {
		if(color[v] != c) {
			b = false;
		}
		return;
	};
	color[v] = c;
	group[v] = g;
	for(auto u : G[v]) {

		dfs(u, 1 - c, g, b);
	}
}

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

	ll N, M;
	cin >> N >> M;

	for(int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	if(N == 1) {
		cout << 1 << endl;
		return  0;
	}

	memset(color, -1, sizeof color);
	int g = 0;
	ll p = 0, q = 0, one = 0;
	for(int i = 0; i < N; i++) {
		if(G[i].size() == 0) {
			one++;
		}
		else if(color[i] == -1) {
			bool b = true;
			dfs(i, 0, g, b);
			if(b) q++;
			else p++;
			g++;
		}
	}

	cout << one * one + 2 * one * (N - one) + p * p + 2 * p * q + 2 * q * q << endl;
}

Measured memory_bytes: 10368
H,W = map(int,input().split())

ans = min(H,W)
for h in range(H//3,H//3+3):
    w = W//2
    s1 = h*W
    s2 = (H-h)*w
    s3 = (H-h)*(W-w)
    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))


for w in range(W//3,W//3+3):
    h = H//2
    s1 = w*H
    s2 = (W-w)*h
    s3 = (W-w)*(H-h)
    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))

if H%3 == 0 or W%3 == 0:
    ans = 0
print(ans)

Measured memory_bytes: 38484
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define MAX 200009
#define PI 3.141592653589793238
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    	freopen("in2.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif

	int T=1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << tp << ": ";
		int a, b, h, m; cin >> a >> b >> h >> m;
		double ha = h * (360/12) + m * (360/(12*60.0));
		double ma = m * (360/60);
		double ang = (abs(ha-ma))*PI/180;
		double c = sqrt(a*a+b*b-2*a*b*cos(ang));
		cout << setprecision(18);
		cout << c;
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 4112
#include "iostream"

using namespace std;

void sonyu( int num, int g, int* cnt, int a[1000000] ) {

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

		int v = a[i];
		int j = i - g;

		while (j >= 0 && a[j] > v) {
			a[j + g] = a[j];
			j-=g;
			*cnt+=1;
		}
		a[j + g] = v;

	}
}

int main() {

	int a[1000000];
	int cnum;
	int num;
	int cnt = 0;

	cin >> num;
	
	for (int i = 0; i < num; i++) {
		cin >> a[i];
	}

	int kaisu = 1;
	int v[100];
	v[0] = 1;
	for (int i = 1; ; i++) {
		v[i] = v[i-1] * 3 + 1;
		if (v[i] > num) break;
		kaisu++;
	}

	cout << kaisu << endl;
	
	for (int i = kaisu - 1; i >= 0; i--) {
		sonyu(num, v[i], &cnt, a);
		cout << v[i];
		if (i != 0) cout << " ";
	}
	cout << endl;

	cout << cnt << endl;
	
	for (int j = 0; j < num; j++) {
		cout << a[j] << endl;
	}
	
	int p = 0;
	return 0;
}

Measured memory_bytes: 5068
s=input()
t=int(input())
b=0
c=0
for i in range(c,len(s)-1):
  a=1
  for j in range(c+1,len(s)):
    if s[c]==s[j]:
      a+=1
    else:
      c=j
      break
  c=j
  b+=(a//2)
b=b*t
if s[0]==s[len(s)-1]:
  a=1
  c=1
  for k in range(len(s)-1):
    if s[k]==s[k+1]:
      c+=1
    else:
      break
  u=s[::-1]
  for l in range(len(s)-1):
    if u[l]==u[l+1]:
      a+=1
    else:
      break
  if a%2==1 and c%2==1:
    b+=t-1
w=s[::-1]
if w==s:
  if len(w)%2==1:
    b=t*len(w)//2
print(b)

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int a,b,c,x,d=0;
    cin >> a >> b >> c >> x;
    if(x==0){
        cout << 0;
        return 0;
    }
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x){
                    d++;
                }
            }
        }
    }
    cout << d;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define N 50000
#define pb push_back
#define mp make_pair
#define MAP map<ll,ll>
#define INF 1000000
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define sl set<ll> 
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;
ll a[100000],dp[100000];
int main(){
	fastio;
	ll n;
	cin>>n;
	foo(i,0,n-1) cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	if(n==1)
		cout<<"0\n";
	else if(n==2)
		cout<<abs(a[1]-a[0])<<"\n";
	else{
		foo(i,2,n-1){
			dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		}
		cout<<dp[n-1]<<"\n";
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, len, max = 0;
	string S;
	cin >> n >> S;

	vector<vector<int>> grid(n, vector<int>(n, 0));

	for ( int i = 0 ; i < n - 1 ; i++ ){
		for ( int j = i + 1 ; j < n ; j++ ){
			if ( grid[i][j] == 0 ){
				len = 0;
				while ( i + len < j && j + len < n && S[i+len] == S[j+len] )
					len++;
				if ( len == 0 ){
					grid[i][j] = -1;
				}else{
					for ( int k = 0 ; k < len ; k++ ){
						grid[i+k][j+k] = len - k;
					}
				}
				if ( len > max )
					max = len;


			}
		}
	}

	cout << max << "\n";

	return 0;
}


Measured memory_bytes: 98176
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on June 15, 2018, 10:57 AM
 */

#include <stdio.h>
#include <stdlib.h>

void insertionSort(
    int *A,
    int N
);

/*
 * 
 */
int main(int argc, char** argv) {
    int size;
    int *A;
    
    scanf("%d", &size);
    A = (int *)malloc(sizeof(int) * size);
    if (A == NULL) return EXIT_FAILURE;
    for (int ix = 0; ix < size; ++ix)
    {
        scanf("%d", &A[ix]);
        if (ix > 0) printf(" ");
        printf("%d", A[ix]);
    }
    printf("\n");
    insertionSort(A, size);
    return (EXIT_SUCCESS);
}

void insertionSort(int *A, int N) // N個の要素を含む0-オリジンの配列A
{   
    int v, j;
    for (int i = 1; i <= N-1; ++i)
    {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        
        for (int p = 0; p < N; ++p) 
        {
            if (p > 0) printf(" ");
            printf("%d", A[p]);
        }
        printf("\n");
    }
}




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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define F first
#define S second

const int MAXN = 3e5 + 10;

int n, a[MAXN], pt[MAXN];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	string s; cin >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'E')
			a[i] = 1;
		else
			a[i] = -1;
		pt[i+1] = pt[i] + int(a[i] == 1);
	}
	int ans = 1e9;
	for (int i = 0; i < n; i++){
		int ret = (i - pt[i]) + (pt[n] - pt[i+1]);
		ans = min(ans, ret);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 2964
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

bool g[100][100];
ll A,B;
ll N;
ll y,x;
P nb(){
g[y][x]=1;
	if(x==97){
		y+=2;
		x=1;
	}
	else{
		x+=2;
	}
	
}

P nw(){
	g[y][x]=0;
	if(x==98){
		y-=2;
		x=2;
	}
	else x+=2;
	
}

int main()
{
	cin>>A>>B;
	rep(i,100) g[i][99]=1;
	for(int i=1;i<100;i+=2){
		rep1(j,99){
			g[i][j]=1;
		}
	}
	x=1;
	y=0;
	rep(i,A-1) nb();
	x=2;
	y=99;
	rep(i,B-1) nw();
	puts("100 100");
	rep(i,100){
		rep(j,100){
			if(g[i][j]) cout<<"#";
			else cout<<".";
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[200005],s1[200005],s2[200005];
    scanf("%s",s);
    int l=strlen(s);
    for(int i=0;i<l;i++)
    {
        if(i%2==0)
        s1[i]='0';
        else
        s1[i]='1';
    }
    for(int i=0;i<l;i++)
    {
        if(i%2==0)
        s2[i]='1';
        else
        s2[i]='0';
    }
    int count=0,count1=0;
    for(int i=0;i<l;i++)
    {
        if(s[i]!=s1[i])
        count++;
        else
        count1++;
    }
    cout<<min(count,count1);
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main(){
    int N;
    cin >> N;
    if(N%10 ==2||N%10 ==4||N%10 ==5||N%10 ==7||N%10 ==9){
        cout <<"hon"<< endl;
    }
    else if(N%10 ==3){
        cout << "bon" << endl;
    }
    else{
        cout << "pon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
char a[4];
int n=0;
int main(){
  for(int i=0;i<4;i++){
 	cin>>a[i];
  }
for(int i=0;i<4;i++){
  for(int j=1;j<4;j++){
	if(a[i]==a[i+j]){
      n++;
    }
  }
}

if(n==2){
  cout<<"Yes"<<endl;
}else{
  cout<<"No"<<endl;
}
  
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
cnt = 0
c = 0
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        cnt += 1
    else:
        c = max(c, cnt)
        cnt = 0
c = max(c, cnt)
print(c)


Measured memory_bytes: 14252
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int N, M;
bool graph[55][55];
bool visited[55];
int visitCnt;
set<pair<int, int> > st;
/*==================================================*/

/*==================================================*/

void dfs(int curNode){
    visited[curNode] = true;
    visitCnt++;
    REP(nextNode,0,N){
        if(graph[curNode][nextNode] && !visited[nextNode]){
            dfs(nextNode);
        }
    }
}

int main() {
    cin>>N>>M;
    REP(i,0,M){
        int a, b;
        cin>>a>>b;
        a--; b--;
        graph[a][b] = true;
        graph[b][a] = true;
    }

    int ans = 0;

    REP(i,0,N){
        REP(j,0,N){
            if(!graph[i][j] || st.find(make_pair(i,j)) != st.end()) continue;
            else graph[i][j] = graph[j][i] = false, st.insert(make_pair(j,i));
            REP(i,0,N) visited[i] = false;
            visitCnt = 0;
            dfs(0);
            if(visitCnt != N){
                ans++;
                //cout<<i<<" -> "<<j<<endl;
            }
            graph[i][j] = graph[j][i]= true;
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

struct Node {
  int depth;
  map<int, Node *> children;
  Node() {}
};

void SetNum(Node *parent, const int &num) {
  if (parent->depth == 3) return;
  FOR(i, 0, 10) {
    if (parent->children.count(i)) {
      SetNum(parent->children[i], num);
    }
  }
  if (parent->children.count(num) == 0) {
    Node *n = new Node();
    n->depth = parent->depth + 1;
    parent->children[num] = n;
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  FOR(i, 0, n) {
    char c;
    cin >> c;
    vec[i] = (int)c - 48;
  }

  Node *root = new Node();
  root->depth = 0;
  FOR(i, 0, n) {
    SetNum(root, vec[i]);
    int a;
    a++;
  }

  int ans = 0;
  FOR(i, 0, 1000) {
    int digit0 = i / 100;
    int digit1 = (i % 100) / 10;
    int digit2 = (i % 10);
    if (root->children.count(digit0)) {
      Node *digit0_node = root->children[digit0];
      if (digit0_node->children.count(digit1)) {
        Node *digit1_node = digit0_node->children[digit1];
        if (digit1_node->children.count(digit2)) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

void Add(int &a, int b) {
  a += b;
  while (a >= MOD) a -= MOD;
  while (a < 0) a += MOD;
}
 
void Mul(int &a, int b) {
  a = 1LL * a * b % MOD;
}
 
int Pow(int b, int e) {
  if (e < 0) e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1) ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}
 
namespace Math {
  const int NMAX = (int)1e7;
  int pow2[1 + NMAX];
  int fact[1 + NMAX], tcaf[1 + NMAX];
  void Precalc() {
    fact[0] = pow2[0] = 1;
    for (int i = 1; i <= NMAX; ++i) {
      pow2[i] = pow2[i - 1];
      Add(pow2[i], pow2[i]);
 
      fact[i] = fact[i - 1];
      Mul(fact[i], i);
    }
    tcaf[NMAX] = Pow(fact[NMAX], -1);
    for (int i = NMAX - 1; i >= 0; --i) {
      tcaf[i] = tcaf[i + 1];
      Mul(tcaf[i], i + 1);
      assert(1LL * fact[i] * tcaf[i] % MOD == 1);
    }
  }
  int Choose(int n, int k) {
    if (k > n || n < 0) return 0;
    return 1LL * fact[n] * tcaf[n - k] % MOD * tcaf[k] % MOD;
  }
};

int main() {
  Math::Precalc();
  ll r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;
  r1--;
  c1--;
  ll a1=0,a2=0,a3=0,a4=0;
  rep(i,r1+1){
      a1=(a1+Math::Choose(i+1+c1,c1))%MOD;
      a2=(a2+Math::Choose(i+1+c2,c2))%MOD;
  }
  rep(i,r2+1){
      a3=(a3+Math::Choose(i+1+c1,c1))%MOD;
      a4=(a4+Math::Choose(i+1+c2,c2))%MOD;
  }
  ll ans=(a1+a4-a3-a2+MOD*3)%MOD;
  cout << ans << endl;
}


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

using namespace std;

int main(){
  int N; cin>>N;
  
  vector<long long> A(N+2,0),diff(N+1,0);
  long long sum=0;
  for(int i=1;i<=N;i++){
    cin>>A[i];
    diff[i-1]=abs(A[i]-A[i-1]);
    sum+=diff[i-1];
  }
  diff[N]=abs(A[N+1]-A[N]);
  sum+=diff[N];
  cout<<endl;
  for(int i=1;i<=N;i++){
    cout<<sum-diff[i-1]-diff[i]+abs(A[i+1]-A[i-1])<<endl;
  }

  return 0;
}


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int A;
    int B;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.A = sc.nextInt();
        this.B = sc.nextInt();
    }
    
    //解答処理
    private String solve() {
        String answer = null;
        
        if ((B-A) % 2 == 0) {
        	answer = "Alice";
        } else {
        	answer = "Borys";
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35640
#include<iostream>
#include<vector>
#include<queue>
#include<string.h>
using namespace std;

struct edge{//Óð\·
	int to,cost,limit;
	edge(int t,int c,int l){
		to=t;cost=c;limit=l;
	}
};

#define INF 1000000

struct Node{//L[ÉüêéóÔð\·
	int now,speed,before;
	double time;
	Node(int n,int s,double t,int bef){
		now=n;speed=s;time=t;before=bef;
	}
};

bool operator < (Node a,Node b){
	return a.time>b.time;
}

int n,m,s,g;

void solve(){
	bool visit[31][31][31];
	//¬ÌÔC¼OÉKê½¬ÌÔC¬xÅ_CNXg
	memset(visit,false,sizeof(visit));
	vector<vector<edge> > E(n+1);
	cin>>s>>g;
	for(int i=0;i<m;i++){//AXgÌì¬
		int in,out,c,l;
		cin>>in>>out>>c>>l;
		E[in].push_back(edge(out,c,l));
		E[out].push_back(edge(in,c,l));
	}

	priority_queue<Node> Q;
	Q.push(Node(s,0,0.0,s));
	while(!Q.empty()){//_CNXg
		Node t=Q.top(); Q.pop();
		if(visit[t.now][t.before][t.speed]) continue;//ùÉ½æ
		visit[t.now][t.before][t.speed]=true;//Üµ½
		if(t.now==g && t.speed==1){printf("%.12lf\n", t.time );  return;}//¦ðoÍ

		for(int i=0;i<E[t.now].size();i++){//ÓªÂÈªÁÄé
			int to=E[t.now][i].to;
			if(to==t.before) continue;//U^[Ö~

			//¬xð¸ç·CÛCâ·
			//¬xª1Èã@½±ÆªÈ¢@§À¬xðI[o[µÈ¢ÈçL[ÉËÁÞ
			for(int s=-1;s<=1;s++){
				if(t.speed+s>=1 && !visit[to][t.now][t.speed+s] && E[t.now][i].limit>=t.speed+s)
					Q.push(Node(to,t.speed+s,t.time+E[t.now][i].cost/((double)t.speed+s),t.now));
			}
		}
	}
	cout<<"unreachable"<<endl;
}

int main()
{
	while(cin>>n>>m && n!=0)
		solve();
	return 0;
}

Measured memory_bytes: 7744
N, M, C = map(int, input().split())
*B, = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(N)]

count = 0
for a in A:
	j = 0
	for ta, b in zip(a, B):
		j += ta * b
	if 0 < j + C:
		count += 1

print(count)


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

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<bool>> grid(h, vector<bool>(w, false));
    char c;
    vector<int> berry(h + 1, 0);
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> c;
            if (c == '#') grid[i][j] = true, berry[i + 1]++;
        }
    }
    vector<vector<int>> ans(h, vector<int>(w, 0));
    int id = 1;
    int x = 0;
    int y = 0;
    int nx, ny;
    bool flag = false;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (!flag){
                if (ans[i][j] != 0) continue;
                if (!grid[i][j]) continue;
                flag = true; nx = i + 1; berry[i + 1]--;
                while (nx < h && !berry[nx + 1]) nx++;
                if (j == w - 1){
                    for (int p = x; p < nx; p++){
                        for (int q = y; q <= j; q++){
                            ans[p][q] = id;
                        }
                    }
                    id++;
                    x = nx; y = 0;
                    flag = false;
                    continue;
                }
            }
            else {
                if (!grid[i][j] && j == w - 1){
                    for (int p = x; p < nx; p++){
                        for (int q = y; q <= j; q++){
                            ans[p][q] = id;
                        }
                    }
                    id++;
                    x = nx; y = 0;
                    flag = false;
                    continue;
                }
                if (grid[i][j] && j == w - 1){
                    berry[i + 1]--;
                    for (int p = x; p < nx; p++){
                        for (int q = y; q < j; q++){
                            ans[p][q] = id;
                        }
                    }
                    id++;
                    for (int p = x; p < nx; p++) ans[p][j] = id;
                    id++;
                    x = nx; y = 0;
                    flag = false;
                    continue;
                }
                if (!grid[i][j]) continue;
                berry[i + 1]--;
                for (int p = x; p < nx; p++){
                    for (int q = y; q < j; q++){
                        ans[p][q] = id;
                    }
                }
                id++;
                y = j;
                continue;
            }
        }
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cout << ans[i][j];
            if (j != w - 1) cout << " ";
            else cout << endl;
        }
    }
}

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
boolean check=true;
while (true) {
int H = sc.nextInt();
int W= sc.nextInt();
if (H == 0 && W == 0) {
break;
}
for(int i=1; i<=H;i++){
    for(int j=1; j<=W;j++){
        if(check==true){
            System.out.printf("#");
            check=false;
        }
        else if(check==false){
            System.out.printf(".");
            check=true;
        }
    }
    if(i==(i/2)*2)check=true;
    else check=false;
    System.out.printf("\n");
    
    }
    System.out.printf("\n");
    check = true;
}
}
}


Measured memory_bytes: 64260
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
unordered_map<ll,ll>Q;
ll a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n ; cin >> n;
    for (int i = 1 ; i <= n ; i++){
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 1 ; i <= n ; i++){
        ans += Q[i - a[i]];
        Q[i + a[i]]++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int K;
  cin >> K;
  vector<ll> A(K,0);
  for(int i=0;i<K;i++){
    cin >> A[K-1-i];
  }
  ll U=2,L=2;
  for(int i=0;i<K;i++){
    // U <= A[i]*S
    // A[i]*T <= L
    ll S = U/A[i];
    if(S*A[i]<U){
      S ++;
    }
    ll T = L/A[i];
    if(T<S){
      cout << -1 << endl;
      return 0;
    }else{
      U = S*A[i];
      L = (T+1)*A[i] -1;
    }
    //cout << U << " " << L << endl;
  }
  cout << U << " " << L << endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  long long k[20202];
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int c = 1;
  for (int i = 0; i < n; i++) {
    k[p[i] - 1] = c++;
  }
  vector<long long> a(n), b(n);
  for (int i = 0; i < n; i++) {
    a[i] = k[i] + n * i;
    b[i] = k[i] - n * i + n * n;
  }
  cout << a[0];
  for (int i = 1; i < n; i++)
    cout << " " << a[i];
  cout << endl;
  cout << b[0];
  for (int i = 1; i < n; i++)
    cout << " " << b[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 1152
aList = []
for i in range(3):
  aList.append(list(map(int, input().split())))
n = int(input())
bList = []
for i in range(n):
  bList.append(int(input()))

aListCheck = []
for i in range(3):
  aListCheckRow = []
  for j in range(3):
    aListCheckRow.append(aList[i][j] in bList)
  aListCheck.append(aListCheckRow)

for i in range(3):
  if aListCheck[i][0] and aListCheck[i][1] and aListCheck[i][2]:
    print('Yes')
    exit()
  if aListCheck[0][i] and aListCheck[1][i] and aListCheck[2][i]:
    print('Yes')
    exit()
if aListCheck[0][0] and aListCheck[1][1] and aListCheck[2][2]:
  print('Yes')
  exit()
if aListCheck[0][2] and aListCheck[1][1] and aListCheck[2][0]:
  print('Yes')
  exit()

print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<ld,ld>
#define x first
#define y second
#define pb push_back
#define N 100000
#define LOGN 16
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;

int f(int n){
    if((n&1)==1)
        return 3*n+1;
    return n/2;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int s;
    cin>>s;
    map<int,bool> memo;
    memo[s] = true;
    for(int m=2;;m++){
        s = f(s);
        if(memo[s]){
            cout<<m;
            return 0;
        }
        memo[s] = true;
    }
    return 0;
}

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

int main(){
  int A,B,x1,x2,x3,x4;
  int count=0;
  cin>>A>>B;
  for(int i=A;i<=B;i++){
    x4=i%10;
    x3=(i/10)%10;
    x2=(i/1000)%10;
    x1=(i/10000)%10;
    if(!(x1-x4||x2-x3)){
      count+=1;
    }
  }
  cout<<count<<endl;
}
    


Measured memory_bytes: 256
iN = int(input())
aH = [int(_) for _ in input().split()]

if iN == 1:
    print(aH[0])
    exit()

iC = 0
for _ in range(100):
    iM = max(aH)
    if iM == 0:
        break
    iH = aH.index(iM)
    if iH == iN-1:
        iC += iM - aH[iH-1]
        aH[iH] = aH[iH-1]
    elif iH == 0 :
        iR = 1
        while True:
            if aH[iH + iR] != iM:
                i2 = aH[iH+iR]
                iC += iM - i2
                for i in range(iH,iH+iR):
                    aH[i]=i2
                break
            else:
                iR += 1
                if iH +iR == iN:
                    iC += iM
                    for i in range(iH,iH+iR):
                        aH[i] =0
                    break
    else:
        iLM = aH[iH-1]
        iR = 1
        while True:
            if aH[iH +iR] != iM:
                i2 = aH[iH+iR]
                if i2 >= iLM:
                    iC += iM - i2
                    for i in range(iH,iH+iR):
                        aH[i]=i2
                else:
                    iC += iM -iLM
                    for i in range(iH,iH+iR):
                        aH[i]=iLM
                break
            else:
                iR += 1
                if iH +iR == iN:
                    iC += iM - iLM
                    for i in range(iH,iH+iR):
                        aH[i] =iLM
                    break
print(iC)


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

using namespace std;

int main(void)
{
    string S;
    cin >> S;
    int sum[2] = {0, 0};
    for(auto i: S) sum[i - '0']++;
    cout << (S.size() - (max(sum[0], sum[1]) - min(sum[0], sum[1]))) << endl;
    return 0;
}

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

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

int main(void) {
	int N;
	cin >> N;
	REP(i,N) {
		int x; cin >> x;
		if(x%2 == 0) {
			if(x%3 == 0 || x%5 == 0) continue;
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}


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

int main() {
  long long int a, b, c;
  cin >> a >> b >> c;
  if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0 << endl;
  else {
    vector<long long int> vec = {a * b, b * c, c * a};
    cout << *min_element(vec.begin(), vec.end()) << endl;
  }
}

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

int main(void){
	int ary[101], n;
	cin >>n;
	for(int i=0; i<n; i++){
		cin >>ary[i];
	}
	for(int i=n-1; i>0; i--){
		cout <<ary[i] <<" ";
	}
	cout <<ary[0] <<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
typedef struct card {
	char suit;
	int num;
}Card;

Card L[MAX/2 + 2], R[MAX/2 +2];

void merge(Card A[], int left, int mid, int right)
{
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	for(i = 0; i < n1; i++)
		L[i] = A[left+i];
	for(i = 0; i < n2; i++)
		R[i] = A[mid+i];
	L[n1].num = R[n2].num = SENTINEL;
	i = j = 0;
	for(k = left; k < right; k++) {
		if(L[i].num <= R[j].num) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
}

void mergeSort(Card A[], int left, int right)
{	
	if(left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int partition(Card A[], int p, int r)
{
	int i, j;
	Card x, t;
	x = A[r];
	i = p - 1;
	for(j = p; j < r; j++) {
		if(A[j].num <= x.num) {
			i++;
			t = A[i];
			A[i] = A[j];
			A[j] = t;
		}
	}
	t = A[i+1];
	A[i+1] = A[r];
	A[r] = t;

	return i+1;
}

void quickSort(Card A[], int p, int r)
{
	if(p < r) {
		int q = partition(A, p, r);
		quickSort(A, p, q-1);
		quickSort(A, q+1, r);
	}
}

int main()
{	
	int i, n, idx;
	int flag = 1;
	char spe;
	Card A[MAX], B[MAX];
	scanf("%d%c", &n, &spe);

	for(i = 0; i < n; i++) {
		scanf("%c%d%c", &A[i].suit, &A[i].num, &spe);
		B[i].suit = A[i].suit;
		B[i].num = A[i].num;
	}

	quickSort(A, 0, n-1);
	mergeSort(B, 0, n);

	for (i = 0; i < n; i++)
		if(A[i].suit != B[i].suit)
			flag = 0;

	if(flag)
		printf("Stable\n");
	else
		printf("Not stable\n");

	for (i = 0; i < n; i++)
		printf("%c %d\n", A[i].suit, A[i].num);

    return 0;
}

Measured memory_bytes: 2948
package main

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

const MAX = 100000

var sc = bufio.NewScanner(os.Stdin)
var smallest int = MAX
var largest int = -1

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func countingSort(A []int, n int) []int {
	C := make([]int, largest+1)
	for _, e := range A {
		C[e]++
	}
	for i := 1; i <= largest; i++ {
		C[i] = C[i] + C[i-1]
	}
	B := make([]int, n)
	for _, e := range A {
		B[C[e]-1] = e
		C[e]--
	}
	return B
}

func calCost(weights []int) int {
	cnt := len(weights)
	if cnt == 1 {
		return 0
	} else if cnt == 2 {
		return weights[0] + weights[1]
	}

	cost := 0
	min := MAX
	for _, w := range weights {
		cost += w
		min = Min(w, min)

	}
	cost += (cnt - 2) * min
	diff := ((min - smallest) + (cnt-2)*(min-smallest)) - (2 * (min + smallest))
	if diff > 0 {
		cost -= diff
	}
	return cost
}

func main() {
	n := scanInt()
	A := make([]int, n)
	for i := range A {
		num := scanInt()
		A[i] = num
		largest = Max(largest, num)
		smallest = Min(smallest, num)
	}

	indexs := make(map[int]int, n)
	cost := 0
	for i, e := range countingSort(A, n) {
		indexs[e] = i
	}
	seen := make(map[int]bool, n)
	for _, e := range A {
		if seen[e] {
			continue
		}
		weights := make([]int, 0)
		weights = append(weights, e)
		seen[e] = true

		for {
			e = A[indexs[e]]
			if seen[e] {
				cost += calCost(weights)
				break
			}
			weights = append(weights, e)
			seen[e] = true
		}
	}
	fmt.Println(cost)
}



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

int trace(int A[], int N){
	for(int i=0;i<N;i++){
	if(i>0) cout << " ";
		cout << A[i] ;
		
		}
	cout << "\n";
}
int insertionSort(int A[], int N){
	for(int i=1;i<N;i++){
		int j=i-1;
		int v=A[i];
		while(j>=0&&A[j]>v){
		A[j+1]=A[j];
		j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
	
}
int main(){
	int A[100];
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i];
		}
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}	

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{  
 int a,b;
 scanf("%d %d",&a,&b);
 if(a < b)
{   
   printf("a < b\n");
}
 else if(a > b)
{  
   printf("a > b\n");
}
else if(a == b)
{ 
  printf("a == b\n");
}
return 0;
}

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

int main() {
	string S;
	cin >> S;
	bool ans=false;
	if (S[0] == S[1]) ans = (S[2] == S[3] && S[1] != S[2]);
	else {
		if (S[0] == S[2]) ans = S[1] == S[3];
		else ans = S[0] == S[3] && S[1] == S[2];
	}
	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
typedef pair<int, int> pii;
const int MAXN = 100 + 10;
pii a[MAXN], c[MAXN];

int main() {
//    freopen("test.txt", "r", stdin);
    int n, x, y;
    cin >> n;
    for (int i= 0; i < n; i++) {
        cin >> x >> y;
        a[i] = {x, y};
    }
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        c[i] = {x, y};
    }
    multiset<int> table;
    sort(a, a+n);
    sort(c, c+n);
    int idx = 0, cnt = 0;
    for (int i = 0; i  < n; i++) {
        auto & item = c[i];
        while (idx < n && a[idx].first < item.first) {
            table.insert(a[idx].second);
            idx++;
        }
        if (table.empty()) continue;
        auto it = table.lower_bound(item.second);
        if (it == table.begin()) continue;
        it--;
        cnt++;
        table.erase(it);
    }
    cout << cnt << endl;



    return 0;
}

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




int main(){

	ll N;
	cin >> N;

	ll mod = 1000000007;

	ll ten=1,nin=1,eig=1;

	for(int i=0;i<N;i++){
		(ten*=10)%=mod;
		(nin*=9 )%=mod;
		(eig*=8 )%=mod;
	}

	ll ans = ( ten - 2*nin + mod + mod + eig ) % mod;

	cout << ans << endl;


}




Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>

#define FOREVER 1

int main(void) {

	int N,K;
	int i=1;

	scanf("%d %d",&N,&K);

    while(FOREVER) {
    	N=N/K;
    	if(N==0) break;
    	i++;
    }

    printf("%d",i++);
    return(0);
}


Measured memory_bytes: 128
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define mn 100005
#define inf 4444444444444444444
#define mod 1000000009
#define FLN "test"
#define pii pair <int, int>
#define XX first
#define YY second

signed main()
{
#ifdef lowie
	freopen(FLN".inp", "r", stdin);
	freopen(FLN".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
  
  	int n, k;
    cin>>n>>k;
  	if (2*k<=n+1) cout<<"YES";
  else cout<<"NO";
    
}

// PLEASE REMOVE "cout" AND "cerr" DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Code by low_
// Contact me via mail: dung.totuan01@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie_review/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
      int t;
      cin >> t;
      cout << a[t-1] << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int k,s;
    int cnt = 0;

    cin >> k >> s;

    for (int i = 0; i < k+1; ++i)
    {
        for (int j = 0; j < k+1; ++j)
        {
            int z = s-i-j;
            if(0<=z&&z<=k) ++cnt;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let a = read_vec::<i32>();
    println!("{}", if a[0] == a[1] {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#include <stdio.h>
          
int main(void){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if(x>=r&&y>=r&&w-x>=r&&h-y>=r){
        printf("Yes\n");
       }
    else{
        printf("No\n");
       }
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int fastpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

signed main(){

    int N, X, Y, Z;
    cin >> N >> X >> Y >> Z;
    int mod = 1000000007;
    int ans = fastpow(10, N, mod);

    mat dp(N + 1, vec(1 << (X + Y + Z - 1), 0));
    dp[0][0] = 1;
    //00000 0000000 11111
    int mask1 = (1 << X) - 1;
    //00000 1111111 10000
    int mask2 = (1 << (X + Y)) - (1 << (X - 1));
    //11111 1000000 00000
    int mask3 = (1 << (X + Y + Z)) - (1 << (X + Y - 1));

    mat nextb(1 << (X + Y + Z - 1), vec(11));
    REP(b, 1 << (X + Y + Z - 1)){
        FOR(n, 1, 11){
            int b2 = ((b << n) | (1 << (n - 1))) & mask1;
            b2 |= ((b & mask2) << n) & mask2;
            b2 |= ((b & mask3) << n) & mask3;
            nextb[b][n] = b2;
        }
    }


    REP(i, N){
        REP(b, 1 << (X + Y + Z - 1)){
            FOR(n, 1, 11){
                int b2 = nextb[b][n];
                if(b2 < (1 << (X + Y + Z - 1))){
                    dp[i + 1][b2] += dp[i][b];
                    dp[i + 1][b2] %= mod;
                }
            }
        }
    }

    REP(b, 1 << (X + Y + Z - 1)){
        ans += mod - dp[N][b];
        ans %= mod;
    }
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 29052
#include <cstdio>
#include <cstring>
#include <vector>
typedef long long lld;
const int MAXS = 105;
std::vector<int> C;
char S[MAXS];
int K, N;

int cnt, sum;

void push() {
    C.push_back(cnt);
    sum += cnt / 2;
    cnt = 0;
}

lld solve() {
    cnt = 1;
    sum = 0;
    for (int i = 1; i < N; ++i) {
        if (S[i] != S[i-1]) {
            push();
        }
        ++cnt;
    }
    push();
    if (C.size() == 1u) {
        return 1LL * K * N / 2;
    }
    if (S[0] != S[N-1]) {
        return 1LL * K * sum;
    }
    int f = C.front();
    int b = C.back();
    int join = (f + b) / 2 - f / 2 - b / 2;
    return 1LL * K * sum + 1LL * (K - 1) * join;
}

int main() {
    scanf(" %s", S);
    scanf("%d", &K);
    N = strlen(S);
    printf("%lld\n", solve());
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;


int main() {
	//cout << fixed << setprecision(10);
	long long int a, b, c, d, e,k;
	cin >> a >> b >> c >> d >> e ;
	cout << ((a - 1) / 10 + 1) * 10 + ((b - 1) / 10 + 1) * 10 + ((c - 1) / 10 + 1) * 10 + ((d - 1) / 10 + 1) * 10 + ((e - 1) / 10 + 1) * 10 - 9 + min((a - 1) % 10, min((b - 1) % 10, min((c - 1) % 10, min((d - 1) % 10, (e - 1) % 10))));
}




Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define		vii 			vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     test(i)        cout<<i<<endl
int dx[] = {-1 , 1 , 0 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 0 , 1 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
const int mxN=3e3+5,oo=0x3f3f3f3f,mod=1e9+7;
string s,t;
int dp[mxN][mxN];
int go(int i,int j){
    if(i==sz(s)||j==sz(t))
        return 0;
    int &ret=dp[i][j];
    if(~ret)
        return ret;
    if(s[i]==t[j])
        return ret=go(i+1,j+1)+1;
    return ret=max(go(i+1,j),go(i,j+1));
}
void build(int i,int j){
    if(i==sz(s)||j==sz(t))
        return;
    if(s[i]==t[j])
        cout<<s[i],build(i+1,j+1);
    else if(go(i,j)==go(i,j+1))
        build(i,j+1);
    else
        build(i+1,j);
}
void solve(){
    cin>>s>>t;
    mem(dp,-1);
    build(0,0);
}
int main() {
    fast();
    solve();
}


Measured memory_bytes: 35840
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int n,k;
	cin>>n>>k;
	int cnt=1;
	while(n--) {
		cnt = min(2*cnt,cnt+k);
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3608
#include <stdio.h>

#define AMAX 20   //define no ato ni ; wo tuketeha ikenai
#define MMAX 2000
int n,q;
int isExist[MMAX +1] = {0};// 0 de syokika
int main(void)
{
  int i,j;
  int num;

  scanf("%d",&n);
  for (i = 0;i<n;i++)
    {
      scanf("%d",&num);
      for(j = MMAX-num; 0<j; j--)
        {
          if(isExist[j])   // A retsu no suuchi wo tashite sono kazu ga mae ni tukurete itara 1
             
            {
              isExist[j+num] = 1; // mae ni tukureta kazu ni ima haittekita kazu wo tasu.
            }
        }
      isExist[num]=1; // suuji ga attara 0 wo 1 ni suru
      // ima haittekita suuji no tokoro wo 1 ni suru
    }

  scanf("%d", &q);
  for (i = 0;i < q; i++)
    {
      scanf("%d",&num);
      if(isExist[num])
        {
          printf("yes\n");
        }
      else
        {
          printf("no\n");
        }
    }
  return 0;
}

Measured memory_bytes: 588
//In the name of God

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

typedef long long ll;
typedef pair <int , int> pii;

const int N = 1e5+10 , mod = 1e9+7;

#define int ll

int dp[N] , a[N];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , k;
   cin >> n >> k;
   for(int i = 1 ; i <= n ; i++)
      cin >> a[i];
   for(int i = 2 ; i <= n ; i++){
      dp[i] = mod;
      for(int j = 1 ; i - j > 0 && j <= k ; j++)
         dp[i] = min(dp[i] , dp[i - j] + abs(a[i] - a[i - j]));
   }
   cout << dp[n];
   return 0;
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

main(){
  int n;
  string s;
  cin >> n >> s;

  int x = 0, max = 0;

  rep(i,n){
    if(s[i] == 'I'){
      x++;
      if(max < x) max = x;
    }else x--;
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
char a[105], b[105];
int d;
int main() {
	scanf("%s%s", a, b);
	d = strlen(a) - strlen(b);
	if(!d) d = strcmp(a, b);
	printf("%s", d ? d>0?"GREATER":"LESS" : "EQUAL");
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	ans := "Yes"
	m := map[string]int{}
	for _, c := range s {
		m[string(c)] += 1
	}
	for _, v := range m {
		if v != 2 {
			ans = "No"
			break
		}
	}
	fmt.Println(ans)
}


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

int main()
{
    int n,i;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    for(i = 0;i < n;++i){
        if(a.at(i) == b.at(i) && b.at(i) == c.at(i)){
            continue;
        }else if(a.at(i) == b.at(i) || b.at(i) == c.at(i) || c.at(i) == a.at(i)){
            ++ans;
        }else{
            ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int a, b, t;
	do {
		scanf("%d%d%d", &a, &b, &t);
	} while ((a < 1 || 20 < a) || (b < 1 || 20 < b) || (t < 1 || 20 < t));
		printf("%d", b*(t/a));
		return 0;
}

Measured memory_bytes: 128