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


vector<ll> divisor(ll N)
{
	vector<ll> ret;
	for(ll i=1;i<=(ll)sqrt(N);i++)
	{
		if(N%i==0)
		{
			if(N/i!=i) ret.push_back(i);
		}
	}
	return ret;
}
/*
 * N/m=N%m
 * r=N%m
 * N=x*m+r
 * r=x
 * N=r*m+r
 * N=r*(m+1)
 * m+1=N/r
 * m=N/r-1
 */
int main()
{
	ll N;
	cin>>N;
	vector<ll> divs=divisor(N);
	ll ans=0;
	for(ll x : divs)
	{
		ll m=N/x-1;
		if(N/m==N%m) ans+=m;	
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3660
import itertools

n = int(input())
li = [0]*5
ans = 0

for i in range(n):
    s = input()
    if s[0] == "M":
        li[0] = li[0] + 1
    if s[0] == "A":
        li[1] = li[1] + 1
    if s[0] == "R":
        li[2] = li[2] + 1
    if s[0] == "C":
        li[3] = li[3] + 1
    if s[0] == "H":
        li[4] = li[4] + 1

for l in itertools.combinations(li, 3):
    ans += l[0] * l[1] * l[2]    

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

void spin_w(int x[]){
  int sai1[6],i;

  for(i=0;i<6;i++){
    sai1[i]=x[i];
  } 

  sai1[0]=x[2];
  sai1[2]=x[5];
  sai1[3]=x[0];
  sai1[5]=x[3];

  for(i=0;i<6;i++){
    x[i]=sai1[i];
  }

}

void spin_s(int x[]){
  int sai1[6],i;
  
  for(i=0;i<6;i++){
    sai1[i]=x[i];
  } 
  sai1[0]=x[4];
  sai1[1]=x[0];
  sai1[4]=x[5];
  sai1[5]=x[1];

  for(i=0;i<6;i++){
    x[i]=sai1[i];
  }
}

void spin_side(int x[]){
int sai1[6],i;

for(i=0;i<6;i++){
  sai1[i]=x[i];
 }

sai1[1]=x[2];
sai1[2]=x[4];
sai1[3]=x[1];
sai1[4]=x[3];

for(i=0;i<6;i++){
  x[i]=sai1[i];
 }
}


int main(){
  int i,j,k,n,sai1[6];
  int a,b;

  for(i=0;i<6;i++){
    scanf("%d",&sai1[i]);
  }
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);

    for(j=0;j<4;j++){
      spin_w(sai1);
      if(sai1[0]==a)break;
    }
    if(sai1[0]!=a){
      for(j=0;j<3;j++){
	spin_s(sai1);
	if(sai1[0]==a)break;
      }
    }

    for(j=0;j<4;j++){
      spin_side(sai1);
      if(sai1[1]==b){
	printf("%d\n",sai1[2]);
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int ans;
            if (b == 1)
                ans = 0;
            else {
                int have = 1;
                int c = 0;
                while (have < b) {
                    have += (a - 1);
                    c++;
                }
                ans = c;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 20820
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	cin >> k;
	int x[32] = { 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 };
	printf("%d\n", x[k-1]);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
	int n;
	cin >> n;
	ll a[n];
	ll ans=1000000000000000;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=-100;i<=100;i++){
		ll t=0;
		for(int j=0;j<n;j++){
			t+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,t);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
def resolve():
    A, B, H, M = map(int, input().split())
    #短針が1時間で進む角度 30c
    deg_H = 360/12
    # 長針が1分間で進む角度 6c
    deg_M = 360/60

    hr = deg_H*H + (deg_H/60)*M
    mr = deg_M*M
    deg = abs(hr-mr)
    if deg>180:
        deg = 360- deg

    # 角度をラジアンに直す
    red = (deg/180)*math.pi
    ans = math.sqrt(A*A + B*B - 2*A*B*math.cos(red))
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9340
import sys

input = sys.stdin.readline


def main():
    N, L = map(int, input().split())
    S = [None] * N
    for i in range(N):
        S[i] = input().rstrip()

    S = sorted(S)
    ans = "".join(S)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll X,Y;
  cin>>X>>Y;
  if(abs(X-Y)<=1) cout<<"Brown"<<endl;
  else cout<<"Alice"<<endl;
  return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
using namespace std;

signed main() {
	int a[3]; cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	printf("%d %d %d\n", a[0], a[1], a[2]);
}

Measured memory_bytes: 3164
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
 
using namespace std;

typedef long long ll;

inline ll read()
{
	ll x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}
 
const int N=1e5+9;

ll n,q;
ll a[N],top=0;
ll cnt[N];
ll ans[N];

int main()
{
	n=read();
	q=read();

	a[0]=n;
	for(int i=1;i<=q;++i)
	{
		ll x=read();
		if(x<=a[0])
			a[0]=x,top=0;
		else
		{
			while(a[top]>=x)--top;
			a[++top]=x;
		}
	}

	cnt[top]=1;
	for(int i=top;i;i--)
	{
		ll x=a[i];
		while(x>=a[0])
		{
			int pos=upper_bound(a,a+i,x)-a-1;
			cnt[pos]+=x/a[pos]*cnt[i];
			x%=a[pos];
		}
		ans[x]+=cnt[i];
	}

	ans[a[0]]+=cnt[0];
	for(int i=n;i;--i)
		ans[i-1]+=ans[i];
	for(int i=1;i<=n;++i)
		printf("%lld\n",ans[i]);
	return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int X, A, B;
  cin >> X >> A >> B;
  cout << (X - A) % B << endl;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  bool same = true;
  ll as = 0,bs = 0,c = 0;
  vector<ll>a(n);
  vector<ll>b(n);
  rep(i,0,n) cin >> a[i];
  rep(i,0,n) cin >> b[i];
  rep(i,0,n){
    if(a[i] != b[i]) same = false;
    if(b[i] >= a[i]) c += (b[i]-a[i]+1)/2;
    as += a[i];
    bs += b[i];
  }
  if(bs-as < c && !same) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    int left = Integer.parseInt(str.substring(0, 2));
    int right = Integer.parseInt(str.substring(2, 4));
    if (1 <= left && left <= 12) {
      if (1 <= right && right <= 12) {
        System.out.println("AMBIGUOUS");
      } else {
        System.out.println("MMYY");
      }
    } else {
      if (1 <= right && right <= 12) {
        System.out.println("YYMM");
      } else {
        System.out.println("NA");
      }
    }
  }
}

Measured memory_bytes: 22612
import math

H = int(input())
i = 1
while ( i * 2 <= H):
    i *= 2

k = int(math.log(i, 2))

def f(n):
    return 2 ** n

def sigma(func, frm, to):
    result = 0;
    for i in range(frm, to+1):
        result += func(i) 
    print(result)
    
sigma(f, 0, k)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"YES"<<endl;
	exit(0);
}
 
void No(){
	cout<<"NO"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int cnt[3] = {0, 0, 0};
    char s;
    while(cin >> s) {
        cnt[s - 'a'] ++;
    }
    sort(cnt, cnt + 3);
    if(cnt[2] - cnt[0] <= 1) Yes();
    else  No();
 	return 0;
}

Measured memory_bytes: 256
function main(input) {
    let nums = input.split('\n')[1].split(' ').map( (n) => parseInt(n, 10));
    let count = 0;
    while( nums.every( (n) => (n % 2) === 0 ) ) {
        count++;
        nums = nums.map( (n) => n / 2 );
    }
    console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29508
#include<iostream>

int main(){
	int a[10],i,n,j;

	for(i=0;i<10;i++){
		std::cin >> a[i];
		}

	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				n = a[i];
				a[i] = a[j];
				a[j] = n;
				}
			}
		}
	for(i=0;i<3;i++){
		std::cout << a[i] << std::endl;;
		}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
int main() {
	ll a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=100005;

vector<int> mp[SIZE];
int color[SIZE],dist[SIZE],dist2[SIZE];
bool vis[SIZE];

void bfs(int s,int dist[]){
	queue<int> que;
	que.push(s);
	while(!que.empty()){
		int u=que.front();
		que.pop();
		for(int i=0;i<mp[u].size();i++){
			int t=mp[u][i];
			if(dist[t] || t==s) continue;
			dist[t]=dist[u]+1;
			que.push(t);
		}
	}
}

void go(int p,int left,int col,int dist[]){
	if(color[p]) return;
	if(!left) return;
	color[p]=col;
	for(int i=0;i<mp[p].size();i++){
		int u=mp[p][i];
		if(dist[u]>dist[p]) continue;
		go(u,left-1,col,dist);
	}
}

void go2(int p){
	if(color[p]==2) return;
	if(vis[p]) return;
	vis[p]=true;
	color[p]=1;
	for(int i=0;i<mp[p].size();i++){
		int u=mp[p][i];
		go2(u);
	}
}

int main(){
	int n;
	cin>>n;
	for(int i=0,a,b;i<n-1;i++){
		cin>>a>>b;
		a--;
		b--;
		mp[a].push_back(b);
		mp[b].push_back(a);
	}
	bfs(n-1,dist);
	bfs(0,dist2);
//	for(int i=0;i<n;i++){
//		cout<<dist[i]<<' ';
//	}
//	cout<<endl;
//	for(int i=0;i<n;i++){
//		cout<<dist2[i]<<' ';
//	}
//	cout<<endl;
	int s=(dist[0]+1)/2;
	int f=(dist[0]+1)-s;
//	cout<<f<<' '<<s<<endl;
	go(0,f,1,dist);
	go(n-1,s,2,dist2);
//	int ttt=0;
//	for(int i=0;i<n;i++) if(color[i]==2) ttt++;
//	cout<<ttt<<endl;
	go2(0);
	f=0;
	for(int i=0;i<n;i++) if(color[i]==1) f++;
	s=n-f;
//	cout<<f<<' '<<s<<endl;
	if(s>=f){
		cout<<"Snuke\n";
	}
	else{
		cout<<"Fennec\n";
	}
	return 0;
}


Measured memory_bytes: 10112
import sys
def solve():
    readline = sys.stdin.readline

    H, W = map(int, readline().split())
    C = [[i]*i for i in range(W+1)]
    rW = range(W); rH = range(H)
    S = [readline() for i in rH]
    P = [[0]*W for i in rH]
    for i in rH:
        p = -1
        Si = S[i]
        Pi = P[i]
        for j in rW:
            if Si[j] == '#':
                c = j - p - 1
                Pi[p+1:j] = C[c]
                p = j
        c = W - p - 1
        Pi[p+1:W] = C[c]

    def gen():
        U = [-1]*W
        V = [0]*W
        for i in rH:
            Si = S[i]; Pi = P[i]
            for j in rW:
                if Si[j] == '#':
                    yield V[j] + (i - U[j] - 1)
                    V[j] = 0
                    U[j] = i
                else:
                    V[j] = max(V[j], Pi[j])
        for u, v in zip(U, V):
            yield v + (H - u - 1)
    sys.stdout.write("%d\n" % (max(gen()) - 1))
solve()

Measured memory_bytes: 56692
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,x,c;
	cin>>x>>a>>b;
	x=x-a;
	c=x%b;
	printf("%d\n",c);
}


Measured memory_bytes: 256
#include<stdio.h>
 
#define INFTY 2000000000
#define MAX 500000
 
int count=0;
void merge(int *S,int left,int mid,int right){
 
  int L[MAX/2+2],R[MAX+2];
  int i,j,k;
  int n1,n2;
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++)
    L[i]=S[left+i];
   
  for(i=0;i<n2;i++)
    R[i]=S[mid+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      S[k]=L[i];
    i+=1;
    }
    else{
      S[k]=R[j];
      j+=1;
    }
  }
}
 
void mergeSort(int *S,int left,int right){
  int mid;
 
  if(left+1< right){
    mid = (left+right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}
     
 
int main(){
 
  int S[MAX];
  int n,i;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
   
  mergeSort(S,0,n);
 
  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    printf("%d",S[i]);
  }
  printf("\n%d\n",count);
   
  return 0;
}

Measured memory_bytes: 4512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll ;
string s;
int n;
ll  res=0;
void dfs(int len,ll sum,ll tmp)
{

  if(len==n+1){res+=sum;return;}
  int sl;
  sl=s[len]-'0';
  dfs(len+1,sum+tmp*9+sl,tmp*10+sl);
  dfs(len+1,sum+sl,sl);

}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  cin>>s;
  n=s.length()-1;
  dfs(1,s[0]-'0',s[0]-'0');
  cout<<res;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string A[] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday",
"Wednesday" };
int D[] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int main()
{
    int m, d, B[13];
    B[0] = 1;
    for (int i = 1; i <= 12; ++i) B[i] = B[i-1] + D[i];
    while (cin >> m >> d) {
        if (!(m | d)) break;
        int t = B[m-1] + d - 2;
        cout << A[t%7] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	string s;
	cin >> s;
	ll cnt = 0;
	int n = s.size();
	rep(i, n) {
		if (s[i] != '?') cout << s[i];
		else cout << 'D';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3720
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

# B > G > R
R,G,B = LI()
K = I()

count = 0

GR = False
while not GR:
    if G <= R:
        G *= 2
        count +=1
    else:
        GR = True

BG = False
while not BG:
    if B <= G:
        B *= 2
        count +=1
    else:
        BG = True

if count <= K:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 27172
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

vector<vector<ll>> path;
vector<ll> ans,ncnt,icnt,mcnt,rcnt,pwr;

ll proinverse(ll x,ll m){
    ll res=1,M=m-2;
    while(M>0){
        if(M&1) res=res*x%m;
        x=x*x%m;
        M>>=1;
    }
    return res;
}

void dfs(ll s,ll par){
    ncnt[s]=1;
    if(path[s].size()==1 && par!=-1){
        ans[s]=0; rcnt[s]=1;
        icnt[par]++;
        ncnt[par]++;
        return;
    }
    for(auto to:path[s]){
        if(to==par) continue;
        dfs(to,s);
    }
    if(par!=-1){
        icnt[par]=(icnt[par]+icnt[s])%MOD;
        ncnt[par]+=ncnt[s];
    }
    mcnt[s]=(mcnt[s]+icnt[s])%MOD;
    ll k=ncnt[s];
    rcnt[s]=(MOD+pwr[ncnt[s]]-1)%MOD;
    for(auto to:path[s]){
        if(to==par) continue;
        ans[s]=(ans[s]+mcnt[to]*(2*pwr[k-1-ncnt[to]]-1)%MOD)%MOD;
        rcnt[s]=(MOD+rcnt[s]-pwr[ncnt[to]]+1)%MOD;
    }
    ans[s]=(MOD+ans[s]+rcnt[s]-pwr[ncnt[s]-1])%MOD;
    mcnt[s]=(mcnt[s]+ans[s])%MOD;
    if(par!=-1){
        mcnt[par]=(mcnt[par]+mcnt[s])%MOD;
        icnt[par]=(icnt[par]+rcnt[s])%MOD;
    }
}

int main(){
    ll n; cin>>n;
    path.assign(n,vector<ll>(0));
    ans.assign(n,0);
    ncnt.assign(n,0);
    icnt.assign(n,0);
    mcnt.assign(n,0);
    rcnt.assign(n,0);
    pwr.assign(n+1,0);
    pwr[0]=1;
    rep(i,n) pwr[i+1]=(pwr[i]*2)%MOD;

    rep(i,n-1){
        ll a,b; cin>>a>>b;
        a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    dfs(0,-1);
    ll sum=0;
    rep(i,n) sum=(sum+ans[i])%MOD;
    cout<<sum*proinverse(pwr[n],MOD)%MOD<<endl;
}


Measured memory_bytes: 141568
/*
    C - Christmas Eve
    https://atcoder.jp/contests/abc115/tasks/abc115_c
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n, k;
    cin >> n >> k;
    vector<int> hi(n);
    for (int i = 0; i < n; i++) {
        cin >> hi[i];
    }
    sort(hi.begin(), hi.end());

    int low = 0, high = 0;
    int diff = 1000000001;
    for (int i = 0; i <= n - k; i++) {
        low = hi[i];
        high = hi[i + k - 1];
        // cout << i << " : " << low << ", " << high << endl;
        if (high - low < diff)
            diff = abs(high - low);
    }
    cout << diff << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
void solve(){
	int n; cin>>n;
	vll arr(n);
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	ll size=0;
	ll curr=arr[0];
	for(int i=1;i<n;i++)
	{
		if(arr[i]<curr)
		{
			size+=curr-arr[i];
			arr[i]+=curr-arr[i];
		}
		curr=arr[i];
	}
	cout<<size<<endl;
}
			
int main(){
	solve();
}


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

char M(char x, char y){

    if(x == 'T' && y == 'F') return 'F';
    else return 'T';

}

signed main(){
    
    int n; cin >> n;
    vector<char> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

    char c = p[0];
    for(int i = 1; i < n; i++){
        c = M(c, p[i]);
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long N, K;
		N = sc.nextLong();
		K = sc.nextLong();

		long a = 0;
		for (int i = 1; i <= N; i++) {
			if (i % K == 0) {
				a++;
			}
		}

		long b = 0;
		for (int i = 1; i <= N; i++) {
			if (i % K == K/2) {
				b++;
			}
		}

		long ans = a * a * a;
		if (K % 2 == 0) {
			ans += b * b * b;
		}

		System.out.println(ans);
	}
}

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

int sum(int x){
  int tmp=0;
  while (x>0){
    tmp+=x%10;
    x/=10;
  }
  return tmp;
}
  





int main() {
  int n,a,b;
  cin>>n>>a>>b;
  
  int answer=0;
  
  for (int i=1;i<n+1;i++){
    if (a<=sum(i) and sum(i)<=b){
      answer+=i;
    }
  }
  
  cout<<answer<<endl;
      
  
}

  













Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] split = s.split(" ");
		int N = Integer.parseInt(split[0]);
		int M = Integer.parseInt(split[1]);
		int C = Integer.parseInt(split[2]);
		s = sc.nextLine();
		split = s.split(" ");
		int[] b = new int[M];
		for (int i = 0; i < M; i++)
			b[i] = Integer.parseInt(split[i]);

		int cnt = 0;
		for (int i = 0; i < N; i++) {
			s = sc.nextLine();
			split = s.split(" ");
			int sum = 0;
			for (int j = 0; j < M; j++) {
				int ai = Integer.parseInt(split[j]);
				sum += ai * b[j];
			}
			sum += C;
			if (sum > 0)
				cnt++;
		}

		System.out.println(cnt);

		sc.close();
	}
}

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

for i in range(len(s)-len(t),-1,-1):
    flag=True
    for j in range(len(t)):
        if s[i+j]!=t[j] and s[i+j]!="?":
            flag = False
            break
    if flag:
        ans = ""
        for k in range(i):
            if s[k]!="?":
                ans+=s[k]
               
            else:
                ans += "a"
        ans+=t
        for k in range(i+len(t),len(s)):
            if s[k]!="?":
                ans+=s[k]
            else:
                ans += "a"
        print(ans)
        exit()
print("UNRESTORABLE")
                

        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main ()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int n;
	cin >> n;
	int dp[n];
	int arr[n];
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	dp[0] = 0;
	dp[1] = abs(arr[0]-arr[1]);
	for(int i = 2; i < n; i++) 
		dp[i] = min(dp[i-1]+abs(arr[i-1]-arr[i]), dp[i-2]+abs(arr[i-2]-arr[i]));
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    string s; cin >> s;
    if(s[2]==s[3] and s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
#define int long long

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

ostream &operator << (ostream &cout, vector <int> &a) {
	cout << "{";
	for (auto & it : a) cout << it << ", ";
	cout << "}";
	return cout;
}

ostream &operator << (ostream &cout, set <int> &a) {
	cout << "{";
	for (auto & it : a) cout << it << ", ";
	cout << "}";
	return cout;
}

const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 15;
int n, m, a[N], p[N];
int val[N];

inline void upd(int l, int r, int x) {
	if(l <= r) {
		p[l] += x;
		p[r + 1] -= x;
	}
}

inline void upd_minus(int l, int r) {
	if(l <= r) {
		val[l]++;
		val[r + 1]--;
	}
}

int ans = -1;

main() {
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		--a[i];
	}
	for(int i = 1; i < n; ++i) {
		if(a[i] <= a[i+1]) {
			upd(0, a[i], a[i+1] - a[i]);
			upd(a[i+1] + 1, m - 1, a[i+1] - a[i]);

			upd(a[i] + 1, a[i+1], 1 + a[i + 1]);
			upd_minus(a[i] + 1, a[i+1]);
		}
		else {
			upd(a[i+1] + 1, a[i], a[i+1] + m - a[i]);

			upd(0, a[i+1], 1 + a[i+1]);
			upd_minus(0, a[i+1]);

			upd(a[i] + 1, m - 1, 1 + m + a[i + 1]);
			upd_minus(a[i] + 1, m - 1);
		}
	}
	for(int i = 0; i < m; ++i) {
		if(i > 0) {
			val[i] += val[i-1];
			p[i] += p[i-1];
		}
		if(ans == -1 || ans >= p[i] - val[i] * i)
			ans = p[i] - val[i] * i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int alpha[26];
set<char> ss;
vector<char> v;
set<string> sss;

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;int k;cin>>s>>k;
  int l=s.size();
  REP(i,l){
    alpha[(int)(s[i]-97)]++;
    ss.insert(s[i]);
  }
  for(auto x:ss){
    v.push_back(x);
    // P(x);
  }
  for(int i=0;i<l;i++){
    for(int j=1;j<=5;j++){
      sss.insert(s.substr(i,j));
    }
  }
  auto itr=sss.begin();
  REP(i,k){
    ++itr;
  }
  --itr;
  P(*itr);
  // s.find(x)==-1
  return 0;
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    string s;
    cin >> s;
    int n = s.size();
    string t = "";
    for(int i=0; i<n; i++){
        if(s[i] == 'A') t += '0';
        else if(s[i] == 'B'){
            if(i < n-1 && s[i+1] == 'C'){
                t += '1';
                i++;
            }
            else t += '2';
        }
        else t += '2';
    }
    ll res = 0;
    ll a = 0;
    for(auto c : t){
        if(c == '2') a = 0;
        else if(c == '1') res += a;
        else a++;
    }
    cout << res;
    return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);
    vector<int> a(N,0);
    Rep(i,N) Scd(a[i]);

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

    if( a[N-1] - a[0] > 1 ) {
        YesNo(false);
    }else if( a[N-1] == a[0] ){
        if( a[0] == N-1 || a[0] <= N/2 ){
            YesNo(true);
        }else{
            YesNo(false);
        }
    }else{
        int count = 0; // unique
        Rep(i,N){
            if( a[i] == a[0] ) count++;
        }
        if( count < a[N-1] && (a[N-1]-count)*2 <= N-count  ){
            YesNo(true);
        }else{
            YesNo(false);
        }
    }

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const int INF = 1001001001;

int main(void){
  ll n, m;
  cin >> n >> m;
  map<int, string> mp;
  vector<vector<P>> v(n);
  REP(i, m){
    int p, y;
    cin >> p >> y;
    v[p-1].emplace_back(P(y, i));
  }
  REP(i, n) sort(ALL(v[i]));
  REP(i, n){
    if(v[i].empty()) continue;
    int s = v[i].size();
    string p = to_string(i+1);
    string place = "000000";
    place.replace(6-p.size(), p.size(), p);
    REP(j, s){
      int k = v[i][j].second;
      string o = to_string(j+1);
      string order = "000000";
      order.replace(6-o.size(), o.size(), o);
      mp[k] = place+order;
    }
  }
  REP(i, m) cout << mp[i] << endl;
  return 0;
}

Measured memory_bytes: 17920
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int main(void) {
	vector<int>a;
	int n, i, temp;
	int count = 0;

	cin >> n;

	for (i = 0;i < n;i++) {
		cin >> temp;
		a.push_back(temp);
	}

	sort(a.begin(), a.end());
	temp = 0;

	for (i = 0;i < n;i++) {
		if (temp < a[i]) {
			temp = a[i];
			count++;
		}
	}

	cout << count << endl;
 
	return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int A,B;
    string s;
    cin >> A >> B >> s;

    A--;
    bool ok = true;
    for (int i = 0;  i < (int)s.size(); ++i) {
        if (i == A+1) {
            if (s[i] != '-') {
                ok = false;
            }
        } else {
            int t = s[i];
            if (s[i] == '-') {
                ok = false;
            }
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


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

using namespace std;

int main() {
    int D;

    cin >> D;

    if(D == 25) cout << "Christmas";
    if(D == 24) cout << "Christmas Eve";
    if(D == 23) cout << "Christmas Eve Eve";
    if(D == 22) cout << "Christmas Eve Eve Eve";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll n;

int f(string s,char c){
    if(s.size() == n)pf(s);
    else for(char i = 'a'; i <= c + 1; ++i)f(s + char(i),max(c,i));
    return 0;
}

//modの値の確認をすること
int main(){
    cin >> n;
    f("a",'a');
    return 0;
}


Measured memory_bytes: 1536
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

int bel[210];
ll a[210];
ll b[70];

inline int Insert(ll x) {
	ll bs = 1ll << 60;
	for(int i = 60; ~i; i--, bs >>= 1)
		if(x & bs) {
			if(b[i]) x ^= b[i];
			else return b[i] = x, 1;
		}
	return 0;
}

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int Case = ri;
	while(Case--) {
		int n = ri;
		for(int i = 1; i <= n; i++) a[i] = rl;
		for(int i = 1; i <= n; i++) {
			char ch = ge;
			while(!isdigit(ch)) ch = ge;
			bel[i] = ch - '0';
		} int res = 0;
		for(int i = n; i >= 1; i--) {
			int ok = Insert(a[i]);
			if(bel[i] && ok) res = 1;
		} printf("%d\n", res);
		memset(b, 0, sizeof(b));
	}
	return 0;
}

Measured memory_bytes: 4008
#include <stdio.h>

int i;

int binarySearch(int n, int A[], int key){
	int left, right, mid;
	left = 0;
	right = n;

	while (left < right){
		mid = (left + right)/2;
		if (key == A[mid])
			return mid;
		if (key > A[mid])
			left = mid + 1;
		else if( key < A[mid])
			right = mid;
	}
	return -1;
}


int main(void) {
	int n,q,j,count=0;
	
	scanf("%d",&n);
	int S[n];
	
	for(i=0; i<n; i++){
		scanf("%d",&S[i]);
	}
	
	scanf("%d",&q);
	int T[q];
	
	for(i=0; i<q; i++){
		scanf("%d",&T[i]);
		if (binarySearch(n,S,T[i])!=-1){
			count++;
		}
	}
	printf("%d\n",count);
	
	return 0;
}





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

int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int l = (m2 - m1) + (h2 - h1)*60;
  cout << l - k << endl;
  return 0;
}


Measured memory_bytes: 3636
N = int(input())
A = (input())
B = (input())
C = (input())

ans = 0
for i in range(N):
    if A[i]==B[i]==C[i]:
        continue
    elif A[i]!=B[i] and B[i]!=C[i] and C[i] !=A[i]:
        ans +=2
    else:
        ans +=1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p,a[51];
  while(cin>>n>>p){
    if(n==0&&p==0){break;}
    for(int i=0; i<n; i++){
    	a[i]=0;
    }
    int x=0,ans;
    int k=p;
    while(1){
    	if(k>0){
      		a[x%n]++;
          	k--;
          	if(a[x%n]==p){ans=x%n; break;}
        }
    	else{
      		k=a[x%n];
      		a[x%n]=0;
        }
      	x++;
    }
    cout<<ans<<endl;
  }
}
      
    
    


Measured memory_bytes: 3056
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
string s,t;
int f[3100][3100];
int main(){
	cin>>s>>t;
	for(int i=s.size();i>=0;i--){
		for(int j=t.size();j>=0;j--){
			if(s[i]==t[j]){
				f[i][j]=f[i+1][j+1]+1;
				continue;
			}
			f[i][j]=max(f[i][j+1],f[i+1][j]);
		}
	}
	int h=0,k=0;
	while(h<s.size()&&k<t.size()){
		if(s[h]==t[k]){
         printf("%c",s[h]);
         h++;
         k++;
         continue;
      }
		if(f[h][k]==f[h+1][k]){
         h++;
         continue;
      }
      k++;
	}
}

Measured memory_bytes: 37120
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100001;

int n, m, deg[N], dp[N];
vector <int> v[N], g[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    while(m--){
        int x, y;
        cin >> x >> y;
        deg[x]++;
        v[x].push_back(y);
        g[y].push_back(x);
    }
    vector <int> topo;
    deque <int> ready;
    for(int i = 1 ; i <= n ; i++)
        if(deg[i] == 0)
            ready.push_back(i);
    while(ready.size()){
        int top = ready.front();
        ready.pop_front();
        topo.push_back(top);
        for(auto &i : g[top]){
            deg[i]--;
            if(deg[i] == 0) ready.push_back(i);
        }
    }
    reverse(topo.begin(), topo.end());
    int ans = 0;
    for(int i = (int)topo.size() - 1 ; i >= 0 ; i--){
        int node = topo[i];
        for(auto &i : v[node])
            dp[node] = max(dp[node], dp[i] + 1);
        ans = max(ans, dp[node]);
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

	int n;

	cin >> n;

	long double x;
	string v;
	long double ans = 0.0;
	

	while (n--) {
		cin >> x >> v;

		if (v == "JPY") ans += x;
		else ans += x * 380000.0;
	}

	Out(ans);
	
	return 0;
}


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

using namespace std;

#define llong long long int
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

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

    llong n;
    cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    string ans = "";
    int diviser = (-1) * 2;
    while (n != 0) {
        if (n % diviser == 0) ans += '0';
        else ans += '1', --n;
        n /= diviser;
    }

    reverse(all(ans));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
color=[0]*9
for i in range(N):
    if a[i]//400>=8:
        color[8]+=1
    else:
        color[a[i]//400]+=1
cnt=0
for i in range(8):
    if color[i]>0:
        cnt+=1
mx=cnt+color[8]
if cnt>0:
    mn=cnt
else:
    mn=1
print(mn,mx)

Measured memory_bytes: 3064