akhauriyash/Code-Regression huggingface dataset:
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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():
    N, M = map(int, input().split())

    MOD = 10 ** 9 + 7
    c = collections.Counter(prime_factorize(M))
    ans = 1
    for i, j in c.items():
        ans *= cmb(N+j-1,N-1)
        ans %= MOD

    print(ans)

main()

Measured memory_bytes: 38512
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <complex>
#include <iomanip>
#include <bitset>
#include <random>
#include <vector>
#include<string>

using namespace std;

int main() {
	long x, y, z, k, a[1111], b[1111], c[1111], i, j,l,t=0,p[1111111];
	cin >> x >> y >> z >> k;
	for (i = 0; i < x; i++)
		cin >> a[i];
	sort(a, a + x);
	for (i = 0; i < y; i++)
		cin >> b[i];
	sort(b, b + y);
	for (i = 0; i < z; i++)
		cin >> c[i];
	sort(c, c + z);
	for (i = 1; i <= x && i <= k; i++) {
		for (j = 1; j <= y && i*j <= k; j++) {
			for ( l= 1; l <= z && i*j*l <= k; l++) {
				p[t] = a[x - i] + b[y - j] + c[z - l];
				t++;
			}
		}
	}
	sort(p, p + t);
	for (i = 1; i <=k; i++)
		cout << p[t-i] << endl;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define inf 1111111111
using namespace std;

int h, n, dp[40001], a[1001], b[1001], dif, rez = inf;

int main()
{
    cin >> h >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i <= h; ++i) dp[i] = inf;

    dp[h] = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = h; j >= 0; --j)
        {
            dp[max(0, j - a[i])] = min(dp[max(0, j - a[i])], dp[j] + b[i]);
        }
        rez = min(rez, dp[0]);
    }
    cout << rez;
    return 0;
}


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

const int maxn = 305;

double dp[maxn][maxn][maxn];

int main()
{

  int n;
  cin >> n;
  int cnt1 = 0, cnt2 = 0, cnt3 = 0;
  for(int i = 0; i < n ; i++)
  {
    int a;
    cin >> a;
    if(a == 1)
      cnt1++;
    else if(a == 2)
      cnt2++;
    else
      cnt3++;
  }

  for(int c = 0; c <= n; c++)
  {
    for(int b = 0; b <= n; b++)
    {
      for(int a = 0; a <= n; a++)
      {
        int k = a + b + c;
        if(k == 0)
          continue;
        if(k > n)
          continue;
        dp[a][b][c] += (1.0 * n)/k;
        if(a)
          dp[a][b][c] += (1.0 * a)/k * dp[a - 1][b][c];
        if(b)
          dp[a][b][c] += (1.0 * b)/k * dp[a + 1][b - 1][c];
        if(c)
          dp[a][b][c] += (1.0 * c)/k * dp[a][b + 1][c - 1]; 
      }
    }
  }

  cout<< fixed << setprecision(10) << dp[cnt1][cnt2][cnt3] << endl;
  return 0;
}

Measured memory_bytes: 112548
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>
#include <typeinfo>
#include <memory>


using namespace std;

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

#define fs first
#define sc second


ll gcd(ll x, ll y){
    ll r = x % y;
    while(r != 0){
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}



int main(){
    string s;
    cin >> s;
    bool res = true;
    for(int i = 0; i < 3; i++){
        if(s[i] == s[i+1]){
            res = false;
        }
    }

    if(res){
        cout << "Good" << endl;
    }
    else{
        cout << "Bad" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#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)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    string s;cin>>s;
    int bcnt=0;
    ll ans=0;
    for(char c : s){
        if(c=='B'){
            bcnt++;
        }else{
            ans+=bcnt;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 640
///                                                     ببِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define vec  vector
#define gcd  __gcd
#define pi   acos( -1 )
#define ll   long long
#define ld   long double
#define N    100256
#define M    1000000007
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define rep( a, b, c, d )  for( int a = b; a <= c; a += d )
#define rvv( a, b, c, d )  for( int a = b; a >= c; a -= d )
#define en                 printf( "\n" )
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() )
#define numcounts          __builtin_popcount
#define mxn( x, y, z )     max( x, min( y, z ) )
#define mnx( x, y, z )     min( x, max( y, z ) )
const int dx[ ] = { 1, -1, 0, 0 };
const int dy[ ] = { 0, 0, -1, 1 };
using namespace std;
ll ttt = 1;
ll n, m, a[1005][1005];
char c;
void solve()
{
    cin >> n >> m;
    a[1][1] = 1;
    for( int i = 1; i <= n; i ++ )
        for( int j = 1; j <= m; j ++ )
        {
            cin >> c;
            if( c == '.' )
            {
                a[i][j] += a[i-1][j];
                a[i][j] += a[i][j-1];
                a[i][j] %= M;
            }
        }
    cout << a[n][m];
}
int main()
{
    //sc( "%I64d", &ttt );
    for( int i = 0; i < ttt; i ++ )
        solve();
}














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

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

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

w,h,n=MI()
xmx=w
ymx=h
xmn=0
ymn=0
for i in range(n):
    x,y,a=MI()
    if a==2:
        xmx=min(x,xmx)
    if a==1:
        xmn=max(x,xmn)
    if a==4:
        ymx=min(y,ymx)
    if a==3:
        ymn=max(y,ymn)
    #print(xmn,xmx,ymn,ymx)
print(max(xmx-xmn,0)*max(ymx-ymn,0))

Measured memory_bytes: 65872
#include <iostream>


int main() {

    int A, B, K;
    std::cin >> A >> B >> K;

    int i=0;
    for (i=A; i<=std::min(A+K-1, B); i++) std::cout << i << std::endl;
    for (i=std::max(i, B-K+1); i<=B; i++) std::cout << i << std::endl;

    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		for(int i=0;i<N;i++) {
			array[i] = sc.nextInt();
		}
		for(int k=0;k<N;k++) {
			if(k!=N-1) {
				System.out.print(array[k]+" ");
			}else {
				System.out.print(array[k]);
			}
		}
		System.out.println();

		for(int i=1;i<N;i++) {
			int v = array[i];
			int j = i-1;
			while(j>=0 && array[j] > v) {
				array[j+1] = array[j];
				j--;
				array[j+1] = v;
			}
			for(int k=0;k<N;k++) {
				if(k!=N-1) {
					System.out.print(array[k]+" ");
				}else {
					System.out.print(array[k]);
				}
			}

			/*if(i!=N-1)*/System.out.println();
		}




	}
}



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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readB(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		B = new int[N];
	}

	public void readB(String str) {
		String[] strArr = str.split("\\s+");
		for (int i = 0; i < N - 1; i++)
			B[i + 1] = Integer.parseInt(strArr[i]);
	}

	int[] B;

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {
		long ans = 0;
		for (int i = 1; i <= N; i++) {
			if (i == 1)
				ans += B[i];
			else if (i == N)
				ans += B[i - 1];
			else
				ans += Integer.min(B[i], B[i - 1]);
		}
		System.out.println(ans);
	}
}


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

int main() {
    ll n;
    std::cin >> n;
    vector<vector<pair<ll,ll>>> data(n, vector<pair<ll,ll>>());
    
    for (int i = 0; i < n; i++) {
        ll t;
        std::cin >> t;
        for (int j = 0; j < t; j++) {
            ll x,y;
            std::cin >> x>>y;
            x--;
            data[i].push_back({x,y});
        }
    }
    ll res = 0;
    for (int i = 0; i < 1<<n; i++) {
        vector<ll> honto(n,0);
        // 0 データなし、1ほんとにほんと認定、2ほんとに嘘認定
        bool ok = true;
        ll tmp = 0;
        queue<ll> hontlist;
        for (int j = 0; j < n; j++) {
            if(i & (1<<j)){
                hontlist.push(j);
                honto[j] = 1;
            }
        }
        while(!hontlist.empty()){
            ll a = hontlist.front();hontlist.pop();
            for (auto e : data[a]) {
                if(e.second == 1 && honto[e.first] == 0){
                    hontlist.push(e.first);
                    honto[e.first] = 1;
                }
                if(e.second == 1 && honto[e.first] == 2){
                    ok = false;
                    break;
                }
                if(e.second == 0 && honto[e.first] == 1){
                    ok = false;
                    break;
                }
                if(e.second == 0 && honto[e.first] == 0){
                    honto[e.first] = 2;
                }
            }
        }
        if(ok){
            for (int k = 0; k < n; k++) {
                if(honto[k] == 1)tmp++; 
            }
            res = max(res,tmp);
        }
        
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main() {
    int H,W;
    for(int i=0;i<10000;i++){
        scanf("%d %d",&H,&W);
        if(H==0||W==0)break;
        for(int h=1;h<=H;h++){
            for(int w=1;w<=W;w++)printf("#");
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2596
sx,sy,tx,ty=list(map(int,input().split()))

dx=tx-sx
dy=ty-sy

result=[]
for i in range(dx):
  result.append("R")
for i in range(dy):
  result.append("U")
for i in range(dx):
  result.append("L")
for i in range(dy):
  result.append("D")

result.append("D")  
for i in range(dx+1):
  result.append("R")
for i in range(dy+1):
  result.append("U")
result.append("L")

result.append("U")
for i in range(dx+1):
  result.append("L")
for i in range(dy+1):
  result.append("D")
result.append("R")


print("".join(result))

Measured memory_bytes: 3188
def main():
  ans = [-1, -1, -1]
  N, Y = map(int, input().split())
  for i in range(N+1):
    for j in range(N+1-i):
      if 1000*i + 5000*j + 10000*(N-i-j) == Y:
        ans = [N-i-j, j, i]
  print(*ans)
if __name__ == "__main__":
  main()
      

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main(){
    int a; string bstr;
    cin >> a >> bstr;
    int b = stoi(bstr.substr(0,1)+bstr.substr(2,2));
    int ans = a * b;
    cout << ans / 100 << endl;
}

Measured memory_bytes: 3652
N,M = map(int,input().split())
L = []
for _ in range(M):
    L.append(list(map(int,input().split())))
L = sorted(L,key=lambda x:x[1])
now = -10
cnt = 0
for x in L:
    if now <= x[0]:
        now = x[1]
        cnt += 1
print(cnt)


Measured memory_bytes: 65472
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let ab = lines.next().unwrap().unwrap();
    let mut ab = ab.split_whitespace();
    let a: usize = ab.next().unwrap().parse().unwrap();
    let b: usize = ab.next().unwrap().parse().unwrap();
    let ans: String = if a < b {
        (0..b).map(|_| a.to_string()).collect()
    } else {
        (0..a).map(|_| b.to_string()).collect()
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;


int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    ll ret = 0;
    
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == i + 1)
        {
            if (i != n - 1)
            {
                swap(a[i], a[i + 1]);
            }
            ret++;
        }
    }
    
    cout << ret << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(), vec.end()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define repc(bit, k, n) for (ll bit = (1 << k) - 1; bit < (1 << n); bit = next_combination(bit))
#define repi(itr, vec) for (auto itr = vec.begin(); itr != vec.end(); ++itr)
using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  if (s.back() == 's')
    s += "es\n";
  else
    s += "s\n";

  cout << s;
  return 0;
}


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

int main() {
    string s, t;
    int ans = 0;
    cin >> s >> t;

    for(int i=0; i<s.size(); i++)
    {
        if(s[i] != t[i]) ans++;
    }

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



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


int main(){
    long long A,B;
    cin >> A >> B;
    cout << A*B-A-B+1 << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll _max = 0;
    ll ans = 0;
    ll i = 0;
    while (i < n - 1)
    {
        while (a[i] >= a[i + 1] && i < n - 1)
        {
            i++;
            ans++;
        }
        _max = max(ans, _max);
        ans = 0;
        i++;
    }
    cout << _max << endl;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys
from collections import namedtuple

DEBUG = False


def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep=" "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


Point = namedtuple("Point", ("id", "to"))
points = {}


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def scc_forward(p, visited, rev_scc_ponints):
    if p in visited:
        return
    visited.add(p)
    for to in points[p].to:
        scc_forward(to, visited, rev_scc_ponints)
    rev_scc_ponints.append(p)


def scc_backword(p, visited, cur_sc):
    if p in visited:
        return 0
    visited.add(p)
    cur_sc.add(p)
    for to in points[p].to:
        scc_backword(to, visited, cur_sc)
    print(repr(cur_sc))
    return len(cur_sc)


def count_max_sc_size(points):
    rev_scc_points = []
    visited_forward = set()
    for p in points:
        scc_forward(p, visited_forward, rev_scc_points)

    max_sc_size = 1
    visited_backward = set()
    for p in rev_scc_points:
        cur_sc_size = scc_backword(p, visited_backward, set())
        if cur_sc_size > max_sc_size:
            max_sc_size = cur_sc_size
    return max_sc_size


def old_main():
    _n, m = read_list(int)
    for _ in range(0, m):
        a, b = read_list(int)
        a -= 1
        b -= 1

        if a not in points:
            points[a] = Point(a, set())
        if b not in points:
            points[b] = Point(b, set())
        f = points[a]
        t = points[b]
        f.to.add(b)
        t.to.add(a)
    print(count_max_sc_size(points))


def main():
    n, m = read_list(int)
    union_find = UnionFind(n)
    for _ in range(0, m):
        a, b = read_list(int)
        a -= 1
        b -= 1
        union_find.union(a, b)

    max_size = 1
    for i in range(0, n):
        if union_find.size(i) > max_size:
            max_size = union_find.size(i)
    print(max_size)


if __name__ == "__main__":
    main()


Measured memory_bytes: 74864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,MAX_LOG=20;
const ll INF=1LL<<60;

vector<int> Zalgo(string S){
    vector<int> A(S.size());
    int c=0;
    for(int i=1;i<S.size();i++){
        if(i+A[i-c]<c+A[c]){
            A[i]=A[i-c];
        }else{
            int j=max(0,c+A[c]-i);
            while(i+j<S.size()&&S[j]==S[i+j]) j++;
            A[i]=j;
            c=i;
        }
    }
    A[0]=S.size();
    
    return A;
}

int main(){
    
    int N;cin>>N;
    string S;cin>>S;
    int ans=0;
    
    for(int s=0;s<N;s++){
        vector<int> A=Zalgo(S.substr(s,N-s));
        for(int i=0;i<N-s;i++){
            ans=max(ans,min(i,A[i]));
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double hp = sc.nextInt();
		double a = 0;
		Integer b[] = new Integer [n];
		for(int i = 0; i < n ; i++){
			int tmp = sc.nextInt();
			if( tmp > a){
				a = tmp;
			}
			b[i] = sc.nextInt();
		}
		/*for( int i = n; i > 0; i--){
			for( int j = 0; j < i - 1 ; j++ ){
				if(b[j] < b[j+1]){
					int tmp = b[j];
					b[j] = b[j+1];
					b[j+1] = tmp;
				}
			}
		}*/
		Arrays.sort(b,Collections.reverseOrder());
		int ans = 0;
		int index = 0;
		while( hp > 0){
			/*if( index < n && b[index] >= a ){
				hp -= b[index];
				ans++;
				index++;
			}else{
				break;
			}*/
			if( index < n && b[index] >= a ){
				hp -= b[index];
				ans++;
				index++;
			}else{
				//hp-=a;
                                //ans++;
				break;
			}
		}
		/*if(hp%a == 0){
			ans += hp/a;
		}else{
			Double tmpA = hp/a;
			int tmpB = tmpA.intValue();
			if(tmpA - tmpB < 0){
				ans += tmpB;
			}else{
				ans += tmpB + 1;
			}
		}*/
		if( hp > 0)
		ans += (a - 1 + hp)/a;
		System.out.print(ans);
	}
}


Measured memory_bytes: 77824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<int(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#undef gc
#undef pc
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
#define fi first
#define se second
#define N 310
int n,K,Mod;
ll C[N][N],f[N][N],s[N][N];
int main(){
	n = rd(),K = rd(),Mod = rd();
	C[0][0] = 1;
	Rep(i,1,n){
		C[i][0] = 1;
		Rep(j,1,i)
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % Mod;
	}
	Rep(i,0,K)
		f[1][i] = 1,s[1][i] = K-i+1;
	Rep(i,2,n+1){
		Rep(j,0,K)
			rep(k,1,i)
                f[i][j]=(f[i][j]+f[i-k][j]*s[k][j+1]%Mod*C[i-2][k-1])%Mod;  
		Dep(j,K,0)
            s[i][j]=(f[i][j]+s[i][j+1])%Mod;
	}
	writeln(f[n+1][0]);
	return 0;
}

Measured memory_bytes: 2432
import java.util.*;
 
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		if(n%k==0) {
		System.out.println((n/k));
		}else {
			System.out.println((n/k)+1);

		}
 
		sc.close();
	}
}

Measured memory_bytes: 22228
#include <stdio.h>
int main(void)
{
int n,b,i,j;
int rev[4][15] = {{0}};
char a,m;

scanf("%d",&n);

for ( i = 0; i < n; i++ ){
   scanf(" %c %d",&a,&b);
     if( a == 'S' )
       rev[0][b] = 1;
     if( a == 'H' )
       rev[1][b] = 1;
     if( a == 'C' )
       rev[2][b] = 1;
     if( a == 'D' )
       rev[3][b] = 1;
}
for ( i = 0; i < 4; i++ ){
   for ( j = 1; j <= 13; j++ ){
     if( rev[i][j] == 0){
     if ( i == 0 )
        m = 'S';
     if(  i == 1 )
        m = 'H';  
     if(  i == 2 )
        m = 'C';
     if(  i == 3 )
        m = 'D';
        
     printf("%c %d\n",m,j);
    }
  }
}

return 0;
}

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

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


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

int main(){
    string s;
    int q;
    cin >> s >> q;
    deque<char> que;
    for (int i = 0;i < s.size();i++){
        que.push_back(s[i]);
    }
    int cnt = 0,num = s.size();
    for (int i = 0;i < q;i++){
        int t;
        cin >> t;
        if (t == 1){
            cnt++;
        }
        else{
            int f;
            char c;
            num++;
            cin >> f >> c;
            if (f == 1){
                if (cnt % 2 == 0){
                    que.push_front(c);
                }
                else{
                    que.push_back(c);
                }
            }
            else{
                if (cnt % 2 == 0){
                    que.push_back(c);
                }
                else{
                    que.push_front(c);
                }
            }
        }
    }

    if(cnt % 2 == 0){
        for (int i = 0;i < num;i++){
            char C = que.front();
            que.pop_front();
            cout << C;
        }
        cout << endl;
    }
    else{
        for (int i = 0;i < num;i++){
            char C = que.back();
            que.pop_back();
            cout << C;
        }
        cout << endl;
    }

    return 0;
}

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

def main(S):
    count=[0,0]
    for i in range(len(S)):
        if i%2==0:
            if S[i]=='0':
                count[0]+=1
            else :
                count[1]+=1
        else :
            if S[i]=='1':
                count[0]+=1
            else :
                count[1]+=1
    print(min(count))

if __name__ == '__main__':
    S = list(input())
    
    main(S)

Measured memory_bytes: 3956
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n = in(); int k = in();
  vector<char> d(k);
  REP(i, k) cin >> d[i];
  
  for (int i = n;; i++) {
    stringstream ss;
    ss << i;
    string s = ss.str();
    //print(s);
    bool flg = true;
    REP(j, k) {
      if (s.find_first_of(d[j]) != -1) {
        flg = false;
        break;
      }
    }
    if (flg) {
      print(s);
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 256
require 'matrix'
while gets
    a = $_.split.map{|s|s.to_i}
    v = Matrix[[a[0], a[1]], [a[3], a[4]]].inv * Vector[a[2], a[5]]
    puts v.to_a.map{|r|sprintf("%.3f", r.to_f.round(3))}.join(" ")
end

Measured memory_bytes: 6464
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>

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

using namespace std;

int main(){

  int count=0;
  double sum=0;
  double ave=0;
  double hen=0,hen1=0,hen2=0;

while(1){

cin >> count;
vector<double> V(count);                     //???????????¢???????¢????

if(count == 0) break;                        //????????????????????¶
sum = 0;
rep(i,0,count){
cin >> V[i];
sum += V[i];                                //??\???????¨?
}

ave = sum/count;                               //??????

hen = 0;
rep(i,0,count){
hen += (V[i]-ave)*(V[i]-ave);                   //??????????¨??????????
}

hen1 = hen/count;                              //?¨??????????

hen2 = sqrt(hen1);

cout <<  fixed << setprecision(8) << hen2 << endl;

}

return 0;

}

Measured memory_bytes: 1288
import sys
h, w, a, b = [int(i) for i in sys.stdin.readline().split()]
dic = dict()
MOD = 10**9+7

def nCr(n, r, mod=MOD):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



res = 0
_sum = 0
for i in range(h - a):
    dic[i] = nCr(i + b, i)
    res += (dic[i] - _sum) * nCr(h - i - 1 + w - b - 1, h - i - 1)
    _sum = dic[i]
    res %= MOD
print(res)

Measured memory_bytes: 128012
#include <stdio.h>
int main() {
	int A[10],v1,v2,i,j;while (scanf("%d",&A[0])!=EOF) {
		j=A[0];for (i=1;i<10;scanf(",%d",&A[i]),j+=A[i++]);scanf(",%d,%d",&v1,&v2);
		double t=(j+0.0)/(v1+v2+0.0);
		double x=t*v1;
		i=j=0;while ((j+A[i]+0.0)<x) j+=A[i],i++;
		printf("%d\n",i+1);
	}
	return 0;
}

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

typedef struct {
  char suit;
  int value;
} Card;

void bubble_sort(Card a[], int n) {
  int i, j;

  for (i = 0; i < n; i++) {
    for (j = n - 1; j > i; j--) {
      if (a[j].value < a[j - 1].value) {
        swap(a[j], a[j - 1]);
      }
    }
  }
}

void selection_sort(Card a[], int n) {
  int i, j, m;

  for (i = 0; i < n; i++) {
    m = i;

    for (j = i; j < n; j++) {
      if (a[m].value > a[j].value) {
        m = j;
      }
    }

    swap(a[i], a[m]);
  }
}

void p(Card a[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    cout << a[i].suit << a[i].value;
    if (i != n - 1) {
      cout << " ";
    }
  }
  cout << endl;
}

int main() {
  bool f = false;
  int n, i;
  Card c1[36], c2[36];

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> c1[i].suit >> c1[i].value;
    c2[i].suit = c1[i].suit;
    c2[i].value = c1[i].value;
  }

  bubble_sort(c1, n);
  p(c1, n);
  cout << "Stable" << endl;

  selection_sort(c2, n);
  p(c2, n);
  for (i = 0; i < n; i++) {
    if (c1[i].suit != c2[i].suit) {
      f = true;
    }
  }
  if (f) {
    cout << "Not stable" << endl;
  } else {
    cout << "Stable" << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
import numpy
N = int(input())
task = numpy.array([list(map(int, input().split())) for _ in range(N)])
task = task[numpy.argsort(task[:, 1])]

ans = 'Yes'

time = 0
for j in task:
    time += j[0]
    if time > j[1]:
        ans = 'No'
        break

print(ans)

Measured memory_bytes: 65172
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 105;
const int MAX_X = 6e3 + 5;

Modint ways [MAX_N][MAX_X];
Modint dp [MAX_N][MAX_X];

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

  ways[n + 1][0] = 1;
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < MAX_X; j++) {
      for (int k = 0; k <= K; k++) {
        int add_xp, rem;
        if (k > i) {
          add_xp = 0;
          rem = k + j;
        } else {
          int nw = k + j;
          add_xp = nw / i;
          rem = nw % i;
        }

        int nj = j + add_xp;
        if (nj < MAX_X) {
          ways[i][nj] += ways[i + 1][j];
          dp[i][nj] += dp[i + 1][j] + ways[i + 1][j] * Modint(rem);
        }
      }
    }
  }

  Modint ans (0);
  for (int i = 0; i < MAX_X; i++) {
    ans += dp[1][i];
  }
  cout << ans << endl;
}


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

public class Main {

    public static void main(String[] args) {
        // ABC042B - 文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition)

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(); // 1 <= n, l <= 100
        int l = sc.nextInt();
        String[] ss = new String[n];

        for (int i = 0; i < n; i++) {
            ss[i] = sc.next();
        }

        Arrays.sort(ss);

        StringBuilder sb = new StringBuilder("");
        for (String s : ss) {
            sb.append(s);
        }

        System.out.println(sb);
    }

}

Measured memory_bytes: 23380
#include <iostream>
typedef long long ll;
ll MOD=1e9+7;
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    if(n<m) {
        int tmp = n;
        n = m;
        m = tmp;
    }
    if(n-m>1) {
        cout << '0' << endl;
        return 0;
    } else if(n==m) {
        ll ans = 1;
        for(int i=1; i<=n; i++) ans = (ans * i) % MOD;
        for(int i=1; i<=m; i++) ans = (ans * i) % MOD;
        cout << (2*ans)%MOD << endl;
    } else {
        ll ans = 1;
        for(int i=1; i<=n; i++) ans = (ans * i) % MOD;
        for(int i=1; i<=m; i++) ans = (ans * i) % MOD;
        cout << ans%MOD << endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
int M,l;main(){string s,t,u;map<string,int>m;for(;cin>>u;t=t.size()<u.size()?u:t)if(++m[u]>M)M=m[u],s=u;cout<<s<<' '<<t<<endl;}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}
ll gcd(ll a,ll b){
  if(a%b)return b;
  return gcd(b,a%b);
}
void update(map<ll,ll> &a,const pair<const ll,const ll> &p){
  if(a.count(p.first)){
    a[p.first]=max(a[p.first],p.second);
  }else{
    a[p.first]=p.second;
  }
}
void solve(long long N, vector<pll> &A){
  {
    vector<vector<ll>> dp(2,vector<ll>(N+1));
    fill(dp[0].begin(),dp[0].end(),N);
    fill(dp[1].begin(),dp[1].end(),N);
    REP(3){
      for(long long j = 0; j <= N; j++){
        if(j>=A[i].first)dp[i%2][j]=max(dp[i%2^1][j],dp[i%2][j-A[i].first]-A[i].first+A[i].second);
        else dp[i%2][j]=dp[i%2^1][j];
      }
    }
    N=dp[0][N];
  }
  {
    vector<vector<ll>> dp(2,vector<ll>(N+1));
    fill(dp[0].begin(),dp[0].end(),N);
    fill(dp[1].begin(),dp[1].end(),N);
    REP(3){
      for(long long j = A[i].second; j <= N; j++){
        if(j>=A[i].second)dp[i%2][j]=max(dp[i%2^1][j],dp[i%2][j-A[i].second]-A[i].second+A[i].first);
        else dp[i%2][j]=dp[i%2^1][j];
      }
    }
    N=dp[0][N];
  }
  cout<<N<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    vector<pll> A(3);
    REP(3)scanf("%lld",&A[i].first);
    REP(3)scanf("%lld",&A[i].second);
    solve(N, A);
    return 0;
}


Measured memory_bytes: 586240
//////////////////////
        	//******************//
			//**  OM THUMMAR  **//
			//**  DA-IICT     **//
			//**  201901070   **//
			//**  I'D=Aom2608 **//
			//******************//
			/////////////////////

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;


#define PI 3.141592653589793
#define MOD 1000000007



int main()
{
	IOS;
	string s;
	cin>>s;
	if(s=="ARC")
	cout<<"ABC";
	else
	cout<<"ARC";
}





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

int main()
{
    int n, k, c;
    cin >> n >> k >> c;
    c++;
    string s;
    cin >> s;
    int f[200005], l[200005];
    int j = 0;
    for(int i = 0; i < k; i++){
        while(s[j] == 'x') j++;
        f[i] = j;
        j += c;
    }
    j = n - 1;
    for(int i = k - 1; i >= 0; i--){
        while(s[j] == 'x') j--;
        l[i] = j;
        j -= c;
    }
    for(int i = 0; i < k; i++){
        if(f[i] == l[i]) cout << f[i] + 1 << endl;
    }
}


Measured memory_bytes: 3332
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std ;
int n,m,a[3],b,c,k,_max,sum=0;
string str;
int main()
{
    //freopen("out.txt","w",stdout);
    //cin>>str;
    //cin>>n;
    cin>>a[0];
    sum+=a[0];
    _max=a[0];
    for(int i=1;i<3;i++)
    {
        cin>>a[i];
        sum+=a[i];
        _max=max(_max,a[i]);
    }
    cin>>k;
    sum-=_max;
    for(int i=0;i<k;i++)
        _max*=2;
    cout<<_max+sum;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

#define ll long long
//#define int long long
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

#define dump(x)  cerr << #x << " = " << (x) << endl; 
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


typedef pair<int, int> P;
struct Point{
	int x, y;
};
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = {1,0,-1,0};


// 素数判定
bool isprime(ll  n){
	if (n < 2) return false;
	else if (n == 2) return true;
	else if (n % 2 == 0) return false;
	else
		for (int i = 3; i*i <= n; i++)
			if (n%i == 0) return false;

	return true;
}

int main(){

	int N;
	cin >> N;

	for (int i = 6;; i += 5){
		if (isprime(i)){
			cout << i << " ";
			N--;
		}
		if (N == 0) break;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	int n;cin>>n;
	int ans=0;
	for(int i=1;i<=n ;i++){
		for(int j=1;i*j<n;j++){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int ans=0;
            string[] week = new string[] { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
            for(int i = 0; i < week.Count(); i++)
            {
                if (input == week[i])
                {
                    ans = 7 - i;
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11220
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    set<int> dic;
    rep(mask,1<<N) {
        bitset<20> s(mask);
        int val = 0;
        rep(i,N) {
            if (s.test(i)) val += A[i];
        }
        dic.emplace(val);
    }

    int Q; cin >> Q;
    while (Q--) {
        int m; cin >> m;
        cout << (dic.count(m) ? "yes" : "no") << ln;
    }
}


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

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

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

    int k = 0;
    for (int i = 0;;) {
        if (i == a[i]) {
            k = -1;
            break;
        }
        int j = a[i];
        a[i] = i;
        i = j;
        k++;
        if (i == 1) break;
    }

    cout << k << endl;

    return 0;
}

Measured memory_bytes: 640
s = input()
q = int(input())
list1 = []
list2 = []
flag = 1
for i in range(q):
    in_line = input().split()
    if in_line[0] == "1":
        flag *= -1
    else:
        if in_line[1] == "1":
            if flag == 1:
                list1.append(in_line[2])
            else:
                list2.append(in_line[2])
        else:
            if flag == 1:
                list2.append(in_line[2])
            else:
                list1.append(in_line[2])
if flag == 1:
    print("".join(list1[::-1]) + s + "".join(list2))
else:
    print("".join(list2[::-1]) + s[::-1] + "".join(list1))

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

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

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j) {
            string x; cin >> x;
            if(x == "snuke") {
                cout << char('A' + j);
                cout << (i + 1) << "\n";
                return 0;
            }
        }
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
typedef multimap<string, int>::iterator itr;
int n,i,c,x;
multimap<string, int>S;
main()
{
    cin >> n;
    for (i = 0; i < n; i++)
    {
        string s,t; cin >> c >> s;
        if (c == 0)
        {
            cin >> x;
            S.insert(make_pair(s, x));
        }
        else if (c == 1)
        {
            itr a = S.lower_bound(s), b = S.upper_bound(s);
            for (itr it = a; it != b; it++)cout << it->second << endl;
        }
        else if (c == 2)S.erase(s);
        else
        {
            cin >> t;
            itr a = S.lower_bound(s), b = S.upper_bound(t);
            for (itr it = a; it != b; it++)cout << it->first << " " << it->second << endl;
        }
    }
}


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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

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

    string str;
    int k;

    cin >> str >> k;

    vector<string> vec;
    for (char c = 'a'; c <= 'z'; c++) {
        rep (i, str.length()) {
            if (str[i] == c) {
                for (int j = 1; j <= int(str.length() - i); j++) {
                    vec.pb(str.substr(i, j));
                    if (j > 5) break;
                }
            }
        }
        if (vec.size() > 100) break;
    }
    sort(all(vec));

    string pre;
    int cnt = 1;
    repall (s, vec) {
        if (s == pre) continue;
        if (cnt == k) {
            print(s);
            break;
        }
        pre = s;
        cnt++;
    }

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 1916