akhauriyash/Code-Regression huggingface dataset:
# ????????????????????°??????
import sys
from decimal import Decimal

def is_parallel(x1, y1, x2, y2, x3, y3, x4, y4):
    d1x = x2 - x1
    d1y = y2 - y1
    d2x = x4 - x3
    d2y = y4 - y3

    return d1x * d2y == d1y * d2x

    # if d1x != 0.0 and d2x != 0.0:
    #     #a1 = d1y / d1x
    #     #a2 = d2y / d2x
    #     #return a1 == a2
    #     return d1x * d2y == d1y * d2x

    # if d1x == 0.0 and d2x == 0.0:
    #     return True

    # return False

def main():
    n = int(sys.stdin.readline().strip())

    for _ in range(n):
        data = sys.stdin.readline().strip().split(' ')
        # x1 = float(data[0])
        # y1 = float(data[1])
        # x2 = float(data[2])
        # y2 = float(data[3])
        # x3 = float(data[4])
        # y3 = float(data[5])
        # x4 = float(data[6])
        # y4 = float(data[7])
        x1 = Decimal(data[0])
        y1 = Decimal(data[1])
        x2 = Decimal(data[2])
        y2 = Decimal(data[3])
        x3 = Decimal(data[4])
        y3 = Decimal(data[5])
        x4 = Decimal(data[6])
        y4 = Decimal(data[7])

        if is_parallel(x1, y1, x2, y2, x3, y3, x4, y4):
            print('YES')
        else:
            print('NO')
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 10076
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

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

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

  vector<P> sc(m);
  rep(i,m){
    cin>>sc[i].first>>sc[i].second;
  }
  int digit[3]={-1,-1,-1};

  rep(i,m){
    if(digit[sc[i].first-1]==-1){
      digit[sc[i].first-1]=sc[i].second;
    }
    else if(digit[sc[i].first-1]!=sc[i].second){
      cout<<"-1";
      return 0;
    }
  }
  if(n==1){
    if(digit[0]==0){
      cout<<"0";
      return 0;
    }
    else if(digit[0]==-1){
      cout<< "0";
      return 0;
    }
    else {
      cout<<digit[0];
      return 0;
    }
  }
   else if(n==2){
     if(digit[0]==0){
     cout<<"-1";
     return 0;
    }
      else if(digit[0]==-1){
        digit[0]=1;
    }
    if(digit[1]==-1) digit[1]=0;
     cout<<digit[0]*10+digit[1];
     return 0;
  }
  else{
    if(digit[0]==0){
      cout<<"-1";
      return 0;
    }
    else if(digit[0]==-1){
       digit[0]=1;
    }
    if(digit[1]==-1){
      digit[1]=0;
    }
    if(digit[2]==-1){
      digit[2]=0;
    }
      cout<<digit[0]*100+digit[1]*10+digit[2];
      return 0;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;
string s;

bool check(int i){
	return s[i] == s[i+1] || s[i+1] == s[i+2] || s[i+2] == s[i];
}

signed main(){
	cin >> s;
	n = s.size();

	if(n == 2){
		if(s[0] == s[1]){
			cout << "1 2" << endl;
			return 0;
		}else{
			cout << "-1 -1" << endl;
			return 0;
		}
	}else{
		for(int i=0; i<n-2; i++){
			if(check(i)){
				cout << i+1 << " " << i+3 << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 512
import sys
from collections import Counter
import random
import numpy as np

n=int(input())
x=np.array(list(map(int,input().split())))
z=sorted(x)
cand=[z[n//2-1],z[n//2]]
#print(int(np.median(x)))
dic={}
for i in range(n):
    a=x[i]
    if(a<=cand[0]):print(cand[1])
    else:print(cand[0])

Measured memory_bytes: 34504
/*
 * ID: adityaa
 * LANG: C++
 */
#include <bits/stdc++.h>
using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(x, y) memset(x, y, sizeof x);
#define pii pair<int , int>
#define asdfg y1
#define int long long
#define double long double
#define endl '\n'
#define PI 3.14159265359

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

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

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

// check base cases n = 0 , n = 1
// max / min questions - check for binary search
const int maxn = (int) 1e6 + 6;
const double EPS = 1e-9;
const int INF = (int)1e18 + 18;
const int mod = (int) 1e9 + 7;
int n , h[maxn] , a[maxn];
int dp[maxn] , t[4 * maxn];

void update(int id , int s , int e , int position , int value){
    if(s == e){
        t[id] = value;
        return;
    }
    int mid = (s + e) >> 1;
    if(position <= mid){
        update(id << 1, s, mid, position, value);
    } else {
        update(id << 1 | 1, mid + 1, e, position, value);
    }
    t[id] = max(t[id << 1] , t[id << 1 | 1]);
}

int get(int id , int s , int e , int l , int r){
    if(e < l || s > r){
        return -INF;
    }
    if(s >= l && e <= r){
        return t[id];
    }
    int mid = (s + e) >> 1;
    return max(get(id << 1 , s , mid , l , r) , get(id << 1 | 1 , mid + 1 , e , l , r));
}

void update(int position , int value){
    update(1, 0, n - 1, position, value);
}

int get(int r){
    return get(1 , 0 , n - 1 , 0 , r);
}

signed main() {
    
    fio;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < n; i++) cin >> a[i];
    
    for(int i = 0; i < n; i++){
        int height = h[i] , beauty = a[i];
        if(i == 0){
            dp[i] = a[i];
            update(height , dp[i]);
        } else {
            int add = get(height);
            dp[i] = add + beauty;
            update(height , dp[i]);
        }
    }
    
    cout << *max_element(dp, dp + n) << endl;
    
    return 0;
    
}


Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	int nn = n;
	
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
		
	if (nn % sum == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main(){
    int A[3];
    cin >>A[0]>>A[1]>>A[2];
    swap(A[0],A[1]);
    swap(A[0],A[2]);
    for(int i=0;i<3;i++){
        cout <<A[i]<<" ";
    }
    cout <<endl;
}

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

int N;
const int MAX_N = 1.0e5 + 100;
ll A[MAX_N], B[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];

    ll C[N];
    ll old_C[N];
    ll a_sum = 0, b_sum = 0;
    for (int i = 0; i < N; i++) {
        C[i] = A[i] - B[i];
        old_C[i] = C[i];
        a_sum += A[i];
        b_sum += B[i];
    }

    if (a_sum < b_sum) {
        cout << -1 << endl;
    }
    else {
        sort(C, C+N);
        sort(old_C, old_C+N);
    
        int i = 0, j = N-1;
        while (C[i] < 0 && C[j] > 0) {
            if (abs(C[i]) <= C[j]) {
                    C[j] += C[i];
                C[i] = 0;
                i++;
            }
            else {
                C[i] += C[j];
                C[j] = 0;
                j--;
            }
        }

        ll ans = 0;
        for (int k = 0; k < N; k++) {
            if (C[k] != old_C[k]) {
                ans++;
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define int long long

void solve()
{
    int n,m,k,i,j,count=0,sum=0,maxi=0,mini=1e18,flag=0;
    
    
    int a[5];
    for(i=0;i<5;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<5;i++)
    {
        if(a[i]==0)
        {
            cout<<i+1;
            return;
        }
    }
    
    
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3580
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)

using namespace std;
string s;
int main(){
    cin>>s;
    int ans=0;
    rep(i,0,s.size()){
        if(s[i]!=s[s.size()-i-1]){
            ans++;
        }
    }
    puts(ans/2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define gcd __gcd
#define mp make_pair
typedef unsigned long long ull;
typedef long long ll;


int ti[100],lo[100],hi[100];

int main(){
	fast;	
	int n;
	cin>>n;
	vector<int> x(n);
	for(int i=0;i<n;i++) cin>>x[i];
	int ans=INT_MAX;
	for(int i=1;i<=100;i++){
			int cost=0;
			for(int j=0;j<n;j++) cost+=(x[j]-i)*(x[j]-i);
			ans=min(ans,cost);
		}
	cout<<ans<<endl;
	
}


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

struct Node
{
    int key;
    Node *parent, *right, *left;
};

//Node *NIL;
Node *root;

/*void Insert(int key)
{
    Node *y = NIL; //親
    Node *x = root;
    Node *z = new Node;
    z->key = key;
    z->right = NIL;
    z->left = NIL;

    //rootもNILも初めはnullptr
    while (x != NIL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }

    z->parent = y;

    if (y == NIL)
    {
        root = z;
    }
    else if (z->key < y->key)
    {
        y->left = z;
    }
    else
    {
        y->right = z;
    }
}*/

void Insert(int key)
{
    Node *y = nullptr;
    Node *x = root;
    Node *z = new Node;
    z->key = key;

    while (x != nullptr)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }

    z->parent = y;
    if (z->parent == nullptr)
    {
        root = z;
    }
    else if (z->key < y->key)
    {
        y->left = z;
    }
    else
    {
        y->right = z;
    }
}

void inorder(Node *u)
{
    if (u == nullptr)
    {
        return;
    }
    inorder(u->left);
    cout << ' ' << u->key;
    inorder(u->right);
}

void preorder(Node *u)
{
    if (u == nullptr)
    {
        return;
    }
    cout << ' ' << u->key;
    preorder(u->left);
    preorder(u->right);
}

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

    int n, k;
    string com;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> com;
        if (com == "insert")
        {
            cin >> k;
            Insert(k);
        }
        else if (com == "print")
        {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 26672
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
const int N=55;
int n,m,d,sz[N],id[N],sum,q[N*N*N],ans;
long long val[N],f[N*N*N],g[N*N*N];
vector<int>E[N];
void dfs(int u){
	sz[u]=1;id[u]=u;
	for(int v:E[u])dfs(v),sz[u]+=sz[v],val[u]+=val[v];
	sum+=sz[u];
}
bool cmp(int x,int y){
	return val[x]*sz[y]<val[y]*sz[x]||val[x]*sz[y]==val[y]*sz[x]&&sz[x]>sz[y];
}
int greedy(int x){
//	printf("greedy x=%d ",x);
	int res=0;
	for(int i=1;i<=n;++i){
		int y=min(x/val[id[i]],(long long)d);
		if(id[i]==1)y=x/val[id[i]];
		res+=y*sz[id[i]];x-=y*val[id[i]];
	}
//	printf("res=%d\n",res);
	return res;
}
int main(){
	scanf("%d%d%d%lld",&n,&m,&d,&val[1]);
	for(int i=2,x;i<=n;++i){
		scanf("%lld%d",&val[i],&x);
		E[x].push_back(i);
	}
	dfs(1);sort(id+1,id+n+1,cmp);
	sum*=min(n,d);
	memset(f,63,sizeof(f));f[0]=0;
	for(int i=1;i<=n;++i){
		for(int j=0;j<sz[i];++j)
			for(int k=j,hd=1,tl=0;k<=sum;k+=sz[i]){
				while(hd<=tl&&q[hd]<k-sz[i]*min(n,d))++hd;
				while(hd<=tl&&f[q[tl]]-val[i]*(q[tl]/sz[i])>f[k]-val[i]*(k/sz[i]))--tl;
				q[++tl]=k;g[k]=f[q[hd]]+val[i]*((k-q[hd])/sz[i]);
//				printf("k=%d g[k]=%lld\n",k,g[k]);
//				for(int x=hd;x<=tl;++x)
//					printf("%d ",q[x]);puts("");
			}
		for(int j=0;j<=sum;++j)f[j]=g[j];
	}
//	for(int i=0;i<=sum;++i)printf("%lld ",f[i]);puts("");
	d-=min(n,d);
//	printf("d=%d\n",d);
	for(int i=0;i<=sum;++i)if(f[i]<=m)ans=max(ans,i+greedy(m-f[i]));
	printf("%d\n",ans);return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using um = unordered_map<long long, long long>;
#define each(i, a) for (auto &&i : (a))

int main() {
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  each(i, x) cin >> i;
  each(i, x) i -= A;
  function<um(int, int)> div_con = [&](int l, int r) {
    um ret;
    if (r - l == 1)
      ret[x[l]]++;
    else {
      int m = (l + r) / 2;
      um lm = div_con(l, m), rm = div_con(m, r);
      each(p, lm) ret[p.first] += p.second;
      each(p, rm) ret[p.first] += p.second;
      each(p, lm) each(q, rm) ret[p.first + q.first] += p.second * q.second;
    }
    return ret;
  };
  cout << div_con(0, N)[0] << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {

  string s;
  cin >> s;
  int N = s.size();

  char c = s[0];
  int ans = INF;
  repi(i, 1, N) {
    if (s[i] != c) {
      ans = min(ans, max(i, N - i));
      c = s[i];
    }
  }
  if (ans == INF) {
    ans = N;
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string S, T;
  cin >> S;
  cin >> T;
  int count = 0;

  for(int i = 0; i < S.size(); i++){
      if(S.at(i) != T.at(i)){
          count++;
      }
  }

  cout << count << endl;

}

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

def main():
    li = [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]
    k = int(input())-1
    print(li[k])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];

    int ans = 0;
    int tmp = 0;
    REP(i,n) {
        if (i < n-1 && v[i] >= v[i+1]) {
            tmp++;
        } else {
            ans = max(ans,tmp);
            tmp = 0;
        }
    }

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

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

//dp[i][j] := i<=L かつ R<=j である列車の本数
int dp[505][505];
//memo[i][j] := 累積和用
//ある列車がa_l, a_rならば、x<=a_lかつa_r<=yであるすべてのdp[x][y]に+1
int memo[505][505];



int main(void){
	rep(i,505){
		rep(j,505){
			dp[i][j] = 0;
			memo[i][j] = 0;
		}
	}
	int n,m,q,l,r;
	cin>>n>>m>>q;
	rep(i,m){
		cin>>l>>r;
		memo[l][r]++;
	}
	REP(i,504){
		ll me = 0;
		rep(j,505){
			if(j==0){
				dp[i][j] = memo[i][j];
				me = memo[i][j];
				continue;
			}
			me += memo[i][j];
			dp[i][j] = me + dp[i+1][j];
		}
	}

	int pin,qin;
	rep(i,q){
		cin>>pin>>qin;
		cout<<dp[pin][qin]<<endl;
	}
	/*reps(i,n){
		reps(j,n){
			if(i>j) continue;
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/

	return 0;
}


Measured memory_bytes: 2944
-- 5.3
-- Sum_{i=0}^{n-1} floor{(a * i + b) / b}
local function floorSum(n, m, a, b)
  local ans = 0
  while true do
    if m <= a then
      ans = ans + ((n - 1) * n // 2) * (a // m)
      a = a % m
    end
    if m <= b then
      ans = ans + n * (b // m)
      b = b % m
    end
    local ymax = (a * n + b) // m
    local xmax = ymax * m - b
    if ymax == 0 then break end
    ans = ans + (n - (xmax + a - 1) // a) * ymax
    n, m, a, b = ymax, a, m, (a - xmax % a) % a
  end
  return ans
end

local q = io.read("*n")
for i = 1, q do
  local n, m, a, b = io.read("*n", "*n", "*n", "*n")
  print(floorSum(n, m, a, b))
end


Measured memory_bytes: 2868
import numpy as np

A1 = list(map(int, input().split()));
A2 = list(map(int, input().split()));
A3 = list(map(int, input().split()));

N = int(input());

#Bの配列を作成
B = [];
for i in range(N):
  b = int(input())
  B.append(b);

#ビンゴの行列を作成
A = np.hstack([A1,A2,A3]);

for i in range(N):
  for j in range(len(A)):
    if B[i] == A[j]:
      A[j] = 0;
      break;
    else:
      pass;


if A[0] == 0 and A[1] == 0 and A[2] == 0:
  print("Yes");
elif A[3] == 0 and A[4] == 0 and A[5] == 0:
  print("Yes");
elif A[6] == 0 and A[7] == 0 and A[8] == 0:
  print("Yes");
elif A[0] == 0 and A[3] == 0 and A[6] == 0:
  print("Yes");
elif A[1] == 0 and A[4] == 0 and A[7] == 0:
  print("Yes");
elif A[2] == 0 and A[5] == 0 and A[8] == 0:
  print("Yes");
elif A[0] == 0 and A[4] == 0 and A[8] == 0:
  print("Yes");
elif A[2] == 0 and A[4] == 0 and A[6] == 0:
  print("Yes");
else:
  print("No");


Measured memory_bytes: 12520
n = int(input())
fmin = 100
for i in range(1,int(n**0.5)+1):
  a = i
  b = n // i
  if b != n/i :
    continue
  
  alen = len(str(a))
  blen = len(str(b))
  f = max(alen, blen)
  fmin = min(fmin,f)
print(fmin)

Measured memory_bytes: 3064
n = int(input())

ans = [0, 0, 0, 0]

for i in range(n):
    s = input()
    if s == 'AC':
        ans[0] += 1
    elif s == 'WA':
        ans[1] += 1
    elif s == 'TLE':
        ans[2] += 1
    else:
        ans[3] += 1

print('AC x {}'.format(ans[0]))
print('WA x {}'.format(ans[1]))
print('TLE x {}'.format(ans[2]))
print('RE x {}'.format(ans[3]))


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/
int main(){
     
     string s;
     cin>>s;
     int n=s.length();
     ll dp[n+1][2];memset(dp,0,sizeof(dp));
     dp[0][1]=1,dp[0][0]=0;
     for(int i=0;i<s.length();i++){
          dp[i+1][0]=(3*dp[i][0])%mod;
          if(s[i]=='1'){
               dp[i+1][1]=(2*dp[i][1])%mod;
               dp[i+1][0]=(3*dp[i][0]+dp[i][1])%mod;
          }
          else{
               dp[i+1][1]=dp[i][1];
          }
     }
     cout<<(dp[n][1]+dp[n][0])%mod;
}
 
 
 
 
 

























Measured memory_bytes: 5260
/*
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600031;

long long n,ar[3][N],dp[3][N];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n;
	for (int i=1;i<=2;i++){
		for (int j=1;j<=n;j++){
			cin>>ar[i][j];
			dp[i][j]=ar[i][j]+max(dp[i][j-1],dp[i-1][j]);
		}
	}

	cout<<dp[2][n]<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 8448
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int mx = 300010;
    vector<bool> is_prime(300010, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i < mx; i++) {
        if (i%7==1 || i%7==6) {
            if (!is_prime[i]) continue;
            for (int j = i*2; j < mx; j += i) {
                is_prime[j] = false;
            }
        } else {
            is_prime[i] = false;
        }
    }

    while (1) {
        int n;
        cin >> n;
        if (n == 1) break;
        
        cout << n << ":";
        for (int i = 0; i <= n; i++) {
            if (is_prime[i]) {
                if (n%i==0) {
                    cout << " " << i;
                }
            }
        }

        cout << endl;
    }
    return 0;
}


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

ll b[300005][61]{};
ll c[300005][61]{};

int main() {
    int N;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int l = 61;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < l; j++) {
            ll t = (1ll<<j);
            if ((t & A[i]) != 0) {
               b[i][j] = 1; 
            }
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < l; j++) {
            c[i + 1][j] = c[i][j] + b[i][j];
        }
    }
    
    ll ans = 0;
    ll mod = pow(10, 9) + 7;
    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j < l; j++) {
            ll t = 1ll<<j;
            ll k;
            if ((t & A[i]) != 0) {
                k = N - (i + 1) - (c[N][j] - c[i + 1][j]);
            } else {
                k = (c[N][j] - c[i + 1][j]);
            }
            t %= mod;
            ans += k * t;
            ans %= mod;
        }
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 288512
#include <stdio.h>
#include <math.h>

int main(){
  int i,n,j,a,sosuu=0,b=0;

  scanf("%d",&n);

  if(n>=1 && n<=10000){

    for(i=0;i<n;i++){
      scanf("%d",&a);
    
    if(a>=2 && a<=100000000){
      for(j=2;j<=sqrt(a);j++){
	  if(a%j == 0) b = 1;
	}

	if(b == 0){
	  sosuu++;
	}
	b=0;
    }
    }
    printf("%d\n",sosuu);
      
    
  }
    return 0;

  }



Measured memory_bytes: 2068
#include<stdio.h>
int main(void)
{
  double r,l,s,pi;
  scanf("%lf",&r);
  pi=3.141592653589;
  l=2.0*r*pi;
  s=r*r*pi;
    printf("%lf %lf\n",s,l);
  return 0;
}

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

int main(){
    double xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int N;
    cin >> N;
    vector<double> x(N+2), y(N+2), r(N+2);
    x[0] = xs;
    y[0] = ys;
    r[0] = 0;
    x[N+1] = xt;
    y[N+1] = yt;
    r[N+1] = 0;
    for (int i = 1; i <= N; i++) cin >> x[i] >> y[i] >> r[i];
    vector<vector<double>> edge(N+2, vector<double>(N+2, 0));
    for (int i = 0; i <= N+1; i++) {
        for (int j = 0; j <= N+1; j++) {
            if (i == j) continue;
            edge[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])) - r[i] - r[j];
            if (edge[i][j] < 0) edge[i][j] = 0;
        }
    }
    vector<double> dist(N+2, 99999999999);
    dist[0]=0;
    priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> pq;
    pq.push({0, 0});
    
    while (!pq.empty()) {
        double d = pq.top().first;
        int now = pq.top().second;
        pq.pop();
        for (int nxt = 1; nxt <= N+1; nxt++) {
            if (dist[nxt] > d + edge[now][nxt]) {
                dist[nxt] = d + edge[now][nxt];
                pq.push({dist[nxt], nxt});
            }
        }
    }
    printf("%.15lf\n", dist[N+1]);
    
    return 0;
}


Measured memory_bytes: 13680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(string, n);
	print((len(n) - 1) * 9 + (string(len(n), '9') == (n + '9').substr(1) ? (n[0] - '0') : ((n[0] - '0') - 1)));
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  st s;
  cin >> s;
  if(s.size() % 2 == 0){
    bool check = 1;
    rep(i, 0, s.size() / 2){
      if(!(s.at(i * 2) == 'h' && s.at(i * 2 + 1) == 'i')) check = 0; 
    }
    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        /* code */
        cin>>a[i];
    }
    vector<bool> dp(k + 1, false);
    for(ll i=1; i<=k; i++)
    {
        if(i < a[0])
        {
            continue;
        }
        for(ll x: a)
        {
            if(i >= x and !dp[i - x])   
            {
                dp[i] = true;
                break;
            }
        }
    }
    if(dp[k])
    {
        cout<<"First"<<'\n';
    }
    else
    {
        cout<<"Second"<<'\n';
    }
    
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 303;
int nn, k, MOD;
int d[N][N];
int ds[N][N];
int cnk[N][N];

int main() {
    ios::sync_with_stdio(false);
    cin >> nn >> k >> MOD;
    ++nn;

    for (int i = 0; i < N; ++i) {
        cnk[i][0] = 1;
        for (int j = 1; j <= i; ++j)
            cnk[i][j] = (cnk[i-1][j-1] + cnk[i-1][j]) % MOD;
    }
    
    for (int n = 1; n <= nn; ++n) {
        for (int v = 0; v <= k; ++v) {
            int &cd = d[n][v];
            if (n == 1) {
                cd = 1;
                continue;
            }
            cd = 0;
            for (int m = 1; m < n; ++m)
                cd = (cd + 1LL * d[n-m][v] * cnk[n - 2][m - 1] % MOD * ds[m][v+1]) % MOD;
        }
        ds[n][N-1] = d[n][N-1];
        for (int i = N - 2; i >= 0; --i)
            (ds[n][i] = d[n][i] + ds[n][i+1]) %= MOD;
    }


    cout << d[nn][0] << "\n";

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin>>n;
    rep(i,len(n)){
      if(n[i]=='9'){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int s = Int32.Parse(str[0]);
            int w = Int32.Parse(str[1]);
            if(w >= s)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}


Measured memory_bytes: 27376
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
ll a[200005],sum[200005],ans=inf;
int main(){
	std::ios::sync_with_stdio(false);
	int n,i;
	ans*=inf;
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
		sum[i]=i>0?sum[i-1]+a[i]:a[i];
	}
	rep(i,n-1)
	{
		ans=min(ans,abs(sum[n-1]-sum[i]-sum[i]));
	}
	cout<<ans<<endl;

} 


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

using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }

  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (row[i]) {
      for (int j = 0; j < w; j++) {
        if (col[j]) {
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Change
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			n = 1000-n;
			int c = 0;
			while(n>=500){
				n-=500;c++;
			}
			while(n>=100){
				n-=100;c++;
			}
			while(n>=50){
				n-=50;c++;
			}
			while(n>=10){
				n-=10;c++;
			}
			while(n>=5){
				n-=5;c++;
			}
			while(n>=1){
				n-=1;c++;
			}
			System.out.println(c);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int H,W;
    cin>>H>>W;
    vector<string> S(H);
    cin>>S;
    vector<vector<int>> dist(H,vector<int>(W,INF));
    queue<pii> q;
    q.push({0,0});
    dist[0][0]=0;
    while(!q.empty()) {
        int y=q.front().first;
        int x=q.front().second; q.pop();
        REP(dir,4) {
            int yy=y+DY[dir];
            int xx=x+DX[dir];
            if(OUTOFRANGE(yy,xx,H,W)) continue;
            if(dist[yy][xx]!=INF) continue;
            if(S[yy][xx]=='#') continue;
            q.push({yy,xx});
            dist[yy][xx]=dist[y][x]+1;
        }
    }
    if(dist[H-1][W-1]==INF) {
        cout<<-1<<endl;
        return 0;
    }
    int sum=0;
    REP(i,H) {
        REP(j,W) {
            if(S[i][j]=='.') sum++;
        }
    }
    cout<<sum-(dist[H-1][W-1]+1)<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    static int count = 100;
    static int max = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] grid = new int[10][10];
        while (sc.hasNext()) {
            String[] lines = sc.nextLine().split(",");
            drop(grid, Integer.parseInt(lines[0]), Integer.parseInt(lines[1]), Integer.parseInt(lines[2]));
        }
        System.out.println(count + "\n" + max);
    }

    static void drop(int[][] grid, int x, int y, int n) {
        int[][] px = { { 0, 0, 1, -1, 0 }, { 0, 0, 2, -2 } };
        int[][] py = { { 1, -1, 0, 0, 0 }, { 2, -2, 0, 0 } };
        switch (n) {
        case 1:
        case 3:
            int m = n == 1 ? 0 : 1;
            for (int i = 0; i < px[m].length; i++) {
                draw(grid, x + px[m][i], y + py[m][i]);
            }
            if (n == 1) {
                break;
            }
        case 2:
            for (int i = -1; i < 2; i++) {
                for (int j = -1; j < 2; j++) {
                    draw(grid, x + i, y + j);
                }
            }
            break;
        }
    }

    private static void draw(int[][] grid, int dx, int dy) {
        if (dx < 10 && dx >= 0 && dy < 10 && dy >= 0) {
            grid[dy][dx]++;
            if (grid[dy][dx] == 1)
                count--;
            max = Math.max(max, grid[dy][dx]);
        }
    }
}


Measured memory_bytes: 25960
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
vector<string> v;
string a = "zzzzzzzzzzzz";
int main(){
	int i,n,j;
	cin >> n;
	for(i=0;i<n;i++){
		string s; cin >> s;
		sort(s.begin(),s.end());
		v.push_back(s);
	}
	sort(v.begin(),v.end());
	v.push_back(a);
	long long ans = 0,cnt = 0;
	for(i=0;i<=n;i++){
		if(i==0){
			cnt++;
		}else{
			if(v[i-1]!=v[i]){
				ans += (cnt*(cnt - 1))/2;
				cnt = 0;
			}
			cnt++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5748
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define MP make_pair
#define INF (1<<29)

typedef pair<long long, int> NODE;

int main() {
	while (true) {
		int n, k;
		int info[100][100];

		cin >> n >> k;
		if (n == 0 && k == 0) break;
		REP(i, n) REP(j, n)
			info[i][j] = INF;
		while(k--) {
			int a, b, c, d;
			scanf("%d %d %d", &a, &b, &c);
			b--; c--;
			if (a == 1) {
				scanf("%d", &d);
				info[b][c] = info[c][b] = min(info[b][c], d);
			} else {
				long long memo[100];
				REP(i, 100) memo[i] = INF;
				priority_queue<NODE, vector<NODE>, greater<NODE> > q;
				memo[b] = 0;
				q.push(MP(0, b));
				while (! q.empty()) {
					NODE dnode = q.top(); q.pop();

					if (dnode.second == c) break;
					REP(i, n) {
						if (memo[i] > dnode.first + info[dnode.second][i]) {
							memo[i] = dnode.first + info[dnode.second][i];
							q.push(MP(memo[i], i));
						}
					}
				}
				if (memo[c] == INF) cout << "-1" << endl;
				else cout << memo[c] << endl;
			}
		}
	}
	return 0;
}

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

int main() {
	string S, T; cin >> S >> T;
	for(int i=1; S!=T && i<S.size(); ++i){
	    S = S.back() + S;
	    S.pop_back();
	}
	if(S==T) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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


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

    string s;
    cin >> s;
    int K;
    cin >> K;
    for(int i=0; i<len(s); i++){
      int n = s[i]-'a';
      if(K == 0) continue;
      if(i == len(s)-1){
        s[i] = (n+K)%26+'a';
        continue;
      }
      if(n!=0 && 26-n <= K){
        K -= (26-n);
        s[i] = 'a';
        continue;
      }
    }
    cout << s << endl;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll n = in(), a = in(), b = in();
    vll v = in(n);

    vvll c(55, vll(55, 0));
    c[0][0] = 1;
    for (int i = 0; i <= 51; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            c[i + 1][j] += c[i][j];
            c[i + 1][j + 1] += c[i][j];
        }
    }

    sort(ALL(v), greater<ll>());
    ll sum = accumulate(v.begin(), v.begin() + a, 0ll);
    double ave = (double)sum / a;
    cout << ave << endl;

    ll ans = 0;
    if (v.front() == v[min(a, n - 1)])
    {
        ll cnt = 0;
        rep(i, n)
        {
            if (v[i] == v[a - 1])
                ++cnt;
        }
        for (int i = a; i <= b; ++i)
        {
            ans += c[cnt][i];
        }
    }
    else if (a == n || v[a - 1] != v[a])
    {
        ans = 1;
    }
    else
    {
        ll l = 0;
        ll r = 0;
        rep(i, n)
        {
            if (v[i] == v[a - 1])
            {
                if (i < a)
                {
                    ++l;
                }
                else
                {
                    ++r;
                }
            }
        }
        ans = c[l + r][l];
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main() {
int N;
cin>>N;
ll H[N];
rep(i,N){
  cin>>H[i];
}
H[0]--;
rep2(i,1,N){
  if(H[i]<H[i-1]){
    cout<<"No"<<endl;
    return 0;
  }
  else if(H[i]>H[i-1]){
    H[i]--;

  }
}
cout<<"Yes"<<endl;
return 0;
}

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

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

    int N, K;
    cin >> N >> K;
    int ans = 1;
    rep(i, N) {
        if (ans <= K) {
            ans *= 2;
        }
        else {
            ans += K;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256