akhauriyash/Code-Regression huggingface dataset:
defmodule Main do
  def main do
    [n, _m, x] = IO.gets("") |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)
    list = Enum.reduce(1..n, [], fn _, acc ->
      acc ++ [(IO.gets("") |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1))]
    end)

    Enum.reduce(1..n, [], fn i, acc ->
      combination(list, i) ++ acc
    end)
    |> Enum.filter(& filter(&1, x))
    |> Enum.map(&sum/1)
    |> Enum.min(fn -> -1 end)
    |> IO.puts
  end

  defp filter(list_of_lists, x) do
    [_ | tail] = List.zip(list_of_lists)
    tail
    |> Enum.map(fn tuple ->
      tuple |> Tuple.to_list() |> Enum.sum()
    end)
    |> Enum.all?(fn sum -> sum >= x end)
  end

  defp sum(list_of_lists) do
    [head | _] = List.zip(list_of_lists)
    head |> Tuple.to_list() |> Enum.sum()
  end

  def combination(_, 0), do: [[]]
  def combination([], _), do: []

  def combination([x | xs], n) do
    for(y <- combination(xs, n - 1), do: [x | y]) ++ combination(xs, n)
  end
end


Measured memory_bytes: 32608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	ee := make([][]edge, n)
	for i := 0; i < n-1; i++ {
		u := getNextInt(scanner) - 1
		v := getNextInt(scanner) - 1
		w := getNextInt(scanner)
		appendEdge(u, v, w, i, ee)
		appendEdge(v, u, w, i, ee)
	}
	cc := make([]int, n)
	dfs(0, -1, 0, ee, cc)
	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, cc[i])
	}
}

func dfs(c, p, w int, ee [][]edge, cc []int) {
	cc[c] = w % 2
	for _, e := range ee[c] {
		if e.to == p {
			continue
		}
		dfs(e.to, c, w+e.w, ee, cc)
	}
}
func appendEdge(from, to, w, id int, ee [][]edge) {
	ee[from] = append(ee[from], edge{
		to: to,
		id: id,
		w:  w,
	})
}

type edge struct {
	to, id, w int
}


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

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(){}
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

struct SCC      //StronglyConnectedComponents
{
    int n;
    int k;
    vector<vector<int>> g, rg;
    vector<bool> used;
    vector<int> cmp;
    vector<int> vs;
    
    void add_edge(int from, int to){
        g[from].push_back(to);
        rg[to].push_back(from);
    }
    
    SCC(int n) : n(n){
        g.resize(n);
        rg.resize(n);
        used.resize(n);
        cmp.resize(n);
        vs.resize(n);
    }
    
    void dfs(int u, int &l){
        used[u] = true;
        for(int v : g[u]){
            if(!used[v]) dfs(v, l);
        }
        vs[l] = u;
        l++;
    }
    
    void rdfs(int u, int k){
        used[u] = true;
        cmp[u] = k;
        for(int v : rg[u]){
            if(!used[v]) rdfs(v, k);
        }
    }
    
    int decomposition(){
        int l = 0;
        for(int i = 0; i < n; i++){
            if(!used[i]) dfs(i, l);
        }
        for(int i = 0; i < n; i++) used[i] = false;
        k = 0;
        for(int i = n - 1; i >= 0; i--){
            if(!used[vs[i]]){
                rdfs(vs[i], k);
                k++;
            }
        }
        return k;
    }
};

vector<int> v[500005];

int main()
{
    int n, m;
    cin >> n >> m;
    SCC g(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    int k = g.decomposition();
    for(int i = 0; i < n; i++){
        v[g.cmp[i]].push_back(i);
    }
    cout << k << endl;
    for(int i = 0; i < k; i++){
        cout << (int)v[i].size();
        for(int j : v[i]) cout << " " << j;
        cout << endl;
    }
}


Measured memory_bytes: 79568
/**/
/*
 * 	Meet me on the battlefield
*/
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
#define pii pair<int,int>
#define sz(x) ((int)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const int inf=1e9;
const int mod=998244353;
#define dpr(x) cout<<#x<<": "<<x<<endl
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int dp[4005][4005];
int n;
int a[4005][2];
string s;
void solve()
{
	cin>>s;
	int n=s.length();
	for(int i=1; i<=n; i++) {
		a[i][0]=s[i-1]-'0'+a[i-1][0];
		a[i][1]='2'-s[i-1]+a[i-1][1];
	}
	for(int i=n+1; i<=2*n; i++) {
		a[i][0]+=a[i-1][0];
		a[i][1]+=a[i-1][1];
	}
	dp[0][0]=1;
	for(int i=1; i<=2*n; i++) {
		for(int j=0; j<=i; j++) {
			if(j>0&&a[i][0]>=j) {
				dp[i][j]+=dp[i-1][j-1];
			}
			if(a[i][1]>=i-j) {
				dp[i][j]+=dp[i-1][j];
			}
			dp[i][j]%=mod;
		}
	}
	ll ans=0;
	// for(int i=0; i<=2*n; i++)
	// 	ans+=dp[2*n][i];
	// ans%=mod;
	cout<<dp[2*n][a[n][0]]<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	auto clk=clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}
/**/

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

int n,s;
int a[10];

int main ()
{
	cin >> n;
	for ( int i = 0 ; i < n ; ++ i )
	    cin >> a[i];
	
	for ( int i = 0 ; i < n ; ++ i )
		for ( int j = i + 1 ; j < n ; ++ j )
		    if ( a[i] < a[j] )
			   swap ( a[i] , a[j] );
	s = a[0] / 2;
	for ( int i = 1 ; i < n ; ++ i )
	    s += a[i];
	cout << s << endl;
	
	return 0;
	 
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    int n = Integer.parseInt(a+b);
    int i = 1;
    while (i*i < n) {
      i++;
    }
    
    System.out.println(i*i == n ? "Yes" : "No");
  }
}

Measured memory_bytes: 21844
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }  // O( log(a) )
bool isPrime(ll n) {                                  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) flag = false;
  }
  return flag;
}
vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  string s_;
  cin >> s_;
  deque<char> s;
  for (auto &s_i : s_) s.push_back(s_i);

  // for (auto &si : s) cout << si;
  // cout << endl;

  int q;
  cin >> q;
  int t, f;
  char c;
  bool isFlipped = false;
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (t == 1)
      isFlipped = !isFlipped;
    else {
      cin >> f >> c;
      if ((f == 1 && !isFlipped) || (f == 2 && isFlipped))
        s.push_front(c);
      else
        s.push_back(c);
    }
  }

  if (!isFlipped) {
    for (auto itr = s.begin(); itr != s.end(); itr++) cout << *itr;
  } else {
    for (auto itr = s.rbegin(); itr != s.rend(); itr++) cout << *itr;
  }
  cout << endl;
}

Measured memory_bytes: 4024
#include<cstdio>
#include<cstring>

enum{ N = 100 + 10};

char a[N][N];
int vis[N][N];
int m,n,cnt;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};

void dfs(int x,int y,char p)
{
    vis[x][y] = 1;
    for(int i=0;i<4;i++)
    {
        int tx = x + dx[i], ty = y + dy[i];
        if(!vis[tx][ty] && tx >= 0 && tx < n && ty >= 0 && ty < m && a[tx][ty] == p)
            dfs(tx,ty,p);
    }
}

int main()
{
    while(~scanf("%d%d",&n,&m),n+m)
    {
        for(int i=0;i<n;i++) scanf("%s",a[i]);
        memset(vis,0,sizeof(vis));
        cnt = 0;
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                if(!vis[i][j])
                {
                    dfs(i,j,a[i][j]);
                    cnt++;
                }
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 1560
#include <bits/stdc++.h>
            using namespace std;
             
            int main(){
              //int a,b,c;
              int a, b, c, d;
              cin >> a >> b >> c >>d;
              //cin >> s;
              //if((a+b)%2==1)cout << 1 + (a+b)/2 << endl;
              //else cout << (a+b)/2 << endl;
              int x, y;
              x = min(a,b);
              y = min(c,d);
              cout << x+y << endl;
              return 0;
            }

Measured memory_bytes: 256
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
 
function main(){
  var read = 0;
  var resultCase = 1;
  while(true){
    var maxWeight = +input[read++];
    if(!maxWeight){
      break;
    }
     
    var treasures = +input[read++];
    var pdp = new Array(maxWeight + 1);//new Int16Array(maxWeight + 1);
    for(var i = treasures; i--;){
      var c = input[read++].split(",");
      var tv = +c[0];
      var tw = +c[1];
 
      var dp = new Array(maxWeight + 1);//new Int16Array(maxWeight + 1);
      for(var w = 1; w <= maxWeight; w++){
        var pdpw = pdp[w]|0;
        dp[w] = pdpw;
        if(w - tw >= 0){
          dp[w] = max((pdp[w-tw]|0) + tv, pdpw);
        }
      }
      pdp = dp;
    }
 
    var resultWeight = 1001;
    var resultCost = 0;
    for(var i = 0; i <= maxWeight; i++){
      var pdpi = pdp[i];
      if(pdpi > resultCost){
        resultCost = pdpi;
        resultWeight = i;
      }
    }
     
    console.log("Case " + resultCase++ + ":\n" + resultCost + "\n" + resultWeight);
  }
}
 
function max(a, b) {
  var t = a - b;
  return a - (t & (t >> 31));
}

Measured memory_bytes: 10344
#include <iostream>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int N;cin >> N;
    set<string> se;
    rep(i,N){
        string s;cin >> s;
        se.insert(s);
    }
    cout << se.size() << endl;
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int notdiv = 0, div4 = 0, div2 = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (t % 2 != 0) {
			notdiv++;
		}
		else if (t % 4 == 0) {
			div4++;
		}
		else {
			div2++;
		}
	}

	if (div2 == 0) {
		if (notdiv <= div4 + 1) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	else {
		if (notdiv > div4) {
			cout << "No" << endl;
			return 0;
		}
		
	}
	cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  int n,k; cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==1) int pos=i;
  }
  
  int selected=0,count=0;
  //if(pos-k<=-1 || pos+k>=n){
    selected+=k;
    count++;
    while(selected<n){
      selected+=k-1;
      count++;
    }
  //}else if(){
    
  cout<<count;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

// a^n mod を計算する

int main(){
  string s;
  cin >> s;
  vector<string> w(3);
  w[0] = "Sunny";
  w[1] = "Cloudy";
  w[2] = "Rainy";
  if(s == w[0]){
    cout << w[1] << endl;
  }else if(s == w[1]){
    cout << w[2] << endl;
  }else{
    cout << w[0] << endl;
  }
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define MOD 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> prob(n, 0);
    for (int i = 0; i < n; ++i)cin >> prob[i];
    sort(prob.begin(), prob.end());
    ll hal1 = prob[n / 2 - 1];
    ll hal2 = prob[n / 2];
    cout << (prob[n / 2] - prob[n / 2 - 1]) << endl;
}




Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
using ll = long long;
int MOD=1e9+7;
using namespace std;
int main(){
    int n;
    cin >> n;
    map<string,int> mp0;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(mp0.find(s)!=mp0.end()){
            mp0[s]++;
        }else{
            mp0[s]=1;
        }
    }
    int m;
    cin >> m;
    map<string,int> mp1;
    for(int i=0;i<m;i++){
        string s;
        cin >> s;
        if(mp1.find(s)!=mp1.end()){
            mp1[s]++;
        }else{
            mp1[s]=1;
        }
    }
    int count=0;
    for(auto itr=mp0.begin();itr!=mp0.end();++itr){
        bool h=true;
        for(auto itr1=mp1.begin();itr1!=mp1.end();++itr1){
            if(itr->first==itr1->first){
                    h=false;
                if(itr->second >= itr1->second){
                    count =max(count,itr->second-itr1->second); 
                  //  cout<<"COUNT"<<endl;
                    break;
                }
            }
            
        }
        if(h){
                count = max(count,itr->second);
               // cout<<itr->first<<itr->second<<endl;
            }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => { trace!(($($args),*)) }
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

const M: usize = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let W: u64 = sc.cin();
    const V: usize = 100000;
    const INF: u64 = 1000_000_000 + 10000;
    let mut weights = vec![INF; V*2];
    weights[0] = 0;
    for _ in 0..n {
        let w: u64 = sc.cin();
        let v: usize = sc.cin();
        for k in (0..V).rev() {
            weights[k+v] = min(weights[k+v], weights[k] + w);
        }
    }
    // trace!(&weights);
    put!(weights.iter().enumerate().filter(|&(_, w)| *w <= W).map(|(i, _)| i).max().unwrap());
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


Measured memory_bytes: 6396
#include<iostream>
#include<string>
using namespace std;
int index_a=0, index_z=0;
int main(){
  string s;cin>>s;
  for(int i=0;i<s.size();i++){if(s[i]=='A'){index_a=i;break;}}
  for(int i=0;i<s.size();i++){if(s[i]=='Z')index_z=i;}
  cout<<index_z-index_a+1<<endl;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H, W;
        H = sc.nextInt();
        W = sc.nextInt();
        char[][] list = new char[H][W];
        String [] list2 = new String[H];
        for(int a=0;a<H;a++){
            list2[a] = sc.next();
        }
        for (int a = 0; a < H; a++) {
            for (int b = 0; b < W; b++) {
                list[a][b] = list2[a].charAt(b);
            }
        }
        int num2=0;
        for(int a=1;a<H-1;a++){
            for(int b=1;b<W-1;b++){
                int num=0;
                if(list[a][b]=='#'){
                    if(list[a-1][b]=='#') num++;
                    if(list[a+1][b]=='#') num++;
                    if(list[a][b-1]=='#') num++;
                    if(list[a][b+1]=='#') num++;
                }
                else num=1;
                if(num==0){
                    num2=1;
                    break;
                }
            }
            if(num2==1)break;
        }
        if(num2==1) System.out.println("No");
        else System.out.println("Yes");
    }
}


Measured memory_bytes: 21712
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;
vector<vector<int>> mini;
vector<pair<int,int>> new_check;
int H,W;
vector<vector<char>> V;
void checking(int y,int x,int point){
	if(y<0)return ;
	if(y>=H)return;
	if(x<0)return;
	if(x>=W)return;
	if(V[y][x]=='#')return;
	if(mini[y][x]!=-1)return;
	else{
		mini[y][x]=point+1;
		new_check.push_back(make_pair(y,x));
	}
}

int main(){

	cin>>H>>W;

	int white_cnt=0;
	for(int i=0;i<H;i++){
		mini.push_back(vector<int>());
		V.push_back(vector<char>());
		for(int j=0;j<W;j++){
			char temp;
			cin>>temp;
			if(temp=='.')white_cnt++;
			V[i].push_back(temp);
			mini[i].push_back(-1);
		}
	}
	mini[0][0]=0;
	new_check.push_back(make_pair(0,0));
	vector<pair<int,int>> check;
	while(true){
		check=new_check;
		new_check.clear();
		for(int i=0;i<check.size();i++){
			int p = mini[check[i].first][check[i].second];
			checking(check[i].first-1,check[i].second,p);
			checking(check[i].first+1,check[i].second,p);
			checking(check[i].first,check[i].second-1,p);
			checking(check[i].first,check[i].second+1,p);
		}
		if(new_check.size()==0)break;
	}
	if(mini[H-1][W-1]==-1)cout<<-1<<endl;
	else{
		cout<<white_cnt-1-mini[H-1][W-1]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
n, k = list(map(int, input().split()))
r,s,p = list(map(int, input().split()))
t = list(input())

win = {"r":p, "s":r, "p":s }
res = 0
for i in range(n-k):
  if(t[i+k] == t[i]):
    t[i+k] = 0
for i in range(n):
  if(t[i] != 0):
    res += win[t[i]]
print(res)

Measured memory_bytes: 4084
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long h = sc.nextLong();
        int n = sc.nextInt();
        long s = 0;
        for(int i = 0; i < n; ++i) {
            s += sc.nextLong();
        }
        String ans = (s >= h) ? "Yes" : "No";
        System.out.println(ans);
    }
}

Measured memory_bytes: 46736
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 0;
  int roop = s.size()/2;
  REP(i, roop) if (s[i] != s[s.size()-1-i]) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j,h;
    ll Q,N,K,P,A,B;
    
    long double a, b;
    long double x;

    vector<ll> aa;
    string S;

    ll flag=0;
    ll temp=0;

    long double X;

    cin  >> X;
    ll tt=100;
    while(1){
        tt=tt*1.01;
        ans++;
        if(tt>=X){
cout << ans<<endl;
break;
        }
    }
    

    return 0;
}

Measured memory_bytes: 3780
#include<stdio.h>

int main(){
    int N,i,j,minj,cout=0,temp;
	scanf("%d",&N);
	int A[N];
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	for(i=0;i<=N-2;i++){
		minj=i;
		for(j=i;j<=N-1;j++){
			if(A[j]<A[minj]){
				minj=j;				
				}	
		}
		if(minj!=i){
	    temp=A[i];
	    A[i]=A[minj];
	    A[minj]=temp;
	    cout++;
	    }
	   }
	   printf("%d",A[0]);
	for(i=1;i<N;i++){
		printf(" %d",A[i]);
	}
	printf("\n");
	printf("%d\n",cout);
		
	return 0;
}




Measured memory_bytes: 2140
using System;

namespace ABC047_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = 0;

            for (var i = 0; i < s.Length - 1; i++)
            {
                if (s[i] != s[i + 1])
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;
template<typename T, T mod>
struct modint {
private:
  T x;

public:
  modint(): x((T)0) {}
  modint(T y): x(y >= 0? y % mod: (mod - (-y) % mod) % mod) {}

  T get() {
    return x;
  }

  modint &operator+=(const modint &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  modint &operator-=(const modint &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  modint &operator*=(const modint &p) {
    x = x * p.x % mod;
    return *this;
  }

  modint &operator/=(const modint &p) {
    *this *= p.inverse();
    return *this;
  }

  modint operator-() const { return modint(-x); }
  modint operator+(const modint &p) const {return modint(*this) += p; }
  modint operator-(const modint &p) const {return modint(*this) -= p; }
  modint operator*(const modint &p) const {return modint(*this) *= p; }
  modint operator/(const modint &p) const {return modint(*this) /= p; }

  bool operator==(const modint &p) const { return x == p.x; }
  bool operator!=(const modint &p) const { return x != p.x; }

  modint inverse() const {
    T a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return modint(u);
  }

  modint pow(int e) const {
    T a = 1, p = x;
    while(e > 0) {
      if (e % 2 == 0) {
	p = (p * p) % mod;
	e /= 2;
      } else {
	a = (a * p) % mod;
	e--;
      }
    }
    return modint(a);
  }
};

const long long MOD = 1000000007;

using mi = modint<long long, MOD>;

int main() {
  int n, m;
  cin >> n >> m;
  if (abs(n - m) > 1) {
    puts("0");
    return 0;
  }

  mi ans = 1;
  for (int i = 0; i < n; ++i) {
    ans *= (n - i);
  }

  for (int i = 0; i < m; ++i) {
    ans *= (m - i);
  }
  if (n == m) ans *= 2;
  cout << ans.get() << endl;
  return 0;
}


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

int main(){
  string s,t[4]={"maerd","remaerd","esare","resare"},s2;cin>>s;
  bool f;
  for(int i=s.size()-1;i>=0;i--) s2.push_back(s.at(i));
  while(s2.size()){
    f=0;
    REP(i,4) if(!(s2.find(t[i]))){
      s2=s2.substr(t[i].size());
      f=1;
      break;
    }
    if(!f) break;
  }
  
  cout<<(f?"YES":"NO");
}

Measured memory_bytes: 512
from itertools import combinations
N, F= map(int, input().split())
goods= [sorted(g) for _ in range(N) for g in list(combinations(list(map(str, input().split()))[1:], 2))]
sets=set((g[0], g[1]) for g in goods)
s= [(s[0], s[1]) for s in sets if goods.count([s[0], s[1]])>=F]
n= [sum(1 for s in sets if goods.count([s[0], s[1]])>=F)]

for a in n:
    print(a)
else:
    if n[0]!=0:
        for t in sorted(sorted(s, key=lambda x: x[1])):
            print(*t)

Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    ld sum=0;
    rep(i,n){
        ld x;
        cin >> x;
        sum += 1/x;
    }
    cout << fixed << setprecision(8) << 1/sum << endl;
}

Measured memory_bytes: 3796
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
#define int long long

int n, k; 
vector<int> a, f;

bool check(int x) {
    vector<int> res(n);
    rep(i, n) {
        int y = x / f[i];
        res[i] = y;
    }
    sort(all(res));
    int cnt = 0;
    rep(i, n) {
        if(a[i] > res[i]) {
            cnt += (a[i] - res[i]);
        }
    }
    if(cnt <= k) return true;
    return false;
}

void solve() {
	cin >> n >> k;
  a.resize(n); f.resize(n);
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    rep(i, n) {
        cin >> f[i];
    }
    if(sum <= k) {
        cout << 0 << endl;
        return;
    }
    sort(all(a)); sort(all(f));
    int ng = 0, ok = 100000000000000;
    while(ok - ng > 1) {
        int mid = (ok + ng) / 2;
        if(check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 4992
h,w = map(int,input().split())
s = [""]*h
mod = 10**9+7
for i in range(h):
  si = str(input())
  s[i] = si
x = [1]*w
for i in range(w):
  if s[0][i] == "#":
    for j in range(i,w):
      x[j] = 0
    break
for i in range(1,h):
  newx = [0]*w
  if s[i][0] == ".":
    newx[0] = x[0]
  for j in range(1,w):
    if s[i][j] == ".":
      newx[j] = (newx[j-1]+x[j])%mod
    else:
      newx[j] = 0
  x = newx
print(x[w-1])
    

Measured memory_bytes: 4212
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.L;
		long ans=n;
		for(int i=1;i<n;i++){
			var e=sc.Ia;
			if(e[0]>e[1]){(e[0],e[1])=(e[1],e[0]);}
			ans+=i*(n-i+1);
			ans-=e[0]*(n-e[1]+1);
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 46252
N = int(input())
for i in range(1, 3501):
    for j in range(1, 3501):
        if 4 * i * j - N * i - N * j > 0 and (N * i * j) % (4 * i * j - N * i - N * j) == 0:
            print(i, j, (N * i * j) // (4 * i * j - N * i - N * j))
            exit()


Measured memory_bytes: 40684
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int num = 0;
  if (N < 10)
  {
    num = N;
  }
  else
  {
    num += 9;
    if (N < 100)
    {
    }
    else if (100 <= N && N < 1000)
    {
      num += N - 99;
      cout << num << endl;
      return 0;
    }
    else
    {
      num += 900;
      if (N < 10000)
      {
      }
      else if (10000 <= N && N < 100000)
      {
        num += N - 9999;
      }
      else
      {
        num += 90000;
      }
    }
  }

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 3604
K, A, B = map(int, input().split())
if A - B >= -2:
    print(1 + K)
    exit()
n = A
K = K - A + 1
if K % 2 == 0:
    n += int(K / 2) * (B - A)
else:
    n += int(K / 2) * (B - A) + 1
print(n)


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

#define MAXN 10000005

int f[MAXN];
bitset<MAXN> prime;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    prime.set();
    for (int i=1; i<=n; i++)
        f[i] = 1;
    for (int p=2; p<=n; p++)
        if (prime[p])
            for (int i=p; i<=n; i+=p) {
                if (i != p)
                    prime[i] = 0;
                int num = i, cur = 0;
                while (num % p == 0) {
                    num /= p;
                    cur++;
                }
                f[i] *= cur + 1;
            }

    long long ret = 0;
    for (int i=1; i<=n; i++)
        ret += (long long) i * f[i];

    cout << ret << "\n";

    return 0;
}


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

int main(){
  int N;
  cin>>N;
  int mini(10000000);
  for (int i(1);i<N;i++){
    int A=i,B=N-i;
    string sa=to_string(A),sb=to_string(B);
    int cnt(0);
    for (int i(0);i<sa.size();i++) cnt+=sa[i]-'0';
    for (int i(0);i<sb.size();i++) cnt+=sb[i]-'0';
    mini=min(mini,cnt);
  }
  cout << mini << endl;
  return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
///////////////////////////////////////////////
int main(){
	int N; SCD(N);
	ll W; SCLLD(W);
	static ll w[100002] = {};
	static int v[100002] = {};

	FORq(i,1,N){
		SCD(w[i]);
		SCLLD(v[i]);
	}

	static ll dp[101][100002] = {};
	FORq(i,0,N){
		FORq(j,0,100000){
			dp[i][j] = 1000000001;
		}
	}

	dp[0][0] = 0;


	FORq(i,1,N){
		FORq(j,0,100000){
			if (j < v[i]){
				dp[i][j] = dp[i-1][j];
				continue;
			}

			dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i]] + w[i]);
		}
	}



	int ans = 0;
	FORq(j,0,100000){
	//	printf("dp[N][%d] = %d\n",j,dp[N][j]);
		if (dp[N][j] <= W) {
			ans = max(ans,j);
		}
	}

	PRINTD(ans);
}


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


void DFS(vector<int> adj[],int src,vector<int> &dp,vector<bool> &visited){
	if(visited[src]==true)
	    return;
	
	visited[src]=true;
	for(auto x:adj[src]){
		if(visited[x]==false){
			DFS(adj,x,dp,visited);
		}
		dp[src]=max(dp[src],1+dp[x]);
	}
}

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> adj[n+1];
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
	}
	vector<bool> visited(n+1,false);
	vector<int> dp(n+1,0);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(visited[i]==false){
			DFS(adj,i,dp,visited);
		}
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
}

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

const int MAX_N = 110000;

int memo[MAX_N]; // memo[i] が i についての答え
int rec(int n) {
    if (n == 0) return 0; // 終端条件
    if (memo[n] != -1) return memo[n]; // すでに探索済みならリターン

    int res = n; // INF の気持ち

    // 1, 6, 6^2, ..., を試す (n を超えない範囲で)
    for (int pow6 = 6; pow6 <= n; pow6 *= 6) res = min(res, rec(n - pow6) + 1);

    // 1, 9, 9^2, ..., を試す (n を超えない範囲で)
    for (int pow9 = 1; pow9 <= n; pow9 *= 9) res = min(res, rec(n - pow9) + 1);

    // メモしながらリターン
    return memo[n] = res;
}

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

    // テーブルを -1 で初期化
    for (int i = 0; i < MAX_N; ++i) memo[i] = -1;
    cout << rec(N) << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(){
  int S,h,m,s;
  scanf("%d",&S);
  h =S/3600   ;
  m =(S % 3600) / 60   ;
  s =S%60   ;
  /*printf("%d %d %d\n",h=S/3600,m=S/s=60,s=S);*/
  printf("%d:%d:%d\n",h, m , s);
     return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n);
    for(ll i=0;i<n;i++) cin >> p[i];
    sort(ALL(p));

    ll ans = 0;
    for(ll i=0;i<k;i++) ans += p[i];
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3544
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n,sum=0;
	string a;
	cin>>n>>a;
	int i,k=0;
	for(i=0;i<n;i++){
		if(a[i]=='I')k++;
		if(a[i]=='D')k--;
		if(sum<k)sum=k;
	}
	cout<<sum<<endl;return 0;
}

Measured memory_bytes: 256
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for _ in range(N)]
l = []
for i in range(N):
  n = 0
  while (n + 1) * A[i] + 1 <= D:
    l.append((n + 1) * A[i] + 1)
    n += 1
  
print(len(l)+ N + X)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}


int main() {
    int n; cin >> n;
    vector<ll> v;ll ans = 0;
    int x; cin >> x; v.push_back(x);
    for(int i = 1;i < n;i++){
        int x; cin >> x;
        v.push_back(x);
        if(v[i-1] > v[i]){
            ans+=v[i-1] - v[i];
            v[i] += v[i-1] - v[i];
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 5372
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,l,r,d;
	cin >> l >> r >> d;
	a = r/d;
	a -= (l-1)/d;
	cout << a << "\n";
}

Measured memory_bytes: 3648
#include <iostream>
 
using namespace std;
 
const int MAX_N = 110;
int height, width;
char field[MAX_N][MAX_N];
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};
 
inline bool VALID_POS(int x, int y) {
    return ( x >= 0 && x < width && y >= 0 && y < height);
}
 
void dfs(int x, int y, char fruit)
{
    if (!VALID_POS(x, y) || field[y][x] != fruit) return;
    field[y][x] = ' ';
 
    for (int i = 0; i < 4; ++i) {
        dfs(x + dx[i], y + dy[i], fruit);
    }  
}
 
 
int solve() {
    int ref = 0;
 
    for (int y = 0; y < height; ++y) {
        for (int x = 0; x < width; ++x) {
            // ???°?????????
            if (field[y][x] == ' ') continue;
 
            dfs(x, y, field[y][x]);
            ref++;
        }
    }
 
    return ref;
}
 
 
int main()
{
     
    while (cin >> height >> width) {
        if (height == 0 && width == 0) break;
 
        for (int y = 0; y < height; ++y) {
            for (int x = 0; x < width; ++x) {
                cin >> field[y][x];
            }
        }
 
        int ans = solve();
 
        cout << ans << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3560
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,m = RI()
ab = LI(m)

g = [ [] for _ in range(n) ]
for i in range(m):
    a = ab[i][0] - 1
    b = ab[i][1] - 1
    g[a].append(b)
    g[b].append(a)
# print(g)

l = list(range(1,n))
ls = list( permutations(l) )
# print(ls)

ans = 0
for i in range(len(ls)):
    flag = True
    v = [0]*n
    p = [0] + list(ls[i])
    # print(p)
    for j in range(len(p)-1):
        if v[p[j]]!=0:
            flag = False
        else:
            if p[j+1] in g[p[j]]:
                v[p[j]] = 1
            else:
                flag = False
    if flag:
        ans += 1
    else:
        pass

print(ans)

Measured memory_bytes: 70624
n=int(input())
ld=n%10
if ld==2 or ld==4 or ld==5 or ld==7 or ld==9:
   print("hon")
elif ld==0 or ld==1 or ld==6 or ld==8:
   print("pon")
else:
   print("bon")

Measured memory_bytes: 9176