akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;

int main() {
    string S;
    cin >> S;
    string T;
    cin >> T;

    int ri = -1;
    for (int i = 0; i < S.size(); i++) {
        if (i > S.size() - T.size()) break;

        bool ok = true;
        for (int j = 0; j < T.size(); j++) {
            if (S[i + j] != T[j] && S[i + j] != '?') {
                ok = false;
                break;
            }
        }

        if (ok) {
            ri = i;
        }
    }

    if (ri == -1) {
        cout << "UNRESTORABLE" << endl;
    } else {
        for (int i = ri; i < ri + T.size(); i++) {
            S[i] = T[i - ri];
        }
        rep(i, S.size()) {
            if (S[i] == '?') {
                S[i] = 'a';
            }
        }

        cout << S << endl;
    }
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll a,b;
  cin>>a>>b;
  ll ans=0;
  vector<ll>v(42,0);
  ll p=0;
  ll q=0;
  for(ll i=0;i<42;i++){

    p=((ll)b>>(ll)(i+1))*((ll)1<<i);
    if(b&((ll)1<<i)){
      p+=((ll)b&(((ll)1<<(i))-1));
      p++;
    }
    q=((ll)(a-1)>>(ll)(i+1))*((ll)1<<i);
    if((a-1)&((ll)1<<i)){
      q+=((ll)(a-1)&(((ll)1<<(i))-1));
      q++;
    }
    v[i]=p-q;
    // cout<<p<<" "<<q<<endl;
  }
  for(ll i=0;i<42;i++){
    if(v[i]%2){
      ans|=((ll)1<<(ll)i);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  map<int, int> mp{};
  int cnt = 0;
  vector<int> tyouhuku(N);
  REP(i, N) {
    cin >> A[i];
    tyouhuku[i] = A[i];
    if (mp[A[i]] == 0) cnt++;
    mp[A[i]]++;
  }
  ll ans = 0;
  sort(tyouhuku.begin(), tyouhuku.end());
  tyouhuku.erase(unique(tyouhuku.begin(), tyouhuku.end()), tyouhuku.end());
  vector<P> Op(0);
  REP(i, tyouhuku.size()) { Op.push_back(P(mp[tyouhuku[i]], tyouhuku[i])); }
  sort(Op.begin(), Op.end());
  int o = 0;
  while(K<cnt){
    cnt -= 1;
    ans += Op[o].first;
    o++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 13304
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define INF 1000000000000000

using namespace std;

ll get(ll mask, vector<ll> hold[], ll cost[], ll store[])
{
    //cout<<"at mask "<<mask<<"\n";
    if(store[mask]!=INF)
        return store[mask];
    if(mask <= 0)
        return store[mask] = 0;
    if(hold[mask].size() == 1)
        return 0;
    ll ans = -INF;    
    ll lim = (1ll<<(hold[mask].size()));
    for(ll i=mask;i>0;i = (i-1)&mask)
        ans = max(ans, cost[i] + get(mask - i, hold, cost, store));        
    
    
    return store[mask] = ans;
}

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll lim = (1ll<<n);
   
   ll mat[n][n];
   for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            cin>>mat[i][j];
   
   ll cost[lim];
   memset(cost,0,sizeof(cost));
   vector<ll> hold[lim];
   for(ll i=0;i<lim;i++)
   {
       for(ll j=0;j<n;j++)
       if((1ll<<j)&i)
            hold[i].pb(j);
   }
   
   for(ll i=0;i<lim;i++)
   {
       for(ll i1=0;i1<hold[i].size();i1++)
            for(ll j = i1+1;j<hold[i].size();j++)
                cost[i]+=mat[hold[i][i1]][hold[i][j]];
   }
   
   ll store[lim];
   for(ll i=0;i<lim;i++)
        store[i] = INF;
   
   ll ans = get(lim-1,hold,cost,store);
   cout<<ans;
   
   return 0;
}

Measured memory_bytes: 11520
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    string s;
    cin>>s;

    int idx=0;
    ll ans=0;
    ll countA=0;
    while(idx<((int)s.size())-2) {
        if(s[idx]=='A' ) {
            if(s[idx+1]=='B' && s[idx+2]=='C') {
                ans++;
                ans+=countA;
                s[idx]='B';
                s[idx+1]='C';
                s[idx+2]='A';
                idx++;
                // dont inc or decrement countA
            } else {
                countA++;
            }
        } else
            countA=0;
        idx++;
    }
    cout<<ans<<endl;
}



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

ss = list(map(int, input().split()))

even_list = [i for i in ss if i % 2 == 0]

res = 0

for i in even_list:
  if i % 3 == 0:
    res += 1
  elif i % 5 == 0:
    res += 1
if res == len(even_list):
  print("APPROVED")
else:
  print("DENIED")

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

int ks(int n){
  int ans=1;
  for(int i=0;i<n;i++){
    ans*=10;
  }
  return ans;
}

int ki(int n){
  if(n==1){
    return 0;
  }
  int ans=1;
  for(int i=0;i<n-1;i++){
    ans*=10;
  }
  return ans;
}

bool hantei(int N,int n,int s,int c){
  int ss=ks(N-s+1);
  int si=ks(N-s+1)/10;
  if(n%ss/si==c){
    return true;
  }
  return false;
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  for(int i=0;i<M;i++){
    cin >> s[i] >> c[i];
  }
  for(int i=ki(N);i<ks(N);i++){
    int flag=0;
    for(int j=0;j<M;j++){
      if(!hantei(N,i,s[j],c[j])){
        flag=1;
      }
    }
    if(flag==1){
      continue;
    }
    else{
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	ll a, b, ans = 0;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		string a = "", b;
		ll num = i;
		while (num) {
			a += num % 10;
			num /= 10;
		}
		b = a;
		reverse(a.begin(), a.end());
		if (a == b)ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<int64_t> as(n);
  for (int i = 0; i < n; i++) {
    std::cin >> as[i];
  }
  int64_t ret = INT64_MAX;
  for (int firstShouldBePositive = 0; firstShouldBePositive < 2;
       firstShouldBePositive++) {
    int64_t sum = 0;
    int64_t candidate = 0;
    for (int i = 0; i < n; i++) {
      sum += as[i];
      int64_t move = 0;
      if (i % 2 == firstShouldBePositive) {
        if (sum <= 0) {
          move = 1 - sum;
        }
      } else {
        if (sum >= 0) {
          move = -1 - sum;
        }
      }
      sum += move;
      candidate += abs(move);
      if (candidate >= ret) {
        break;
      }
    }
    ret = std::min(candidate, ret);
  }
  std::cout << ret << std::endl;
  return 0;
}


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

//しっかり制約確認したか?
int main()
{
    ll n, k; cin >> n >>  k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    ll l = v[0], r = 0;
    for(int i = k; i < n; i++){
        r = v[i];
        if(l < r){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
        l = v[i-k+1];
    }

    system("pause");
}


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

int selectionSort(int A[], int N){
    int t = 0;
    for(int i = 0; i <= N - 2; i++){
        int minj = i;
        for(int j = i; j <= N - 1; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        swap(A[i], A[minj]);
        if(i != minj) t++;
    }
    return t;
}

int main(){
    int A[100], N, t;
    
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    
    t = selectionSort(A, N);
    
    for(int i = 0; i < N; i++){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl << t << endl;
    
    return 0;
}


Measured memory_bytes: 3104
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    ans=0
    for i in range(n):
        ans+=abs(a[i])
    print(ans)
else:
    num=0
    for i in range(n):
        if a[i]<0:
            num+=1
        a[i]=abs(a[i])
    if num%2==0:
        print(sum(a))
    else:
        print(sum(a)-(min(a)*2))


Measured memory_bytes: 19976
import math
import numpy as np
import sys
def IL(): return list(map(int,sys.stdin.readline().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()

y = s[:4]
d = s[5:7]+s[8:]

f = 0
if int(y) < 2019:
    f = 1
elif int(y) == 2019:
    if int(d) <= 430:
        f = 1

if f:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 21644
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll mod = 1e9+7;
const ll INF = 2e9;
const double PI = 3.1415926535;

char s[100000][11];
vector <string> strlist;

int main(void){
    int n; cin >> n;
    for(int i = 0;i < n;i++)scanf("%s", &s[i]);
    for(int i = 0;i < n;i++){
        sort(s[i], s[i] + 10);
        strlist.push_back(s[i]);
    }
    sort(strlist.begin(), strlist.end());
    
    ll c = 1;
    ll ans = 0;
    for(int i = 1;i < n;i++){
        if(strlist[i] == strlist[i-1])c++;
        else {
            ans += c*(c-1)/2;
            c = 1;
        }
    }
    ans += c*(c-1)/2;
    cout << ans << endl;
	return 0;
}

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

string s, t;

string transform(string s)
{
    map<char, char> mp;
    char m = 'a';
    for(int i = 0; i < s.size(); i++)
    {
        if(mp.find(s[i]) == mp.end())
        {
            mp[s[i]] = m;
            s[i] = m;
            m++;
        }
        else
        {
            s[i] = mp[s[i]];
        }
    }
    return s;
}

int main()
{
    cin >> s >> t;
    if(transform(s) == transform(t))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

// Light version
using Data = int;
const int len = 1 << 12;

struct BIT {
  vector<Data> data;
  BIT() : data(len, 0) {}
  void update(int i, Data value) {
    for (; i < len; i |= i+1) data[i] += value;
  }
  Data query(int i) {
    Data s = 0;
    for (; i >= 0; i = (i&i+1)-1) s += data[i];
    return s;
  }
};

int main()
{
  int n;
  cin>>n;
  int m=2*n;
  vector<pair<bool, int>> v(m);
  vecint bpos(n);
  vecint wpos(n);
  REP(i,m) {
    string s;
    int a;
    cin>>s>>a;
    --a;
    v[i] = make_pair(s=="B", a);
    if (s=="B") {
      bpos[a] = i;
    } else {
      wpos[a] = i;
    }
  }
  vector<vecint> bcnt(n+1, vecint(m+1));
  vector<vecint> wcnt(n+1, vecint(m+1));
  REP(i,n+1) {
    bcnt[i][0] = 0;
    wcnt[i][0] = 0;
    REP(j,m) {
      bool c;
      int a;
      tie(c,a) = v[j];
      bcnt[i][j+1] = bcnt[i][j] + (c && a < i ? 1 : 0);
      wcnt[i][j+1] = wcnt[i][j] + (!c && a < i ? 1 : 0);
    }
  }
  constexpr int INF = 1e9;
  vector<vecint> costb(n+1, vecint(n+1, 0));
  vector<vecint> costw(n+1, vecint(n+1, 0));
  REP(i,n+1) {
    REP(j,n+1) {
      int bi = bpos[i];
      costb[i][j] = i+j-bcnt[i][bi]-wcnt[j][bi];
      int wj = wpos[j];
      costw[i][j] = i+j-bcnt[i][wj]-wcnt[j][wj];
    }
  }
  vector<vecint> dp(n+1, vecint(n+1, INF));
  dp[0][0] = 0;
  REP(i,n+1) {
    REP(j,n+1) {
      if (i) dp[i][j] = min(dp[i][j], dp[i-1][j] + costb[i-1][j]);
      if (j) dp[i][j] = min(dp[i][j], dp[i][j-1] + costw[i][j-1]);
    }
  }
  cout<<dp[n][n]<<endl;
  return 0;
}


Measured memory_bytes: 110080
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
	int n, ansX = -1, ansY = -1, ansH = -1, minX = -1, maxX = -1, minY = -1, maxY = -1;
	cin >> n;
	int *x = new int[n], *y = new int[n], *h = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> h[i];
		if (maxX == -1 || maxX < x[i])
			maxX = x[i];
		if (minX == -1 || minX > x[i])
			minX = x[i];
		if (maxY == -1 || maxY < y[i])
			maxY = y[i];
		if (minY == -1 || minY > y[i])
			minY = y[i];
	}
	for (int i = minX; i <= maxX; i++) {
		for (int j = minY; j <= maxY; j++) {
			int k0 = 0;
			while (h[k0++] == 0);
			int H = h[--k0] + abs(i - x[k0]) + abs(j - y[k0]);
			bool f = true;
			for (int k = 0; k < n; k++) {
				if (h[k] + abs(i - x[k]) + abs(j - y[k]) != H && !(h[k] + abs(i - x[k]) + abs(j - y[k]) > H && h[k] == 0)) {
					f = false;
					break;
				}
			}
			if (f) {
				ansX = i, ansY = j, ansH = H;
				break;
			}
		}
	}
	/*
	if (ansX == -1) {//TLEを利用してWAの原因を調べる
		while (1);
	}
	*/
	cout << ansX << " " << ansY << " " << ansH << endl;
	return 0;
}

Measured memory_bytes: 256
(X, Y, Z, K), As, Bs, Cs = readlines.map{|l| l.split.map(&:to_i)}

@as, @bs, @cs = [As, Bs, Cs].map{|xs| [nil] + xs.sort.reverse}
ans = []
for i in 1 .. X
  for j in 1 .. Y
    break if i*j > K
    for k in 1 .. Z
      break if i*j*k > K
      ans << @as[i] + @bs[j] + @cs[k]
    end
  end
end
puts ans.sort.reverse.take(K)

Measured memory_bytes: 4792
#include <stdio.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <string.h>
#include <queue>

#define INF 1000000009

using namespace std;

int main(){
	int N,M;
  	cin >> N >> M;
	vector<vector<int>> e(N);
  	int d[100005];
  	int back[100005];
  	for(int i=0; i<M; i++){
    	int a,b;
      	cin >> a >> b;
        e[a-1].push_back(b-1);
      	e[b-1].push_back(a-1);
    }
  	memset(d, INF, sizeof(d));
  	memset(back, 0, sizeof(back));
  	d[0] = 0;
  	queue<pair<int, int>> que;
  	pair<int, int> s(0, 0);
  	que.push(s);
  	while(!que.empty()){
    	pair<int, int> p = que.front();
      	que.pop();
      	int i = p.second;
      	for(int j=0; j<e[i].size(); j++){
          	int to = e[i][j];
    		if(d[to] > d[i]+1){
            	d[to] = d[i]+1;
              	back[to] = i;
              	pair<int, int> p2(d[to], to);
              	que.push(p2);
            }
        }
    }
  
  	for(int i=0; i<N; i++){
    	if(d[i] == INF){
        	cout << "No" << endl;
          	return 0;
        }
    }
  	cout << "Yes" << endl;
  	for(int i=1; i<N; i++){
    	cout << back[i]+1 << endl;
    }
}

Measured memory_bytes: 10916
//arc076_c.cpp
//Sat Jun  9 07:54:59 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;


ll kaijo(int k){
	ll sum = 1;
	for (int i=1;i<=k;i++)
	{
		sum *= i;
		if (sum > 1000000007){
			sum = sum%1000000007;
		}
	}
	return sum;
}

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

	if (abs(n-m)==1){
		if (m>n){
			int temp = m;
			m = n;
			n = temp;
		}
		ll ans = (kaijo(n)*kaijo(m))%1000000007;
		cout << ans << endl;
	}else if (n==m){
		ll ans = (kaijo(n)*kaijo(m)*2)%1000000007;
		cout << ans << endl;
	}else {
		cout << "0" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}


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

	ll  d, n, m, k, ans = 0, ret = M;
	bool flag = false, flag2 = false;
	string s, t;
	ll a, b, c, e, f, g, h;
	cin >> a >> b >> c >> d >> e >> f >> g;
	if (a >= 1 && d >= 1 && e >= 1) {
		f = a - 1;
		g = d - 1;
		h = e - 1;
		ans += b + 3 + (f / 2) * 2 + (g / 2) * 2 + (h / 2) * 2;
	}
	ll cur = b + (a / 2) * 2 + (d / 2) * 2 + (e / 2) * 2;
	cout << max(ans,cur) << endl;
	return 0;
}


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

int main()
{
    string T;
    string P;
    cin >> T;
    cin >> P;
    size_t pos = T.find(P, 0);
    while (pos != string::npos){
        cout << pos << endl;
        pos = T.find(P, pos + 1);
    }
    return 0;
}

Measured memory_bytes: 3200
//use std::io::{stdout, Write, BufWriter}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
    }
    let (mut x, mut y, mut z) = (a, b, c);
    let mut ans = 0;
    while x % 2 == 0 && y % 2 == 0 && z % 2 == 0 {
        let b_x = x;
        x = (y + z) / 2;
        let b_y = y;
        y = (z + b_x) / 2;
        z = (b_x + b_y) / 2;
        if (x, y, z) == (a, b, c) {
            println!("-1");
            return;
        }
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = a[0] - 1;
    ll p = 2;
    reps(i, 1, n) {
        if (a[i] < p) continue;
        if (a[i] == p) {
            p++;
        }
        else {
            ans += (a[i] - 1) / p;
        }
    }
    cout << ans << endl;
    return 0;
}


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


int main()
{
  int n;
  cin >> n;
  double ans = 0;
  rep(i, n)
  {
    double a;
    cin >> a;
    ans += 1 / a;
  }
  printf("%.6lf\n", 1 / ans);
  return 0;
}

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

int main() {
    int64_t X, N;
    cin >> X >> N;

    set<int64_t> st;
    for (int64_t i = 0; i < N; i++) {
        int64_t p;
        cin >> p;
        st.insert(p);
    }

    for (int64_t i = 0; ; i++) {
        //引く
        for (int64_t target : { X - i, X + i }) {
            if (st.count(target) == 0) {
                cout << target << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

struct WeightedUnionFind {
  vector<int> data;
  vector<ll> ws;
  WeightedUnionFind(int sz) : data(sz, -1), ws(sz) { }
  bool merge(int x, int y, ll w) {
    w += weight(x); w -= weight(y);
    if ((x = root(x)) == (y = root(y))) return false;
    if (data[x] > data[y]) swap(x, y), w = -w;
    data[x] += data[y]; data[y] = x; ws[y] = w;
    return true;
  }
  bool find(int x, int y) { return root(x) == root(y); }
  ll diff(int x, int y) { return weight(y) - weight(x); }
  ll weight(int t) { root(t); return ws[t]; }
  int root(int k) {
    if (data[k] < 0) return k;
    int par = root(data[k]);
    ws[k] += ws[data[k]];
    return data[k] = par;
  }
  bool issame(int x, int y) { return root(x) == root(y); }
};

void solve() {
  int n;
  cin >> n;
  int Q;
  cin >> Q;

  WeightedUnionFind uni(n);
  while (Q--) {
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    if (uni.issame(x, y)) {
      if (uni.diff(x, y) == z) continue;
      cout << "No" << endl;
      return;
    }
    uni.merge(x, y, z);
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cstdio>
#include <functional>
#include <map>
#include <numeric>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
const int dy[] = { -1, 1, 0, 0 };
const int dx[] = { 0, 0, 1, -1 };

template <typename T>
map<T, int> coordinate_compression_map(vector<T> const & xs) {
    int n = xs.size();
    vector<int> ys(n);
    iota(whole(ys), 0);
    sort(whole(ys), [&](int i, int j) { return xs[i] < xs[j]; });
    map<T,int> f;
    for (int i : ys) {
        if (not f.count(xs[i])) { // make unique
            int j = f.size();
            f[xs[i]] = j; // f[xs[i]] has a side effect, increasing the f.size()
        }
    }
    return f;
}

int main() {
    while (true) {
        // input
        int n; scanf("%d", &n);
        if (n == 0) break;
        vector<int> l(n), t(n), r(n), b(n);
        repeat (i, n) {
            scanf("%d%d%d%d", &l[i], &t[i], &r[i], &b[i]);
        }
        // solve
        // // compress
        vector<int> xs, ys;
        repeat (i, n) {
            xs.push_back(l[i]);
            ys.push_back(t[i]);
            xs.push_back(r[i]);
            ys.push_back(b[i]);
        }
        sort(whole(ys)); ys.erase(unique(whole(ys)), ys.end());
        sort(whole(xs)); xs.erase(unique(whole(xs)), xs.end());
        map<int, int> cy = coordinate_compression_map(ys);
        map<int, int> cx = coordinate_compression_map(xs);
        // // dfs
        int h = cy.size();
        int w = cx.size();
        auto f = vectors(2 * h + 3, 2 * w + 3, false);
        repeat (y, 2 * h + 3) f[y][0] = f[y][2 * w + 2] = true;
        repeat (x, 2 * w + 3) f[0][x] = f[2 * h + 2][x] = true;
        repeat (i, n) {
            repeat_from (y, 2 * cy[b[i]] + 2, 2 * cy[t[i]] + 3) f[y][2 * cx[l[i]] + 2] = f[y][2 * cx[r[i]] + 2] = true;
            repeat_from (x, 2 * cx[l[i]] + 2, 2 * cx[r[i]] + 3) f[2 * cy[b[i]] + 2][x] = f[2 * cy[t[i]] + 2][x] = true;
        }
        int result = 0;
        stack<pair<int, int> > stk;
        repeat (y, 2 * h + 3) repeat (x, 2 * w + 3) if (not f[y][x]) {
            result += 1;
            f[y][x] = true;
            stk.emplace(y, x);
            while (not stk.empty()) {
                int y, x; tie(y, x) = stk.top(); stk.pop();
                repeat (i, 4) {
                    int ny = y + dy[i];
                    int nx = x + dx[i];
                    if (not f[ny][nx]) {
                        f[ny][nx] = true;
                        stk.emplace(ny, nx);
                    }
                }
            }
        }
        // output
        printf("%d\n", result);
    }
    return 0;
}

Measured memory_bytes: 2824
a, b, c, d, e, f = map(int,input().split())

S = [0] * 1501
for i in range(1500//c + 1):
    for j in range(1500//d + 1):
        if c * i + d * j <= 1500:
            S[c * i + d * j] = 1

S2 = [0] * 1501
t = 0
for i in range(1501):
    if S[i] == 1:
        t = i
    S2[i] = t

#print(S2[:100])

ans = [0, 0, 0]
for i in range(30):
    for j in range(30):
        water = i * 100 * a + j * 100 * b
        if 0 < water <= f:
            sugar_max = min(f - water, water * e * 0.01)
            sugar = S2[int(sugar_max)]
            noudo = sugar / (water + sugar)
            #print(i, j, water, sugar_max, sugar, noudo)
            if noudo >= ans[0]:
                #print(i, j, sugar)
                ans[0] = noudo
                ans[1] = water + sugar
                ans[2] = sugar

print(ans[1], ans[2])



Measured memory_bytes: 40684
s = input().strip()

DIV = 10**9 + 7
new = list(range(13))
old = None

c = s[-1]
if c == '?':
    old = [int(t < 10) for t in range(13)]
else:
    c = int(c)
    old = [int(t == c) for t in range(13)]

digit = 10
for i, c in enumerate(reversed(s[:-1])):
    for j in range(13):
        new[j] = 0
    if c == '?':
        for m in range(10):
            for mod, cnt in enumerate(old):
                shifted = (mod + m * digit) % 13
                new[shifted] += cnt
    else:
        c = int(c)
        for mod, cnt in enumerate(old):
            shifted = (mod + c * digit) % 13
            new[shifted] += cnt
    for j in range(13):
        new[j] %= DIV
    new, old = old, new
    digit = (digit * 10) % 13

print(old[5])

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

namespace ABC123 {
	class ABC123_C {
		static void Main(string[] args) {
			var N = long.Parse(Console.ReadLine());
			var capacityList = new List<double>();
			for (int i = 0; i < "ABCDE".Length; i++) {
				capacityList.Add(long.Parse(Console.ReadLine()));
			}

			Console.WriteLine((long)Math.Ceiling(N / capacityList.Min()) + 4);
		}
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define foi(i,n) for(int i = 0 ; i< n ;i++)
#define mod 1000000007
int dp[100001][2];
class graph{
public:
    int V,E;
    map<int,list<int>> adj;
    void init(int v,int e){
        V = v ; E = e;
        foi(i,e){
            int u,v;
            cin >> u >> v;

            adj[u].pb(v);
            adj[v].pb(u);
        }
    }

    int dfsHelper(int node,int parent,int color){ // 0 -> black y 1 -> white
            //cout << node << " " << parent << endl;
            if(dp[node][color]!=-1) return dp[node][color];
            int answer = 1  ;
            for(auto y : adj[node]){
                if(y == parent) continue;
                if(color == 0){
                    answer=  (answer%mod*(dfsHelper(y,node,1))%mod)%mod;
                }
                else{
                    int a = dfsHelper(y,node,1);
                    int b = dfsHelper(y,node,0);
                    answer = (((a%mod+b%mod)%mod)*(answer%mod))%mod;
                }
            }
            return dp[node][color] = answer;
    }

};

/*map<pair<int,string>,bool> visited;

bool solve(int n,int k,int *arr,string &s){
    if(k < 0) return 0;
    if(k == 0) return 1;
    if(visited.count({k,s})!=0) return visited[{k,s}];
    for(int i = 0 ; i < n ; i++){
        bool temp  = false;
        if(s[i]=='0'){
            s[i] = '1';
            temp = solve(n,k-arr[i],arr,s);
            s[i] = '0';
            if(temp == true) return visited[{k,s}] = true;
        }
    }
    return visited[{k,s}] = false;
}*/

int32_t main(){
    foi(i,100001) {
        dp[i][0] = -1;
        dp[i][1] = -1;
    }
    int n = 0;
    cin >> n;
    //cout << n << endl;
    graph g;
    g.init(n,n-1);
    int answer =0;
    answer += g.dfsHelper(1,1,1);
    answer  = (g.dfsHelper(1,1,0)%mod + answer%mod)%mod;
    cout << answer ;
}


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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    int lastPossibleIndex = 0;
    for (int i = 0; i < N - 1; i++) {
        if (A[i] * 2 < A[i + 1]) {
            lastPossibleIndex = i + 1;
        }
        A[i + 1] += A[i];
    }

    cout << N - lastPossibleIndex << endl;
    return 0;
}

Measured memory_bytes: 1024
import collections
n=int(input())
half_n=n//2
t=list(map(int,input().split()))
even_lis=[]
odd_lis=[]
set_t=list(set(t))
if len(set_t)==1:
    print(n//2)
    exit()
for i in range(0,n,2):
    even_lis.append(t[i])
for i in range(1,n,2):
    odd_lis.append(t[i])
even_count=collections.Counter(even_lis)
odd_count=collections.Counter(odd_lis)
if even_count.most_common()[0][0]!=odd_count.most_common()[0][0]:
    ans=(half_n-even_count.most_common()[0][1])+(half_n-odd_count.most_common()[0][1])
else:
    ans=(half_n-even_count.most_common()[0][1])+(half_n-odd_count.most_common()[1][1])
    ans_2=(half_n-even_count.most_common()[1][1])+(half_n-odd_count.most_common()[0][1])
    ans=min(ans,ans_2)
print(ans)


Measured memory_bytes: 21332
// 2011/07/12 Tazoe

#include <iostream>
using namespace std;

void eratos(bool is_prime[], int n)
{
	if(n>=1)
		is_prime[0] = false;
	if(n>=2)
		is_prime[1] = false;

	for(int i=2; i<n; i++)
		is_prime[i] = true;

	for(int i=2; i<n; i++){
		if(!is_prime[i])
			continue;
		for(int j=i+i; j<n; j+=i)
			is_prime[j] = false;
	}
}

int main()
{
	bool is_prime[60000];
	eratos(is_prime, 60000);

	while(true){
		int n;
		cin >> n;
		if(cin.eof())
			break;

		int pre;
		for(pre=n-1; !is_prime[pre]; pre--);

		int pos;
		for(pos=n+1; !is_prime[pos]; pos++);

		cout << pre << ' ' << pos << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[57][57];
int main(){
	Lancer();
	ll n, x, a,mn=10000000000, sum = 0,res=0;
	cin >> n >> x;
	for (int i = 0; i < n; i++){
		cin >> a;
		sum += a;
		mn = min(a, mn);
	}
	x -= sum;
	x /= mn;
	res = n + x;
	cout << res;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int main(){
  ll N, M;
  cin >> N >> M;
  ll x = (M-2*N)/4;
  ll ret = N;
  if(2*N >= M){
    ret = M/2;
  }else{
    if(x >= 0){
      ret += x;
    }
  }
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
x_1, y_1, x_2, y_2 = map(int,input().split())

diff_x = x_2 - x_1
diff_y = y_2 - y_1

x_3 = x_2 - diff_y
y_3 = y_2 + diff_x

x_4 = x_3 - diff_x
y_4 = y_3 - diff_y

print(x_3,y_3,x_4,y_4)

Measured memory_bytes: 3060
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int N; std::cin >> N;
    std::vector<int> A(N);
    for(int i(0); i < N; ++i) std::cin >> A[i];
    long long ans(1000), cur(1000), st(0);
    bool decre(true);
    for(int i(0); i < N; ++i){
        if(decre && (i < N-1 && A[i] < A[i+1])){
            decre = false;
            st += cur / A[i];
            cur %= A[i];
        }else if(i == N-1 || (!decre && A[i] > A[i+1])){
            decre = true;
            cur += st * A[i];
            st = 0;
            chmax(ans, cur);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin>>a>>b;
  if(a>=2*b){
    cout<<a-2*b;
  }else{
    cout<<0<<endl;
  }   
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll a, b, n;
    cin >> a >> b >> n;

    cout << (a * min(n, b-1)) / b  << endl;
    return 0;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;

public class Ticket
{
    public int AIndex;
    public int BIndex;
    public int Discount;

    public Ticket(string s)
    {
        var vals = s.Split(' ').Select(int.Parse).ToArray();
        AIndex = vals[0] - 1;
        BIndex = vals[1] - 1;
        Discount = vals[2];
    }
}

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var A = vals[0];
        var B = vals[1];
        var M = vals[2];
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var tickets = new Ticket[M];
        for (int i = 0; i < M; i++)
        {
            tickets[i] = new Ticket(Console.ReadLine());
        }

        var min = a.Min() + b.Min();
        foreach (var ticket in tickets)
        {
            var v = a[ticket.AIndex] + b[ticket.BIndex] - ticket.Discount;
            min = Math.Min(v, min);
        }

        Console.WriteLine(min);
    }
}

Measured memory_bytes: 36060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int d, n;
  cin >> d >> n;
  if (n == 100)
    n = 101;
  cout << ((int) pow(100, d)) * n;
}


Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
a=Array.new(m,0)
b=Array.new(m,0)
m.times do |i|
    a[i],b[i]=gets.split.map(&:to_i)
end

n.times do |i|
    puts a.count(i+1)+b.count(i+1)
end


Measured memory_bytes: 14332
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] array = new String[n];
        for (int i=0;i<n;i++) {
            array[i] = sc.next();
        }
        Arrays.sort(array);
        for (String s:array) {
            System.out.print(s);
        }
        System.out.println();
    }
}

Measured memory_bytes: 23124
N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]

MOD=10**9+7

if N>1:
    dp=[0]*(N+1)
    dp[0]=1
    dp[1]=1

    for i in range(M):
        dp[a[i]]=-1

    for i in range(2,N+1):
        if dp[i]==-1:
            continue

        if dp[i-2]!=-1:
            dp[i]+=dp[i-2]
        
        if dp[i-1]!=-1:
            dp[i]+=dp[i-1]
        
        dp[i]=dp[i]%MOD

    print(dp[N])

else:
    if M==0:
        print(1)
    else:
        print(0)

Measured memory_bytes: 80812
void main() {
	(rs.canFind("9") ? "Yes" : "No").writeln;
}

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

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
def max2(x,y):
    return x if x > y else y

R, C, K = map(int, input().split())
V = [[0]*R for _ in range(C)]
for _ in range(K):
    r, c, v = map(int, input().split())
    V[c-1][r-1] = v

dp = [[0]*4 for _ in range(R)]
for j in range(R):
    if V[0][j] != 0:
        dp[j][1] = max2(dp[j - 1][1], dp[j - 1][0]) + V[0][j]
    if j != 0:
        dp[j][0] = max2(dp[j - 1][1], dp[j - 1][0])
for i in range(1,C):
    for j in range(R):
        v = V[i][j]
        if v != 0:
            if dp[j][2] != 0:
                dp[j][3] = max2(dp[j][2] + v, dp[j][3])
            if dp[j][1] != 0:
                dp[j][2] = max2(dp[j][1] + v, dp[j][2])
            dp[j][1] = max2(v, dp[j][1])
        if j != 0:
            if v != 0:
                dp[j][1] = max2(max(dp[j - 1][k] for k in range(4)) + v, dp[j][1])
            dp[j][0] = max2(max(dp[j - 1][k] for k in range(4)), dp[j][0])
print(max(dp[-1]))


Measured memory_bytes: 148244
#include<stdio.h>

int main(void)
{
 int a,b,c,d,e,k;

 scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&k);

 if((e-a <= k)){

 printf("Yay!");}

 else{
 printf(":(");}

 return 0;
 }


Measured memory_bytes: 128
// https://atcoder.jp/contests/abc110/tasks/abc110_c

fun main() {
    abc110c()
}

fun abc110c() {
    val s = readLine()!!
    val t = readLine()!!
    val current = s.groupingBy { it }.eachCount()
    val target = t.groupingBy { it }.eachCount()
    if (current.size != target.size) {
        println("No")
        return
    }
    val cv = current.values.sorted()
    val tv = target.values.sorted()
    for (i in cv.indices) {
        if (cv[i] != tv[i]) {
            println("No")
            return
        }
    }
    println("Yes")
}

Measured memory_bytes: 45484
/*
    author  : real_rpg  
    country : India
    time    : 00:51:12 IST
*/
 
#include "bits/stdc++.h" 
#define ll long long
#define ld long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fld(i,a,b,c) for(ld i=a; i<b; i+=c)
#define fl(i,a,b,c) for(ll i=a; i<b; i+=c)
#define rfl(i,a,b,c) for(ll i=a; i>=b; i-=c) 
#define endt (double)(clock() - tStart)/CLOCKS_PER_SEC
#define rep(i,n) fl(i,0,n,1)
#define rep1(i,n) fl(i,1,n,1)
#define rrep(i,n) rfl(i,n-1,0,1)
#define sas int tt; cin >> tt; rep(tc,tt) 
#define pb  push_back
#define ep emplace_back
#define F first
#define S second
using namespace std; 
const int md = 1e9 + 7;
const int MAX = 1e5 + 5;
const int MAXN = 1e6 + 5;

void solve() {
    ll n; cin>>n;
    while(1) {
        string s=to_string(n);
        set <char> ss;
        rep(i,s.length()) ss.insert(s[i]);
        if(ss.size()==1) {
            cout<<s;
            return;
        } n++;
    }
}

int main() {             
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); cout.tie(NULL); 
    //clock_t tStart = clock(); 
    solve(); 
    //printf("\n%.6f\n", endt);
    return 0; 
}

Measured memory_bytes: 256
n = int(input())
numbers = list(map(int,input().split()))

from fractions import Fraction
def inverse(f):
    return Fraction(f.denominator,f.numerator)

aaa = []
for i in numbers:
    b = Fraction(1,i)
    aaa.append(b)

ans = inverse(sum(aaa))

print(float(ans))

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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == N - 1)
      cout << "Three" << endl;
  }
  // ここにプログラムを追記
}

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

using namespace std;

int main (){
    int n; cin >> n;
    float v[n];

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

    float ans=0;

    sort(v,v+n);
    ans = v[0];
    for(int i = 1; i < n; i++){
        ans = (ans + v[i]) / 2;
    }

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

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

constexpr int MaxRemW = 3 * 100 + 30;
// dp[k][i][j] := k番目を見ているときで、既にi個入れたとき、重さ i * w_1 + j での価値の最大値
vector<int64_t> w(101);
vector<int64_t> v(101);
vector<vector<int64_t>> dp(101, vector<int64_t>(MaxRemW + 1));
vector<vector<int64_t>> next_dp(101, vector<int64_t>(MaxRemW + 1));

int main() {
  int N; int64_t W; cin >> N >> W;
  rep(i, N) {
    cin >> w[i] >> v[i];
  }
  int64_t ans = 0;
  rep(k, N) {
    rep(i, 101) {
      dp[i].swap(next_dp[i]);
      next_dp[i].clear();
      next_dp[i].resize(MaxRemW + 1);
    }
    rep(i, k + 1) rep(j, MaxRemW) {
      maximize(next_dp[i][j], dp[i][j]);
      auto currW = i * w[0] + j;
      if (currW > W) continue;
      auto next_j = j + (w[k] - w[0]);
      if (next_j > MaxRemW) continue;
      auto nextW = (i + 1) * w[0] + next_j;
      if (nextW > W) continue;
      maximize(next_dp[i + 1][next_j], dp[i][j] + v[k]);
      maximize(ans, next_dp[i + 1][next_j]);
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 768