akhauriyash/Code-Regression huggingface dataset:
n,m,x=map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]

ans = 1234567890123

for bit in range(1<<n):
    syu = [0]*m
    cost = 0
    for i in range(n):
        if (bit>>i)&1:
            cost += ca[i][0]
            for j in range(1,m+1):
                syu[j-1] += ca[i][j]
    ok = True
    for i in range(m):
        if syu[i] < x:
            ok = False

    if ok:
        ans = min(ans,cost)
print(ans if ans != 1234567890123 else -1)

Measured memory_bytes: 68436
import java.util.*;

import static java.lang.System.*;

class Main {
    public static Scanner sc = new Scanner(in);
    public static Random rand=new Random();

    public List<Integer> getPrimeList(int max){
		LinkedList<Integer> primes=new LinkedList<Integer>();

		PLoop:for(int i=2;i<max;i++){
			for(int prime:primes){
				if(i%prime==0){
					continue PLoop;
				}
				if( prime*prime>i){
					break;
				}
			}
			primes.add(i);
		}
		return primes;
	}


    public void run() {
    	List<Integer> plist=new ArrayList<Integer>(getPrimeList(1300000));

    	TCase:while(true){
    		int n=sc.nextInt();
    		if(n==0)return;
    		if(plist.contains(n)){
    			ln(0);
    		}else{
    			int ind=Collections.binarySearch(plist,n);

    			ln(plist.get(~ind)-plist.get(~ind-1));
    		}
    	}
    }
    public static void main(String[] args) {
        new Main().run();
    }

    public int[] nextIntArray(int n){
        int[] res=new int[n];
        for(int i=0;i<n;i++){
            res[i]=sc.nextInt();
        }
        return res;
    }
    public static void pr(Object o) {
        out.print(o);
    }
    public static void ln(Object o) {
        out.println(o);
    }
    public static void ln() {
        out.println();
    }
}

Measured memory_bytes: 58204
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e8;
const int MAX_V = 201;
int a[4];
int c[10];
bool use[10];
int t[10][10];
void HarshadNumber() {
	int n;
	cin >> n;
	int s = 0;
	int nt = n;
	while (nt > 0)
	{
		s += nt % 10;
		nt /= 10;
	}
	if (n % s == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

int main() {
	HarshadNumber();
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vl                    vector<ll>
#define SZ(x)                 (x).size()
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define dbg(x)                cout <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;
void FAST_IO();
void ara_read(vec &v,ll n);
////////////////////////

int main()
{
	FAST_IO();
	ll n , k; cin>>n>>k;
	string s; cin>>s;
	for(int i=0; i< n; i++){
		if(i==k-1){
			if(s[i]<='a'){
				s[i]=s[i]+' ';
				cout<<s[i];
			}
		}
		else{
			cout<<s[i];
		}
	}
	cout<<endl;
	
   return 0;
}

void FAST_IO()
{
     ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);

}
void ara_read(vec &v,ll n){
	ll temp;
	for(ll i=0; i<n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
	
}


Measured memory_bytes: 256
h, w = map(int,input().split())
s = [input() for i in range(h)]

def f(i, j):
    t = [[-1]*w for j in range(h)]
    t[i][j] = 0
    q = [(i,j)]
    while q:
        y, x = q.pop(0)
        if y - 1 >= 0 and s[y-1][x] != "#" and t[y-1][x] == -1:
            t[y-1][x] = t[y][x] + 1
            q.append((y-1,x))
        if y + 1 < h and s[y+1][x] != "#" and t[y+1][x] == -1:
            t[y+1][x] = t[y][x]+1
            q.append((y+1,x))
        if x - 1 >= 0 and s[y][x-1] != "#" and t[y][x-1] == -1:
            t[y][x-1] = t[y][x] + 1
            q.append((y,x-1))
        if x + 1 < w and s[y][x+1] != "#" and t[y][x+1] == -1:
            t[y][x+1] = t[y][x] + 1
            q.append((y,x+1))
    return max(max(tt) for tt in t)
result = 0
for i in range(h):
    for j in range(w):
        if s[i][j] != "#":
            result = max(result,f(i,j))
print(result)



    
        
    
    


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif
vector<int> Zalgo(string s){
	int N = s.size();
	vector<int> Z(N);
	Z[0] = N;
	int i = 1, j = 0;
	while(i<N){
		while(i+j<N && s[j]==s[i+j]) ++j;
		Z[i] = j;
		if(j==0){
			++i;
			continue;
		}
		int k = 1;
		while(i+k<N && k+Z[k]<j) Z[i+k]=Z[k],++k;
		i += k, j -= k;
	}
	return Z;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	string s; cin >> s;
	string x,y;
	{
		int N = s.size();
		auto z = Zalgo(s); z.pb(0);
		rep1(i,N){
			if(z[i] == N-i){
				x = s.substr(0,i);
				break;
			}
		}
	}
	{
		int N = x.size();
		auto z = Zalgo(x); z.pb(0);
		rep1(i,N){
			if(z[i] == N-i){
				y = s.substr(0,i);
				break;
			}
		}
	}
	auto f = [&](ll N){
		V<ll> c0(26),c1(26);
		for(char c: y) c0[c-'a']++;
		for(char c: x) c1[c-'a']++;
		V<ll> len = {si(y),si(x)};
		VV<ll> cnt = {c0,c1};
		while(len.back() < N){
			len.pb(len[si(len)-1]+len[si(len)-2]);
			V<ll> c(26);
			rep(i,26) c[i] = cnt[si(cnt)-1][i] + cnt[si(cnt)-2][i];
			cnt.pb(c);
		}
		V<ll> res(26);
		function<void(int,ll)> dfs = [&](int k,ll N){
			assert(len[k] >= N);
			if(k == 0){
				rep(i,N) res[y[i]-'a']++;
				return;
			}
			if(k == 1){
				rep(i,N) res[x[i]-'a']++;
				return;
			}
			if(len[k-1] <= N){
				rep(i,26) res[i] += cnt[k-1][i];
				dfs(k-2,N-len[k-1]);
			}else{
				dfs(k-1,N);
			}
		};
		dfs(si(len)-1,N);
		return res;
	};
	ll L,R; cin >> L >> R;
	auto r = f(R), l = f(L-1);
	rep(i,26) cout << r[i]-l[i] << " ";
	cout << endl;
}


Measured memory_bytes: 2128
using System;

class Program {
    static void Main( string[] args )
    {
        int s = int.Parse( Console.ReadLine() );
        int h = s / 3600;
        s %= 3600;
        int m = s / 60;
        s %= 60;
        Console.WriteLine( "{0}:{1}:{2}", h, m, s );
    }
}

Measured memory_bytes: 9116
#include<bits/stdc++.h>
 
#define ll long long 
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
ll z , o , ans ;

ll N = 1e4 + 15820 ;

int main(){ skorost ;

	int n ;

	cin >> n ;

	cout << ( n * ( n + 1 ) ) / 2 ;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    static int MOD = (int)1e9+7;

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();
        int[] clone = arr.clone();

        long ans = 0;

        long lcm = 1;

        int max = 0;
        for (int i=0; i<n; i++) max = Math.max(max, arr[i]);

        int[] div = new int[max+1];

        for (int i=0; i<n; i++){
            int tmp = arr[i];
            for (int j=2; j*j<=tmp; j++){
                int cnt = 0;
                while (tmp%j==0){
                    cnt++;
                    tmp /= j;
                }
                div[j] = Math.max(div[j], cnt);
            }
            if (tmp!=1) div[tmp] = Math.max(div[tmp], 1);
        }

        for (int i=2; i<=max; i++){
            lcm *= pow(i, div[i]);
            lcm %= MOD;
        }

        for (int i=0; i<n; i++){
            ans += lcm*pow(clone[i], MOD-2);
            ans %= MOD;
        }

        System.out.println(ans);

    }
    public static long pow(long m, long n){
        if (n==0) return 1;
        else if (n==1) return m;
        long x = pow(m, n/2);
        return n%2==0 ? x*x%MOD : x*(x*m%MOD)%MOD;
    }

    public static long lcm(long m, long n){
        return m*n/gcd(m, n);
    }
    public static long gcd(long m, long n){
        if (m<n) gcd(n, m);
        if (n==0) return m;
        return gcd(n, m%n);
    }
}

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

struct ab{
	int a;
	int b;
};
int cmp(const void *a, const void*b)
{
	return ((ab*)a)->a - ((ab*)b)->a;
}
int main(void){
	//N回挿入するということで・・・
	//K番目に小さい数というのは
	//小さい数のbを見ていって
	//K番目のbの左のa
	ab ab[100001];
	long long N;
	long long K;
	cin >> N >> K;
	long long i;
	for(i=0;i<N;i++){
		cin >> ab[i].a >> ab[i].b;
	}
	qsort(ab,N,sizeof(struct ab),cmp);
	long long count = 0;
	for(i=0;i<N;i++){
		count += ab[i].b;
		if(count >=K){
			cout << ab[i].a << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1788
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize
    }

    let mut ans = 0;

    println!("{}", if n % 2 == 0 { n / 2 } else { (n + 1) / 2 });
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
#define nl '\n'
#define pb push_back
#define mp make_pair

using namespace std;
const int K = 105;
const int N = 200005;
template<typename T>
class ConvexHullTrick{
public:
    deque<pair<T,T> > dq;
    ConvexHullTrick(){};
    //min
    //x:monotonic
    T get(T x){
        while(dq.size()>=2){
            T l=dq[0].first*x+dq[0].second;
            T r=dq[1].first*x+dq[1].second;
            if(l<=r) break;
            dq.pop_front();
        }
        return dq[0].first*x+dq[0].second;
    }
    //x:other
    T getg(T x){
        int l=-1,r=dq.size()-1;
        while(r-l>1){
            int mid=(r+l)/2;
            T tl=dq[mid].first*x+dq[mid].second;
            T tr=dq[mid+1].first*x+dq[mid+1].second;
            if(tl<=tr) r=mid;
            else l=mid;
        }
        return dq[r].first*x+dq[r].second;
    }
    void add(pair<T,T> x){
        while(dq.size()>=2){
            pair<T,T> l=dq[dq.size()-1];
            pair<T,T> r=dq[dq.size()-2];
            if((x.second-l.second)*(r.first-l.first)>=(l.first-x.first)*(l.second-r.second)) break;
            dq.pop_back();
        }
        dq.pb(x);
    }
};
int h[200001];
int dp[200001];
int32_t main()
{
	fio();
	int n,c;
	cin>>n>>c;
	for(int i=0;i<n;i++)
		cin>>h[i];
	ConvexHullTrick<int> cht;
	dp[0]=0;
	cht.add({-h[0]*2,h[0]*h[0]});
	for(int i=1;i<n;i++)
	{
		dp[i]=cht.getg(h[i])+h[i]*h[i]+c;
        cht.add({-h[i]*2,h[i]*h[i]+dp[i]});
	}
	cout<<dp[n-1]<<endl;
	
}



Measured memory_bytes: 6656
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
from fractions import gcd

NN = 202020
MOD = 10**9+7
INF = float("inf")

s = input()
k = int(input())
strings = set()

for i in range(len(s)):
    for j in range(5):
        end = i+j+1
        if end > len(s):
            break
        strings.add(s[i:end])

strings = sorted(list(strings))
# print(strings)

print(strings[k-1])


Measured memory_bytes: 65644
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

l = []
for i in range(1, N+1):
  l.append(i)
  
p_list = list(itertools.permutations(l))
a = p_list.index(P)
b = p_list.index(Q)
ans = abs(b-a)
print(ans)

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 26;

int n, m;
int f[N][M];
char s[N], t[N];

int main()
{
	scanf("%s%s", s, t);
	n = strlen(s), m = strlen(t);
	
	memset(f, -1, sizeof f);
	for (int i = n - 1; i >= 0; i -- )
	{
		for (int j = 0; j < M; j ++ ) f[i][j] = f[i + 1][j];
		f[i][s[i] - 'a'] = i;
	}
	
	int a = 0, b = 0;
	for (int i = 0; i < m; i ++ )
	{
		int c = t[i] - 'a';
		if (f[0][c] == -1)
		{
			puts("-1");
			return 0;
		}
		
		if (f[b][c] == -1) a ++ , b = 0;
		b = f[b][c] + 1;
	}
	printf("%lld\n", (LL)a * n + (LL)b);
	return 0;
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define maxn 405
#define o 203
using namespace std;

int n,H,in[maxn];
int F[maxn],hd[maxn],sz[maxn];
int Find(int u){ return !F[u] ? u : F[u] = Find(F[u]); }

int main(){
	scanf("%d%d",&n,&H);
	for(int i=1;i<=n;i++){
		int A,B,C,D;
		scanf("%d%d%d%d",&A,&B,&C,&D);
		int x , y;
		if(C == 0) x = A;
		else x = - C;
		if(D == 0) y = -B;
		else y = D;
		x += o , y += o;
		in[y] ++ ,in[x] --;
		if(Find(x) != Find(y))
			F[Find(x)] = Find(y);
		sz[Find(y)] = 2; 
	}
	bool ER = 0;
	for(int i=1;i<maxn;i++){
		if(i < o && in[i] < 0) ER = 1;
		if(i > o && in[i] > 0) ER = 1;
		if(i > o && in[i] < 0) hd[Find(i)] = 1;
	}
	for(int i=1;i<maxn;i++) if(Find(i) == i && sz[i] > 1 && !hd[i])
		ER = 1;
	if(ER) puts("NO");
	else puts("YES");
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,a,b;
	cin>>n>>a>>b;
	int ans=1;
	if(n%12>=6)ans*=-1;
	switch(n%6){
	    case 0:
	        cout<<a*ans<<" "<<b*ans<<endl;
	        break;
	    case 1:
	        cout<<(a-b)*ans<<" "<<b*ans<<endl;
	        break;
	    case 2:
	        cout<<(a-b)*ans<<" "<<a*ans<<endl;
	        break;
	    case 3:
	        cout<<-b*ans<<" "<<a*ans<<endl;
	        break;
	    case 4:
	        cout<<-b*ans<<" "<<(a-b)*ans<<endl;
			break;
	    case 5:
	        cout<<-a*ans<<" "<<(a-b)*ans<<endl;
	        break;
	}
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,k;
    cin>>n>>k;
    Vec h(n);
    rep(i,n)cin>>h[i];
    sort(ALL(h));
    reverse(ALL(h));
    ll ans=INF;

    for(ll i=0;i+k-1 <n;i++){
        ll tmp = h[i]-h[i+k-1];
        ans = min(ans,tmp);
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 1024
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;




int main(){
    ll t;
    cin>>t;
    while(t--){
        ll a,b;
        cin>>a>>b;
        if(a>b){swap(a,b);}
        ll k=sqrt(a*b);
        ll count=k;
        if(k*k==a*b){count--;}
        count*=2;
        if(k*k==a*b && a<k){count--;}
        if(k*k!=a*b && k*(k+1)>=a*b){count--;}
        if(k*k!=a*b && a<=k){count--;}
        
        cout<<count<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var A = input[1];
        var B = input[2];
        var C = input[3];
        var D = input[4];
        var nedan1 = ((N + A - 1) / A) * B;
        var nedan2 = ((N + C - 1) / C) * D;
        Console.WriteLine(Math.Min(nedan1, nedan2));
    }
}


Measured memory_bytes: 20468
#!/usr/bin/ruby
while (h,w,l=gets.split.map(&:to_i))!=[0,0,0]
d=[[0,-1],[1,0],[0,1],[-1,0]]
d0="NESW".split('')
f=(h+2).times.map{[1]*(w+2)}
g=(h+2).times.map{(w+2).times.map{[nil]*4}}
z=x=y=0
h.times{|i|
	s=gets.chomp
	w.times{|j|
		if (k=d0.index(s[j..j]))
			x=j+1;y=i+1;z=k
		end
		if s[j..j]!='#'
			f[i+1][j+1]=nil
		end
	}
}
c=0
while l>0
	break if g[y][x][z]&&(l%=c-g[y][x][z])==0
	g[y][x][z]=c
	while true
		if !f[y+d[z][1]][x+d[z][0]]
			x+=d[z][0];y+=d[z][1]
			break
		end
		z=(z+1)%4
	end
	l-=1
	c+=1
end
puts "#{y} #{x} #{d0[z]}"
end

Measured memory_bytes: 10348
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long S = sc.nextLong();
        System.out.println( solve(N, S) );
    }

    private static long solve(long N, long S) {
        if( N == S ) return N+1;

        long rootN = (long)Math.sqrt(N);

        // n^2 以上で表現されるもの
        for (long b = 2; b <= rootN; b++) {
            if( f(b, N) == S ) {
                return b;
            }
        }

        // pb + q の形で表現されるもの
        long min = Long.MAX_VALUE;
        for (long p = rootN; p >= 1; p--) {
            long b = (N - S + p) / p;
            if( b >= 2 && f(b, N) == S ) {
                min = Math.min(b, min);
            }
        }

        if( min != Long.MAX_VALUE ) {
            return min;
        } else {
            return -1;
        }
    }

    private static long f(long b, long n) {
        if( b <= 1 ) throw new IllegalArgumentException("wtf");
        if( n < b ) {
            return n;
        } else {
            return f(b, n/b) + (n % b);
        }
    }
}

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

int main() {
    string s;
    cin >> s;
    int i = s.size() - 1;
    while(i >= 0) {
        if(i >= 4 && s.substr(i - 4, 5)== "dream"){
            i -= 5;
        }
        else if(i >=4 && s.substr(i - 4, 5)== "erase") {
            i -= 5;
        }
        else if(i >=6 && s.substr(i - 6, 7)== "dreamer") {
            i -= 7;
        }
        else if(i >=5 && s.substr(i - 5, 6)== "eraser") {
            i -= 6;
        }
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>

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

	std::vector<int> emp(n, 0);
	for(int i = 2; i <= n; ++i){
		int a;
		std::cin >> a;
		++emp.at(a - 1);
	}

	for(int i = 0; i < n; ++i){
		std::cout << emp.at(i) << std::endl;
	}

	return 0;
}


Measured memory_bytes: 4052
import itertools


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

L = [0, 1]
num = N
bit_list = list(itertools.product(L, repeat=num))

A = []
C = []
for i in range(N):
    CiAi = list(map(int, input().split()))
    Ci, Ai = CiAi[0], CiAi[1:]
    C.append(Ci)
    A.append(Ai)

if __name__ == "__main__":

    min_cost = float('inf')
    for bit in bit_list:
        cost = 0
        understand = [0 for _ in range(M)]
        for i in range(N):
            if bit[i] == 1:
                cost += C[i]
                for j in range(M):
                    understand[j] += A[i][j]
        
        clear = True
        for u in understand:
            if u < X:
                clear = False
                break
        
        if clear and cost < min_cost:
            min_cost = cost
    
    if min_cost == float('inf'):
        print(-1)
    else:
        print(min_cost)

Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
int main () {
  int n ;
  cin >> n;
  int a [n];
  int d = 0 ;
  int e = 0 ;int k =999999999;
  for (int i = 0 ; i < n; i++) {
    cin >> a[i];
    d+= a[i];}
  for (int i =0; i <n;i++){
    e+= a[i];
    int r = d - e; 
    if (k > abs(r-e)) {
      k= abs(r-e); } }
  cout << k; }
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s_a,s_b,s_c;
    cin >> s_a >> s_b >> s_c;
    bool hata = true;
    char c = s_a.at(0);
    s_a.erase(s_a.begin());
    if(s_a.size() == 0) {
        cout << "A" << endl;
        return 0;
    }
    while(hata) {
        if(c == 'a') {
            if(s_a.size() == 0) {
                cout << "A" << endl;
                return 0;
            }
            c = s_a.at(0);
            s_a.erase(s_a.begin());
        }else if(c == 'b') {
            if(s_b.size() == 0) {
                cout << "B" << endl;
                return 0;
            }
            c = s_b.at(0);
            s_b.erase(s_b.begin());
        }else {
            if(s_c.size() == 0) {
                cout << "C" << endl;
                return 0;
            }
            c = s_c.at(0);
            s_c.erase(s_c.begin());
        }
    }
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

q, h, s, d = ril()
n = ri()
x = min(4 * q, 2 * h, s)
if 2 * x < d:
    print(n * x)
else:
    print(n // 2 * d + n % 2 * x)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
    char code[4];
    scanf("%s",code);
    int count = 0;
    if(code[0] == code[1]) count++;
    if(code[1] == code[2]) count++;
    if(code[2] == code[3]) count++;
    if(count == 0) printf("Good\n");
    else printf("Bad\n");
}

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

int main() {
  ll N, K, Q;
  cin >> N >> K >> Q;
  vector<ll> p(N, 0);
  for (ll i = 0; i < Q; i++) {
    ll who;
    cin >> who;
    p[who - 1]++;
  }

  for (ll i = 0; i < N; i++) {
    if (K - (Q - p[i]) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int H, W, K;
    cin >> H >> W >> K;

    vector< vector<char> > c(H, vector<char>(W));
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cin >> c[i][j];
        }
    }

    int ans = 0;
    for(int bit=0; bit<(1<<(H+W)); bit++) {
        int tmp = 0;
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                if(c[i][j] == '#' && (bit>>i & 1) && (bit>>(H+j) & 1)) ++tmp;
            }
        }
        if(tmp == K) ++ans;
    }

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


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  if (n % 3 != 0){
    int ok = 1;
    for (int i = 0; i < n; i++){
      if (a[i] != 0)
        ok = 0;
    }
    if (ok)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  else {
    ll t = 0;
    for (int i = 0; i < n; i++){
      t ^= a[i];
    }
    if (t == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())

void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

void test_case(){
    int n;
    cin>>n;
    lld sum=0;
    for(int i=1;i<=n;++i){
        if(i%3==0 || i%5==0){
            // sum+=i;
            continue;
        }
        else{
            sum+=i;
        }
    }
    test(sum);
}

int main(){
    fastio;
    file();
    int T=1;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
    //     cout<<"Case #"<<nr<<": ";
		test_case();
    }
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

int main()
{
	cout << setprecision(10);
	cin >> s;
	if(s == "SUN") cout << 7 << endl;
	if(s == "MON") cout << 6 << endl;
	if(s == "TUE") cout << 5 << endl;
	if(s == "WED") cout << 4 << endl;
	if(s == "THU") cout << 3 << endl;
	if(s == "FRI") cout << 2 << endl;
	if(s == "SAT") cout << 1 << endl;
	

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char c[4];
  scanf("%s",c);
  if(strcmp("SUN",c)==0) printf("7\n");
  else if(strcmp("MON",c)==0) printf("6\n");
  else if(strcmp("TUE",c)==0) printf("5\n");
  else if(strcmp("WED",c)==0) printf("4\n");
  else if(strcmp("THU",c)==0) printf("3\n");
  else if(strcmp("FRI",c)==0) printf("2\n");
  else printf("1\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N,A,B;
vector<ll> vec;
string S;


//解法
void solve() {

	ll pos = 0;

	rep(i, A) {
		if (!(S[pos] >= '0' && S[pos] <= '9')) {
			cout << "No";
			return;
		}
		pos++;
	}
	
	if (S[pos] != '-') {
		cout << "No";
		return;
	}
	pos++;

	rep(i, B) {
		if (!(S[pos] >= '0' && S[pos] <= '9')) {
			cout << "No";
			return;
		}
		pos++;
	}

	cout << "Yes";

	return;
}

int main() {
	//入力

	cin >> A>>B>>S;


	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vii vector<ii>
#define vs vector<string>
#define si set<ll>
#define endl "\n"
#define pb push_back
#define x first
#define y second
//g++ -std=c++11 -Wall -Wextra -pedantic-errors main.cpp -o main
const int ms = 1e3 + 5, base = 31, mod = 1e9 + 7;
using namespace std;

ll n, m, dp[ms][ms];
string mat[ms];

ll solve(int i, int j){

	if (i == n-1 && j == m-1) return 1;
	
	if (dp[i][j] != -1) return dp[i][j];
	
	ll resp = 0;
	
	if (i+1 < n && mat[i+1][j] != '#')
		resp += solve(i+1, j)%mod;
	if (j+1 < m && mat[i][j+1] != '#')
		resp += solve(i, j+1)%mod;
		
	resp %= mod;	
	
	return dp[i][j] = max(dp[i][j], resp);
}

int main(){
	ios::sync_with_stdio(false), cin.tie(0);
	
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));
	
	for (int i = 0; i < n; i++){
		string line; cin >> mat[i];
	}
	
	cout << solve(0,0) << endl;
	
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define REP(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
using namespace std;

string s;
int main(){
    int a=0,b=0;
    cin>>s;
    fore(i,s){
        if(i=='A'){
            a++;
        }else{
            b++;
        }
    }
    if(a==0||b==0){
        puts("No");
    }else{
        puts("Yes");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void pf(int n){
for(int i=2;i<=sqrt(n);i++){
if(n%i==0){
printf(" %d",i);
pf(n/i);
return;
}
}
printf(" %d\n",n);
}
int main(){
int n;
scanf("%d",&n);
printf("%d:",n);
pf(n);
}

Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  string s[2];
  cin >> s[0] >> s[1];
  reverse(s[0].begin(), s[0].end());
  if (s[0] == s[1]) YES;
  else NO;


  return 0;
}

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

const int maxn = 1e5 + 5;
const long long INF = 1e18;
int n, f[maxn];
long long ini[maxn], dp[maxn][3];

inline void putit(){
	scanf("%d", &n); char opt[30];
	scanf("%lld", &ini[1]); f[1] = 1;
	for(int i = 2; i <= n; ++i){
		scanf("%s", opt + 1); f[i] = (opt[1] == '+') ? 1 : -1;
		scanf("%lld", &ini[i]);
	} 
}

inline void check(){
	for(int i = 1; i <= n; ++i){
		printf("dp[%d][0] = %lld ", i, dp[i][0]);
		printf("dp[%d][1] = %lld ", i, dp[i][1]);
		printf("dp[%d][2] = %lld ", i, dp[i][2]);
		printf("\n");
	}
}

inline void workk(){
	long long lin0, lin1, lin2;
	dp[1][0] = ini[1]; dp[1][1] = dp[1][2] = -INF;
	for(int i = 2; i <= n; ++i){
		if(f[i] == 1){
			lin0 = dp[i - 1][0] + ini[i];
			lin1 = dp[i - 1][1] - ini[i];
			lin2 = dp[i - 1][2] + ini[i];
			dp[i][0] = max(lin0, lin1); dp[i][1] = max(lin1, lin2); dp[i][2] = lin2;
		}
		else{
			lin0 = dp[i - 1][0] - ini[i];
			lin1 = dp[i - 1][1] + ini[i];
			lin2 = dp[i - 1][2] - ini[i];
			dp[i][1] = max(lin1, lin0); dp[i][2] = max(lin2, lin1);
			dp[i][0] = max(lin0, lin1); dp[i][1] = max(dp[i][1], dp[i][2]);
		}
	}
	//check();
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int main()
{
	//freopen("lpl.in", "r", stdin);
	//freopen("lpl.out", "w", stdout);
	putit();
	workk();
	return 0;
}

Measured memory_bytes: 3712
x = list(map(int,input().split(" ")))
n = x[0]
k = x[1]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

xk = Base_10_to_n(n, k)
print( len(xk) )

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
const ll mod = 1e9 + 7;
 
const int nmax = 9;

int n, m;
int G[nmax][nmax];
int vis[nmax];

int dfs(int cur) {
  int visited = 0;
  for (int i = 1; i <= n; i++) {
    visited += vis[i];
  }
  if (visited == n) return 1;
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    if (G[cur][i] && !vis[i]) {
      vis[i] = 1;
      ret += dfs(i);
      vis[i] = 0;
    }
  }
  return ret;
}
 
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    G[x][y] = 1;
    G[y][x] = 1;
  }
  vis[1] = 1;
  cout << dfs(1) << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P> v2,que;
ll n,m,d,a,b,c,ans,cnt,st;
int main(void){
    cin>>n>>m>>d;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v2.push_back({a,b});
    }
    sort(v2.begin(),v2.end());
    for(int j=0;j<n;j++){
        a=v2[j].first;
        b=v2[j].second;
        cnt=(b+d-1)/d;
        ll N=que.size();
        for(int i=st;i<N;i++){
            auto q=que[i];
            if(q.first>=a){
                cnt-=q.second;
                if(cnt<=0)break;
            }
            else{
                st=i+1;
            }
        }
        if(cnt>0){
            ans+=cnt;
            if(N-1>=0&&que[N-1].first>=v2[n-1].first){
                que[N-1].second+=cnt;
            }
            //cout<<N-1<<endl;
            else que.push_back({a+2*m,cnt});
        }
    }
    //for(auto x:que){
    //    cout<<x.first<<" "<<x.second<<endl;
    //}
    cout<<ans<<endl;
}


Measured memory_bytes: 11500
#include <bits/stdc++.h>
using namespace std;
const int INF=1<<29;
 
int main() {
  int n,d[5];
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n-2; i++) {
    if(a[i]==a[i+1] && a[i]==a[i+2]) a[i]=INF;
  }
  a.erase(remove(a.begin(),a.end(),INF),a.end());
  memset(d,0,sizeof(d));
  for(int i=2; i<a.size(); i++) {
    if(i>=3 && a[i-2]==a[i-1]) {
      if(a[i-2]>a[i-3]) {
        if(a[i]<a[i-1]) d[0]++;
        else if(a[i]>a[i-1]) d[2]++;
      } else {
        if(a[i]>a[i-1]) d[1]++;
        else if(a[i]<a[i-1]) d[2]++;
      }
    }
    if(a[i-1]>a[i-2] && a[i]<a[i-1]) d[3]++;
    if(a[i-1]<a[i-2] && a[i]>a[i-1]) d[4]++;
  }
  for(int i=0; i<5; i++) {
    if(i) cout << " ";
    cout << d[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3108
/* ex 5_4
   TKC001 */

#include <stdio.h>
#include <string.h>

int main(void){

    char str[11], *p_str;
    int max = 0, len, i, j;
    //入力
    scanf("%s", &str[0]);

    p_str = str;

    while (*p_str != 0){
        //strのx文字目かからの文字列の長さ(xは繰り返しの回数)
        len = strlen(p_str);

        for (i = len; i > 0; i--){
            //x文字目からi-1文字目までがすべてATGCで構成されているか調べる。
            for (j = 0; j < i; j++){
                if(*(p_str+j) != 'A' && *(p_str+j) != 'T' && *(p_str+j) != 'G' && *(p_str+j) != 'C') break;
                if(j+1 > max) max = j+1;//breakされないときはx文字目からj文字目まで全てATGCで構成されている。
                }            
        }
        //xを増やす
        p_str++;
    }
    
    //出力
    printf("%d", max);

    return 0;
}

Measured memory_bytes: 1708
#include<stdio.h>
#include<string.h>
int main()
{
    int i, n,len;
    char str[1000];

    scanf("%d",&n);
    getchar();
    while(n--)
    {
        gets(str);
        len=strlen(str)-6;
        for(i=0; i<len; i++)
        if(str[i]=='H'&&str[i+1]=='o'&&str[i+2]=='s'&&str[i+3]=='h'&&str[i+4]=='i'&&str[i+5]=='n'&&str[i+6]=='o')
        str[i+6]='a';
        puts(str);
    }
    return 0;
}


Measured memory_bytes: 584
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,i=0;
    string s;
    cin>>n;
    cin.ignore();
    for(;i<n;i++){
        getline(cin,s);
        while(s.find("Hoshino")!=string::npos)s.replace(s.find("Hoshino"),7,"Hoshina");
        cout<<s<<endl;
    }
}

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

#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;

ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}

const int N = 1e6+9;
// int a[N];

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

    int n; cin >> n;
    string s; cin >> s;

    if(s.substr(0, n/2) == s.substr(n/2)) {
        cout << "Yes\n";
    } else cout << "No\n";
    
    


    return 0;
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a == 5 && b == 5 && c == 7)
    {printf("YES\n");}
    else if(a == 5 && b == 7 && c == 5) 
    {printf("YES\n");}
    else if(a == 7 && b == 5 && c == 5)
    {printf("YES\n");}
    else
    {printf("NO\n");}
    return 0;
}

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

int count (int n, int x){
	int cnt = 0;
	for(int i=1;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n+1;k++){
				if(i+j+k==x) cnt++;
				}
			}
		}
	return cnt;
	}
	
int main(){
	int n,x;
	
	while(1){
		cin>>n>>x;
		if(n==0 &&x==0) break;
		cout<<count(n,x)<<endl;
		}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++){
            nums[i] = sc.nextInt();
        }
        int[] dp = new int[1000001];
        Arrays.sort(nums);
        for (int i = 1; i < n; i++){
            if (nums[i] == nums[i-1] && dp[nums[i]] == 0){
                for (int j = nums[i]; j < dp.length; j+=nums[i]){
                    dp[j] = 1;
                }
            }
        }
        
        int elm, ans = 0;
        for (int i = 0; i < n; i++){
            elm = nums[i];
            if (dp[elm] == 1) continue;
            ans++;
            for (int j = elm; j < dp.length; j+=elm){
                dp[j] = 1;
            }
        }
        System.out.println(ans);
    }
}
class FastReader{ 
    BufferedReader br; 
    StringTokenizer st; 
    public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    int nextInt(){ 
        return Integer.parseInt(next()); 
    } 
    long nextLong(){ 
        return Long.parseLong(next()); 
    } 
    double nextDouble(){ 
      return Double.parseDouble(next()); 
    } 
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    } 
}


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

using namespace std;

int zerolength(string a, string b, string c)	{
  	int res = 0;
	if (a.length() == 0)
      	res++;
 	if (b.length() == 0)
      	res++;
 	if (c.length() == 0)
      	res++;
  	return res;
}

int main()	{
	string a, b, c;
  	char next;
  	cin >> a >> b >> c;
  	next = a[0];
  	a.erase(a.begin());
  	while (1)	{
      	switch(next)	{
          case 'a': if (a.length() == 0)	{
          				cout << "A" << endl;
            			return 0;
          			}
            		next = a[0];
            		a.erase(a.begin());
            		break;
          case 'b': if (b.length() == 0)	{
          				cout << "B" << endl;
            			return 0;
          			}
            		next = b[0];
            		b.erase(b.begin());
					break;
          case 'c': if (c.length() == 0)	{
            			cout << "C" << endl;
            			return 0;
          			}
            		next = c[0];
            		c.erase(c.begin());
            		break;
        }
    }
  	
  	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int A,B,C,D;
  
  scanf("%d %d %d %d",&A,&B,&C,&D);
   
  if(A*B>C*D) printf("%d",A*B);
  else printf("%d",C*D);
  
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define ZERO(a) memset(a,0,sizeof(a))

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[101][100010];
ll n,k;
ll a[101];

ll rec(ll i, ll num){
  if(dp[i][num]!=-1)
    return dp[i][num];
  if(i==n-1){
    if(num>a[i])
      return dp[i][num]=0;
    else
      return dp[i][num]=1;
  }


  ll res=0;
  REP(j, a[i]+1)
    res = (res+rec(i+1,num-j))%MOD;

  return dp[i][num]=res;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin>>n>>k;
  REP(i,n)cin>>a[i];
  REP(i,n+1)REP(j,k+1)dp[i][j]=0;

  for(ll i=n-1; i>=0; i--){
    vll cum(k+3);
    if(i!=n-1){
      REP(num,k+1)
        cum[num+1] = (cum[num]+dp[i+1][num])%MOD;
    }

    for(ll num=0; num<=k; num++){
      if(i==n-1){
        if(num>a[i])
          dp[i][num]=0;
        else
          dp[i][num]=1;
      }
      else{
        dp[i][num]=(MOD+cum[num+1]-cum[max(0LL,num-a[i])])%MOD;
        //cout<<i<<":"<<num<<":"<<dp[i][num]<<endl;
      }
    }

  }

  ll ans = dp[0][k];
  cout<<ans<<endl;

}


Measured memory_bytes: 80000
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
typedef long long  ll;
typedef long double ld;
typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii;
const ld pi=3.14159265359;
const int maxn=2e5+7;
const int mod=1e9+7;
const ll INF=9223372036854775807;
const int inf=2e9+7; 
#define int long long
/*Almost copy pasted part :)*/
int a[maxn];

int32_t main(){
	int n;
	cin>>n;
	bool p=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]%2)
			p=1;
	}
	cout<<(p ? "first" : "second")<<endl;
	
}

Measured memory_bytes: 1024
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let H = readStr() |> int64

let rec count acc h n =
  if h=0L then acc
  elif h=1L then acc+n
  else count (acc+n) (h/2L) (n*2L)

count 0L H 1L |> printfn "%d"

Measured memory_bytes: 13916