akhauriyash/Code-Regression huggingface dataset:
/*input
01B0
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	string s;
	cin>>s;
	string ans="";
	REP(i,SZ(s)){
		if(s[i]=='B'){
			if(SZ(ans)) ans.pop_back();
		}
		else ans.pb(s[i]);
	}
	cout<<ans<<'\n';
	return 0;
}


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

use proconio::marker::Usize1;

#[fastout]
fn main() {
    input! {
        n: usize, k: usize,
    }
    let mut b = vec![0; n];
    for _ in 0..k {
        input! {
            d: usize,
            a: [Usize1; d],
        }
        for &x in a.iter() {
            b[x] += 1;
        }
    }
    let ans = b.iter().filter(|&&x| x == 0).count();
    println!("{}", ans);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int block;
int m[2000000];
int a[2000000];
struct query{
  int l,r,idx;  
};
int value = 0;
bool comper(query a, query b)
{
    if(a.l / block != b.l / block)
        return a.l < b.l;
    return a.l / block % 2 ? a.r < b.r : a.r > b.r;
}

void add(int pos)
{
    int val=a[pos];
    m[val]++;
    if (m[val]==1)
    {
        value++;
    }
    else if (!m[val])
    {
        value--;
    }
}
void remove(int pos)
{
    int val=a[pos];
    m[val]--;
    if (!m[val])
    {
        value--;
    }
}

int main(void){
    Fast;
int n, q;
cin >> n >> q;
block = sqrt(n);


for(int i = 1; i < n + 1; i++)
cin >> a[i];

query qr [q];

for(int i = 0; i < q; i++)
cin >> qr[i].l >> qr[i].r,
qr[i].idx = i;


sort(qr, qr + q, comper);

set<int>s;
int L = 1, R = 1,ml = 0, mr = 0;
int ans[q];

for(int i = 0; i < q; i++){
   int L = qr[i].l;
   int R = qr[i].r;
   while(mr < R)
       mr++, add(mr);
       
       
    while(ml >  L)
       ml--, add(ml);

    
    while(ml < L)
      remove(ml), ml++;
    
    while(mr > R)
      remove(mr), mr--;
     
     
        ans[qr[i].idx] = value;
    
}


for(int i = 0; i < q; i++)
cout << ans[i] << "\n";








}

Measured memory_bytes: 15444
#Green bin -C-
n=int(input())
s=[]
for i in range(n):
    f=list(input())
    f.sort()
    s.append(f)
s.sort()
k=0
a=1
t=0
for i in range(1,n):
    if s[k]==s[i]:
        a+=1
    else:
        t=t+(a*(a-1))//2
        a=1
        k=i
if s[n-1]==s[k]:
    t=t+(a*(a-1))//2
print(t)

Measured memory_bytes: 97368
from collections import defaultdict
from bisect import bisect_right

S = input()
T = input()
N = len(S)

# SにT中の文字が含まれていない場合
set_s = set(S)
set_t = set(T)
for c in set_t:
    if not c in set_s:
        print(-1)
        exit()

# それぞれのアルファベットの位置を格納
idxs = defaultdict(list)
for i in range(N):
    idxs[S[i]].append(i)

p = -1
loop_cnt = 0
for c in T:
    idx = bisect_right(idxs[c], p)
    #print(idxs[c], p, idx)
    if idx >= len(idxs[c]):
        loop_cnt += 1
        p = idxs[c][0]
    else:
        p = idxs[c][idx]

ans = N * loop_cnt + p + 1
print(ans)


Measured memory_bytes: 7916
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#define LL long long
#define MAXN 100005
#define MOD 1000000007
using namespace std;
int a[MAXN], b[MAXN];
LL ans;
pair<int, int> A[MAXN], B[MAXN];
int n;
int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
    A[1] = make_pair(a[1], a[1]);
    for(int i = 2; i <= n; i++)
    {
        if(a[i] == a[i - 1]) A[i] = make_pair(1, a[i]);
        else
            A[i] = make_pair(a[i], a[i]);
    }
    B[n] = make_pair(b[n], b[n]);
    for(int i = n - 1; i >= 1; i--)
    {
        if(b[i] == b[i + 1]) B[i] = make_pair(1, b[i]);
        else
            B[i] = make_pair(b[i], b[i]);
    }
    ans = 1LL;
    for(int i = 1; i <= n; i++)
    {
        int l = max(A[i].first, B[i].first), r = min(A[i].second, B[i].second);
        if(l > r) ans = 0;
        else
            ans = (ans * (LL)(r - l + 1)) % MOD;
    }
    printf("%d\n", (int)ans);
    return 0;
}


Measured memory_bytes: 2560
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<int, int>;
using lu = unsigned long long;
using l = long long;
using vs = vector<string>;
using vii = vector<ii>;
using vl = vector<l>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using ll = pair<l, l>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using mll = unordered_map<l, l>;
using sl = unordered_set<l>;
const l      INF = numeric_limits<l>::max();
const double EPS = 1e-10;
const double PI = 3.14159265358979323846;
const l      e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6,
        e8 = 10 * e7, e9 = 10 * e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a, b, c) for (l a = l(b); a < l(c); a++)
#define B(a, b, c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream &in, ostream &out);
int  main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7;  // end of template

void solve(istream &in, ostream &out) {
  l n, m;
  in >> n >> m;
  vl  p(m);
  vll y(m);
  vl  id(n + 1);
  vll v(m);
  F(i, 0, m) {
    in >> p[i] >> y[i].first;
    y[i].second = i;
  }
  sort(all(y));
  vl z(m);
  for (ll i : y) {
    l j = i.second;
    z[j] = p[j] * e6 + ++id[p[j]];
  }
  for (l x : z) { out << setfill('0') << setw(12) << x << lf; }
}


Measured memory_bytes: 7040
/**
 * C - Modulo Summation
 * https://atcoder.jp/contests/abc103/tasks/abc103_c
 * 
 * ポイント
 * m = anの最小公倍数-1
 * mは計算するのは無理なので、
 * ai-1を足していく
 **/
#include<iostream>
#include<vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    int res = 0;
    for(int i=0; i<N; i++) {
        int ai;
        cin >> ai;
        res += ai - 1;
    }
    cout << res << endl;
}

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

int main(){
  int w,h;
  string g[100];
  const int INF = 10000000;

  cin >> h >> w;
  for(int i=0;i<h;i++)cin >> g[i];

  int dp[100][100];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)dp[i][j] = 0;

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      dp[i][j] = g[i][j] - '0';
      if(i && j)dp[i][j] += min(dp[i-1][j],dp[i][j-1]);
      else if(i)dp[i][j] += dp[i-1][j];
      else if(j)dp[i][j] += dp[i][j-1];
    }
  }

  cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 0
// #define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using pll = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; using vb = vector<bool>; using vvb = vector<vb>;
#define rep0(TMS) for (int CNT = 0; CNT < (int)(TMS); CNT++)
#define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++)
#define rep2(CNT, START, GOAL) for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++)
#define rep3(CNT, START, GOAL) for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--)
#define all(CONT) begin(CONT), end(CONT)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
void prec(const int &DIG) { cout << fixed << setprecision(DIG); cerr << fixed << setprecision(DIG); }
template <typename T> void CERR(const T &ELEM) { cerr << ELEM; }
#define dbl(OBJ) cerr << #OBJ << ": "; CERR(OBJ); cerr << "\n"
template <typename T, typename ...Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); }
#define dbs(...) cerr << "(" << #__VA_ARGS__ << "): ("; CERR(__VA_ARGS__); cerr << ")\n"
#define itrep(ITR, CONT) for (auto ITR = begin(CONT); ITR != end(CONT); ITR++)
template <typename T> void CERR(const vector<T> &VEC) { cerr << "{ "; itrep(ITR, VEC) { CERR(*ITR); cerr << ", "; } cerr << "}"; }
#define YN(FLG) cout << (FLG ? "YES" : "NO") << "\n"
#define Yn(FLG) cout << (FLG ? "Yes" : "No") << "\n"
#define yn(FLG) cout << (FLG ? "yes" : "no") << "\n"

// #include <atcoder/all>

// using namespace atcoder;

// const ll INF = LONG_LONG_MAX;
const int INF = INT_MAX;
// const ll MOD = 1000000007; // 998244353;

ll solve(string &S, int k) {
	// dbl(k);
	ll res = 0;
	ll temp = S[0] - '0';
	rep(i, S.size() - 1) {
		if (k & (1 << i)) { // i文字目の直後に+がある
			res += temp;
			temp = S[i + 1] - '0';
		} else {
			temp *= 10;
			temp += S[i + 1] - '0';
		}
	}
	res += temp;
	// dbl(res);
	return res;
}

int main() {
	string S; cin >> S;
	// reverse(all(S));
	int N = S.size();
	ll ans = 0;
	rep(k, 1 << (N - 1)) ans += solve(S, k);
	cout << ans << endl;
}

Measured memory_bytes: 3608
// Created by martinezdiego on 19/5/19

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  string s;
  cin >> n >> k >> s;
  s[k-1] = tolower(s[k-1]);
  cout << s << '\n';
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# C
# 
import numpy as np
# input
n = int(input())
a = np.array(list(map(int,input().split())))
b = np.array(list(map(int,input().split())))
l = a-b
l_fu = np.where(l<0,l,0).sum() * (-1)
fu = np.sum(l<0)
z = np.sum(l==0)
m = np.sort(l)[::-1]
o = x = 0
# calc
if sum(l) < 0:
  o = -1
else:
  if fu == 0:
    o = 0
  else:
    for i in range(n):
      if m[i] > 0:
        x += m[i]
        if x >= l_fu:
          o = i+1+fu
          break
      else:
        break
# output
print(o)

Measured memory_bytes: 31624
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
 *
 * @author inferno
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int x = Integer.parseInt(Integer.toString(a) + Integer.toString(b));
            if (Math.round(Math.sqrt(x)) == Math.sqrt(x))
                out.println("Yes");
            else
                out.println("No");
        }

    }

    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: 22996
import java.util.Scanner;

/**
 * Design of a Mansion
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int H, A, B;
		H = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();

		int ans = 0;

		for (int i = A; i <= B; i++) {
			if (H % i == 0) ans++;
		}

		System.out.println(ans);
	}
}



Measured memory_bytes: 26244
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<map>
#include<vector>
using namespace std;
int n,m,k,rw=1000000007;
int yq[30][30],nx[(1<<20)+5][25],dp[2][21][(1<<20)+5];
int main()
{
	scanf("%d%d%d",&n,&m,&k);--n;
	for(int i=1;i<=m;i++)
		for(int j=0;j<n;j++)
			yq[i][j]=-1;
	for(int i=1,a,b,c;i<=k;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		yq[a][b-1]=c;
	}
	for(int i=0;i<(1<<n);i++)
	{
		int la=-1;
		for(int j=n-1;j>=0;j--)
		{
			if((i&(1<<j)))la=j;
			nx[i][j]=la;
		}
        //for(int j=0;j<n;j++)cout<<nx[i][j];
	}
	dp[0][n][0]=1;
	int now=1;
	for(int i=1;i<=m;i++)
	{
		for(int s=0;s<(1<<n);s++)
			dp[now][0][s]=dp[now^1][n][s];
		for(int j=0;j<=n;j++)
			for(int s=0;s<(1<<n);s++)
				dp[now^1][j][s]=0;
		for(int j=0;j<n;j++)
		{
			for(int s=0;s<(1<<n);s++)
			{
				if(dp[now][j][s])
				{
					for(int k=0;k<=1;k++)
					{
						if(yq[i][j]!=-1&&yq[i][j]!=k)continue;
						int t=((s>>j)&1);
						if(k==0&&t==1)continue;
						if(k==t)(dp[now][j+1][s]+=dp[now][j][s])%=rw;
						if(k==1&&t==0)
						{
							int la=nx[s][j];
							if(la==-1)(dp[now][j+1][s|(1<<j)]+=dp[now][j][s])%=rw;
							else (dp[now][j+1][(s|(1<<j))^(1<<la)]+=dp[now][j][s])%=rw;
						}
					}
				}
			}
		}
		now^=1;
	}
	int ans=0;
	for(int s=0;s<(1<<n);s++)
	{
		(ans+=dp[now^1][n][s])%=rw;
	}
	printf("%d\n",(ans+rw)%rw);
}

Measured memory_bytes: 217472
#include<bits/stdc++.h>
using namespace std;
main(){
  int a[44],n;
  a[0]=a[1]=1;
  cin>>n;
  for(int i=2;i<=n;i++)a[i]=a[i-1]+a[i-2];
  cout<<a[n]<<endl; 
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <cstdlib>
#include <typeinfo>

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

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

string T;

int main() {
    cin >> T;
    replace(T.begin(), T.end(), '?', 'D');
    cout << T << endl;
}


Measured memory_bytes: 3764
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
vector<double > x, y;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int tempx, tempy;
        cin >> tempx>>tempy;
        x.push_back(tempx);
        y.push_back(tempy);
    }
    vector<double> d;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
            d.push_back(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
        }
    }
    double sum=0;
    //cout << d.size() << "\n";
    for(int i=0;i<d.size();i++){
        sum+=d[i];
    }
    int n1=1;
    for(int i=1;i<=n;i++){
        n1*=i;
    }
    cout << setprecision(15)<<sum/double(n) << "\n";
}


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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int


int main()
{
  double r;
  cin>>r;
  cout << fixed;
  cout << setprecision(16)<<r*r*M_PI<<" "<<2*r*M_PI<<endl;;

  //cout <<setprecision(16) << r * r * M_PI << " " << 2 * r * M_PI << endl;
  ;

  return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
 int n;cin>>n;
  string s;cin>>s;
  bool ok =false;
  
  if(s.substr(0,n/2)==s.substr(n/2) ){ 
    ok =true;
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
 
  
}
  

Measured memory_bytes: 256
#include<stdio.h>
struct Node{
  int a,b,c;
};
struct Node N[100000];
int h,o,S[100000];

int depth(int);

int main(){
  int i,j,l,m,n,q,e,y;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    N[i].a=-1;
    N[i].b=-1;
    N[i].c=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&l,&m);
    for(j=0;j<m;j++){
      scanf("%d",&q);
      if(j==0){
        N[l].b=q;
      }
      else{
        N[y].c=q;
      }
      y=q;
      N[q].a=l;
      }
    }
    for(i=0;i<n;i++){
      S[i]=depth(i);
    }
    for(i=0;i<n;i++){
      printf("node %d: ",i);
      printf("parent = %d, ",N[i].a);
      printf("depth = %d, ",S[i]);
      if(N[i].a==-1){
        printf("root, ");
      }
      else if(N[i].b==-1){
        printf("leaf, ");
      }
      else{
        printf("internal node, ");
      }
      printf("[");
      for(j=0,e=N[i].b;e!=-1;j++,e=N[e].c){
        if(j>0){
          printf(", ");
        }
        printf("%d",e);
      }
      printf("]\n");
    }
    return 0;
}

int depth(int r){
  int t=0;
  for(; N[r].a!=-1 ;t++){
    r=N[r].a;
  }
  return t;
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
signed main() {
	int n,m,i,j;
	vector<ll> sum;
	cin>>n>>m;
	ll a[n+1],pf[n+1];
	for(i=1;i<=n;++i) cin>>a[i];
	pf[0] = 0ll;
	for(i=1;i<=n;++i) pf[i] = pf[i-1] + a[i];
	ll maxi = 0ll;
	for(i=1;i<=n;++i) {
		for(j=i;j<=n;++j) {
			sum.push_back(pf[j]-pf[i-1]);
			maxi = max(maxi,pf[j]-pf[i-1]);
		}
	}
	vector<bool> yes(sum.size(),true);
	int max_bit = 0;
	while(maxi) {
		max_bit++;
		maxi/=2;
	}
	ll ans = 0ll;
	vector<int> x;
	for(i=max_bit;i>=0;i--) {
		int cnt = 0;
		for(j=0;j<sum.size();++j) {
			if(yes[j]==true) {
				if((sum[j] & (1ll<<i)) != 0) ++cnt;
				else x.push_back(j);
			}
		}
		if(cnt>=m) {
			ans = ans + (1ll<<i);
			for(j=0;j<x.size();++j)
				yes[x[j]] = false;
		}
		x.clear();
	}
	cout<<ans;
}

Measured memory_bytes: 8428
def inpl(): return [int(i) for i in input().split()]
def nextin(nwin,prin):
    if prin[1] != nwin[1]+1 and nwin[1] != W-1:
        return [nwin[0],nwin[1]+1]
    if prin[1] != nwin[1]-1 and nwin[1] != 0:
        return[nwin[0],nwin[1]-1]
    else:
        return[nwin[0]+1,nwin[1]]

H, W = inpl()
HW = [[0 for _ in range(W)] for _ in range(H)]
N = int(input())
a = inpl()
previn = [0,-1]
nowin = [0,0]
for i in range(1,N+1):
    for _ in range(a[i-1]):
        nh,nw = nowin
        HW[nh][nw] = i
        nowin = nextin(nowin,previn)
        previn = [nh,nw]
for i in HW:
    print(*i)
        

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
const int MOD = 1000000007;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;
 
int main(){
    int a,b,c;cin >> a >> b >> c;
    string frag = "NO";
    ll sum = 0;
    for(int i = 0;i<10000000;i++){
        sum += a;
        if(sum % b == c) {
            frag = "YES";
            break;
        }
    }
    cout << frag <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <iostream>
//#include <iomanip>
//#include <vector>
//#include <cmath>
//#include <algorithm>
using namespace std;


#define F first
#define PB push_back
#define MP make_pair

typedef long long ll;

ll p = pow(10, 9) + 7;
int siz = pow(10, 9);



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, l;
    cin >> n >> l;
    map<int, int> mp;
    for(int i = 0; i < l; i++)
    {
        int a;
        cin >> a;
        mp[a] = 1;
    }

    bool done = true;
    do{
        done = true;
        int temp = n;
        while(temp > 0)
        {
            int kl =temp % 10;
            if(mp.count(kl))
            {
                done = false;
            }
            temp = temp / 10;
        }
        if(!done)
        {
            n++;
        }
    }while(!done);
    cout<<n << endl;




}

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

using namespace std;

int main()
{
	long long int n,c,k;
	long long int t[100000] = {0};

	scanf("%lld %lld %lld", &n,&c,&k);

	for(int i = 0; i < n; i++)
	{
		scanf("%lld", &t[i]);
	}

	sort(t,t+n);

	long long int bus = 1;
	int pass = 1;
	int first = 0;

	for(int i = 1; i < n; i++)
	{
		if (pass < c && t[i] <= t[first] + k)
		{
			pass++;
		}else
		{
			bus++;
			pass = 1;
			first = i;
		}
	}

	printf("%lld\n", bus);

	return 0;
}
	

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

int Y(int s, int t){
    if(t==1) return s;
    else    return Y(s, t-1)*s;
}

int main() {
    int x;
    cin>>x;
  
    int max = 1;
    
    int b=2;
    int p=2;
            p=2;
    
    for(b=2; b<=x; b++){    //1^pは除外
        for(p=2; p<10; p++){
           if(Y(b,p)<=x and Y(b,p)>max){
                max = Y(b,p);
            }
        }
    }
    
    cout<<max<<endl;
 
    
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class AConsecutiveIntegers {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n = s.nextInt();
            int k = s.nextInt();
            out.println(n - k + 1);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re register
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;

int head[M],cnt=1;
void init(int n){cnt=1;for(int i=0;i<=n;i++)head[i]=0;}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}

int vs[M];
void dfs(int x){
	vs[x]=1;
	for(int i=head[x];i;i=ee[i].nxt){
		int y=ee[i].to;
		if(vs[y])continue;
		dfs(y);
	}
}
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n,m;
  	cin>>n>>m;
  	int u,v;
  	for(int i=1;i<=m;i++)cin>>u>>v,add(u,v,1),add(v,u,1);
  	int ans=0;
	  for(int i=1;i<=n;i++)
  	{
  		if(vs[i])continue;
  		dfs(i);
  		ans++;
	  }
	  cout<<ans-1<<endl;
	return 0;
}

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

int main()
{
  int N , A , dev , min ;
  min = 30 ;
  
  cin >> N ;
  
  for(int i=0; i<N; i++)
  {
    cin >> A ;
    
    dev = 0 ;
    
    while(A%2==0)
    {
      A /= 2 ;
      dev++ ;
    }
    
    if(dev<min)
      min = dev ;
    
    if(min==0)
      break;
  }
  
  cout << min << endl ;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        //int b = sc.nextInt();
        if (a == 0)
            System.out.println(0);
        else if (a % 2 == 0)
            System.out.println(a / 2);
        else
            System.out.println((a / 2) + 1);
    }
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(void)
{
    int n, x, c, sum;
    c = 0;
    sum = 0;
    scanf("%d %d", &n, &x);
    int a[n];
    a[0] = 0;
    int i;
    for (i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    int j;
    for (j = 0; j <= n; j++)
    {
        c = c + a[j];
        if (c <= x)
        {
            sum++;
        }
    }
    printf("%d\n", sum);
    return 0;
}

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

int main() {
	int N;
	int P = 0;
	int W = 0;
	int G = 0;
	int Y = 0;
	int cnt = 4;
	char S;
	cin >> N;
	
	for (int i=0; i < N; i++) {
		cin >> S;
		if (S == 'P') P++;
		if (S == 'W') W++;
		if (S == 'G') G++;
		if (S == 'Y') Y++;
	}
	
	if (P == 0) cnt--;
	if (W == 0) cnt--;
	if (G == 0) cnt--;
	if (Y == 0) cnt--;
	
	if (cnt == 3) {
		cout << "Three" << endl;
	}
	else {
		cout << "Four" << endl;
	}
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Vec  = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	ll yokin = 100;
	ll x;
	cin >> x;
	int year = 0;
	while (yokin < x)
	{
		yokin += yokin / 100;
		year++;
	}
	cout << year << endl;
}



Measured memory_bytes: 3640
import numpy as np
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
A=np.array(A)
N=int(input())
B=[]
for i in range(N):
    B.append(int(input()))

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                A[i][j]=0

flg=False
for i in range(3):
    if sum(A[i])==0:
        flg=True
        break
    if sum(np.transpose(A)[i])==0:
        flg=True
        break
if A[0][0]+A[1][1]+A[2][2]==0:
    flg=True
if A[0][2]+A[1][1]+A[2][0]==0:
    flg=True

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12504
#include <stdio.h>

int main()
{
	int A, B, C, D, diff;
	scanf("%d %d %d %d", &A, &B, &C, &D); 
	
	int temp;
	if (A > C) {
		temp = A;
		A = C;
		C = temp;
		temp = B;
		B = D;
		D = temp;
	}
	
	if (C > B) 
		diff = 0;
	else {
		if (B >= D)
			diff = D - C;
		else if (B < D)
			diff = B - C;
	}
	printf("%d", diff);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<double,pair<int,int> >
#define F first
#define S second
using namespace std;
#define mod 1000000007

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;ll k;cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++) cin>> arr[i];
    int lo=1; int hi=(*max_element(arr,arr+n));
    while(lo<hi){
        int mid=lo+(hi-lo)/2;
        ll curr=0;
        for(int i=0;i<n;i++){
            if(arr[i]>mid){
                curr+=(ll)ceil(arr[i]/mid);
            }
        }
        if(curr<=k) hi=mid;
        else lo=mid+1;
    }
    cout<<lo<<endl;


}


Measured memory_bytes: 4360
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll m = min({a, b, c, d, e});
    
    ll count = (n + m - 1)/ m;

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

Measured memory_bytes: 256
A, B, N = [ int(i) for i in input().strip().split(' ')]
max_floor = 0
if B > N:
    max_floor = int(A * N / B) - A * int(N/B)
    print(max_floor)
else:
    floor = int(A * (B-1) / B) - A * int((B-1)/B)
    if max_floor < floor:
        max_floor = floor
    print(max_floor)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 int digits(int n){
     int c=0;
     while(n>0){
         n=n/10;
         c++;
         
     }
     return c;
     
 }
int main()
    {int n,sum=0;cin>>n;
    for(int i=1;i<=n;i++){
        int k=digits(i);
        if(k%2!=0)sum++;
    }
    cout<<sum<<endl;
        
    }

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
  int i, n, now = 0, min = 120, s;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d", &s);
    now += s;
    if(s % 10 && min > s) min = s;
  }
  if(now % 10) printf("%d", now);
  else {
    if(min == 120) printf("0");
    else printf("%d", now - min);
  }
  return 0;
}

Measured memory_bytes: 128
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
const ll mod=998244353;

ll duz[nax];

int n;

vi graf[nax];

int kt[3][2];

int zak[nax];

map <ll,ll> mapa[3];

int ost[nax];
int czas;

void dod(ll &a, ll b)
{
	a=(a+b)%mod;
}

int main()
{
	scanf("%d", &n);
	duz[0]=1;
	duz[1]=1;
	for (int i=1; i<=18; i++)
		duz[1]=(duz[1]*10)%mod;
	for (int i=2; i<nax; i++)
		duz[i]=(duz[i-1]*duz[1])%mod;
	for (int h=0; h<3; h++)
	{
		for (int i=1; i<=n; i++)
		{
			graf[i].clear();
			zak[i]=0;
		}
		int m;
		scanf("%d", &m);
		for (int j=1; j<=m; j++)
		{
			int a, b;
			scanf("%d%d", &a, &b);
			graf[a].push_back(b);
			graf[b].push_back(a);
		}
		for (int i=n; i; i--)
		{
			czas++;
			for (int j : graf[i])
				if (j>i)
					ost[zak[j]]=czas;
			int x=0;
			while(ost[x]==czas)
				x++;
			mapa[h][x]=(mapa[h][x]+duz[i])%mod;
			zak[i]=x;
		}
		//~ debug() << h << " " << range(zak+1, zak+1+n) << " " << range(kt[h], kt[h]+2);
	}
	ll wyn=0;
	//~ for (int i=0; i<3; i++)
		//~ wyn=(wyn*kt[i][1])%mod;
	//~ for (int i=0; i<3; i++)
	//~ {
		//~ ll x=1;
		//~ for (int j=0; j<3; j++)
			//~ x=(x*kt[j][i==j])%mod;
		//~ wyn=(wyn+x)%mod;
	//~ }
	for (auto i : mapa[0])
		for (auto j : mapa[1])
			wyn=(wyn+i.second*j.second%mod*mapa[2][i.first^j.first])%mod;
	printf("%lld\n", wyn);
	return 0;
}


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

int main(void){
    long long n, x;
    cin >> n >> x;
    
    long long ans = 0, now, last;
    int i;
    for(i = 1; i <= n; i++){
        cin >> now;
        if(i == 1){
            last = now;
            continue;
        }
        
        if(now + last > x){
            ans += now + last - x;
            if(now >= now + last - x){
                now -= now + last - x;
            }else{
                now = 0;
            }
        }
        
        last = now;
    }
    
    cout << ans << endl;
    
    return 0;
}


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

double S(int x, int y, double z) {

  return x * y * sin(z /180 * M_PI) / 2;

}

double res1(int x , int y , double z) {

  return sqrt(x * x + y * y - 2 * x * y * cos(z / 180 * M_PI));

 }

double L(int x, int y, double z) {

  return x + y + z;

  }

double h(int x, double y) {

  return 2 * y / x;

}

int main() {

  double a , b , c , C;

  cin >> a >> b >> C;

  c = res1(a, b, C);

  printf("%.13lf\n",S(a, b, C));

  printf("%.13lf\n",L(a, b, c));

  printf("%.13lf\n",h(a, S(a, b, C)));

  return 0;

}

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

typedef long long ll;

multiset <int> S;
int n, m;
int a;
ll res;

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        S.insert(a);
    }
    while (m--) {
        multiset <int>::iterator it = S.end(); it--;
        int a = *it / 2; S.erase(it);
        S.insert(a);
    }
    for (multiset <int>::iterator it = S.begin(); it != S.end(); it++)
        res += *it;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
int n,m,k,tot;
char a[1200][1000];
int ans[1200][1000];
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='.')continue;;int w=i;if(!ans[i][j])ans[w][j]=++tot;w--;
			while(w>0&&!ans[w][j])ans[w][j]=ans[i][j],w--;
		}
	}
	
	for(int i=n;i;i--)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='.')continue;int w=i;if(!ans[i][j])ans[w][j]=++tot;w++;
			while(w<=n&&!ans[w][j])ans[w][j]=ans[i][j],w++;
		}
	}
	//for(int i=1;i<=n;i++)
	//{for(int j=1;j<=m;j++)
	//cout<<ans[i][j]<<" ";puts("");}puts("");
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(!ans[j][i])continue;int w=i;if(!ans[j][i])ans[j][i]=++tot;w--;
			while(w>0&&!ans[j][w])ans[j][w]=ans[j][i],w--;
		}
	}
	//for(int i=1;i<=n;i++)
	//{for(int j=1;j<=m;j++)
	//cout<<ans[i][j]<<" ";puts("");}puts("");
	for(int i=m;i;i--)
	{
		for(int j=1;j<=n;j++)
		{
			if(!ans[j][i])continue;int w=i;if(!ans[j][i])ans[j][i]=++tot;w++;
			while(w<=m&&!ans[j][w])ans[j][w]=ans[j][i],w++;
		}
	}
	for(int i=1;i<=n;i++)
	{for(int j=1;j<=m;j++)
	cout<<ans[i][j]<<" ";puts("");}
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int have = n / 200;
	cout << 9 - have + 1 << endl;
}

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

def pow(x, n):
    ans = 1
    n_tmp = n
    while n:
        if n % 2:
            ans *= x
            ans %= mod
        x *= x
        n >>= 1
    return ans

mod = 10**9+7 #出力の制限

a = pow(8, n) # 0,9を含まない
b = pow(9, n) - pow(8, n) # 0 or 9 のどちらかを含む
c = pow(10, n) # 全て
ans = c-2*b-a
if ans < 0:
    ans += mod
print(ans%mod)


Measured memory_bytes: 10760
N , K = map(int,input().split())
R , S , P = map(int,input().split())
T = list(input())
is_get_list = [True] * K
ans = 0


for i in range(K , N):
    now = T[i]
    before = T[i - K]
    if now == before and is_get_list[i - K]:
        is_get_list.extend([False])
    else:
        is_get_list.extend([True])
# print(is_get_list)
for i in range(N):
    if not is_get_list[i]:
        continue
    if T[i] == 'r':
        ans += P
    if T[i] == 's':
        ans += R
    if T[i] == 'p':
        ans += S
print(ans)

Measured memory_bytes: 4792
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  string A,B,C; cin >> A >> B >> C;
    
  
  char x = A[0];
 
  
   while( A.size() != 0 || B.size() != 0 || C.size() != 0){
    if(x == 'a'){ 
     if( A.size() == 0){ cout << 'A' << endl; return 0;}
       x = A[0];  A = A.substr(1,A.size() - 1);}
   
    else if(x == 'b'){ 
      if(B.size() == 0){ cout << 'B' << endl; return 0;}
      x = B[0]; B = B.substr(1,B.size() - 1);}
   
    else if(x == 'c'){ 
      if(C.size() == 0){ cout << 'C' << endl; return 0;}
      x = C[0]; C = C.substr(1,C.size() - 1);}
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  
  int t[n+1],x[n+1],y[n+1];
  t[0] = 0, x[0] = 0, y[0] = 0;
  for(int i=1 ; i < n+1 ; i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  
  bool flag = true;
  for(int i=1 ; i < n+1 ; i++){
    int dif_t = t[i] - t[i-1];
    int dif_v = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
    
    if(dif_t < dif_v) flag = false;
    else if(dif_t % 2 != dif_v % 2) flag = false;
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};


int main() {
    string s,t; cin >> s >> t;
    int a,b; cin >> a >> b;
    string u; cin >> u;
    if (u==s) a--;
    else b--;

    cout << a << " " << b << endl;
}  

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    public static int value(char l){
        switch (l){
            case 'A': l = 10;
            break;
            case 'B': l = 11;
            break;
            case 'C': l = 12;
            break;
            case 'D': l = 13;
            break;
            case 'E': l = 14;
            break;
            case 'F': l = 15;
            break;
        }
        return l;
    }

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        char a = in.next().charAt(0);
        char b = in.next().charAt(0);
        int x = value(a);
        int y = value(b);
        if (x == y){
            System.out.println('=');
        }
        else if (x < y){
            System.out.println('<');
        }
        else{
            System.out.println('>');
        }

    }
}

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

int main()
{
    int a,b,c,d,e=0;
    cin >> a >> b >> c;
    d = b-a;
    e = c-b;
    if(d == e){
        cout << "YES"<<endl;
    }
    else{
        cout << "NO" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
n,m = gets.split.map &:to_i
x = gets.split.map &:to_i

if n >= m
    puts 0
    exit
end

x.sort!
diffs = []

(m-1).times do |i|
    diffs[i] = x[i+1] - x[i]
end

sorted_diffs = diffs.sort.reverse

road = x[-1] - x[0]

(n-1).times do |i|
    road -= sorted_diffs[i]
end

puts road

Measured memory_bytes: 10480
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a<b)b=a;
			int c = sc.nextInt();
			if(b<c)c=b;
			int d = sc.nextInt();
			int e = sc.nextInt();
			if(d<e)e=d;
			System.out.println(c+e-50);
		}
		
	}	
}

Measured memory_bytes: 17168
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let mut n: i64 = sc.read();
    let k: i64 = sc.read();
    n %= k;
    let ans = std::cmp::min(n, k - n);
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.06.01 20:59:28
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

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

int main() {
    int n;
    scanf("%d", &n);
    printf("%d\n", (n - 2) * 180);

    /* --------------------------------- */
    return 0;
}

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

suc = "Yes"
maxN = H[0]
for i in range(N):
    if maxN - 1 > H[i]:
        suc = "No"
        break
    elif maxN < H[i]:
        maxN = H[i]
print(suc)



Measured memory_bytes: 20616
#include<stdio.h>
#include <string.h>
int isPrime(int x){
	int i;
	if(x<2) return 0;
	else if(x==2) return 1;
	if(x%2==0) return 0;
	for(i=3;i*i<=x;i+=2){
		if(x%i==0) return 0;
	}
	return 1;
}
int p,cnt,cnt2,food;
int n,d=0,g,kakaku[31],flag,youso[1000001]={0};
int main()
{
	scanf("%d %d",&n,&p);
	while(1){
		//memset(youso, 0, sizeof(youso));
		for(int i=0;i<1000001;i++){
			youso[i]=0;
		}
		if(n==0&&p==0){
			break;
		}
		for(cnt=1;cnt<=n;cnt++){
			scanf("%d",&food);
			youso[food]=1;
			kakaku[cnt]=food;
		}
		for(cnt=0;cnt<=p;cnt++){
			if(youso[cnt]==1){
				for(cnt2=1;cnt2<=n;cnt2++){
					if(cnt+kakaku[cnt2]<=p){
						youso[cnt+kakaku[cnt2]]=1;
					}
				}
			}
		}
		flag=0;
		for(cnt=p;cnt>=0;cnt--){
			if(youso[cnt]==1){
				g=cnt;
				d=isPrime(g);
				if(d==1){
					flag=1;
					d=cnt;
					printf("%d\n",d);
					break;
				}
			}
		}
		if(flag==0){
			printf("NA\n");
		}
		d=0;
		flag=0;
		
		scanf("%d %d",&n,&p);
	}
	return 0;
}

Measured memory_bytes: 6648