akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;


int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int N, A, B, h[200000],left=0,right=1000000000,bomb;
	cin >> N >> A>>B;
	for (int i = 0; i < N; i++) {
		cin >> h[i];

	}
	while (right - left != 1) {
		long long int mid = (left + right) / 2;
		bomb = mid;
		for (int i = 0; i < N; i++) {
			bomb -= max(( h[i] - mid * B +A-B- 1) / (A - B),0LL);
		}
		if (bomb >= 0) {
			right = mid;
		}
		else {
			left = mid;
		}
	}
	cout << right << endl;
}

Measured memory_bytes: 1024
import sys
def main():
    input = sys.stdin.readline
    H,W=map(int, input().split())
    N=int(input())
    *A,=map(int, input().split())
    c=[[0] * W for _ in range(H)]
    ai=0
    for i in range(H):
        for j in range(W):
            k = j if i&1==0 else W-j-1
            c[i][k]=ai+1
            A[ai]-=1
            if A[ai]<=0: ai+=1
    for i in range(H):
        print(*c[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 42352
#!/usr/bin/env python3
from collections import deque

h, w = map(int, input().split())
maze = [input() for _ in range(h)]
ans = 0


def bfs(sx, sy):
    dx = (1, 0, -1, 0)
    dy = (0, 1, 0, -1)
    d = [[-1] * w for _ in range(h)]
    q = deque([])

    q.append((sx, sy))
    d[sx][sy] = 0
    ans = 0

    while q:
        x, y = q.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != "#" and d[nx][
                    ny] == -1:
                q.append((nx, ny))
                d[nx][ny] = d[x][y] + 1
                ans = max(ans, d[nx][ny])
    return ans


for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            ans = max(ans, bfs(i, j))
print(ans)


Measured memory_bytes: 9404
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int j = 0,k = 0;
    for(int i = 0,flag = 0;i < n - 1;i++)
    {
        if(flag == 0 && v.at(i) > v.at(i + 1))
        {
            j = i;
            flag++;
            continue;
        }
        else if(flag == 1 && v.at(i) > v.at(i + 1))
        {
            k = i + 1;
            break;
        }
    }
    if(j != k)
    {
        swap(v.at(j),v.at(k));
    }
    bool flag = true;
    for(int i = 0;i < n;i++)
    {
        if(v.at(i) != i + 1)
        {
            cout << "NO";
            flag = false;
            break;
        }
    }
    if(flag)
    {
        cout << "YES";
    }
    
    return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        in.nextLine();
        char[][] chs = new char[a][b];
        for (int i = 0; i < a; i++) {
            chs[i] = in.nextLine().substring(0, b).toCharArray();
        }
        if (valid(chs)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static boolean valid(char[][] chs) {
        int a = chs.length;
        int b = chs[0].length;
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                if (chs[i][j] != '#') continue;
                if (j < b-1 && chs[i][j+1] == '#') continue;
                if (j > 0 && chs[i][j-1] == '#') continue;
                if (i < a-1 && chs[i+1][j] == '#') continue;
                if (i > 0 && chs[i-1][j] == '#') continue;
                return false;
            }
        }
        return true;
    }
}

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

#define ll long long
#define ull unsigned long long
#define ld long double

#define tiii tuple < int, int, int >
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >
#define pis pair < int, string >

#define vi vector < int >
#define vd vector < double >
#define vld vector < ld >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >
#define vpis vector < pis >

#define pb push_back
#define mt make_tuple
#define gt0 get < 0 >
#define gt1 get < 1 >
#define gt2 get < 2 >

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 9;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;

    int n;

    cin >> n;

    ll a[n + 5];

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

    ll ans = 0;

    for(int i = 1; i < n; i++){
        if(a[i] < a[i - 1]) ans += (a[i - 1] - a[i]), a[i] = a[i - 1];
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  ll N;cin>>N;
  vector<ll> cnt(1e5+10,0);
  ll ans=0;
  rep(i,N){
    ll a;cin>>a;
    if(a>1e5) ans++;
    else{
      cnt[a]++;      
    }
  }
  rep(i,1e5+1){
    if(cnt[i]>=i) ans+=cnt[i]-i;
    else ans += cnt[i];
  }
  cout<<ans<<endl;
}

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

typedef long long ll;
#define int         ll
typedef vector<int> vi;
#define test        int t; cin >> t; while(t--)
#define max(a,b)   (a>b?a:b)
#define min(a,b)   (a<b?a:b)
const int mod = 1000000007;

template <typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
    for (T i : v) {
        out << i << " ";
    }
    return out;
}

int n, k, c;
string s;


int32_t main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> k >> c >> s;

    vector<int> l(k), r(k);
    int i = 0, cnt = 0;
    while (i < n && cnt < k) {
        if (s[i] != 'x') {
            l[cnt] = i;
            cnt++;
            i += c+1;
        } else {
            i++;
        }
    }
    i = n - 1, cnt = k - 1;
    while (i >= 0 && cnt >= 0) {
        if (s[i] != 'x') {
            r[cnt] = i;
            cnt--;
            i -= (c+1);
        } else {
            i--;
        }
    }

    for (int i = 0; i < k; ++i){
            if(l[i]==r[i]){
                cout<<l[i]+1<<endl;
            }
    }

    return 0;
}

Measured memory_bytes: 5012
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h1, h2, m1, m2, k;
        h1 = sc.nextInt();
        m1 = sc.nextInt();
        h2 = sc.nextInt();
        m2 = sc.nextInt();
        k = sc.nextInt();

        int start, end;
        start = 60 * h1 + m1;
        end = 60 * h2 + m2;
        int ans = (end - start) - k;

        System.out.println(ans);
    }
}


Measured memory_bytes: 35796
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![(0, 0); n];
    for i in 0..n {
        seq[i].1 = read::<i64>();
        seq[i].0 = read::<i64>();
    }
    seq.sort();
    let mut sum = 0;
    for i in 0..n {
        sum += seq[i].1;
        if sum > seq[i].0 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

int main() {
	ll N; cin >> N;
	if(N % 2 == 1) {
		cout << 0 << endl;
	} else {
		N /= 2;
		ll cnt = 0;
		while(N > 0) {
			cnt += N / 5;
			N /= 5;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    int h,w,k;cin >> h >> w >> k;
    int ans=0;
    vector<string> inlist(h);
    REP(i,h)cin >> inlist[i];
    FOR(i,0,(1<<h))FOR(j,0,(1<<w)){
        vector<string> tmp = inlist;
        REP(s,h){
            if(i & (1<<s)){
                REP(t,w){
                    tmp[s][t]='X';
                }
            }
        }
        REP(s,w){
            if(j & (1<<s)){
                REP(t,h){
                    tmp[t][s]='X';
                }
            }
        }
        int tmpcnt=0;
        REP(a,h)REP(b,w){
            if(tmp[a][b]=='#')tmpcnt++;
        }
        if(tmpcnt==k)ans++;
    }
    cout << ans << endl;
}//https://atcoder.jp/contests/abc173/tasks/abc173_c

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

int main()
{
	int n;
	long long x;
	scanf("%d%lld", &n, &x);
	std::vector<long long> a(n);
	for (int i{}; i < n; i++)
		scanf("%lld", &a[i]);
	std::sort(a.begin(), a.end());
	for (int i{1}; i < n; i++)
		a[i] += a[i - 1];
	if (a.back() < x)
		printf("%d\n", n - 1);
	else
	{
		int count{};
		for (int i{}; i < n; i++)
		{
			if (a[i] > x) break;
			count++;
		}
		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool cmp(long long a, long long b)
{
    return a>b;
}
int main()
{
    int n,m;
    cin>>n>>m;
    long long mx = -(99999999);
    long long arr[9999][3];
    for(int i=1; i<=n; i++){
        for(int j=0; j<3; j++)cin>>arr[i][j];
    }

    for(int i=0; i<8; i++){
        vector<long long>v;
        for(int j=1; j<=n; j++){

            long long sum=0;
            for(int k=0; k<3; k++){
                if((i/(1<<k))%2==0)sum+=arr[j][k];
                else sum-=arr[j][k];
            }
           v.push_back(sum);
        }
        sort(v.begin(),v.end(),cmp);
        long long ans=0;
        for(int i=0; i<m; i++){
            ans+=v[i];
        }
        mx = max(mx, ans);
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 256
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
     int A=int.Parse(str[0]);
      int B=int.Parse(str[1]);
      int C=int.Parse(str[2]);
      int K=int.Parse(Console.ReadLine());
      int ans=0;
		int[] intarr=new int[3];
      intarr[0]=A;
      intarr[1]=B;
      intarr[2]=C;
		int count=1;
          Array.Sort(intarr);
      while(count<=K){
        intarr[2]=(2*intarr[2]);
     ans=intarr[0]+intarr[1]+intarr[2];
       count++;

      }
               Console.WriteLine(ans);
    }
    
  }

}

Measured memory_bytes: 11092
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        HashSet<Integer> a = new HashSet<>();
        for (int i = 0; i < 3; i++){
            a.add(scan.nextInt());
        }
        System.out.println(a.size());
    }
}

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

int main() {
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  vector<tuple<int, int, int>> YPi(M);
  for (int i = 0; i < M; i++) {
    int P, Y;
    cin >> P >> Y;
    YPi.at(i) = make_tuple(Y, P, i);
  }

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

  vector<int> cnt(N + 1, 1);

  vector<pair<int, int>> ans(M);
  for (int i = 0; i < M; i++) {
    ans.at(get<2>(YPi.at(i))) = make_pair(get<1>(YPi.at(i)), cnt.at(get<1>(YPi.at(i)))++);
  }

  for (int i = 0; i < M; i++) {
    cout << setw(6) << setfill('0') << ans.at(i).first;
    cout << setw(6) << setfill('0') << ans.at(i).second << "\n";
  }
}


Measured memory_bytes: 3840
#include <iostream>
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <cstdio>
#include <math.h>
#include <map>
#include <algorithm>
#include <deque>
#include <stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>pa;
const int N =3e4+100;
const int inf=0x3f3f3f3f;


int main()
{
    set<char>s;
    for(int i=1;i<=4;i++) {
        char c;
        scanf("%c",&c);
        s.insert(c);
    }
    if(s.size()==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
L, R = map(int, input().split())

# L ≤ i < j ≤ R

#(i×j)mod2019


l_mod = L % 2019
r_mod = R % 2019

l_count = L // 2019
r_count = R // 2019

min_mod2019 = 2020

if l_count < r_count: # 2019 の倍数を跨いでいるとき
    print(0)
    
elif l_count == r_count: # 2019 の倍数を跨がないとき
    for i in range(l_mod, r_mod):
        for j in range(i+1, r_mod+1):
            tmp = (i * j) % 2019
            if tmp < min_mod2019:
                min_mod2019 = tmp
    print(min_mod2019)

Measured memory_bytes: 3064
n,k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        if a[i] > a[j]: cnt += 1

y = 0
for a1 in a:
    for a2 in a:
        if a1 > a2: y += 1

ans = (cnt * k + y * k * (k-1)//2)%MOD
print(ans)

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int taxi = b;
		int train = a*n;
		System.out.println(Math.min(train, taxi));

	}

}


Measured memory_bytes: 21844
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  string s; cin >> s;
  int n=s.size();
  int ans=0;
  string s1="",s2="";

  rep(i,n){
    if (i%2==0){
      s1+="0";
      s2+="1";
    } else {
      s1+="1";
      s2+="0";
    }
  }

  int d1=0, d2=0;

  rep(i,n){
    if (s[i]!=s1[i]){d1++;}
    if (s[i]!=s2[i]){d2++;}
  }

  ans = min(d1,d2);

  cout << ans;

  


  

  return 0;
}


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

int main()
{
  int n, ans=0;
  string s, t;
  
  cin >> s >> t;
  
  n = max(s.length(), t.length());
  for(int K=0; K<n; K++){
    if(s[K]!=t[K]) ans++; 
  }
  
  cout << ans << "\n";
}

Measured memory_bytes: 3916
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

void dfs(ll cur, ll pre, const VV<ll> &edges, V<ll> &pars, V<ll> &depth, ll d = 0) {
    pars[cur] = pre;
    depth[cur] = d;
    for(ll nxt : edges[cur]) if(nxt != pre) dfs(nxt, cur, edges, pars, depth, d + 1);
}

bool solve() {
    ll N;
    cin >> N;
    VV<ll> edges(N);
    V<ll> digits(N);
    for(ll i = 0; i < N - 1; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
        digits[a]++;
        digits[b]++;
    }

    V<ll> parents(N);
    V<ll> depth(N);
    for(ll i = 0; i < N; i++) if(digits[i] != 1) {
        dfs(i, -1, edges, parents, depth);
        break;
    }
    
    set<ll> leaves;
    for(ll i = 0; i < N; i++) if(digits[i] == 1) leaves.insert(i);
    V<ll> cnts(N);
    V<ll> ord(N);
    iota(ALL(ord), 0ll);
    sort(ALL(ord), [&](ll a, ll b) { return depth[a] > depth[b]; });
    for(ll ele : ord) {
        if(cnts[ele] == 1) continue;
        if(2 <= cnts[ele]) return true;
        ll par = parents[ele];
        if(par != -1) cnts[par]++;
        else return true;
    }

    return false;
}

int main() {
    cout << (solve() ? "First" : "Second") << endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

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

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}

// original: https://ei1333.github.io/luzhiled/snippets/math/prime-factor.html
map< long long, int > prime_factor(long long n) {
  map< long long, int > ret;  // <prime, count> 
  for(long long i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

void solve() {
  LL A, B; cin >> A >> B;
  LL C = gcd(A, B);
  LL ans = 1;

  for (auto p : prime_factor(C)) {
    if (p.second) ans++;
  }
  
  cout << ans << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
S = 1
if A.count(0)==0:
    for i in range (N):
        S *= A[i]
        if S == 0:
            break
        if S >(10**18):
            S = -1
            break
else:
    S = 0

print(S)

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

string s,t;
int ans=INT_MAX;

int main()
{
	cin>>s>>t;

	for(int i=0;i<=s.size()-t.size();i++)
	{
		string n=s.substr(i,t.size());
		int d=0;
		for(int i=0;i<t.size();i++)
			if(n[i]!=t[i]) d++;
		ans=min(ans,d);
	}

	cout<<ans;
}

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

typedef long long ll;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    rep(i, H) cin >> a[i];
    rep(i, H) {
        bool f = true;
        rep(j, W) {
            if (a[i][j] == '#') f = false;
        }
        if (f) {
            rep(j, W) {
                a[i][j] = ' ';
            }
        }
    }
    rep(j, W) {
        bool f = true;
        rep(i, H) {
            if (a[i][j] == '#') f = false;
        }
        if (f) {
            rep(i, H) {
                a[i][j] = ' ';
            }
        }
    }
    rep(i, H) {
        bool f = false;
        rep(j, W) {
            if (a[i][j] != ' ') {
                cout << a[i][j];
                f = true;
            }
        }
        if (f) cout << "\n";
    }
}

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

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

    while(n > 0)
    {
        if(n % 10 == 7)
        {
            cout << "Yes";
            return 0;
        }

        n /= 10;
    }

    cout << "No";

    return 0;
}

Measured memory_bytes: 3620
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import Control.Monad
import Data.List
import qualified Data.Vector.Unboxed as UV

tmain=do
    let h = 1000
    let w = 1000
    let bx = replicate 1000 $ UV.replicate 1000 '.'
    print $ f w bx

main=do
    [h,w] <- map read.words<$>getLine
    bx <- map (UV.fromListN w.B.unpack).B.lines <$> B.getContents
    print $ f w bx

f w !bx = UV.last $ foldl' p (UV.cons 1 $ UV.replicate (w-1) (0::Int)) bx where
    p !v0 bl = UV.tail $ UV.scanl' m 0 $ UV.zip v0 bl
        where
            m b (u, f)
                | f == '#' = 0
                | (b+u) < (10^9+7) = b+u
                | otherwise = b+u-(10^9+7)

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    vector<vector<char>> chart(H,vector<char>(W));
    REP(i,H)REP(j,W)cin >> chart.at(i).at(j);
    vector<bool> erase1(H);
    REP(i,H){
        REP(j,W){
            if(chart.at(i).at(j) == '#')break;
            if(j == W-1)erase1.at(i) = 1;
        }
    }
    REP(i,H)if(erase1.at(H-1-i))chart.erase(chart.begin()+H-1-i);
    H = chart.size();
    vector<bool> erase2(W);
    REP(i,W){
        REP(j,H){
            if(chart.at(j).at(i) == '#')break;
            if(j == H-1)erase2.at(i) = 1;
        }
    }
    REP(i,W)if(erase2.at(W-1-i))REP(j,H)chart.at(j).erase(chart.at(j).begin()+W-1-i);
    REP(i,chart.size()){
        REP(j,chart.at(0).size())cout << chart.at(i).at(j);
        cout << "\n";
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
a, b, c = map(int, input().split())
k = int(input())
def two(num):
  for i in range(1,8):
    if (2**(i-1)<=num) & (num<2**(i)):
      return i
  return 0
ab = two(a/b)
b_ = b*2**ab
b_c = two(b_/c)

if k>=(ab+b_c):
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;cin>>n;
    ll ans = n-1;
    REP(i,1,1000010)
    {
        if (n%i==0)
        {
            ans = min(ans, i-1+(n/i)-1);
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
// 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
#include <typeinfo>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(ll a=0;a<t;a++)
int main()
{
	ll w, n;

	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	ll a[32];
	roop(i, 32) {
		a[i] = i + 1;
	}
	roop(i, n) {
		int swap[2]; char kanma;
		cin >> swap[0] >> kanma >> swap[1];
		ll before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	roop(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    if(n%2 != 0){
        cout << "No";
    }else{
        for(int i=0; i<n/2; i++){
            if(s[i] != s[i+n/2]){
                cout << "No";
                break;
            }
            if(i == n/2 -1){
                cout << "Yes";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
        else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main() {
    int N,M;
    cin >> N >> M;
    vector<int>p(N);
    for(int i = 0; i < N; i++) {
        cin >> p[i];
        p[i]--;
    }
    UnionFind uf(N);
    for(int i = 0; i < M; i++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        uf.unite(x,y);
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(uf.same(i,p[i])) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

const ll mod = 1e9 + 7;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> alp(26, 0);
    REP(i, 0, n){
        alp[s[i]-'a']++;
    }
    ll ans = 1;
    REP(i, 0, 26){
        //cout << alp[i] << endl;
        if(alp[i] == 0){continue;}
        ans = (ans * (alp[i]+1)) % mod;
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String S = in.next();

            if (N % 2 == 1) {
                System.out.println("No");
                return;
            }

            for (int i = 0; i < N / 2; i++) {
                if (S.charAt(i) != S.charAt(N / 2 + i)) {
                    System.out.println("No");
                    return;
                }
            }

            System.out.println("Yes");
        }
    }
}


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


public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);


        int n = in.nextInt();
        int i = in.nextInt();
        out.println(n-i+1);




        out.flush();

    }
    static boolean check(char [] ca,char [] cb) {
        for (char c = 'a';c<='z';c++) {
            HashSet<Character> set = new HashSet<>();
            for (int i = 0; i < ca.length; i++) {
                if(ca[i] == c) {
                    set.add(cb[i]);
                }
                if(set.size() > 1) {
                    return false;
                }
            }
        }
        return  true;
    }
}

class Envelope {
    private int width;
    private int height;

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }

    public Envelope(int width,int height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public String toString() {
        return width + " " + height;
    }
}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

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

    public Integer nextInt() {return Integer.valueOf(next());}
    public Long nextLong() {return  Long.valueOf(next());}
    public Double nextDouble() {return Double.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

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

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

    int a,b,c;
    cin>>a>>b>>c;
    if(a>b)swap(a,b);
    if(b>c)swap(c,b);
    if(a>b)swap(a,b);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


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


int main() {
int X;
cin >> X;
if (X < 600) {
  cout << 8<< endl;
  } else if (X < 800) {
    cout << 7 << endl;
  }else if (X < 1000) {
    cout << 6 << endl;
  }else if (X < 1200) {
    cout << 5 << endl;
  }else if (X < 1400) {
    cout << 4 << endl;
  }else if (X < 1600) {
    cout << 3 << endl;
  }else if (X < 1800) {
    cout << 2 << endl;
  }else if (X < 2000) {
    cout << 1 << endl;
  }

return 0;
}



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

#define int long long

int mod;

vector<int> Graph[100009];

vector< int > down(100009);

vector< int > up(100009);

vector< int > pref[100009];

vector< int > suff[100009];

vector< int > children[100009];


void dfs(int node, int last){
    int p = 1;

    for(int a : Graph[node]){

        if(a == last) continue;

        dfs(a,node);
        children[node].push_back(a);

        p*=(down[a]+1);
        p%=mod;

    }
    down[node] = p;
}


void dfs_2(int node){
    for(int i = 0; i < children[node].size(); i++){

        int a = children[node][i];

        int p = 1;

        if(node != 1){
            p*=(up[node]+1);
            p%=mod;
        }

        if(i) p*=(pref[node][i-1]);
        p%=mod;

        if(i+1 < suff[node].size()) p*=(suff[node][i+1]);
        p%=mod;

        up[a] = p;

        dfs_2(a);

    }
}


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

    int n;

    cin >> n >> mod;

    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        Graph[a].push_back(b);
        Graph[b].push_back(a);
    }

    dfs(1,-1);

    for(int i = 1; i <= n; i++){

        int p = 1;

        for(int a : children[i]){
            p*=(down[a]+1);
            p%=mod;
            pref[i].push_back(p);
        }

        p = 1;
        reverse(children[i].begin(), children[i].end());

        for(int a : children[i]){
            p*=(down[a]+1);
            p%=mod;
            suff[i].push_back(p);
        }

        reverse(children[i].begin(), children[i].end());
        reverse(suff[i].begin(), suff[i].end());

    }

    dfs_2(1);

    for(int i = 1; i <= n; i++){

        int p = 1;

        if(i != 1) p*=(up[i]+1);
        p%=mod;

        if(pref[i].size()) p *= (pref[i].back());
        p%=mod;

        cout << p << endl;

    }
}


Measured memory_bytes: 30464
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t h, w, k;
    cin >> h >> w >> k;

    vector<bitset<1000>> bs(h);
    for (auto i : irange(0L, h)) {
        cin >> bs[i];
    }

    int64_t ans = numeric_limits<int64_t>::max();
    for (auto s : irange(0uL, 1uL << (h - 1))) {
        bitset<10> d(s);

        int64_t tmp = d.count();
        vector<int64_t> nums(d.count() + 1);
        for (auto i : irange(0L, w)) {
            int64_t idx = 0;
            bool over_k = false;
            for (auto j : irange(0L, h)) {
                nums[idx] += bs[j][i];

                if (nums[idx] > k) {
                    over_k = true;
                    break;
                }

                if (d[j]) {
                    ++idx;
                }
            }

            if (!over_k) {
                continue;
            }

            ++tmp;

            idx = 0;
            nums.assign(nums.size(), 0);
            over_k = false;
            for (auto j : irange(0L, h)) {
                nums[idx] += bs[j][i];

                if (nums[idx] > k) {
                    over_k = true;
                    break;
                }

                if (d[j]) {
                    ++idx;
                }
            }

            if (over_k) {
                tmp = numeric_limits<int64_t>::max();
                break;
            }
        }

        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

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

int main(){
	int L, R;
	cin >> L >> R;

	if (R-L+1 >= 2019) {
		cout << 0 << endl;
		return 0;
	}

	int ans = 2019;
	for (int i = L; i < R; i++){
		for (int j = i+1; j <= R; j++){
			int k = (i%2019)*(j%2019);
			k %= 2019;
			ans = min(ans, k);
		}
	}
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 3612
import math
n=int(input())
x=list(map(float, input().split()))
y=list(map(float, input().split()))

c=[abs(x[i]-y[i]) for i in range(n)]

for i in range(1,4):
    ans=0
    for d in c:
        ans += d**i
    print(f"{ans**(1/i):.6f}")
print(f"{max(c):.6f}")


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

int main(){
    int N; cin >> N;
    vector<vector<int>> P(N, vector<int>(3));
    for (int i = 0; i < N; i++)
    {
        cin >> P[i][0] >> P[i][1] >> P[i][2];
    }

    vector<vector<int>> dp(N, vector<int>(3,0)); //dp[i][j] := i日めにjをした時の幸福度の最大値
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if(i == 0) dp[i][j] = P[i][j];
            else{
                for (int k = 0; k < 3; k++)
                {
                    if(j == k) continue;

                    dp[i][j] = max(dp[i][j], dp[i-1][k] + P[i][j]);
                }
                
            }
        }
    }

    /* for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    } */
    

    cout << *max_element(&dp[N-1][0], &dp[N-1][0] + 3) << endl;
}

Measured memory_bytes: 11136
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
 
	
	ll A, B;
	cin >> A>>B ;

	
	cout << A*B/gcd(A,B)<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string s; cin >> s;
  deque<char> deq;
  for (ll i = 0; i < s.size(); i++) {
    deq.push_back(s[i]);
  }
  ll Q; cin >> Q;
  ll count1 = 0;
  for (ll i = 0; i < Q; i++) {
    ll x; cin >> x;
    if (x == 1) {count1++;}
    if (x == 2) {
      ll f; char c; cin >> f >> c;
      if ((count1+f)%2 == 1) {
        deq.push_front(c);
      } else {
        deq.push_back(c);
      }
    }
  }
  if (count1 % 2 == 0) {
    while (!deq.empty()) {
      cout << deq.front(); deq.pop_front();
    }
  }
  if (count1 % 2 == 1) {
    while (!deq.empty()) {
      cout << deq.back(); deq.pop_back();
    }
  }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    string s; cin>>s;
    int n=s.size();
    string t="keyence";
    for(int l=0;l<n;l++){
        for(int r=l;r<n;r++){
            string tmp;
            for(int i=0;i<n;i++){
                if(l<=i&&i<r) continue;
                tmp+=s[i];
            }
            // cout<<tmp<<endl;
            if(tmp==t){
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

a,b,x = map(int,input().split())

tot = a*a*b

if tot//2 <= x:
    t = 2*(tot-x)/(a*a)
    print(np.rad2deg(np.arctan(t/a)))
else:
    t = 2*x/(a*b)
    print(90-np.rad2deg(np.arctan(t/b)))

Measured memory_bytes: 20516
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

void run_case() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    for(auto &x: a) cin >> x;
    for(auto &x: b) cin >> x;
    for(int i = 0; i < n; ++i) c[i] = i+1;
    LL cnt = 1, ansa = 0, ansb = 0;
    do {
        bool flag = true;
        for(int i = 0; i < n && flag && !ansa; ++i)
            if(a[i] != c[i]) flag = false;
        if(flag && !ansa) ansa = cnt;
        flag = true;
        for(int i = 0; i < n && flag && !ansb; ++i)
            if(b[i] != c[i]) flag = false;
        if(flag && !ansb) ansb = cnt;
        cnt++;
        next_permutation(c.begin(), c.end());
    } while(!ansa || !ansb);
    cout << abs(ansa - ansb);
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll a[maxn];
int main() {
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	sort(a+1,a+1+n);
	if(n==2){
		cout<<a[n]<<endl;
		return 0;
	}
	for(int i=1;i*2<=n;i++){
		swap(a[i],a[n-i+1]);
	} 
	ll sum = 0;
	for(int i=2;i<=n;i++){
		sum+=a[(i+1)/2];
	//	cout<<sum<<endl;
	}
	cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 5184
n=int(input())
k=int((n*2)**0.5+1)
if k*(k-1)!=n*2:
    print('No')
    exit()
print('Yes')
a=1
b=[[] for i in range(k)]
for i in range(k):
    for j in range(i+1,k):
        b[i].append(a)
        b[j].append(a)
        a+=1
print(k)
for i in b:print(k-1,*i)

Measured memory_bytes: 9416
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
int N;cin >> N;
int ans=0;
vector<int> d(N);
for(int i=0;i<N;i++){cin >> d.at(i);}
for(int i=0;i<N;i++)
{
  for(int j=i+1;j<N;j++){ans+=d.at(i)*d.at(j);}
}
cout << ans;
}

Measured memory_bytes: 256
n ,m,x = map(int,input().split())
a = [None] * n
c = [None] * n
ans = float('inf')
for i in range(n):
    a[i] = list(map(int,input().split()))
    c[i] = a[i][0]
    a [i] = a[i][1:]
for i in range(2 ** n):
    rikai = [0] * m
    kane = 0
    bi = format(i,'012b')
    for j in range(n):
        if (i >> j)%2 == 1:
            kane += c[j]
            rikai = [rikai[f] + a[j][f] for f in range(m)]
    if all(rikai[f] >= x for f in range(m)):
        ans = min(ans,kane)
if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 74532
print([0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())])

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 998244353
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    string a;
    cin>>a;
    bool ok=false;
    int memo=1;
    int m=0;
    string s;
    for(int j=0;j<a.size();j++){
      if(a[j]=='.'){
        ok=true;
        memo=j+1;
      }
      else{
        s+=a[j];
      }
    }
    memo+=m;
    if(ok) for(int j=0;j<9-(a.size()-memo);j++)s+='0';
    else for(int j=0;j<9;j++)s+='0';
    A[i]=stol(s.c_str());
  }
  int ans=0;
  vector<vector<vector<int>>>dp(32,vector<vector<int>>(32,vector<int>(32)));
  for(int i=0;i<N;i++){
    int a=A[i];
    int x=0;
    while(a%10==0&&a!=0)a/=10,x++;
    int b=a;
    int y=0;
    while(b%2==0&&b!=0)b/=2,y++;
    int c=a;
    int z=0;
    while(c%5==0&&c!=0)c/=5,z++;
    for(int j=0;j<32;j++){
      //2を探す
      for(int k=1;k<32;k++){
        int sum=j+x;
        sum+=min(y,k);
        if(sum>=18)ans+=dp[j][0][k];
      }
      //5を探す
      for(int k=1;k<32;k++){
        int sum=j+x;
        sum+=min(z,k);
        if(sum>=18)ans+=dp[j][k][0];
      }
      int sum=j+x;
      if(sum>=18)ans+=dp[j][0][0];
    }
    dp[x][y][z]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5164
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var X = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            Console.WriteLine((X - A) % B);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum;

ii p[N];

void f(int t)
{
	int q=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(j==n-i+t)
				continue;
			q++;
			p[q].fi=i;
			p[q].se=j;
		}
	}
	cout<<q<<endl;
	for(int i=1;i<=q;i++)
		cout<<p[i].fi<<sp<<p[i].se<<endl;
}

int main()
{
	fast;
	cin>>n;
	if(n%2==0)
		f(1);
	else
		f(0);

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll cnt=a/c,cnt2=a/d;
ll r=c*d/(__gcd(c,d));
ll k=a/r;
ll f=cnt+cnt2-k;
 cnt=b/c,cnt2=b/d;
 r=c*d/(__gcd(c,d));
k=b/r;
ll f2=cnt+cnt2-k;
ll h=f2-f+(a%c==0 || a%d==0);
cout<<b-a+1-h<<endl;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    string s;
    string t;
    cin >> s >> t;
    cout << t << s;
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<double> v(n);
  for (int i = 0; i < n; i++) {
    double a;
    cin >> a;
    v[i] = (a + 1) / 2;
  }
  vector<double> s(n + 1);
  for (int i = 0; i < n; i++) s[i + 1] = s[i] + v[i];
  double ans = 0.0;
  for (int i = 0; i <= n - k; i++) {
    ans = max(ans, s[i + k] - s[i]);
  }
  printf("%.9lf\n", ans);
  return 0;
}


Measured memory_bytes: 3456