akhauriyash/Code-Regression huggingface dataset:
A,B=map(int,input().split())


def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


divA=divisor(A)
divB=divisor(B)

C=[]
for i in divA:
    if i in divB:
        C.append(i)

        
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

cnt=0
for i in C:
    if is_prime(i):
        cnt+=1

print(cnt+1)


Measured memory_bytes: 4168
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 1
flag = 0
for i in range(N):
  ans *= A[i]
  if ans == 0:
    print(0)
    flag += 1
    break
  elif ans > 10**18:
    print(-1)
    flag += 1
    break
if flag == 0:
  print(ans)

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

#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
const int MAXN = 1e6+5;
const int MOD= 998244353;
int a[5][5],vis[5][5];
int visx[MAXN],visy[MAXN];
int main(){
    memset(vis,0,sizeof(vis));
    memset(visx,-1,sizeof(visx));
    rep(i,1,3){
        rep(j,1,3)scanf("%d",&a[i][j]),visx[a[i][j]]=i,visy[a[i][j]]=j;
    }
    int n;
    cin>>n;
    while(n--){
        int x;
        cin>>x;
        if(visx[x]==-1)continue;
        vis[visx[x]][visy[x]]=1;
    }
    int flag=0;
    rep(i,1,3){
        int num=0;
        rep(j,1,3)if(vis[i][j])num++;
        if(num==3){
            flag=1;
            break;
        }
    }
    rep(j,1,3){
        int num=0;
        rep(i,1,3)if(vis[i][j])num++;
        if(num==3){
            flag=1;
            break;
        }
    }
    int num1=0,num2=0;
    rep(i,1,3){
        if(vis[i][i])num1++;
        if(vis[i][3-i+1])num2++;
    }
    if(num1==3||num2==3)flag=1;
    if(flag)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 6016
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

def palindrome?(s)
    n=s.size
    (n/2).times do|i|
        return false unless s[i]==s[n-1-i]
    end
    return true
end
S=get_nsp
N=S.size
if palindrome?(S) and palindrome?(S[0..(N-1)/2-1]) and palindrome?(S[(N+3)/2-1..N-1])
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 2044
import std.algorithm;
import std.conv;
import std.array;
import std.stdio;
import std.string;

void main(){
    int N;
    while(N = readln.chomp.to!int, N){
        string s = readln.chomp;
        
        foreach(i; 0..N)
            s = s.group.map!(a => a[1].to!string ~ a[0].to!string).reduce!"a ~ b";
        writeln(s);
    }
}

Measured memory_bytes: 2860
W, H, N = map(int, input().split())

ans = [[1 for _ in range(W)] for _ in range(H)]

for i in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        for j in range(H):
            for i in range(x):
                ans[j][i] = 0
                
    elif a == 2:
        for j in range(H):
            for i in range(x, W):
                ans[j][i] = 0

    elif a == 3:
        for j in range(y):
            for i in range(W):
                ans[j][i] = 0        
        
    elif a == 4:
        for j in range(y, H):
            for i in range(W):
                ans[j][i] = 0

print(sum(map(sum, ans)))

Measured memory_bytes: 3572
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
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 n = n - 1;

    let mut rojar: Vec<u8> = vec![];

    while n >= 26 {
        let r = n % 26;
        rojar.push(r as u8);
        n = (n / 26) - 1;
    }
    rojar.push(n as u8);

    //println!("{:?}", rojar);

    for i in 0..rojar.len() {
        let c = match rojar[rojar.len() - i - 1] {
            0 => 'a',
            1 => 'b',
            2 => 'c',
            3 => 'd',
            4 => 'e',
            5 => 'f',
            6 => 'g',
            7 => 'h',
            8 => 'i',
            9 => 'j',
            10 => 'k',
            11 => 'l',
            12 => 'm',
            13 => 'n',
            14 => 'o',
            15 => 'p',
            16 => 'q',
            17 => 'r',
            18 => 's',
            19 => 't',
            20 => 'u',
            21 => 'v',
            22 => 'w',
            23 => 'x',
            24 => 'y',
            25 => 'z',
            _ => 'z',
        };
        print!("{}", c);
    }
    println!("");

    let mut ans = 0;
}

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

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2248
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <complex>
#include <cassert>

#define enp     puts("**chkchkchkchkchk**")
#define A       first
#define B       second
#define MP      make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;

const int INF = 0x60000000;
const int MINF = -1000000000;
const int mod = 99999997;
const ll cons = 100000000000;
const double pi = 3.141592653589793;



int main()
{
	int w, h;

	scanf("%d%d", &w, &h);

	vector < pair <int, int> > dat;

	for (int i = 0; i < w; i++)
	{
		int x;
		scanf("%d", &x);
		dat.push_back(MP(x, 0));
	}
	
	for (int i = 0; i < h; i++)
	{
		int x;
		scanf("%d", &x);
		dat.push_back(MP(x, 1));
	}

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

	int row = 0, col = 0;
	ll ans = 0;

	for (int i = 0; i < dat.size(); i++)
	{
		if (dat[i].B == 0)
		{
			ans += ((ll)h - row + 1)*(ll)dat[i].A;
			col++;
		}
		else
		{
			ans += ((ll)w - col + 1)*(ll)dat[i].A;
			row++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	int C[N], A[N][M];
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	int minc = 2000000000;
	for (int i = 0; i < pow(2, N); i++) {
		int b[N], var = i;
		for (int j = N - 1; j >= 0; j--) {
			b[j] = var / pow(2, j);
			var = var % (int) pow(2, j);
		}
		for (int j = 0; j < M; j++) {
			int cum = 0;
			for (int k = 0; k < N; k++) {
				cum += b[k] * A[k][j];
			}
			if (cum < X) {
				break;
			} else if (j == M - 1) {
				int c = 0;
				for (int k = 0; k < N; k++) {
					c += b[k] * C[k];
				}
				minc = min(c, minc);
			}
		}
	}
	cout << (minc == 2000000000 ? -1 : minc) << endl;
	return 0;
}


Measured memory_bytes: 4064
//Replacing

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, ll>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    int q;cin>>q;
    vector<int>m(100001);
    vector<int>p(100001);
    rep(i,0,n){
        m[a[i]]+=a[i];
        p[a[i]]++;
    }
    int ans = accumulate(range(m),0LL);
    rep(i,0,q){
        int b,c;cin>>b>>c;
        ans-=m[b];
        m[c]+=p[b]*c;
        ans+=p[b]*c;
        p[c]+=p[b];
        m[b]=p[b]=0;
        cout<<ans<<nnn;
    }
    return 0;
}

Measured memory_bytes: 5572
import java.io.*;
public class Main{  
    public static void main(String[] args){
        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			int time = Integer.parseInt(reader.readLine());
			int h = time / 3600;
			int m = (time % 3600) / 60;
			int s = (time % 3600) % 60;
			System.out.println(h + ":" + m + ":" + s);

        }catch(IOException e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define MM <<" "<<
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setpercision(x)
using ll=long long;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N,M;cin>>N>>M;
    ll info[N];
    ll ans=0;
    rep(i,N)cin>>info[i];
    ll sum[N];
    sum[0]=info[0];
    repl(i,1,N)sum[i]=sum[i-1]+info[i];
    map<ll,ll> count;
    rep(i,N){
        sum[i]%=M;
        if(count.count(sum[i]))count[sum[i]]++;
        else count.emplace(sum[i],1);
    }
    for(auto p:count){
        ll now;
        if(p.fi)now=p.se*(p.se-1)/2;
        else now=(p.se+1)*p.se/2;
        ans+=now;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5760
# -*- coding: utf-8 -*-
import bisect
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, K, A, B):
    from itertools import accumulate
    sa = [0] + list(accumulate(A))
    sb = [0] + list(accumulate(B))

    ans = 0
    for n, a in enumerate(sa):
        if a > K:
            continue
        m = bisect.bisect_right(sb, K-a) - 1
        ans = max(ans, n+m)
    return ans


def main():
    N, M, K = read_int_n()
    A = read_int_n()
    B = read_int_n()
    print(slv(N, M, K, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 135768
/*input
2
cccbca 5
acb 1
*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
#define ps pair<string,int>
#define ll long long
using namespace std;
const int N = 55;

string a[N];
ll c[N];
int n;
map< ps, ll > d;
struct query {
	ps state;
	ll val;
	query(){state = {"", -1}; val = 0; }
	query(ps _state, ll _val) {state = _state; val = _val;}
};
bool operator>(query a, query b){
	return a.val > b.val;
}
pair<string,int> compose(string left, string right){
	int pos_l = left.size() - 1, pos_r = 0;
	while (pos_l >=0 && pos_r < (int)right.size()){
		if (left[pos_l] != right[pos_r]) return {"", -1}; // cannot compose.  
		pos_l--;
		pos_r++;
	}
	string res = "";
	if (pos_l < 0){
		for(int i=pos_r;i<right.size();++i) res += right[i];
		return {res, 1};
	}
	if (pos_r == right.size()){
		for(int i=0;i<=pos_l;++i) res += left[i];
		return {res, 0};
	}
	return {res, -1};
}
bool is_palindrome(string s){
	if (s.size() <= 1) return true;
	int n = s.size();
	for(int i=0;i<n;++i){
		if (s[i] != s[n-1-i]) return false;
	}
	return true;
}
long long solve(){
	priority_queue< query, vector<query>, greater<query> > pq;
	for(int i=1;i<=n;++i){
		ps curNode = {a[i],1};
		if (d[curNode]) d[curNode] = min(d[curNode], c[i]);
		else d[curNode] = c[i];
		pq.push(query(curNode, 1LL * c[i]));
	}
	while (pq.size()){
		ps u = pq.top().state;
		ll curVal = pq.top().val;	pq.pop();
		if (curVal != d[u]) continue;
		// cout << u.first << ' ' << curVal << '\n';
		if (is_palindrome(u.first)) return curVal;
		for(int i=1;i<=n;++i){
			string left = a[i], right = u.first;
			if (!u.second) swap(left, right);
			ps v = compose(left, right);
			if (v.second == -1) continue;
			if (!d[v] || d[v] > curVal + c[i]){
				pq.push(query(v, curVal + c[i]));
				d[v] = curVal + c[i];
			}
		}
	}
	return -1;
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i=1;i<=n;++i){
		cin >> a[i] >> c[i];
	}
	// up(i,1,n) cout << c[i] << '\n';
	// cout << compose("abc", "cba").first << compose("abc", "cba").second << '\n';
	cout << solve();
	// compose the G[1][0];
	return 0;
}

Measured memory_bytes: 3700
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;
const int maxl=100000;
ll v[270000],w[270000];
vector<pl>pv[10000];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    for(int i=0;i++<n;)
        cin>>v[i]>>w[i];
    int m=11;
    for(int i=1;i<min(n+1,1<<m);i++)
    {
        vector<pl>cv,v1;
        for(int u=i;u>0;u/=2)
            cv.eb(w[u],v[u]);
        v1.eb(0,0);
        for(int i=0;i<(int)cv.size();i++)
            for(int j=0,k=v1.size();j<k;j++)
                if(v1[j].fi+cv[i].fi<=maxl)
                    v1.eb(v1[j].fi+cv[i].fi,v1[j].se+cv[i].se);
        sort(all(v1),[](pl&x,pl&y){return x.fi==y.fi?x.se>y.se:x.fi<y.fi;});
        pv[i].eb(0,0);
        for(pl&t:v1)
            if(t.se>pv[i].back().se)
                pv[i].eb(t);
    }
    int q;
    cin>>q;
    for(int qi=0;qi<q;qi++)
    {
        int u,u2,l;
        cin>>u>>l;
        vector<pl>cv,v1;
        for(u2=u;u2>=1<<m;u2/=2)
            cv.eb(w[u2],v[u2]);
        v1.eb(0,0);
        for(int i=0;i<(int)cv.size();i++)
            for(int j=0,k=v1.size();j<k;j++)
                if(v1[j].fi+cv[i].fi<=l)
                    v1.eb(v1[j].fi+cv[i].fi,v1[j].se+cv[i].se);
        ll ans=0;
        for(pl&t:v1)
            ans=max(ans,t.se+(lower_bound(all(pv[u2]),pl(l-t.fi,INF))-1)->se);
        cout<<ans<<'\n';
    }
    return 0;
}

Measured memory_bytes: 50668
#include<bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<=n;i++)
using namespace std;
int main(){
 int n,x;
 while(cin >> n >> x){
  if(!n && !x) break;
  int cnt = 0;
  rep(i,1,n)rep(j,i+1,n)rep(k,j+1,n){
   if(i!=j&&j!=k&&k!=i && i+j+k == x) cnt++;
  }
  cout << cnt << endl;
 }
 return 0;
}



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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	string s;
	cin >> s;
	int n = s.length();
	rep(i,(n-1)/2) {
		if(s[i] != s[n-1-i]) {
			cout << "No" << endl;
			//cout << i << " " << 1 << endl;
			return 0;
		}
	}
	int k = (n-1)/2;
	int loopTimes = k % 2 == 0 ? k/2 : (k-1)/2;
	//cout << loopTimes << endl;
	for(int i=0; i<loopTimes; i++) {
		if(s[i] != s[k-1-i]) {
			cout << "No" << endl;
			//cout << i << " " << 2 << endl;
			return 0;
		}
		if(s[(n+3)/2-1+i] != s[n-1-i]) {
			cout << "No" << endl;
			//cout << i << " " << 3 << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
  return 0;
}


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

int N, M, Q;
int a[50], b[50], c[50], d[50];

int main() {
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; ++i) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    int ma = 0;
    for (int i0 = 1; i0 <= M; ++i0) {
        for (int i1 = i0; i1 <= M; ++i1) {
            for (int i2 = i1; i2 <= M; ++i2) {
                for (int i3 = i2; i3 <= M; ++i3) {
                    for (int i4 = i3; i4 <= M; ++i4) {
                        for (int i5 = i4; i5 <= M; ++i5) {
                            for (int i6 = i5; i6 <= M; ++i6) {
                                for (int i7 = i6; i7 <= M; ++i7) {
                                    for (int i8 = i7; i8 <= M; ++i8) {
                                        for (int i9 = i8; i9 <= M; ++i9) {
                                            vector<int> A{i0, i1, i2, i3, i4, i5, i6, i7, i8, i9};
                                            int point = 0;
                                            for (int i = 0; i < Q; ++i) {
                                                if (A[b[i]-1] - A[a[i]-1] == c[i]) {
                                                    point += d[i];
                                                }
                                            }
                                            if (ma < point) {
                                                ma = point;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ma << "\n";
}

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    string s;
    cin >> s;

    for ( int i = 0; i < s.size(); i += 2 ) {
        if ( i + 1 == s.size() ) {
            cout << "No" << endl;
            return 0;
        }
        if ( s[i] == 'h' && s[i+1] == 'i' ) {
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <set>

int main()
{
    int64_t X;
    std::cin >> X;

    int64_t x = 1;
    int64_t b = 0;
    while (true) {

        if (x * x * x * x * x - b > 1000000000) {
            break;
        }
        b = x * x * x * x * x;
        ++x;
    }

    for (int64_t i = -x; i < x; ++i)
    {
        for (int64_t j = -x; j < x; ++j)
        {
            if (i * i * i * i * i - j * j * j * j * j == X) {
                std::cout << i << " " << j << std::endl;
                return 0;
            }
        }
    }

    return 0;
}


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

namespace ABC
{
    class ABC171B
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            string line;
            string[] sa;
            line = Console.ReadLine();
            sa = line.Split(' ');
            long N = long.Parse(sa[0]);
            int K = int.Parse(sa[1]);

            int[] P = new int[N];
            line = Console.ReadLine();
            sa = line.Split(' ');
            for (int i = 0; i < N; ++i)
            {
                P[i] = int.Parse(sa[i]);
            }
            List<int> list = new List<int>(P);
            list.Sort();
            long sum = 0;
            for (int i = 0; i < K; ++i)
            {
                sum += list[i];
            }
            Console.WriteLine(sum);



#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
#endif
        }
    }
}


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

int main(){
  int N,Max,i,j ;

  cin >> N ;
  int counter[N],A[N],m_A[N] ;

  for(i=0;i<=N-1;i++){
    A[i] = i+1 ;
    m_A[i] = A[i] ;
    counter[i]=0 ;
  }

  for(i=0;i<=N-1;i++){
    while(A[i]%2==0){
      counter[i]++ ;
      A[i] = A[i]/2 ;
    }
  }

  for(i=0;i<=N-1;i++){
    if(counter[0] <= counter[i]){
      counter[0] = counter[i] ;
      m_A[0] = m_A[i] ;
      Max = m_A[i] ;
    }else{
      Max = m_A[0] ;
    }
  }

  cout << Max << endl ;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
 
int main(void){
    // Your code here!
    string S;
    
    cin >> S;
    
    for(int i = 0; i < S.length()/2;i++){
        //cout << S[i] << " " << S[S.length()-i-1] << endl;
        if(S[i]!=S[S.length()-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    
    //cout << "1" << endl;
    
    for(int i = 0; i < (S.length()-1)/4;i++){
        //cout << S[i] << " " << S[(S.length()-1)/2-i-1] << endl;
        if(S[i]!=S[(S.length()-1)/2-i-1]){
            cout << "No" << endl;
             return 0;
        }
    }
    
    //cout << "2" << endl;
        
    reverse(S.begin(),S.end());
    for(int i = 0; i < (S.length()-1)/4;i++){
        if(S[i]!=S[(S.length()-1)/2-i-1]){
            cout << "No" << endl;
             return 0;
        }
    }
    
    cout << "Yes" << endl;
   
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef unsigned long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll H,W;cin >> H >> W;
  if(H==1 || W==1)cout << 1 << endl;
  else cout << (H*W+1ll)/2ll << endl;
  return 0;
}


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

int n, m;
string s, t;

int main() {
    cin >> n >> m >> s >> t;
    for (int i = min(n, m); i; i--) {
        if (!(n % i) && !(m % i)) {
            long long len = 1LL * n * m / i;
            bool flag = 1;
            int t1 = len / n, t2 = len / m;
            long long lcm = 1LL * t1 * t2 / __gcd(t1, t2);
            for (long long j = 0; j < len; j += lcm) {
                flag &= (s[j / t1] == t[j / t2]);
            }
            if (flag) { cout << len << endl; exit(0); }
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n), a(m * n);
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i * m + j];
    }

    int best = 1e9;
    rep(pat, 1 << n) {
        int cost = 0;
        vector<int> u(m);
        rep (i, n) {
            if ((pat >> i) & 1) {
                cost += c[i];
                rep (j, m) {
                    u[j] += a[i * m + j];
                }
            }
        }
        bool ok = true;
        rep(j, m) {
            if (u[j] < x) {
                ok = false;
                break;
            }
        }
        if (ok) {
            best = min(best, cost);
        }
    }

    put((best == 1e9 ? -1 : best));

    return 0;
}

Measured memory_bytes: 3632
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

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


def IsAllEven(L, n):
    for i in range(len(L)):
        if L[i] % (2**n) != 0:
            return False
    return True


i = 0
while True:
    i += 1
    if not IsAllEven(list_A, i):
        break
print(i-1)


Measured memory_bytes: 9024
#include<iostream>
#include<cstdio>
#include<vector>
#include<climits>
using namespace std;

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

int land[202][202];
int sea[202][202];

const int inf = INT_MAX / 4;

int main() {
  for(int N, M; cin >> N >> M, (N || M); ) {
    REP(i, N) REP(j, N) land[i][j] = inf;
    REP(i, N) REP(j, N) sea[i][j] = inf;

    REP(i, M) {
      int a, b, c;
      char ch;
      scanf("%d%d%d %c", &a, &b, &c, &ch);
      a--, b--;
      if( ch == 'L' )
        land[a][b] = land[b][a] = c;
      else
        sea[a][b] = sea[b][a] = c;
    }

    int R;
    static int Z[1024];
    scanf("%d", &R);
    REP(r, R) scanf("%d", &Z[r]);
    REP(r, R) Z[r]--;

    REP(i, N) land[i][i] = sea[i][i] = 0;
    REP(k, N) REP(i, N) REP(j, N) land[i][j] = min(land[i][j], land[i][k] + land[k][j]);
    REP(k, N) REP(i, N) REP(j, N) sea[i][j] = min(sea[i][j], sea[i][k] + sea[k][j]);

    static int dp[202][1024];
    REP(i, 202) REP(j, 1024) dp[i][j] = inf;
    dp[Z[0]][0] = 0;
    REP(r, R - 1) REP(ship, N) {
      int next = dp[ship][r + 1];
      next = min(next, dp[ship][r] + land[Z[r]][Z[r + 1]]);
      REP(mship, N)
        next = min(next, dp[mship][r] + land[Z[r]][mship] + sea[mship][ship] + land[ship][Z[r + 1]]);
      dp[ship][r+1] = next;
    }

    int best = inf;
    REP(ship, N)
      best = min(best, dp[ship][R - 1]);
    cout << best << endl;
  }
  return 0;
}

Measured memory_bytes: 2040
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

int main(){
    int H, W; cin >> H >> W;
    vector<string> A(H);
    rep(i,H) cin >> A[i];

    queue<pair<int, int>> que;
    vector<vector<int>> counter(H, vector<int>(W,-1));
    rep(i,H){
        rep(j,W){
            if (A[i][j] == '#'){
                que.push(make_pair(i,j));
                counter[i][j] = 0;
            }
        }
    }

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

    int ans = 0;
    while(!que.empty()){
        auto v = que.front(); que.pop();
        int y = v.first;
        int x = v.second;
        for (int i = 0; i < 4; i++){
            int ny = y + dy[i];
            int nx = x + dx[i];

            if (ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
            if (counter[ny][nx] != -1) continue;
            counter[ny][nx] = counter[y][x]+1;
            que.push(make_pair(ny,nx));
            ans = counter[ny][nx];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 17116
#include <bits/stdc++.h>
    using namespace std;
    int main() {

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

for(int i=0;i<s.size();i++)
{
    string x;
    x+=s[s.size()-1];
    x+=s.substr(0,s.size()-1);
    s=x;
   // cout<<s<<endl;
    if(s==t)
    {
        cout<<"Yes";
        return 0;
    }
}
cout<<"No";
    }


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

using namespace std;
#define ll long long
#define N 100000

int main (void) {
    int a, b, m;
    int A[N], B[N], c[N];
    int x[N], y[N];
    int d[N];

    scanf("%d%d%d", &a, &b, &m);

    for (int i = 0; i < a; i++){
        scanf("%d", &A[i]);
    }
    int mina = A[0];
    for (int i = 1; i < a; i++){
        if(mina > A[i]) mina = A[i];
    }

    for (int i = 0; i < b; i++){
        scanf("%d", &B[i]);
    }
    int minb = B[0];
    for (int i = 1; i < b; i++){
        if(minb > B[i]) minb = B[i];
    }

    for (int i = 0; i < m; i++){
        scanf("%d%d%d", &x[i], &y[i], &c[i]);
        d[i] = A[x[i]-1]+B[y[i]-1]-c[i];
    }
    int mind = d[0];
    for (int i = 1; i < m; i++){
        if(mind > d[i]) mind = d[i];
    }

    int ret;
    if(mina+minb > mind) ret = mind;
    else ret = mina+minb;

    cout << ret << endl;

    return 0;
}

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

int main(){
  ll k;cin >> k;
  if( k%2 == 0 || k%5 == 0 ){
    cout << -1 << endl;
    return 0;
  }
  ll ans = 1;
  ll a = 7;
  while( a%k != 0 ){
    a = ( a*10 + 7 )%k;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
bool ok = 0;
string s;
string to[]={"maerd","remaerd","esare","resare"};
int main(){
    //string s;
    cin>>s;
    reverse(s.begin(),s.end());
    string t = "";
    rep(i,s.size()){
        t += s[i];
        rep(i,4){
            if(t==to[i]) t="";
        }
    }
    if(t=="") cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 3692
using System.Collections.Generic;
using System;

public class PriorityQueue<T> where T : IComparable
{
    private IComparer<T> _comparer = null;
    private int _type = 0;
    private T[] _heap;
    private int _sz = 0;
    private int _count = 0;
    public PriorityQueue(int maxSize, IComparer<T> comparer)
    {
        _heap = new T[maxSize];
        _comparer = comparer;
    }
    public PriorityQueue(int maxSize, int type = 0)
    {
        _heap = new T[maxSize];
        _type = type;
    }
    private int Compare(T x, T y)
    {
        if (_comparer != null) return _comparer.Compare(x, y);
        return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
    }
    public void Push(T x)
    {
        _count++;
        var i = _sz++;
        while (i > 0)
        {
            var p = (i - 1) / 2;
            if (Compare(_heap[p], x) <= 0) break;
            _heap[i] = _heap[p];
            i = p;
        }
        _heap[i] = x;
    }
    public T Pop()
    {
        _count--;
        T ret = _heap[0];
        T x = _heap[--_sz];
        int i = 0;
        while (i * 2 + 1 < _sz)
        {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b;
            if (Compare(_heap[a], x) >= 0) break;
            _heap[i] = _heap[a];
            i = a;
        }
        _heap[i] = x;
        return ret;
    }
    public int Count() => _count;
    public T Peek() => _heap[0];
    public bool Contains(T x)
    {
        for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true;
        return false;
    }
    public void Clear()
    {
        while (this.Count() > 0) this.Pop();
    }
    public IEnumerator<T> GetEnumerator()
    {
        var ret = new List<T>();
        while (this.Count() > 0)
        {
            ret.Add(this.Pop());
        }
        foreach (var r in ret)
        {
            this.Push(r);
            yield return r;
        }
    }
    public T[] ToArray()
    {
        T[] array = new T[_sz];
        int i = 0;
        foreach (var r in this)
        {
            array[i++] = r;
        }
        return array;
    }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(a, n, m);
    }
    static void getAns(int[] a, int n, int m)
    {
        var pq = new PriorityQueue<int>(n + 10, 1);
        for (int i = 0; i < n; i++) pq.Push(a[i]);
        for (int i = 0; i < m; i++)
        {
            var w = pq.Pop();
            pq.Push(w / 2);
        }
        var sum = 0L;
        for (int i = 0; i < n; i++)
            sum += pq.Pop();
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 28896
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int K , n , len;
string s;

namespace Doubling{
  static const int N = 101010;
  int t[N] , wa[N] , wb[N] , sa[N] , h[N];
  void sort(int *x,int *y,int n,int m){
    rep(i,0,m) t[i] = 0;
    rep(i,0,n) t[x[y[i]]]++;
    rep(i,1,m) t[i] += t[i-1];
    per(i,0,n) sa[--t[x[y[i]]]] = y[i];
  }
  bool cmp(int *x,int a,int b,int d){
    return x[a] == x[b] && x[a+d] == x[b+d];
  }
  void da(int *s,int n,int m){
    int *x=wa,*y=wb;
    rep(i,0,n) x[i] = s[i] , y[i] = i;
    sort(x , y , n , m);
    for(int j=1,p=1;p<n;m=p,j<<=1){
      p = 0;rep(i,n-j,n) y[p++] = i;
      rep(i,0,n) if(sa[i] >= j) y[p++] = sa[i] - j;
      sort(x , y , n , m);
      swap(x , y);p = 1;x[sa[0]] = 0;
      rep(i,1,n) x[sa[i]] = cmp(y,sa[i],sa[i-1],j)?p-1:p++;
    }
  }
  void cal_h(int *s,int n,int *rk){
    int j,k=0;
    for(int i=1;i<=n;++i) rk[sa[i]] = i;
    for(int i=0;i<n;h[rk[i++]] = k)
      for(k&&--k,j=sa[rk[i]-1];s[i+k]==s[j+k];++k);
  }
}
struct DA{ // [0,n] , in[n] = 0 , n load
  static const int N = 101010;
  int p[18][N] , rk[N] , in[N] , Log[N] , n;
  void Build(){
    Doubling::da(in,n+1,300);
    Doubling::cal_h(in,n,rk);
    Log[0] = -1;for(int i=1;i<=n;++i) Log[i] = Log[i-1] + (i==(i&(-i)));
    for(int i=1;i<=n;++i) p[0][i] = Doubling::h[i];
    for(int j=1;1<<j<=n;++j){
      int lim = n+1-(1<<j);
      for(int i=1;i<=lim;++i)
        p[j][i] = min(p[j-1][i] , p[j-1][i+(1<<j>>1)]);
    }
  }
  int lcp(int a,int b){
    a = rk[a] , b = rk[b];
    if(a > b) swap(a , b);++a;
    int t = Log[b-a+1];
    return min(p[t][a] , p[t][b-(1<<t)+1]);
  }
}da;

int main(){
  cin >> K >> s;
  n = sz(s);
  ++K;
  len = (n + K - 1) / K;
  da.n = n;
  rep(i,0,n) da.in[i] = s[i];
  da.in[n] = 0;
  da.Build();
  vector<pii> order;
  rep(i,0,n-len+1) order.pb(mp(da.rk[i],i));
  sort(all(order));
  int l = -1 , r = sz(order) - 1;
  while(l + 1 < r) {
    int mid = (l + r) >> 1;
    int i = order[mid].se;
    int times = 0;
    for(int j=0;j<n;++times) {
      int lcp = i != j ? da.lcp(i , j) : n - i;
      if(lcp >= len || j + lcp >= n) j += len;
      else if(s[i + lcp] > s[j + lcp]) j += len;
      else if(len != 1) j += len - 1;
      else {times = K + 1;break;}
    }
    if(times <= K) r = mid;
    else l = mid;
  }
  cout << s.substr(order[r].se , len) << endl;
  return 0;
}


Measured memory_bytes: 11768
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b==c||a+c==b||b+c==a)
	 cout<<"Yes"<<endl;
	else
	 cout<<"No"<<endl;
	 return 0;
	
}

Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
x=gets.split.map(&:to_i).sort!
x_dis=Array.new
sum=0
(m-1).times.with_index{|i|
  x_dis << (x[i+1]-x[i]).abs
}
(x_dis.sort!.size-n+1).times.with_index{|i|
  sum+=x_dis[i]
}
puts sum


Measured memory_bytes: 9968
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int x;
    vector<int>a(n);
    for(int &x :a)
    {
        scanf("%d",&x);
    }
    auto sum=[&](int L,int R){
            long long s=0;
            for(int i=L;i<=R;i++)
            {
                s+=a[i];
            }
            return s;
            
        };
    long long dp[405][405];
    for(int L=n-1;L>=0;L--)
    {
        for(int R=L;R<n;R++)
        {
            if(L==R)
            {
                dp[L][R]=0;
            }
            else
            {
                /* code */
                dp[L][R]=1e18+5;
                long long s=sum(L,R);
                for(int i=L;i<R;i++)
                {
                    dp[L][R]=min(dp[L][R],dp[L][i]+dp[1+i][R]+s);
                }
            }
            
        }
    }
    cout<<dp[0][n-1];
}

Measured memory_bytes: 1536
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;

int main(){
	int q, x;
	char com[20];
	list<int> v;
	scanf("%d", &q);
	for (int i = 0; i < q; i++){
		scanf("%s", com);
		if (com[0] == 'i'){
			scanf("%d", &x);
			v.push_front(x);
		}
		else if (com[6] == 'L'){
			v.pop_back();
		}
		else if (com[6] == 'F'){
			v.pop_front();
		}
		else if (com[0] == 'd'){
			scanf("%d", &x);
			for (list<int>::iterator it = v.begin(); it != v.end(); it++){
				if (*it == x){
					v.erase(it);
					break;
				}
			}
		}
	}
	int i = 0;
	for (list<int>::iterator it = v.begin(); it != v.end(); it++){
		if (i++)
			printf(" ");
		printf("%d", *it);
	}
	printf("\n");
}

Measured memory_bytes: 34000
#include<stdio.h>
int main()
{
  int a,b,i,h[10];
  for(i=0;i<7;i++){
    scanf("%d%d",&a,&b);
      h[i]=a-b;
  }
  for(i=0;i<7;i++){
    printf("%d\n",h[i]);
    }
  return 0;
}

Measured memory_bytes: 600
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t K;

void solve()
{
    std::cin >> K;
	std::vector<int64_t> num(K);

	num[0] = 7 % K;
	for (int64_t i = 1; i < K; i++)
	{
		num[i] = (10 * num[i - 1] + 7) % K;
	}

	int64_t ans = -1;
	for (int64_t i = 0; i < K; i++)
	{
		if (num[i] == 0)
		{
			ans = i + 1;
			break;
		}
	}
	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 11016
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
 
public class Main
{
    public static void main(String[] args)
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        long[] L=new long[n];
        for(int i=0;i<n;i++)
            L[i]=in.nextLong();
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                for(int k=j+1;k<n;k++)
                {
                    if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i])
                    {
                        if(L[i]+L[j]>L[k] && L[i]+L[k]>L[j] && L[k]+L[j]>L[i])
                            cnt++;
                    }

                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 37092
#include <bits/stdc++.h>
using namespace std;
int main(){
    long N,W; cin>>N>>W;
    vector<vector<long>> obj(4);
    long bw,v; cin>>bw>>v;
    obj[0].push_back(v);
    for(int i=0;i<N-1;i++){
        long w; cin>>w>>v;
        obj[w-bw].push_back(v);
    }
    for(int i=0;i<4;i++)
        sort(begin(obj[i]),end(obj[i]),greater<long>());
    for(int i=0;i<4;i++)
        obj[i].insert(begin(obj[i]),0);
    long f1=0,MAX=0;
    for(int i=0;i<obj[0].size();i++){
        f1+=obj[0][i];
        long f2=0;
        for(int j=0;j<obj[1].size();j++){
            f2+=obj[1][j];
            long f3=0;
            for(int k=0;k<obj[2].size();k++){
                f3+=obj[2][k];
                long f4=0;
                for(int l=0;l<obj[3].size();l++){
                    f4+=obj[3][l];
                    if((i*bw+j*(bw+1)+k*(bw+2)+l*(bw+3))>W)
                        break;
                    MAX=max(MAX,f1+f2+f3+f4);
                }
            }
        }   
    }
    cout<<MAX;
}

Measured memory_bytes: 256
#include<stdio.h>
    int main(void){
    int h,m,s;
    int inp;
    scanf("%d",&inp);
    h = inp/3600;
    m = inp%3600/60;
    s = inp%3600%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0 ;
    }

Measured memory_bytes: 592
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main
{
    public static void main(String[]args)
    {

        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Solver solver = new Solver();
        solver.solve(1,in,out);
        out.close();
    }
    static class Solver
    {

        public int a[];

        public void solve(int ca,InputReader in,PrintWriter out)
        {
            while(ca -- != 0)
            {
                int n = in.nextInt();
                int w = in.nextInt();
                int h = in.nextInt();
                int ans = 0;
                for(int i = 0;i<n;i++)
                {
                    int a = in.nextInt();
                    int b =  in.nextInt();
                    if(a >= w && b >= h)
                    {
                        ans++;
                    }
                }
                out.print(ans);
            }
        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
        public BigInteger nextBigInteger()
        {
            return new BigInteger(next());
        }

    }
}


Measured memory_bytes: 21588
def resolve():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t=int(input())
    sa=abs(a-b)
    vsa=v-w
    if vsa<=0:
        print("NO")
    elif vsa*t<sa:
        print("NO")
    else:
        print("YES")
resolve()

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T &t, const U &u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T &t, const U &u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    V<string> cand;
    string s;
    cin >> s;
    int K;
    cin >> K;

    rep(i, s.size()) {
        string t;
        for (int j = i; j < min<int>(s.size(), i + 5); ++j) {
            t.pb(s[j]);
            cand.pb(t);
        }
    }
    sort(ALL(cand));
    cand.erase(unique(ALL(cand)), cand.end());
    cout << cand[K - 1] << endl;

    return 0;
}

Measured memory_bytes: 1660
import math
N, M = map(int, input().split())
ulim = M//N
mid = int(math.sqrt(M))
if ulim >= mid:
    ans = []
    for i in range(1, mid+1):
        if M%i == 0:
            ans.append(i)
            if M//i <= ulim:
                ans.append(M//i)
    print(max(ans))

else:
    for i in reversed(range(1, ulim+1)):
        if M%i == 0:
            print(i)
            break


Measured memory_bytes: 3060