akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int N, A;

// dp[j][k][s] ... x_1 から x_j から k 枚選んで x_i の合計を s にするような選び方の総数
// 0 ≦ j ≦ N, 0 ≦ k ≦ N, 0 ≦ s ≦ NX
long long dp[51][51][2501];

int main() {

  cin >> N >> A;

  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }

  dp[0][0][0] = 1;

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= 2500; k++) {
        
        if (0 < j && (k - x[i - 1]) >= 0) {
          dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]];
        } else {
          dp[i][j][k] = dp[i - 1][j][k];
        }
      }
    }
  }

  long long sum = 0;

  for (int i = 1; i <= N; i++) {
    sum += dp[N][i][i * A];
  }
  
  cout << sum << endl;
  
  return 0;

}

Measured memory_bytes: 50048
n = int(input())
num_list = [i for i in range(1,n+1)]
num2_list = [i for i in num_list if i%3==0]#3で割り切れる値
list_str = [s for s in map(str,num_list) if '3' in s]#3が含まれる場合
list_in = list(map(int,list_str))#list変換
list_uniq = list(set(num2_list+list_in))
list_uniq.sort()
print(' '+' '.join(str(i) for i in list_uniq))



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

int main() {
    string s;
    cin >> s;
    int ans = 7;
    string w[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" };
    for (unsigned int i = 0; i < 7; i++) {
        if(s == w[i]) {
            ans -= i;
        }
    }
    cout << ans << endl;
}

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

int main(){
	vector<int> x(5);
	rep(i, 5) cin >> x[i];
	rep(i, 5) {
		if (x[i] == 0) {
			cout << i+1 << endl;
			return 0;
		}
	}
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;


    
int main(){
    int N, Y;
    cin >> N >> Y;
    int ax, ay, az;
    bool isOK = false;
    REP(x,N+1){
        REP(y,N+1-x){
            int z = N - x - y;
            if(10000*x+5000*y+1000*z==Y){
                isOK = true;
                ax = x;
                ay = y;
                az = z;
                break;
            }
        }
        if(isOK) break;
    }
    if(isOK) cout << ax << " " << ay << " " << az << endl;
    else cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
import sys
def main():
    INF=sys.maxsize
    Vmax=1000
    N,W=tuple(map(int,sys.stdin.readline().split()))
    V,w,v=N*Vmax,[0],[0]
    for _ in [0]*N:
        ww,vv=tuple(map(int,sys.stdin.readline().split()))
        w.append(ww)
        v.append(vv)
    dp=[[INF for _ in range(V+1)] for _ in range(N+1)]
    dp[0][0]=0
    for i in range(1,N+1):
        for j in range(V+1):
            dp[i][j]=min(dp[i][j],dp[i-1][j])
            if 0<=j-v[i]<=V:dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i])
    res=0
    for j in range(V+1):
        if dp[N][j]<=W:res=j
    print(res)
if __name__=='__main__':main()

Measured memory_bytes: 218220
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

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

double x[111], y[111], z[111], r[111];
double dis[111][111];
bool used[111];

int main() {
  int n;
  for (;;) {
    cin >> n;
    if (n == 0) break;
    rep (i, n) cin >> x[i] >> y[i] >> z[i] >> r[i];
    rep (i, n) used[i] = false;
    rep (i, n) rep (j, n) dis[i][j] = max(sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2) + pow(z[i] - z[j], 2)) - r[i] - r[j], 0.);
    double res = 0;
    used[0] = true;
    rep (i, n - 1) {
      int next = -1;
      double mincost = 1e10;
      rep (j, n) if (used[j]) rep (k, n) if (!used[k]) {
	  //cout << j << " " << k << " " << dis[j][k] << endl;
	  if (mincost >= dis[j][k]) {
	    mincost = dis[j][k];
	    next = k;
	  }
	}
      res += mincost;
      used[next] = true;
    }
    printf("%.3lf\n", res);
  }
}

Measured memory_bytes: 1072
X = int(input())
res = X
j = 0
Flags = []
flg = True
for i in range(2,X+1):
  j = i+i
  flg = True
  while flg:
    Flags.append(j)
    if j > X:
      flg = False
    j += i
while res in Flags:
  res += 1
print(res)

Measured memory_bytes: 51244
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;
 int main() {
   int tH, tA, aH, aA;
   cin >> tH >> tA >> aH >> aA;
   int alpha = aH / tA;
   int beta = tH / aA;
   if( aH % tA != 0) {
     alpha++;
   }
   if ( tH % aA != 0) {
     beta++;
   }
   if (alpha > beta) {
     cout << "No" <<endl;
   }
   else {
     cout << "Yes" << endl;
   }
 }

Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D

const int maxi = 20000;
const char UP = '/';
const char DOWN = '\\';
const char FLAT = '_';

template<typename I, typename F>
void for_each2(I begin, I end, F fnc){
    if (begin == end) return;
    fnc(true, begin == end - 1, *begin);
    while(++begin <= end - 1) fnc(false, begin == end - 1, *begin);
}

class Area {
    public:
        int start;
        int end;
        int area;
        Area(int start, int end, int area) : start(start), end(end), area(area) {};
        Area() = default;
        inline bool contains(const Area &a){
            return start <= a.start && a.end <= end;
        }
};

vector<Area> areas;
vector<int> starts;
const int max_s = 20000;

int main(int argc, char const* argv[])
{
    starts.reserve(max_s/2);

    int c;
    int i = 0;
    while ((c = getchar()) != EOF) {
        if(starts.empty() && c != DOWN){
            // nop
        }else if(c == DOWN){
            starts.push_back(i);
        }else if(c == UP){
            int s;
            s = starts.back();
            Area a(s, i, i-s);
            while (!areas.empty()) {
                auto p = areas.back();
                if(a.contains(p)){
                    a.area += p.area;
                    areas.pop_back();
                } else {
                    break;
                }
            }
            areas.push_back(a);
            starts.pop_back();
        }
        i++;
    }

    int sum = 0;
    for_each(areas.begin(), areas.end(), [&sum](Area &x)
        { sum += x.area; });
    printf("%d\n", sum);
    if(areas.size() > 0){
        printf("%d ", areas.size());
        for_each2(areas.begin(), areas.end(), [](bool is_first, bool is_last, Area &v)
            { printf(!is_last ? "%d " : "%d\n", v.area); });
    }else{
        puts("0");
    }

    return 0;
}

Measured memory_bytes: 2752
#この解答を自分で写経してみる
N,M=map(int,input().split())
AB=[map(int,input().split()) for _ in range(M)]
#map関数を格納したリストを作る
#この_表記で繰り返すという文化に慣れよう

links=[[] for _ in range(N+1)]
#移動先を出力する
#リストの入れ子にしたかったら、最初から入れ子として定義しないといけない
#何か + for _ in range(M)　で、何かをM回繰り返す
for a,b in AB:
#map関数それぞれに対して、値を抽出する
    links[a].append(b)
    links[b].append(a)

from collections import deque
result=[-1]*(N+1)
#これで[-1,-1,,,]のリストは作れる
#各部屋ごとの出力先

q=deque([1])
#始点の定義
while len(q)>0:
    i=q.popleft()
    for j in links[i]:
        if result[j] ==-1:
            result[j] = i
            #新しいものをどんどん加えていくことで、層がどんどん深くなっていく
            q.append(j)
print("Yes")
print("\n".join(str(i) for i in result[2:] ))
    

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

const ll MOD = 1e9 + 7;

ll DP[10010][101][10];

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	string s;
	int d;
	cin >> s >> d;
	int n = s.size();
		
	M00(dig, 10) {
		M00(i, d) {
			DP[1][i][dig] = (dig % d == i) ? 1 : 0;
		}
	}
	for(int len = 2; len <= n; len++) {
		M00(dig, 10) {
			M00(i, d) {
				int next = (i - dig) % d;
				next += d;
				next %= d;
				M00(dig2, 10) {
					DP[len][i][dig] += DP[len-1][next][dig2];
					DP[len][i][dig] %= MOD;
				}
			}
		}
	}
	/*
	M00(i, n) {
		M00(j, 10) {
			M00(k, d) {
				cout << DP[i+1][k][j] << " ";
			}
			cout << endl;
		}
	}
	*/

	int cur = 0;
	ll ans = 0;
	M00(i, n) {
		M00(j, s[i] - '0') {
			ans += DP[n - i][cur][j];
			ans %= MOD;
		}
		cur -= s[i] - '0';
		cur %= d;
		cur += d;
		cur %= d;
	}
	if(cur == 0) ans++;
	ans--;
	ans %= MOD;
	ans += MOD;
	ans %= MOD;
	cout << ans << endl;
}


Measured memory_bytes: 82444
N=io.read("n")
M=io.read("n")
k={}
A={}
t={}
for i=1,N do
  k[i]=io.read("n")
  A[i]={}
  for j=1,k[i] do
    A[i][j]=io.read("n")
    t[A[i][j]]=(t[A[i][j]] or 0)+1
  end
end
local count=0
for i,v in pairs(t) do
  if v==N then
    count=count+1
  end
end
print(count)
    
  

Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
	int a,b,c,d;
	scanf ("%d %d %d",&a,&b,&c);
	d=(a*b);
	if (d<c){
		printf ("%d\n",d);
	}
	else {
		printf ("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 128
from collections import Counter
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct+=b,
        b = b + 1
    if n > 1:
        fct+=n,
    return Counter(fct).values()
a = 0
n = int(input())
if n == 1:exit(print(0))
for i in factorize(n):
  c = s = 0
  while s <= i:
    c += 1
    s = (c+1)*c//2
  a += c - 1
print(a)

Measured memory_bytes: 65868
from itertools import accumulate
N,W = map(int,input().split())
w = [[] for i in range(4)]
w1,v1 = map(int,input().split())
w[0].append(v1)
for i in range(N-1):
    wi,vi = map(int,input().split())
    w[wi-w1].append(vi)
num = []
for i in range(4):
    w[i].sort(reverse= 1)
    w[i] = [0]+list(accumulate(w[i]))
    num.append(len(w[i]))
ans = 0
for n1 in range(num[0]):
    for n2 in range(num[1]):
        for n3 in range(num[2]):
            for n4 in range(num[3]):
                wc = w1*(n1+n2+n3+n4) + n2 + 2*n3 + 3*n4
                if wc <= W:
                    vc = w[0][n1]+w[1][n2]+w[2][n3]+w[3][n4]
                    ans = max(ans,vc)
print(ans)
        

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
typedef long long ll;

ll s[100010], t[100010], p[100010];
ll counts[2][100010];

int main() {
  ll N, M; scanf("%lld%lld", &N, &M);
  REP(i, N) { scanf("%lld%lld", s+i, t+i); }
  REP(i, M) { scanf("%lld", p+i); }
  sort(p, p+M);

  ll ret = 0;
  REP(i, N) {
    int s_index = lower_bound(p, p+M, s[i]) - p;
    int t_index = lower_bound(p, p+M, t[i]) - p;
    if (s_index == t_index) {
      ret += abs(t[i] - s[i]);
    } else {
      int group = s_index % 2;
      if (s_index < t_index) { --t_index; }
      else { --s_index; }
      ret += abs(s[i] - p[s_index]);
      if ((s_index + t_index) % 2) { ret += abs(t[i] - p[t_index]); }
      counts[group][min(s_index, t_index) + 1] += 1;
      counts[group][max(s_index, t_index) + 1] -= 1;
    }
  }

  REP(group, 2) {
    ll sum = 0;
    FOR(i, 1, M) {
      sum += counts[group][i];
      if (i % 2 == group) { ret += sum * (p[i] - p[i-1]); }
    }
  }

  printf("%lld\n", ret);
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
typedef long long LL;

struct SEG{
    int n;
    int mi[maxn<<2],mi2[maxn<<2],lazy[maxn<<2];
    void init(int N){
        n=N;
        for(int i=0;i<(maxn<<2);i++){
            mi[i] = n;
            mi2[i] = n+1;
            lazy[i] = n+1;
        }
    }
    void push_down(int rt){
        if(lazy[rt]!=n+1){
            lazy[rt<<1] = min(lazy[rt<<1],lazy[rt]);
            lazy[rt<<1|1] = min(lazy[rt<<1|1],lazy[rt]);
            mi[rt<<1] = min(mi[rt<<1],lazy[rt]);
            mi[rt<<1|1] = min(mi[rt<<1|1],lazy[rt]);
            lazy[rt] = n+1;
        }
    }
    void update(int rt,int L,int R,int l,int r,int val){
        if(L<=l&&r<=R){
            // if(mi[rt]<val)
            mi[rt] = min(mi[rt],val);
            lazy[rt] = min(lazy[rt],val);
            return;
        }
        int m = (l+r)>>1;
        push_down(rt);
        if(m>=L) update(rt<<1,L,R,l,m,val);
        if(m<R)  update(rt<<1|1,L,R,m+1,r,val);
        mi[rt] = min(mi[rt<<1],mi[rt<<1|1]);
    }
    int query(int rt,int pos,int l,int r){
        if(l==r) return mi[rt];
        push_down(rt);
        int m=(l+r)>>1;
        if(m>=pos) return query(rt<<1,pos,l,m);
        else return query(rt<<1|1,pos,m+1,r);
    }
}row,col;

int main(void)
{
    int n;
    scanf("%d",&n);
    row.init(n);
    col.init(n);
    LL ans = 1ll*(n-2)*(n-2);
    int q;
    scanf("%d",&q);
    while(q--){
        int op,x;
        scanf("%d%d",&op,&x);
        if(op==1){
            int pos = row.query(1,x,1,n);
            ans -= pos-2;
            col.update(1,1,pos,1,n,x);
        }
        else{
            int pos = col.query(1,x,1,n);
            ans -= pos-2;
            row.update(1,1,pos,1,n,x);
        }
    }
    printf("%lld\n",ans);
}



Measured memory_bytes: 22580
# -*- coding: utf-8 -*-
x,y,z,k = map(int, input().split())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)


d = [e1+e2 for e1 in a for e2 in b]
d.sort(reverse=True)
d = d[:k]

e = [e1+e2 for e1 in d for e2 in c]
e.sort(reverse=True)


for i in range(k):
    print(e[i])



Measured memory_bytes: 161624
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(int)(n); ++i)
 
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;}

const int NM = 2 * 1e3+10;
int l[NM];

bool isValid(int i, int j, int k){
    if(l[i]+l[j] > l[k] && l[i]+l[k] > l[j] && l[j]+l[k] > l[i]){
        return true;
    }
    return false;
}
int main(){
    int n; cin >> n;
    rep(i, n) cin >> l[i];

    sort(l, l+n);
    ll ans=0;
    for(int i=0; i<n;i++){
        for(int j=i+1; j<n; j++){
            // 二分探索
            auto itr = lower_bound(l, l+n, l[i]+l[j]);
            ll ng = distance(itr, l+n);
            ans += n-j-1-ng;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using IP = pair<int, P>;
using LLP = pair<ll, LP>;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    size_t sz = v.size();
    os << "[";
    for (size_t i = 0; i < sz-1; i++) {
        os << v[i] << ", ";
    }
    os << v[sz-1] <<  "]";
    return os;
}

template<typename T>
void printArray(T *arr, size_t sz) {
    cerr << "[";
    for (size_t i = 0; i < sz-1; i++) {
        cerr << arr[i] << ",";
    }
    cerr << arr[sz-1] <<  "]";
}

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}


// print floating-point number
// cout << fixed << setprecision(12) <<

// }}}

int N, K;
ll v[51];

void solve()
{
    ll ans = 0;
    ull b = 0;
    REP (i, N+1) {
        if (i > K) continue;
        REP (j, i+1) {
            ull b = ((((1ull<<j)-1) << (N-j)) | (1ull<<(i-j))-1);
            priority_queue<ll, vector<ll>, greater<ll> > q;
            REP (i, N) {
                if ((b>>i)&1) {
                    q.push(v[i]);
                }
            }
            ll a = 0, c = K-i;
            while (!q.empty()) {
                ll x = q.top();
                if (x < 0 && c > 0) {
                    c--;
                } else {
                    a += x;
                }
                q.pop();
            }
            ans = max(ans, a);
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP (i, N) cin >> v[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

string concat(string s, string t)
{
    int n = s.size();

    for (int i = n; i >= 1; --i) {
        string ss = s.substr(n - i, i);
        string tt = t.substr(0, i);

        if (ss == tt) {
            return s.substr(0, n-i) + ss + t.substr(i, n-i);
        }
    }

    return s + t;
}

int main()
{
    int N;
    cin >> N;

    string s, t;
    cin >> s;
    cin >> t;

    cout << concat(s, t).size() << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
long long n, m, k, r;
vector <int> qw;
vector <int> kn;
void xy (int w)
{
    if (w==n+m)
    {
        int rr=0;
        for (int i=0; i<n; ++i)
            for (int j=0; j<m; ++j)
            {
                if (!(qw[i]==1 || kn[i*m+j]==0 || qw[n+j]==1))
                    rr+=1;
            }
        if (rr==k)
            r+=1;
    }
    else
        for (int i=1; i<3; ++i)
        {
            qw[w]=i;
            xy(w+1);
        }
}
int main ()
{
    cin >> n >> m >> k;
    for (int i=0; i<n+m; ++i)
        qw.push_back(0);
    r=0;
    for (int i=0; i<n*m; ++i)
        kn.push_back(0);
    for (int i=0; i<n; ++i)
    {
        for (int j=0; j<m; ++j)
        {
            char t;
            cin >> t;
            if (t=='#')
                kn[i*m+j]=1;
        }
    }
    xy(0);
    cout << r << endl;
}


Measured memory_bytes: 3620
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int x, a;

void solve()
{
    cout << (x < a ? 0 : 10) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x >> a;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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


int main(){


  int cards[4][14] , n = 0, v;
  char f;

  for( int i = 0 ; i < 4 ; i++ ){
    for( int j = 0 ; j < 14 ; j++ ){
      cards[i][j] = 0;
    }

  }
  cin >> n;
 
  for( int i = 0 ; i < n ; i++ ){
   
    cin >> f >> v;
    
    if( f == 'S' ){
      cards[0][v] = 1;
    } else if( f == 'H' ){
      cards[1][v] = 1;
    } else if( f == 'C'){
      cards[2][v] = 1;
    } else if(f == 'D'){
      cards[3][v] = 1;
    }
  }

  for( int i = 0 ; i < 4 ; i++ ){
    for( int j = 1 ; j < 14 ; j++ ){
 
      if( cards[i][j] == 0 ){
	if( i == 0 ){
	  cout << 'S' << ' ' << j << "\n";
	} else if( i == 1 ){
	  cout << 'H' <<  ' ' << j << "\n"; 
    	} else if( i == 2 ){
	  cout << 'C' <<  ' ' << j << "\n"; 
    	} else if( i == 3 ){
	  cout << 'D' <<  ' ' << j << "\n"; 
	}
      }
      
    }
  }
  return 0;

 
    

    
}

Measured memory_bytes: 1160
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
A = list(map(int, input().split()))

ans = [0] * N
for i, j in enumerate(A):
    ans[j - 1] = i + 1
print(' '.join(map(str, ans)))

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

char locker[3][3] ={{'A', 'B', 'C'},
		    {'D', 'E', 'F'},
		    {'G', 'H', 'I'}};
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool dfs(string s, int x, int y){
  if(s.empty()){
    return true; 
  }
  bool res = false;
  for (int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(0 <= nx && nx < 3 &&
       0 <= ny && ny < 3 &&
       s[0] == locker[ny][nx])
      res = res | dfs(s.substr(1), nx, ny);
  }
  return res;
}

int main(){
  for (int i = 0; i < 1000; i++){
    int x, y;
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++){
      for (int j = 0; j < 3; j++){
	if(s[0] == locker[i][j]){
	  x = j;y = i;
	}
      }
    }

    if(dfs(s.substr(1), x, y))
      cout << s << endl;
  }
  return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;
const ll com_max = 510000;

ll fac[com_max], inv[com_max], finv[com_max];

void com_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (ll i = 2; i < com_max; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll com(ll n, ll k) {
    if (n < k) {
        return 0;
    }
    if (n < 0 || k < 0) {
        return 0;
    }

    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

void prime_map(map<ll, ll> &m, ll num) {
    for (ll i = 2; i * i <= num; i++) {
        while (num % i == 0) {
            m[i]++;
            num /= i;
        }
    }
    if (num != 1) {
        m[num] = 1;
    }
    return;
}

int main() {
    ll n, m;
    cin >> n >> m;
    com_init();
    map<ll, ll> prime;
    prime_map(prime, m);
    ll ans = 1;
    for (auto iter = prime.begin(); iter != prime.end(); iter++) {
        ll num = iter->second;
        ans *= com(num + n - 1, num);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 15568
#include <iostream>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll H,W;
	cin >> H >> W;

	ll ans = INF*INF;
	ll a=0,b=0,c=0;

	for(int h = 0; h <= H; h++){
		if(W%2==0) a = h*W/2,b = h*W/2;
		else a = h*(W-1)/2,b = h*(W+1)/2;
		c = W*(H-h);

		ll s_max = max(max(a,b),c);
		ll s_min = min(min(a,b),c);
		if(s_max - s_min < ans) ans = s_max - s_min;

		a = h*W;
		if((H-h)%2==0) b = (H-h)/2 * W,c = b;
		else b = (H-h-1)/2 * W,c = (H-h+1)/2 * W;

		s_max = max(max(a,b),c);
		s_min = min(min(a,b),c);
		if(s_max - s_min < ans) ans = s_max - s_min;
	}

	for(int w = 0; w <= W; w++){
		if(H%2==0) a = H/2*w, b = a;
		else a = (H-1)/2*w, b = (H+1)/2*w;
		c = H*(W-w);

		ll s_max = max(max(a,b),c);
		ll s_min = min(min(a,b),c);
		if(s_max - s_min < ans) ans = s_max - s_min;

		a = w*H;
		if((W-w)%2==0) b = H*(W-w)/2 , c = b;
		else b = H*(W-w-1)/2, c = H*(W-w+1)/2;
		s_max = max(max(a,b),c);
		s_min = min(min(a,b),c);
		if(s_max - s_min < ans) ans = s_max - s_min;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int day, month, year;
  char s[10];
  cin >> s;
  sscanf(s, "%4d/%2d/%2d", &year, &month, &day);
  cout << ((year <= 2018 || (year == 2019 && month <= 4)) ? "Heisei" : "TBD") << endl;
}

Measured memory_bytes: 256
//package com.company;

import java.io.*;
import java.util.*;


public class Main {
    public static void main(String[] args) throws IOException {
        MyScanner sc = new MyScanner(System.in);
        long[] cnt = new long[200010];
        int n = sc.nextInt();
        long k = sc.nextLong();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            cnt[a] += b;
        }
        long tt = 0;
        for (int i = 0; i < cnt.length; i++) {
            tt += cnt[i];
            if (tt >= k){
                System.out.println(i);
                return;
            }
        }
    }

    static class MyScanner {
        StringTokenizer st;
        BufferedReader br;

        public MyScanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public MyScanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException { return Double.parseDouble(next()); }

        public boolean ready() throws IOException {return br.ready();}
    }
}

Measured memory_bytes: 43464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;
  cin >> n >> m;
  int a,b;
  priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int, int> > > que_day;
  priority_queue<int > que_money;
  rep(i,n){
    cin >> a >> b;
    que_day.push(mp(a,b));   //日 金
  }
  ll ans=0;
  rep(i,m){
    if(!que_day.empty()){
      //      cout << ""<<endl;
      pair<int,int> day=que_day.top();
      //      cout << day.first << endl;
      while(day.first<=i+1){
	que_money.push(day.second);
	que_day.pop();
	if(que_day.empty()) break;
	day=que_day.top();
      }
    }

    if(!que_money.empty()){
      //          cout << que_money.top() << endl;
      ans += ((ll) que_money.top());
      que_money.pop();
    }    
  }
  cout <<  ans << endl;


  return 0;
    

}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
ll h, w, c[10][10], a[202][202];
signed main() {
	cin >> h >> w;
  rep(i, 10) rep(j, 10) cin >> c[i][j];
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(k, 10) rep(i, 10) rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  ll ans = 0;
  rep(i, h) rep(j, w) if(0 <= a[i][j]) ans += c[a[i][j]][1];
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2, 3, 3), (0, 2))

    def test_2(self):
        self.assertEqual(think(500000000000, 500000000000, 1000000000000), (0, 0))

    def test_3(self):
        self.assertEqual(think(1, 1, 10), (0, 0))


def solve():
    a, b, k = read()
    result = think(a, b, k)
    write(result)


def read():
    return read_int(3)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b, k):
    if a >= k:
        return a - k, b
    rem = k - a
    if b >= rem:
        return 0, b - rem
    else:
        return 0, 0


def write(result):
    print('{0:d} {1:d}'.format(result[0], result[1]))


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 6448
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main()
{
   string s,p;
   cin>>s>>p;
   s=s+s;
   if(s.find(p)!=-1)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
   return 0;
 }


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

int main() {
    int N, ac = 0, wa = 0, tle = 0, re = 0;
    std::cin >> N;
    for(int i = 0; i < N; ++i) {
        std::string tmp;
        std::cin >> tmp;
        if(tmp == "AC") {
            ++ac;
        }
        else if(tmp == "WA") {
            ++wa;
        }
        else if(tmp == "TLE") {
            ++tle;
        }
        else {
            ++re;
        }
    }
    std::cout << "AC x " << ac << std::endl;
    std::cout << "WA x " << wa << std::endl;
    std::cout << "TLE x " << tle << std::endl;
    std::cout << "RE x " << re << std::endl;
    return 0;
}

Measured memory_bytes: 3224
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "damage", long, "cost");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b, c;
    scan(a, b, c);
    if ((a == b && a != c) || (a == c && a != b) || (b == c && a != b))
    {
        writeln("Yes");
    }
    else
    {
        writeln("No");
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
  string S;
  std::cin >> S;
  int count = 0;
  deque<char> Q;
  for(int i=0;i<S.size();i++){
    if(Q.empty()){
      Q.push_back(S[i]);
    }else if(S[i] == Q.back()){
      Q.push_back(S[i]);
    }else{
      Q.pop_back();
      count+=2;
    }
  }
  std::cout << count << '\n';
  return 0;
}


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

class dsu {
  int N;
  vector<int> PS;
public:
  dsu() : N(0) {}
  dsu(int n) : N(n), PS(n, -1) {}
  int merge(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < N);
    int x = leader(a), y = leader(b);
    if (x == y) return x;
    if (-PS.at(x) < -PS.at(y)) swap(x, y);
    PS.at(x) += PS.at(y);
    PS.at(y) = x;
    return x;
  }
  bool same(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < N);
    return leader(a) == leader(b);
  }
  int leader(int a) {
    assert(0 <= a && a < N);
    if (PS.at(a) < 0) return a;
    return PS.at(a) = leader(PS.at(a));
  }
  int size(int a) {
    assert(0 <= a && a < N);
    return -PS.at(leader(a));
  }
  vector<vector<int>> groups() {
    vector<int> B(N), S(N);
    for (int i = 0; i < N; i++) {
      B.at(i) = leader(i);
      S.at(B.at(i))++;
    }
    vector<vector<int>> ret(N);
    for (int i = 0; i < N; i++) {
      ret.at(i).reserve(S.at(i));
    }
    for (int i = 0; i < N; i++) {
      ret.at(B.at(i)).push_back(i);
    }
    ret.erase(
      remove_if(ret.begin(), ret.end(), [&](const vector<int>& v) { return v.empty(); }),
      ret.end()
    );
    return ret;
  }
};

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> V(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    V.at(i) = {a, b};
  }
  
  reverse(V.begin(), V.end());

  dsu D(N);
  vector<long> ans;
  long tmp = (long) N * (N - 1) / 2;

  for (int i = 0; i < M; i++) {
    ans.push_back(tmp);
    auto [a, b] = V.at(i);
    if (D.same(a, b)) continue;
    tmp -= (long) D.size(a) * D.size(b);
    D.merge(a, b);
  }
  reverse(ans.begin(), ans.end());
  for (auto a : ans) cout << a << "\n";
}

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

int main(){
    int k, s;
    cin >> k >> s;
    int cnt=0;
    for(int x=0; x<k+1; x++){
        for(int y=0; y<k+1; y++){
            int z = s-x-y;
            if(0<=z && z<=k){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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;
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const ll INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;

    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	string str;cin >> str;
	sort(ALL(str));
	cout << (str == "abc" ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {

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

    int ans=0;
    for(int i=1;i<n;i++) {
        if(s[i]==s[i-1]&&s[i]=='1') {
            s[i]='0';
            ans++;
        }
        else if(s[i]==s[i-1]&&s[i]=='0') {
            s[i]='1';
            ans++;
        }
    }

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

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for(int i = 0; i < k; i++)
			list.add(sc.nextInt());

		for(int i = 1; i < n; i++) {
			k = sc.nextInt();
			List<Integer> list2 = new ArrayList<>();			
			for(int j = 0; j < k; j++) {
				int menu = sc.nextInt();
				if (list.contains(menu)) {
					list2.add(menu);
				}
			}
			list = list2;
		}
		out.println(list.size());
		
		out.close();
	}
	static boolean func(StringBuilder sb1, StringBuilder sb2) {
		boolean res = true;
		for(int i = 0; i < sb1.length(); i++) {
			if ( sb1.charAt(i) != sb2.charAt(i)) {
				res = false;
				break;
			}
		}
		return res;
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



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

int main() {
  int n;
  cin >> n;
  
  int64_t sum = 0;
  int front;
  cin >> front;
  
  for (int i = 1; i < n; i++) {
    int x;
    cin >> x;
    if (x < front)
      sum += front - x;
    else
      front = x;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
int main(){
    int a,b;std::cin>>a>>b;
    for(int i=1;i<10000;i++){
        if(i*8/100==a&&i*10/100==b){
            std::cout<<i<<std::endl;
            return 0;
        }
    }
    std::cout<<-1<<std::endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s[10],sum=0,minn;
    int n=150;
    for(int i=0;i<5;i++)
    {
        scanf("%d",&s[i]);
        if(n>s[i]%10&&s[i]%10!=0)
        {
            minn=i;
            n=s[i]%10;
        }
    }
    for(int i=0;i<5;i++)
    {
        if(minn==i)
            sum=sum+s[i];
        else
        {
            if(s[i]%10==0)
                sum=s[i]+sum;
            else
                sum=sum+((s[i]/10)+1)*10;
        }
    }
    printf("%d\n",sum);
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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 double PI=3.14159265358979323846;

int mod = 1e9+7;
int INF = 1e9+7;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


int main(){

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

  ll ans = 1;
  for(ll A=1; A*A<=M; A++){
    if(M%A != 0) continue;
    ll B = M/A;
    if(A*N <= M) ans = max(ans, A);
    if(B*N <= M) ans = max(ans, B);
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
//３つの整数a, b, cを読み込み、それらが a < b < cの条件を満たすならば"Yes"を、満たさないならば"No"を出力するプログラム
#include <stdio.h>

int main(void)
{
    //変数定義
    int iInputA;
    int iInputB;
    int iInputC;

    //変数の初期化
    iInputA = 0;
    iInputB = 0;
    iInputC = 0;

    scanf ("%d %d %d",&iInputA,&iInputB,&iInputC);
    if ((iInputA < iInputB) && (iInputB < iInputC))
    {
        printf("Yes\n");
    }   
    else 
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2104
defmodule Main do
  def main do
    s = IO.gets("") |> String.trim() |> String.codepoints()
    t = IO.gets("") |> String.trim() |> String.codepoints()

    checkarray(s, t, 0)
    |> IO.puts()
  end

  defp checkarray([s_head | []], [t_head | []], count) do
    if s_head == t_head do
      count
    else
      count + 1
    end
  end

  defp checkarray([s_head | s_rest], [t_head | t_rest], count) do
    if s_head == t_head do
      checkarray(s_rest, t_rest, count)
    else
      checkarray(s_rest, t_rest, count + 1)
    end
  end
end

Measured memory_bytes: 122784
# coding: utf-8
# Your code here!
import bisect

N,M,K=map(int,input().split())

A=list(map(int,input().split()))
B=list(map(int,input().split()))

sum_A=[0]
for i in range(N):
    sum_A.append(sum_A[-1]+A[i])


sum_B=[0]
for i in range(M):
    sum_B.append(sum_B[-1]+B[i])

ans=0
for i in range(N+1):
    target=K-sum_A[i]
    if target>=0:
        j=bisect.bisect(sum_B,target)
        ans=max(ans,i+j-1)

print(ans)
    

Measured memory_bytes: 47492
N,M,L = map(int,input().split())
INF = 10**18
d = [[INF for j in range(N)] for i in range(N)]

# 入力
for _ in range(M):
    A,B,C = map(int,input().split())
    if L < C:
        continue
    d[A-1][B-1] = C
    d[B-1][A-1] = C

# 初期化
for i in range(N):
    d[i][i] = 0

# ワーシャルフロイド1回目
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

for i in range(N):
    for j in range(N):
        if d[i][j] <= L:
            d[i][j] = 1
        else:
            d[i][j] = INF

# 初期化
for i in range(N):
    d[i][i] = 0

# ワーシャルフロイド2回目
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

Q = int(input())

for _ in range(Q):
    s,t = map(int,input().split())
    if d[s-1][t-1] == INF:
        print(-1)
    else:
        print(d[s-1][t-1]-1)



Measured memory_bytes: 58968
use std::io::{self, Read};

fn main() {
	let mut input = String::new();
	let _ = io::stdin().read_to_string(&mut input);
	let lines: Vec<&str> = input.split("\n").collect();
	let a = lines[0].parse::<i32>().unwrap();
	let b = lines[1].parse::<i32>().unwrap();
	
	println!("{}",6 - a - b);
}



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


signed main(){
    int N;
    cin >> N;
    int E[2][8]={{2, 10, 3, 9, 4, 8, 6, 12},{6, 2, 10, 3, 9, 4, 8, 12}};
    if(N==3){
        cout << "2 5 63 " << endl;
        return 0;
    }
    REP(i,N){
        cout << E[N%2][(i%8)]+(i/8)*12 << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384