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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N,M; cin >> N >> M;
  map<int,int> m;
  for(int i = 0; i < M; i++){
    int tmp1,tmp2; cin >> tmp1 >> tmp2;
    m[tmp1]++;
    m[tmp2]++;
  }

  for(auto x: m){
    if(x.second % 2 == 1){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

int main() {
  ll N, K, oneplace;//oneplaceは１が下から何桁目かを表す
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  rep(i,N) {
    if(A[i] == 1) {
      oneplace = i + 1;
      break;
    }
  }
  cout << (N + K - 3)/(K - 1)<< endl;
  return 0;
}


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


int main() {
    ll l,r;
    ll c=2019;
    cin >> l >> r;
    ll ans=0;
    if (r-l<c) {
        l=l%c;
        r=r%c;
        if (l<r) {
            ans = c;
            for (int i=l;i<=r-1;i++) {
                for (int j=i+1;j<=r;j++) ans=min(ans,(i*j)%c);
            }
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    S = []
    max_move = 0
    for _ in range(H):
        S.append(list(input()))

    for hs in range(H):
        for ws in range(W):
            if S[hs][ws] == '#':
                continue
            answer = bfs(S, H, W, hs, ws)
            if max_move < answer:
                max_move = answer
    print(max_move)

def bfs(S, H, W, hs, ws):
    visited = [[-1] * W for _ in range(H)]
    s = (hs, ws, 0)
    queue = [s]
    c = s
    max_c = 0
    while len(queue) > 0:
        c = queue.pop(0)
        count = c[2]
        if count > max_c:
            max_c = count
        # 確認済みに追加
        visited[c[0]][c[1]] = 1
        # 上
        enqueue(c[0] - 1, c[1], S, H, W, queue, count, visited)
        # 左
        enqueue(c[0], c[1] - 1, S, H, W, queue, count, visited)
        # 下
        enqueue(c[0] + 1, c[1], S, H, W, queue, count, visited)
        # 右
        enqueue(c[0], c[1] + 1, S, H, W, queue, count, visited)
    # 最短距離を返す
    return max_c

def enqueue(i, j, S, H, W, queue, count, visited):
    if i >= 0 and i < H and j >= 0 and j < W and visited[i][j] == -1 and S[i][j] == '.':
        queue.append((i, j, count + 1))
        visited[i][j] = 1

main()


Measured memory_bytes: 3188
import java.util.*;
import java.text.DecimalFormat;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextInt();
    long b = sc.nextInt();
    sc.close();

    for(int i = 0; i < 3; i++) {
      switch (i) {
        case 0:
          long d = a / b;
          System.out.print(d + " ");
          break;
        case 1:
          long r = a % b;
          System.out.print(r + " ");
          break;
        case 2:
          DecimalFormat f = new DecimalFormat("0.00000");
          double e = (double)a / (double)b;
          System.out.print(f.format(e));
          break;
      }
    }
  }
}


Measured memory_bytes: 26352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N=sc.nextInt();
        int[] a=new int[N];
        
        int count=0;
        
        
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt()-1;
            
        }
        for(int i=0;i<N;i++) {
			if(i==a[a[i]]){
			    count+=1;
			}
		}
        
        System.out.println(count/2);
        
        
        
        
    }
}


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

typedef long long ll;
typedef unsigned long long llu;
typedef long double ldo;
template <class C> void setmin(C &a,C b){if(a>b)a=b;}
template <class C> void setmax(C &a,C b){if(a<b)a=b;}
#define MOD				(ll)1000000007
#define pp				pair<ll,ll>
#define vll				vector<ll>
#define vpp				vector<pp>
#define forz(iter,n)	for(ll iter=0;iter<n;++iter)
#define urep(iter,s,e)	for(ll iter=s;iter>=e;--iter)
#define rep(iter,s,e)	for(ll iter=s;iter<e;++iter)
#define print(A,n)		{forz(iter,n)cout<<A[iter]<<' ';cout<<endl;}
#define printv(vec)		{for(auto const&iter:vec)cout<<iter<<' ';cout<<endl;}
#define take(A,n)		{forz(iter,n)cin>>A[iter];}
#define pb				push_back
#define pob				pop_back
#define eb				emplace_back
#define pf				push_front
#define pof				pop_front
#define mkp				make_pair
#define all(a)			a.begin(),a.end()
#define ff				first
#define ss				second
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define bs(v,x)			binary_search(all(v),x)
#define ub(v,x)			upper_bound(all(v),x)		//x>a[<-pos]
#define lb(v,x)			lower_bound(all(v),x)		//x<=a[pos->]
#define zoom			ios_base::sync_with_stdio(false);cin.tie(NULL);
//for(auto const&x:mp)

int main()
{
	zoom;
	ll n,h,w;
	cin>>n>>h>>w;
	ll cc=0;
	forz(i,n)
		forz(j,n)
		{
			if((i+h-1<n)&&(j+w-1<n))
				cc++;//,cout<<i<<j<<endl;
		}
	cout<<cc<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define M(x) ((x) % MOD)
#define N 100001
using namespace std;

typedef unsigned ui;
typedef long long ll;
typedef unsigned long long ul;

ui a[N];

int main(void) {
	ios::sync_with_stdio(0); cin.tie(0);
#ifdef _DEBUG
	ifstream cin("1.in");
#endif
	ui n; cin >> n;
	for (ui i = 0; i != n; ++i) cin >> a[i];
	sort(a, a + n);
	ui x = 0, sum = 0;
	for (ui i = 0; i != n; ++i) sum += a[i];
	while (x != n && a[x] % 10 == 0) x++;
	if (x == n) cout << 0 << endl;
	else if (sum % 10 == 0) cout << sum - a[x] << endl;
	else cout << sum << endl;
	return 0;
}

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

int main(void) {
	char people[300000];
	int n, dir[300001][2] = { 0 },min = 3000000;
	scanf("%d", &n);
	scanf("%s", people);
	for (int i = 0; i < n; i++) {
		if (people[i] == 'E')dir[i + 1][0] = dir[i][0] + 1, dir[i + 1][1] = dir[i][1];
		else dir[i + 1][1] = dir[i][1] + 1, dir[i + 1][0] = dir[i][0];
	}

	for (int i = 1; i <= n; i++) {
		if ((dir[i - 1][1] - dir[0][1]) + (dir[n][0] - dir[i][0]) < min)
			min = (dir[i - 1][1] - dir[0][1]) + (dir[n][0] - dir[i][0]);
	}
	printf("%d\n", min);

}

Measured memory_bytes: 2816
n, t = map(int, input().split())
tl = list(map(int, input().split()))
time = 0
to = 0
for i in range(n):
    if t <= tl[i]-to:
        time += t
        to = tl[i]
    else:
        time += tl[i]-to
        to = tl[i]
else:
    time += t
print(time)

Measured memory_bytes: 26832
#include <iostream>

using namespace std;

typedef long long ll;
const int maxn=300000+10;
const ll mod=998244353;

ll n,a,b,k;
ll fac[maxn],inv[maxn];

ll qpow_mod(ll x,ll n)
{
    int s=1;
    while(n)
    {
        if(n&1) s=s*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return s;
}

void csh()
{
    fac[0]=1;
    for(int i=1;i<=300000;i++) fac[i]=fac[i-1]*i%mod;
    inv[300000]=qpow_mod(fac[300000],mod-2);
    for(int i=300000;i>0;i--) inv[i-1]=inv[i]*i%mod;
}

ll C(ll n,ll a)
{
    return fac[n]*inv[a]%mod*inv[n-a]%mod;
}

int main()
{
    csh();
    cin>>n>>a>>b>>k;
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        if(((k-i*a)%b!=0)||(k-i*a<0)||((k-i*a)/b>n)) continue;
        ans=(ans+C(n,i)*C(n,(k-i*a)/b))%mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int MX_N = 105;

int N;
vector<int> al[MX_N];
int d[MX_N], p[MX_N];

int bfs(vector<int> s) {
    queue<int> q;
    memset(d,-1,sizeof d);
    for (int u : s) d[u] = 0, q.push(u);
    int far = 1;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        if (d[u]>d[far]) far = u;
        for (int v : al[u]) {
            if (d[v]==-1) p[v] = u, d[v] = d[u]+1, q.push(v);
        }
    }
    //cout<<"bfs :: " << far << endl;
    return far;
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    FOR(i,1,N-1){
        int a, b; cin >> a >> b;
        al[a].push_back(b);
        al[b].push_back(a);
    }

    ll mcol = 1e18, mleaf = 1e18;
    FOR(u,1,N){
        bfs({u});
        int maxd = 0, maxi[N+1];
        FOR(i,1,N) maxi[i] = 1;
        FOR(i,1,N) maxd = max(maxd,d[i]), maxi[d[i]] = max(maxi[d[i]], SZ(al[i])-1);
        ++maxd;
        ll ans = SZ(al[u]);
        bool skip = 0;
        FOR(i,1,N) {
            ans *= maxi[i];
            if (ans > 1e16) { skip = 1; break; }
        }
        if (!skip) {
            if (maxd < mcol) mcol = maxd, mleaf = ans;
            else if (maxd == mcol) mleaf = min(mleaf, ans);
        }

        for (auto& v : al[u]) {
            bfs({u,v});
            int maxd = 0, maxi[N+1];
            FOR(i,1,N) maxi[i] = 1;
            FOR(i,1,N) maxd = max(maxd,d[i]), maxi[d[i]+1] = max(maxi[d[i]+1], SZ(al[i])-1);
            ++maxd;
            ll ans = 2;
            bool skip = 0;
            FOR(i,1,N) {
                ans *= maxi[i];
                if (ans > 1e16) { skip = 1; break; }
            }
            if (!skip) {
                if (maxd < mcol) mcol = maxd, mleaf = ans;
                else if (maxd == mcol) mleaf = min(mleaf, ans);
            }
            //if (1 || (i == 2 && v == 4)) {
            //    cout << "EDGE " << i << ' ' << v << endl;
            //    FOR(i,1,N) cout << d[i]+1 << " :: " << SZ(al[i])-1 << endl;
            //    FOR(i,1,N) cout << maxi[i] << ' ';
            //    cout << endl;
            //    cout << maxd << " " << ans << " :: " << mcol << " " << mcol << endl;
            //}
        }
    }
    cout << mcol << ' ' << mleaf;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

//----------------library in this time--------------------------------
template <typename T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <typename T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <typename T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

//------------------------main function-------------------------------
void Main(){
    i64 a, b;
    cin >> a >> b;
    i64 sum = a + b, dif = a - b, pro = a * b, ans = 0;
    ans = max(sum, dif);
    ans = max(ans, pro);
    cout << ans << endl;
}
//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    
    Main();
    return 0;
}

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

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (auto &a : A)
    cin >> a;
  int ans = N;
  for (auto x : A) {
    ans -= x;
  }
  cout << (ans >= 0 ? ans : -1) << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

vector <int> yakusus(int k){
    vector <int> ret;
    for(int i=1; i<=k-1; i++){
        if (k%i == 0){
            ret.push_back(i);
        }
    }
    //dump(k)
    //dumparr(ret)
    return ret;
}

int main(void){
    int n; cin >> n;
    vector <int> as;
    int a;
    REP(i, n){
        cin >> a;
        as.push_back(a);
    }
    vector <vector <int>> yakusus;
    REP(i, n+1){
        vector <int> d;
        yakusus.push_back(d);
    }
    for(int i=1; i<=n; i++){
        for(int j=i; j<=n; j+=i){
            yakusus[j].push_back(i);
        }
    }
    vector <int> balls;
    for(int i=n-1; i>=0; i--){
        if (as[i] == 1){
            balls.push_back(i+1);
            for(auto y: yakusus[i+1]){
                if (as[y-1] == 0){as[y-1]=1;} else {as[y-1]=0;}
            }
        }
    }
    cout << balls.size() << endl;
    REP(i, balls.size()){
        if (i < balls.size()-1){
            cout << balls[i] << " ";
        } else {
            cout << balls[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 23912
import java.util.Scanner;

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

		while (true) {

			String word = scan.next();
			char chara;
			int side;
			int preside = 0;
			int count = 0;

			if (word.equals("#"))
				break;

			for (int i = 0; i < word.length(); i++) {
				chara = word.charAt(i);
				if (chara == 'q' || chara == 'w' || chara == 'e'
						|| chara == 'r' || chara == 't' || chara == 'a'
						|| chara == 's' || chara == 'd' || chara == 'f'
						|| chara == 'g' || chara == 'z' || chara == 'x'
						|| chara == 'c' || chara == 'v' || chara == 'b') {
					side = 0;
				} else {
					side = 1;
				}
				if (i == 0) {
					preside = side;
				} else if (preside != side) {
					count++;
				}
				preside = side;

			}
			System.out.println(count);
		}

	}
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
    ll h=0,w=0;
    cin>>h>>w;
    if(h==1 ||  w==1)
        cout<<"1";
    else if(h*w%2==0)
        cout<<h*w/2;
    else
        cout<<(h*w)/2+1;



    }

    return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

ll N;
string A, B, C;
int main(){
   cin >> N >> A >> B >> C;
   ll ans = 0;
   REP(i, N){
      set<char> s = {};
      s.insert(A[i]); s.insert(B[i]); s.insert(C[i]);
      if (s.size() == 3){
         ans += 2;
      }
      else if (s.size() == 2){
         ans += 1;
      }
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = list(inputs[0])

    types = 0
    prev_color = None

    for c in S:
        if prev_color != None and prev_color != c:
            types += 1
        prev_color = c
    types += 1
    return types


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 4084
lst = []

for i in range(6):
    r = int(input())
    lst.append(r)
    

for i in range(4):
    for j in range(3,i,-1):
        if lst[j] < lst[j-1]:
            lst[j],lst[j-1] = lst[j-1],lst[j]
    

R = lst[1]+lst[2]+lst[3]

if lst[4] > lst[5]:
    S = lst[4]
else:
    S = lst[5]

print(R+S)


Measured memory_bytes: 5600
N = int(input())
A = list(map(int,input().split()))
x2 = A[0]
for i in range(2, N+1):
    if i % 2 == 0:
        x2 += A[i-1]
    else:
        x2 -= A[i-1]
x2 //= 2
X = [None for i in range(N)]
X[1] = x2
for i in range(2, N):
    X[i] = A[i-1]-X[i-1]
X[0] = A[N-1] - X[N-1]
Y = [str(i*2) for i in X]
print(" ".join(Y))    

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

#define EPS (1e-7)

double calc(){
  int n, m;
  double p = 0, q = 0;
  cin >> n >> m;

  for(int i = 0; i < m; i++){
    double a, b;
    cin >> a >> b;
    p += a * b;
    q += b;
  }

  return p / q;
}

int main(){
  int T;

  while(cin >> T){
    double mymax = 0;

    for(int i = 0; i < T; i++){
      mymax = max(mymax, calc());
    }

    cout << (mymax >= calc() + EPS ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
	
	public static class UnionFind {
		int[] par;
		
		public UnionFind(int n){
			par = new int[n];
			for(int i = 0; i < n; i++){
				par[i] = -1;
			}
		}
		
		public int find(int x){
			if(par[x] < 0){
				return x;
			}else{
				return par[x] = find(par[x]);
			}
		}
		
		public boolean union(int x, int y){
			final int root_x = find(x);
			final int root_y = find(y);
			
			if(root_x == root_y){
				return false;
			}
			
			final int size = par[root_x] + par[root_y];
			
			if(par[root_x] < par[root_y]){ // size(root_x) > size(root_y)
				par[root_y] = root_x;
				par[root_x] = size;
			}else{
				par[root_x] = root_y;
				par[root_y] = size;
			}
			
			return true;
		}
		
		public boolean same(int x, int y){
			return find(x) == find(y);
		}
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		final int m = sc.nextInt();
		
		UnionFind uf = new UnionFind(n);
		for(int i = 0; i < m; i++){
			final int s = sc.nextInt();
			final int t = sc.nextInt();
			
			uf.union(s, t);
		}
		
		final int q = sc.nextInt();
		for(int i = 0; i < q; i++){
			final int s = sc.nextInt();
			final int t = sc.nextInt();
			
			System.out.println(uf.same(s, t) ? "yes" : "no");
		}
	}

	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public void close() throws IOException {
			br.close();
		}
	}

}

Measured memory_bytes: 44224
def digit_num(_num):
    _digit = 0
    while _num:
        _digit += 1
        _num //= 10
    return _digit

def ACGC021_A():
    _num = int(input())
    _digit = digit_num(_num)
    _topdig = _num // 10 ** (_digit - 1)
    if (_num - _topdig * 10 ** (_digit - 1)) == 10 ** (_digit - 1) - 1:
        print(_topdig + 9 * (_digit - 1))
    else:
        print(_topdig - 1 + 9 * (_digit - 1))

ACGC021_A()

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <queue>

using namespace std;


int main()
{
    priority_queue<int> pq;

    while ( true ) {
	char str[100];
	scanf("%s", str);
	if ( !strcmp( str, "end" ) ) break;
	if ( !strcmp( str, "insert" ) ) {
	    int d;
	    scanf("%d", &d);
	    pq.push(d);
	}
	else {
	    int d = pq.top();
	    pq.pop();
	    printf("%d\n", d);
	}
    }

    return 0;
}

Measured memory_bytes: 6324
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

P p[5000];
int dp[5000][3000], pos[2][50000];

class BIT{
public:
	int n = 1;
	vector<int> bit;
	//[1, m]のBIT作成
	void init(int m){
		while(n < m+1)n *= 2;
		bit.resize(n);
		fill(all(bit), 0);
	}
	
	void add(int i, int x){
		while(i <= n){
			bit[i] += x;
			i += i&-i;
		}
	}
	
	int get(int i){
		int s = 0;
		while(i > 0){
			s += bit[i];
			i -= i&-i;
		}
		return s;
	}
};

BIT bit;
int n;
int dist(int c, int i, int x){
	int ans = pos[c][x]+bit.get(2*n)-bit.get(pos[c][x])-i;
	return ans;
}

signed main(){
	scanf("%lld", &n);
	rrep(i,2*n){
		char c;
		int x;
		scanf(" %c %lld", &c, &x);
		int cc = (c == 'B' ? 0 : 1);
		p[i] = P(cc, x);
		pos[cc][x] = i;
	}
	
	fill((int*)dp, (int*)(dp+5000), inf);
	dp[0][0] = 0;
	rrep(i,2*n){
		bit.init(2*n);
		rrep(j,min(i, n))bit.add(pos[1][j], 1);
		rep(j,n+1){
			if(i < j or i-j > n){
				if(j+1 <= n)bit.add(pos[0][j+1], 1);
				continue;
			}
			int a = j, b = i-j;
			if(b > 0)chmin(dp[i][a], dp[i-1][a]+dist(1, i, b));
			if(a > 0)chmin(dp[i][a], dp[i-1][a-1]+dist(0, i, a));
			if(b > 0)bit.add(pos[1][b], -1);
			if(a+1 <= n)bit.add(pos[0][a+1], 1);
		}
	}
	
	/*rrep(i,2*n){
		rep(j,n+1){
			if(dp[i][j] != inf)printf("%lld ", dp[i][j]);
			else printf("-1 ");
		}
		printf("\n");
	}*/
	printf("%lld\n", dp[2*n][n]);
	return 0;
}




Measured memory_bytes: 117504
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, ta[26][50], mu;
string s[50];

signed main() {
	cin >> n;
	rep(i, n) {
		cin >> s[i];
		rep(j, s[i].size()) {
			ta[s[i][j] - 'a'][i]++;
		}
	}
	vector<char> rin;
	rep(i, 26) {
		mu = 100;
		rep(j, n) {
			if (ta[i][j] < mu)mu = ta[i][j];
		}
		while (mu > 0) {
			rin.push_back(i + 'a');
			mu--;
		}
	}
	rep(i, rin.size())cout << rin[i];
	cout << endl;
	ggr
}

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

int main(){
    char c;
    int a = 700;
    for(int i = 0; i < 3; ++i){
        scanf("%c", &c);
        if(c == 'o'){
            a += 100;
        }
    }
    printf("%d\n", a);
    return 0;
}


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

int func() {
  vector<int> lst = { 1, 2, 3 };  // 昇順にソートされた配列
  do {
    cout << lst.at(0) << " " << lst.at(1) << " " << lst.at(2) << endl;
  } while (next_permutation(lst.begin(), lst.end()));
}

int main() {
  int N; cin >> N;
  vector<int> P(N), Q(N), R(N);
  for (int i = 0; i < N; i++) cin >> P.at(i);
  for (int i = 0; i < N; i++) cin >> Q.at(i);
  for (int i = 0; i < N; i++) R.at(i) = i + 1;
  int a, b;
  int tmp = 1;
  do {
    bool match = true;
    for (int i = 0; i < N; i++) {
      if (P.at(i) != R.at(i)) match = false;
    }
    if (match) a = tmp;
    tmp++;
  } while (next_permutation(R.begin(), R.end()));
  tmp = 1;
  do {
    bool match = true;
    for (int i = 0; i < N; i++) {
      if (Q.at(i) != R.at(i)) match = false;
    }
    if (match) b = tmp;
    tmp++;
  } while (next_permutation(R.begin(), R.end()));
  
  cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 1e6 + 1000;
int n,a[N];
ll tr[N];
ll A,P,Q;
int lowbit(int x){return x & -x;}
ll ask(int pos){ll res = 0; for(;pos;pos -= lowbit(pos)) res += tr[pos]; return res;}
void add(int pos,int v){for(;pos <= n;pos += lowbit(pos)) tr[pos] += v; return;}

int main()
{
	n = read(); for(int i = 1;i <= n;i ++) if((i & 1) != ((a[i] = read()) & 1)) {puts("No"); return 0;}
	for(int i = n;i >= 1;i --){A += ask(a[i]); add(a[i],1);}
	if(A % 3) {puts("No"); return 0;}
	for(int i = 1;i <= n;i ++) tr[i] = 0;
	for(int i = n;i >= 1;i -= 2){P += ask(a[i]); add(a[i],1);}
	for(int i = 1;i <= n;i ++) tr[i] = 0;
	for(int i = n - 1;i >= 1;i -= 2){Q += ask(a[i]); add(a[i],1);}
	if(P + Q != A / 3) {puts("No"); return 0;}
	else {puts("Yes"); return 0;}
}


Measured memory_bytes: 8448
# -*- coding: utf-8 -*-

nums = [int(e) for e in input().split()]

n = [int(e) for e in input().split()]

short = 0
# print(nums[1])
# print(n[int(nums[1]-1)])

n.append(nums[0] + n[0])
# print(n)
# print(range(nums[1]))

# short = n[1] - n[0]

for i in range(nums[1]):
    # if i < int(nums[1]-1):
    # print("a",n[i+1], n[i])
    if n[i+1] - n[i] >= short:
        short = n[i+1] - n[i]

print(nums[0] - short)


Measured memory_bytes: 26444
//
//  main.c
//  q_03_02
//
//  Created by k19104kk on 2020/08/29.
//  Copyright © 2020 AIT. All rights reserved.
//
 
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
    long long n;
    scanf("%lld", &n);
    
    long long ai[n], as[n];
    
    for (int i=0; i<n; i++) {
        scanf("%lld", &ai[i]);
        
        if (i==0) {
            as[i] = ai[i];
        } else {
            as[i] = as[i-1]+ai[i];
        }
    }
    
    long long result = 0;
    
    long long waru = 1000000007;
    
    for (int i=1; i<n; i++) {
       result += (ai[i]%waru) * ((as[i-1])%waru);
       result %= waru;
       // result += (ai[i]%waru) * ((as[n-1]-as[i])%waru);
       // result %= waru;
    }
    
    printf("%lld\n", result);
    return 0;
}

Measured memory_bytes: 4832
#include<stdio.h>
int main()
{
    int i, arr[5], count=0;
  for(i=0; i<5; i++)
  {
      scanf("%d", &arr[i]);
      if(arr[i] == 0) count=i+1;
      else continue;
  }
  printf("%d\n", count);

  return 0;

}


Measured memory_bytes: 1732
input = gets.chomp.split("\s")
a, b = input[0].to_i, input[1].to_i

until (a == 0) && (b == 0)
	if a > b
		print(b, " ", a, "\n")
	else
		print(a, " ", b, "\n")
	end
	
	input = gets.chomp.split("\s")
	a, b = input[0].to_i, input[1].to_i
end

Measured memory_bytes: 6104
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int A, B;
   cin >> A >> B;
   if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;
   else cout << "Impossible" << endl;
   return 0;
}


Measured memory_bytes: 256
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

vi v;

void bfs(int n, int m, int num) 
{ 
	queue<int> q; 

	q.push(num); 

	while (!q.empty()) 
	{ 
		int stepNum = q.front(); 
		q.pop(); 

		if (stepNum <= m && stepNum >= n) 
			v.push_back(stepNum);

		if (num == 0 || stepNum > m) 
			continue; 

		int lastDigit = stepNum % 10; 

		int stepNumA = stepNum * 10 + (lastDigit- 1); 
		int stepNumC=stepNum*10+lastDigit;
		int stepNumB = stepNum * 10 + (lastDigit + 1); 

		if (lastDigit == 0) {
			q.push(stepNumB); 
			q.push(stepNumC);
		}

		else if (lastDigit == 9) {
			q.push(stepNumA); 
			q.push(stepNumC);
		}

		else
		{ 
			q.push(stepNumA); 
			q.push(stepNumB);
			q.push(stepNumC); 
		} 
	} 
} 
 
void displaySteppingNumbers(int n, int m) 
{ 

	for (int i = 1 ; i <= 9 ; i++) 
		bfs(n, m, i); 
} 

int32_t main() 
{
	int n = 0, m = 3234566667; 
	int k;cin>>k;

	displaySteppingNumbers(n,m);
	sort(v.begin(),v.end());
	cout<<v[k-1];
	return 0; 
} 


Measured memory_bytes: 1636
from collections import Counter
n = int(input())
s = list()
li = [0]*5
for _ in range(n):
    k = input()[0]
    if k=="M":
        li[0]+=1
    elif k=="A":
        li[1]+=1
    elif k=="R":
        li[2]+=1
    elif k=="C":
        li[3]+=1
    elif k=="H":
        li[4]+=1

import itertools
li = itertools.combinations(li,3)
ans = 0
for k in li:
    cnt  =1
    for i in k:
        cnt*=i
    ans += cnt
print(ans)

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

int main(){
    while (1){
        int x,y;
        cin>>x>>y;
        if (x==0 && y==0){
            break;
        }else{
            if (y<x){
                cout<<y<<" "<<x<<endl;
            }else{
                cout<<x<<" "<<y<<endl;
            }
        }
    }
}


Measured memory_bytes: 3000
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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 inf = 1001001001;
const ll linf = 1001001001001001001;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator++() { x += 1; return *this;}
  mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
  mint& operator--() { x -= 1; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { mint res(*this); return res+=a; }
  mint operator-(const mint a) const { mint res(*this); return res-=a; }
  mint operator*(const mint a) const { mint res(*this); return res*=a; }
  bool operator==(const int n) const { mint a(n); return this->x == a.x; }
  bool operator==(const ll n) const { mint a(n); return this->x == a.x; }
  bool operator!=(const int n) const { mint a(n); return this->x != a.x; }
  bool operator!=(const ll n) const { mint a(n); return this->x != a.x; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<mint>> dp(n,vector<mint>(2,0));
    dp[0][0] = mint(2);
    dp[0][1] = mint(1);
    rep(i,n-1) rep(j,2){
        if(j == 0) {
            dp[i+1][0] += dp[i][0]*(s[i+1]=='1' ? 2 : 1);
            dp[i+1][1] += dp[i][0]*(s[i+1]=='1' ? 1 : 0);
        } else {
            dp[i+1][1] += dp[i][j]*3;
        }
    }
    mint ans = dp[n-1][0]+dp[n-1][1];
    cout << ans.x << endl;
}


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

int n;
int a[100010];
int dp[100010];


int rek(int x) {
	if (x == n-1) return 0;
	int &ret = dp[x];
	if (ret != -1) return ret;
	
	ret = rek(x+1)+abs(a[x]-a[x+1]);
	if (x+2 < n) {
		ret = min(ret, rek(x+2)+abs(a[x]-a[x+2]));
	}
	
	return ret;
}

int main () {
	
	cin >> n;
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
		dp[i] = -1;
	}
	
	cout << rek(0);
	
	return 0;
}

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

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 5;
const int INF = 2e9;
map<int, int> fn;
set<int> f;
void primF(ll n){
    int cnt[1001];
    memset(cnt, 0, sizeof cnt);
    while(n % 2 == 0){
        cnt[2]++;
        f.insert(2);
        n /= 2;
    }
    fn[2] = max(fn[2], cnt[2]);
    for(int i = 3; i <= sqrt(n); i += 2){
        while(n % i == 0){
            cnt[i]++;
            f.insert(i);
            n /= i;
        }
    }
    if(n > 2){
        f.insert(n);
        fn[n] = max(1, fn[n]);
    }
    for(int i = 0; i <= 1000; i++){
        if(cnt[i]){
            fn[i] = max(fn[i], cnt[i]);
        }
    }
}
long long modPow(ll p, long long pow){
    long long ans = 1;
    //long long p = 2;
    while(pow){
        if(pow & 1)
            ans = (ans * p) % 1000000007;
        p = (p * p) % 1000000007;
        pow >>= 1;
    }
    return ans;
}
int main() {
    //usaco("milkvisits");

#ifdef LOCAL
    setIn("in.txt");
    setOut("out.txt");
#endif

    ll n;
    cin >> n;

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

    ll nm = 1;
    for(auto x : f){
        //cout << x << " " << fn[x] << endl;
        nm = (nm * modPow(x, fn[x])) % MOD;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans = (ans + nm * modPow(a[i], MOD - 2)) % MOD;
    }
    //cout << nm << endl;
    cout << ans << endl;
}

Measured memory_bytes: 1280
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))

L=[0]
R=[0]
for i in range(n-1):
    L.append(gcd(L[i],a[i]))
    #R.insert(0,gcd(R[-1-i],a[-1-i]))
    R.append(gcd(R[i],a[-1-i]))
#print(L)
#print(R)
ans = 0
for i in range(n):
  #ans = max(ans,gcd(L[i],R[i]))
  ans = max(ans,gcd(L[i],R[-1-i]))
print(ans)

Measured memory_bytes: 94688
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int main() {

    int n, r;
    scanf("%d %d", &n, &r);

    printf("%d", (n >= 10 ? r : r + 100 * (10 - n)));


    return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<string.h>
using namespace std;
int main() {
	int row, jump;
	int dp[151][11][76];
	int val[151][11];
	int Size[151];
	int num[151][11];

	while (cin >> row >> jump, row)
	{
		
		for (int i = 0; i < row; i++) {
			cin >> Size[i];
			for (int j = 0; j < Size[i]; j++) {
				cin >> num[i][j] >> val[i][j];
			}
		}

		memset(dp, 0x7f, sizeof(dp));			//初期化
		for (int i = 0; i < Size[0]; i++)		//岸からのジャンプ
			dp[0][i][0] = 0;
		for (int i = 0; i < Size[1]; i++)
			dp[1][i][1] = 0;

		for (int i = 0; i < row-1; i++) {
			for (int j = 0; j < Size[i]; j++) {
				for (int k = 0; k < Size[i + 1]; k++) {
					int risk = (val[i][j] + val[i + 1][k])*abs(num[i][j] - num[i+1][k]);
					for (int m = 0; m <= jump; m++)
						dp[i + 1][k][m] = min(dp[i + 1][k][m], dp[i][j][m] + risk);
				}
				if (i == row - 2)continue;
				for (int k = 0; k < Size[i + 2]; k++) {
					int risk = (val[i][j] + val[i + 2][k])*abs(num[i][j] - num[i + 2][k]);
					for (int m = 0; m < jump; m++)
						dp[i + 2][k][m+1] = min(dp[i + 2][k][m+1], dp[i][j][m] + risk);
				}
			}

		}
		int Min = 0x7f7f7f7f;

		for (int i = 0; i < Size[row - 1]; i++)
			for (int j = 0; j <= jump; j++) {
				Min = min(Min, dp[row - 1][i][j]);

			}
		for (int i = 0; i < Size[row - 2]; i++)
			for (int j = 0; j < jump; j++)
				Min = min(Min, dp[row - 2][i][j]);
		
		cout << Min << endl;
	}
	return 0;
}


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

const ll M = 1000000007;
vector<ll> fac(300001);
vector<ll> ifac(300001);

//べき乗高速化
ll mpow(ll x, ll n){
	ll ans = 1;
	while(n != 0){
		if (n&1) ans = ans * x % M;
		x = x*x % M;
		n  = n >> 1;
	}
	return ans;
}

//aCbを計算
ll comb(ll a, ll b){
	if (a == 0 && b == 0) return 1;
	if (a < b || a < 0){
		return 0;
	}
	ll temp = ifac[a-b] * ifac[b] % M;
	return temp * fac[a] % M;
}

int main(){
	ll n,k;
	
	cin >> n >> k;
	
	fac[0] = 1;
	ifac[0] = 1;
	
	for (ll i = 0; i < 300000; ++i) {
		fac[i+1] = fac[i] * (i+1) % M;
		ifac[i+1] = ifac[i] * mpow(i+1,M-2) % M;
	}
	
	for (ll i = 1; i <= k; ++i) {
		ll ans1 = comb(n-k+1,i) % M;
		ll ans2 = comb(k-1,i-1) % M;
		cout << ans1 * ans2 % M << endl;
	}
	
	
}




Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N + 1, vector<int>());
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> fennec(N + 1, 0), snuke(N + 1, 0);
    function<void(int, int, vector<int>*)> dfs = [&](int now, int before, vector<int>* temp) {
        if (before != -1) (*temp)[now] = (*temp)[before] + 1;
        for (auto i : G[now]) if (i != before) dfs(i, now, temp);
    };
    dfs(1, - 1, &fennec);
    dfs(N, -1, &snuke);
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (fennec[i] <= snuke[i]) ++ans;
    }
    if (ans - 1 >= N / 2) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

}

Measured memory_bytes: 16640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "1\n0\n";
    } else if (n == 2) {
        cout << "2\n0\n11\n";
    } else {
        cout << n-1 << '\n';
        for (int i=0; i<n-1; i++) {
            cout << "1" + string(i, '0') + "1" << '\n';
        }
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ull H;
    cin >> H;
    int msb = sizeof(ull) * 8 -  __builtin_clzll(H);
    cout << (((ull)1 << msb) - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    A = Scanner.map_int()
    now = 1
    ans = 0
    for i in range(N):
        if now == A[i]:
            now += 1
        else:
            ans += 1
    ans = ans if ans != N else -1
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 72484
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e12;


long cnt[1000001];

int main(){
	long n;
	cnt[0]=0;cnt[1]=0;cnt[2]=1;
	for(long i=3;i<1000000;i++){
		bool flag=true;
		for(long j=2;j*j<=i;j++)if(i%j==0){
			flag=false;
			break;
		}
		if(flag)cnt[i]=cnt[i-1]+1;
		else cnt[i]=cnt[i-1];
	}
	
	while(cin>>n)cout<<cnt[n]<<endl;
	return 0;
}

Measured memory_bytes: 8972