akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int long long
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define MP make_pair
#define PB emplace_back
#define all(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF = 1e18L;
const double eps = 1e-9;
const int mod = 1e9 + 7;

int32_t main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    IOS;
    int n;
    cin >> n;
    if (n == 1)
    {
        cout << "1\n";
        return 0;
    }
    vector<int> fq(n + 1);
    for (int i = 2; i <= n; i++)
    {
        int x = i;
        for (int j = 2; j * j <= x; j++)
        {
            if (x % j == 0)
            {
                int cnt = 0;
                while (x % j == 0)
                {
                    cnt++;
                    x /= j;
                }
                fq[j] += cnt;
            }
        }
        if (x > 1)
        {
            fq[x] += 1;
        }
    }
    int ans = 1;
    for (int i = 2; i <= n; i++)
    {
        if (fq[i])
        {
            (ans *= fq[i] + 1) %= mod;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int cnt = 0;
    
    for (long a = 1; a <= N; a++) {
        for (long b = a; a * b < N; b++) {
            if (a == b) cnt++;
            else cnt += 2;
        }
    }
    
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define mn(a, b) (a < b ? a : b)
#define mx(a, b) (a > b ? a : b)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define base 331
#define eps 1e-10

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double db;

int const MAXn = 3e3 + 2;

db dp[MAXn][MAXn];

int main(){

    //freopen(".in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++){
        db x;
        cin>>x;
        if(i == 1){
            dp[1][1] = x;
            dp[1][0] = 1 - x;
            continue;
        }
        for(int j = 0; j < i; j++){
            dp[i][j + 1] = dp[i][j + 1] + (dp[i - 1][j] * x);
            dp[i][j] = dp[i][j] + (dp[i - 1][j] * (1 - x));
        }
    }
    db sol = 0;
    for(int i = n; i > n / 2; i--){
        sol += dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<sol;
    return 0;
}


Measured memory_bytes: 139136
N=int(input())
p=list(map(int,input().split()))
g=0
for i in range(1,N-1):
  if p[i-1]<p[i] and p[i]<p[i+1]:
    g+=1
  elif p[i-1]>p[i] and p[i]>p[i+1]:
    g+=1
print(g)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	string S;
	cin >> N >> S;
	
	// 長さで二分探索
	int min = 0;
	int max = N;
	while(max - min > 0){
		// cout << min << " " << max << endl;
		int mid = (max+min+1)/2;
		bool found = mid > 0 ? false : true;
		
		if(!found){
			string words[5000];
			for(int i = 0; i < N-mid+1; i++){
				words[i] = S.substr(i, mid);
			}
			
			for(int i = 0; i < N-mid+1; i++){
				for(int j = i+mid; j < N-mid+1; j++){
					if(words[i] == words[j]){
						found = true;
						break;
					}
				}
				if(found){
					break;
				}
			}
		}
		
		if(found){
			min = mid;
		}
		else{
			max = mid - 1;
		}
	}
	
	cout << min << endl;
	
	return 0;
}


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

int main()
{
  int a;
  int b;
  
  cin >> a >> b;
  
  if (a * b % 2 == 0)
  {
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 3616
# agc027_a.py
n,x = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) == x:
    print(n)
    exit()

a.sort()
cnt = 0
for i in a:
    if x>=i:
        cnt += 1
        x -= i
if cnt == n:
    cnt-=1
print(cnt)


Measured memory_bytes: 3060
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        s: chars
    }
    let n = 13;
    let mut dp = vec![0; n];
    dp[0] = 1;
    let md = 1000_000_000 + 7;

    let mut mul = 1;
    for i in (0..s.len()).rev() {
        let mut next_dp = vec![0; n];
        let c = s[i];
        if c == '?' {
            for k in 0..10 {
                for j in 0..n {
                    next_dp[(k * mul +j) % n] += dp[j];
                    next_dp[(k * mul +j) % n] %= md;
                }
            }
        } else {
            let k = c.to_digit(10).unwrap() as usize;
            for j in 0..n {
                next_dp[(k * mul +j) % n] += dp[j];
                next_dp[(k * mul +j) % n] %= md;
            }
        }
        mul *= 10;
        mul %= n;
        dp = next_dp;
    }
    println!("{}",  dp[5]);
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(){

  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(17==a+b+c){
    if((a==5)&&(b==5)){
      puts("YES");
    }else if((a==5)&&(c==5)){
      puts("YES");
    }else if((b==5)&&(c==5)){
      puts("YES");
    }else {
      puts("NO");
    }
  }else{
    puts("NO");
  }


return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  int n, t; cin >> n >> t;
  vi h(n); rep(i, n) cin >> h[i];

  ll ans = INF;
  sort(all(h));
  rep(i, n - t + 1){
    int x = h[i + t - 1] - h[i];
    ans = min(ans, (ll)x);
  }

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

Measured memory_bytes: 640
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	s := io.Next()
	cnt := map[byte]int{}
	for i := 0; i < n; i++ {
		cnt[s[i]]++
	}
	ans := 0
	for i := 0; i < cnt['R']; i++ {
		if s[i] == 'W' {
			ans++
		}
	}
	io.Println(ans)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;

typedef long long int ll;
const int maxn = (2 << 20) + 5; 
ll n;
ll A[maxn];
ll Plus[maxn];
ll Xor[maxn];
ll cnt = 0;
ll ans[10];

bool check()
{
	ll l = ans[0], r = ans[1], res1, res2;
	//printf("(%lld, %lld)\n", l+1, r+1); //
	if(l == 0) 
	{
		res1 = Plus[r];
		res2 = Xor[r];
	}
	else
	{
		res1 = Plus[r] - Plus[l-1];
		res2 = Xor[r] ^ Xor[l-1];
	}
	if(res1 == res2) { cnt++; return true; }
	else return false;
}

void Sum(ll p)
{
	ll s = (n-1)-p-1;
	cnt += (s+1)*s/2;
}

void solve()
{
	ll i, j, flag = 1; int ok = 1;
	for(i = 0; i < n-1; i++)
	{
		if(i == flag) flag++; 
		for(j = flag; j < n; j++)
		{
			ans[0] = i;
			ans[1] = j;
			if(!check())
			{
				cnt += max((ll)0, (j-i-2)); //
				ok = 0;
				break;
			}
		}
		flag = j;
		if(j == n) { Sum(i); break; } //扫完全部，说明子序列都可以扫完
	}
}

int main()
{
	cin >> n;
	for(ll i = 0; i < n; i++) scanf("%lld", &A[i]);
	for(ll i = 0; i < n; i++) 
	{
		if(i == 0)
		{
			Plus[i] = A[i];
			Xor[i] = A[i];
		} 
		else
		{
			Plus[i] = A[i] + Plus[i-1];
			Xor[i] = A[i] ^ Xor[i-1];
		}
	}
	solve();
	cout << cnt+n <<endl;
	return 0;
}

Measured memory_bytes: 5888
while n=gets
 a=n.chomp.to_i
 num=[a]
 nu=[]
 9.times do |i|
  b=gets.chomp.to_i
  num[i+1]=b
 end
 num=num.sort
 w=num[9]+num[8]+num[7]
 10.times do |j|
  c=gets.chomp.to_i
  nu[j]=c
 end
 nu=nu.sort
 k=nu[9]+nu[8]+nu[7]
 puts w.to_s+' '+k.to_s
end

Measured memory_bytes: 6092
a,b,k = map(int,input().split())

li1 = [i for i in range(a,a+k) if i <= b]
li2 = [i for i in range(b+1-k,b+1) if i >= a]

li1.extend(li2)
li1 = set(li1)

for i in sorted(li1):
    print(i)



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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

char str[15];
int n;

void ans(int i, int max){
	if(i == n){
		puts(str);
	}else{
		for(int j = 0; j <= max; ++j){
			str[i] = 'a' + j;
			if(j == max){
				ans(i + 1, max + 1);
			}else{
				ans(i + 1, max);
			}
		}
	}
}

int main(){
	cin >> n;
	ans(0, 0);
}


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

int main()
{
  int n, m, x;
  cin >> n >> m >> x;
  
  int cost_left = 0, cost_right = 0;
  int tmp;
  for (int i = 0; i < m; i ++)
  {
    cin >> tmp;
    if (tmp < x) cost_left ++;
    else cost_right ++;
  }
  
  if (cost_left < cost_right) cout << cost_left << endl;
  else cout << cost_right << endl;
  
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 1) {
			cnt1++;
		}		
		if (a[i] % 4 == 0) {
			cnt2++;
		}
	}
	if (cnt2 - cnt1 >= 0 || (cnt1 - cnt2 == 1 && cnt2 + cnt1 == n)) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

int main(){
   char A[100];
   cin>>A;
   int n=strlen(A)/2;
   int i;
   for(i=0;i<n;i++){
       if(A[i]!=A[n+1+i]){printf("No");return 0;}
   }
   int s=n/2;
   for(i=0;i<s;i++){
       if(A[i]!=A[n-1-i]){printf("No");return 0;}
   }
   printf("Yes\n");
}


Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//const int mod = 1e9+7;
int a, b;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    quickread();
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int N;
  cin >> N;
  vector<lli> A(N);
  int Z;
  lli jk=-1;
  lli maximum=-1;
  
  rep(i, N) {cin >>A[i];  maximum=max(maximum,A[i]);}
  rep(i, N) {
    if(jk<min(maximum-A[i],A[i])&&A[i]!=maximum)
    {jk=min(maximum-A[i],A[i]);
     Z=i;
    }
  }
  cout << maximum <<" "<<A[Z] << endl;
  

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  ll n;
  cin>>n;
  ll a[n],b[n];
  for(ll i=0;i<n;i++)
   {
     cin>>a[i];
     cin>>b[i];
   }
   string ans="No";
   ll count=0;
   for(ll i=0;i<n;i++)
   {
     if(a[i]==b[i])
         count++;
      else
      {
        if(count>2)
        {
          ans="Yes";
          break;
        }
        count=0;
      }  
   }
   if(count>2)
    ans="Yes";
  cout<<ans<<endl;
 return 0; 
}

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

int main(){
    string s;
    cin >> s;
    set<char> c;
    for (int i = 0; i < s.size(); i++)
    {
        c.insert(s[i]);
    }
    cout << (s.size() == c.size() ? "yes" : "no") << "\n";
}

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

int n,t;
vector <int> a;

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

    cin >> n;

    for(int i=0;i<n;i++)
    {
    	cin >> t;
    	a.push_back(t);
    }

    if(a[0]!=0)
    {
    	cout << -1 << '\n';
    	return 0;
    }

    long long int res = 0;
    int val = 0;
    for(int i=n-1;i>0;i--)
    {
    	//cout << i << ' ' << val << '\n';
    	if(a[i]-a[i-1] > 1)
    	{
    		cout << -1 << '\n';
    		return 0;
    	}
    	if(a[i]!=0)
    	{
    		if(val < a[i])
    		{
    			res += a[i];
    			val = a[i] - 1;
    		}
    		else
    		{
    			val--;
    		}
    	}
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 1400
def kannon(n):
    a = [1]
    for i in range (1,n+1):
        a.append(a[i-1])
        if i >= 2:
            a[i] += a[i-2]
        if i >= 3:
            a[i] += a[i-3]
    return (a[-1] -1)//3650 + 1

while True:
    n = int(input())
    if n==0:
        break
    print(kannon(n))


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n,i,j,cur = 1,ans;
    cin >> n;
    ans = 0;
    rep(i,0,n){
        cin >> j;
        if(j == cur){
            cur++;
        }
        else {
            ans++;
        }
    }
    if(ans == n)ans = -1;
    cout << ans;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

	
	int32_t main(){
		IOS;
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		cout<<max(a*c,max(b*c,max(a*d,b*d)))<<endl;
		return 0;
	}


Measured memory_bytes: 3644
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5596
import java.util.*;

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

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        long[] b = new long[n + 1];
        long[] w = new long[n + 1];
        long m = Long.MAX_VALUE;
        for (int i = 1; i <= n; i++) {
            int a = scanner.nextInt();
            b[i] = b[i - 1];
            w[i] = w[i -  1];
            if (a < 0) {
                b[i] -= a;
            } else {
                w[i] += a;
            }
            if (i >= k) {
                m = Math.min(m, Math.min(b[i] - b[i - k], w[i] - w[i - k]));
            }
        }
        System.out.println(w[n] - m);
    }
}

Measured memory_bytes: 58940
#include <bits/stdc++.h>
#define ll long long int
#define N 1000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */
int main()
{
     ll n,m;

     cin >>  n >> m;

    ll a[n+1];
    ll sum=0;
     f(i,1,n) {cin >> a[i];
     sum+=a[i];}

     ll cnt=0;
     ll ans=0;
 
     ll v=sum/(4*m);
     if(sum%(4*m)!=0)
     v++;

     f(i,1,n)
     {
         if(a[i]>=v)
         {
             ans++;
         }
     }

     if(ans>=m)
     cout << "Yes";
     else
     {
         cout  << "No";
     }
     
}

Measured memory_bytes: 256
//package abc057a;

import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int a, b, ans = 0;
		
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		ans = a + b;
		if(ans >= 24) ans -= 24;
		System.out.println(ans);

	}

}


Measured memory_bytes: 23636
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}





Measured memory_bytes: 2624
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    int n , m ; 
    cin >> n >> m; 
    vector<vector<int> > graph(n + 1);
    for(int i = 0; i < m; i++){
        int x , y ; 
        cin >> x >> y ; 
        graph[x].push_back(y) ; 
        graph[y].push_back(x) ; 
    }
    vector<int> v ; 
    for(int i = 1; i <= n; i++){
        v.push_back(i) ; 
    }
    int ans = 0 ; 
    do{
        if ( v[0] != 1 ) break;
        debug() << imie(v) ;
        bool flag = true;
        for(int i = 1; i < (int) v.size(); i++){
            int before = v[i - 1];
            bool ok = false;
            for(int &c : graph[v[i]]){
                if ( c == before ) ok = true ;
            }
            if ( !ok ) {
                flag = false;
                break;
            }
        }
        if ( flag ) {
            ans++ ;
            debug() << "Result : "  imie(v) ;
        }
    }while(next_permutation(v.begin(),v.end()));
    cout << ans << endl;
    return 0 ;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

// void add(int n, vector<pair<int, vector<int>>> &t) {
//   for (int i = 0; i < t[n].second.size(); ++i) {
//     int m = t[n].second[i];
//     t[m].first += t[n].first;
//     add(m, t);
//   }
// }

void add(int n, vector<tuple<int, int, vector<int>>> &t) {
  if (get<1>(t[n]) == 1) return;
  get<1>(t[n]) = 1;
  for (int i = 0; i < get<2>(t[n]).size(); ++i) {
    int m = get<2>(t[n])[i];
    if (get<1>(t[m]) == 1) continue;
    get<0>(t[m]) += get<0>(t[n]);
    add(m, t);
  }
}

signed main(void)
{
  int n; cin >> n;
  int q; cin >> q;

  // vector<pair<int, vector<int>>> t(n);
  vector<tuple<int, int, vector<int>>> t(n);
  for (int i = 0; i < n; ++i) {
    // t[i] = make_pair(0, vector<int>());
    t[i] = make_tuple(0, -1 ,vector<int>());
  }
  for (int i = 0; i < n - 1; ++i) {
    int a, b; cin >> a >> b;
    get<2>(t[a - 1]).push_back(b - 1);
    get<2>(t[b - 1]).push_back(a - 1);
    // t[a - 1].second.push_back(b - 1);
    // t[b - 1].second.push_back(a - 1);
  }
  // cout << "input" << endl;

  for (int i = 0; i < q; ++i) {
    int p, x; cin >> p >> x;
    get<0>(t[p - 1]) += x;
    // t[p - 1].first += x;
  }

  add(0, t);

  for (int i = 0; i < n; ++i) {
    cout << get<0>(t[i]);
    // cout << t[i].first;
    if (i != n - 1) cout << " ";
    else cout << endl;
  }

  
}



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

int main(){
int i,n,x;
i=1;
cin>>n;
while(i<=n){
x=i;
 if(x%3==0){
  cout<<" "<<i;
 }else {
 for(x=i;x;x/= 10){
  if (x%10==3){ cout<<" "<<i;
  break;}
 }
 }
i++;
}
cout<<endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    if(X > Y) swap(X, Y);
    if((X + Y) % 3 != 0) {cout << 0 << endl; return 0;}
    int tmp = (X + Y) / 3;
    X -= tmp;
    Y -= tmp;
    //cout << X << " " << Y << endl;
    fact();
    cout << C(X + Y, X) << endl;

    return 0;
}


Measured memory_bytes: 16640
def main():
    s = input()

    odd = 1
    even = 1

    for i in range(1,len(s)+1):
        if i % 2 == 0:
            if s[i-1] == 'R':
                odd = 0
        else:
            if s[i-1] == 'L':
                even = 0

    if odd == 1 and even == 1:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
using namespace std;
int r,l,a,f,t;
char o[10];
int main()
{
	int n,i,p,ans;
	while(scanf("%d",&n)&&n!=0)
	{
	a=1;f=2;r=3;l=4;t=5;ans=1;
	for(i=1;i<=n;i++)
	{
		scanf("%s",o);
		if(o[0]=='N')
		{
			t=a;a=f;f=7-t;
		}else if(o[0]=='S')
		{
			f=a;a=t;t=7-f;
		}else if(o[0]=='W')
		{
			l=a;a=r;r=7-l;
		}else if(o[0]=='E')
		{
			r=a;a=l;l=7-r;
		}else if(o[0]=='R')
		{
			p=l;
			l=f;
			f=r;
			r=t;
			t=p;
		}else if(o[0]=='L')
		{
			p=r;
			r=f;
			f=l;
			l=t;
			t=p;
		}
		ans+=a;
	}
	cout<<ans<<endl;
    }
	return 0;
	
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

#define PI 3.14159265358979323846
  
double min(double x, double y)  
{  
    return (x < y)? x: y;  
      
}  
  
double calcAngle(double h, double m)  
{  
    // validate the input  
    if (h <0 || m < 0 || h >12 || m > 60)  
       // printf("Wrong input");  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    // Calculate the angles moved  
    // by hour and minute hands  
    // with reference to 12:00  
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
  
    // Find the difference between two angles  
    double angle = abs(hour_angle - minute_angle);  
  
    // Return the smaller angle of two possible angles  
    angle = min(360 - angle, angle);  
  
    return angle;  
}  

int main() 
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double d=calcAngle(h,m);
    //cout<<d<<"\n";
    //cout<<fixed<<setprecision(20)<<cos((117*PI)/(180));
    double y=cos((d*PI)/180.0);
   // cout<<y<<"\n";
//     			double ans=(double)a*a+(double)b*b-(double)2*a*b*y;
// 			cout<<fixed<<setprecision(10)<<sqrt(ans);
    // if(d==180)
    // cout<<fixed<<setprecision(20)<<a+b;
    // else if(d==0)
    // cout<<fixed<<setprecision(20)<<abs(b-a);
    // else
    // {
        
          double r=a*a+b*b-(2*a*b*y);
        
        r=sqrt(r);
        cout<<fixed<<setprecision(10)<<r;
   // }
}

/*1.000000000
2.414213562
127.321336469



*/

Measured memory_bytes: 4164
n, x, m = map(int, input().split())
s = set([x])
t = [x]
p = 1
for i in range(n):
    x = x * x % m
    if x in s:
        break
    else:
        s.add(x)
        t.append(x)
    p += 1
if p == n:
    print(sum(s))
    exit()

q = t.index(x)
l = p - q
b = sum(t[q:p])
ans = sum(t[:q])
n -= q
ans += n // l * b + sum(t[q:q + n % l])
print(ans)


Measured memory_bytes: 76908
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int old = sc.nextInt();
		if(old ==3 || old == 5 || old == 7) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 22612
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
int main(void){
    int N;
    int ans = INT_MAX;
    int A;
    cin >> N;
    for(int i = 0; i < N; i++){
        int crack_Coount = 0;
        cin >> A;
        while(A%2 ==0){
            crack_Coount++;
            A /= 2;
        }
        ans = min(ans,crack_Coount);
    }
    
    cout << ans << endl;
    
}



Measured memory_bytes: 256
from sys import stdin
def main():
  from builtins import int, range
  readline = stdin.readline
  n, w = map(int, readline().split())
  t = [-1] * (w + 1)
  t[w] = 0
  for _ in range(n):
    nw, nv = map(int, readline().split())
    for i in range(nw, w + 1):
      ti = t[i]
      if ti == -1:
        continue
      if t[i - nw] < ti + nv:
        t[i - nw] = ti + nv
  print(max(t))
main()

Measured memory_bytes: 7724
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

signed main() {
	int a, b; cin >> a >> b;
	if (a < b)cout << 0 << endl;
	else cout << 10 << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var s string
	fmt.Scan(&s)

	for i := len(s)/2 - 1; i >= 1; i-- {
		found := true
		for j := 0; j < i; j++ {
			if s[j] != s[i+j] {
				found = false
				break
			}
		}
		if found {
			fmt.Println(i * 2)
			return
		}
	}
}


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

bool isPrime(int x){
    if ( x == 2 ){
        return true;
    }

    if ( x % 2 == 0 ){
        return false;
    }

    for( int i = 3; i <= x/2 ; i+=2 ){

        if( x % i == 0 ){
            return false;
        }
    }
    return true;
}

int minPrime(int x){
    while(1){
      if(isPrime(x)){
          return x;
      }
      x++;
    }
    return -1;
}

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

    cout << minPrime(X) << endl;

	return 0;
}



Measured memory_bytes: 256
N, K = map(int, raw_input().split())
S = raw_input()

T = []
if S[0]=="0":
  T = [0]
p = 0
for i in range(1, N+1):
  if i==N or S[i]!=S[i-1]:
    T += [i-p]
    p = i
if S[-1]=="0":
  T += [0]

if len(S)<=2*K+1:
  ans = sum(T)
else:
  t = sum(T[:2*K+1])
  ans = t
  for i in range(2*K+1, len(T)):
    t -= T[i-2*K-1]
    t += T[i]
    if i%2==0:
      ans = max(ans, t)
print ans


Measured memory_bytes: 6848
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int n;

string chara[] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" };

int number[10];



void Show() {
	for (int i = 0; i < n; i++) {
		cout << chara[number[i]];
	}
	cout << endl;
}




void roll(int keta, int maxs) {
	
	for (int i = 0; i < maxs + 2; i++) {
		number[keta] = i;
		if (keta < n - 1) {
			roll(keta + 1, max(maxs, i));

		}
		else {
			Show();
		}
	}
}





int main()
{
	cin >> n;

	for (int i = 0; i < 10; i++) { number[i] = 0; }

	int maxs = 0;

	if (n <= 1) {
		Show();
		return 0;
	}

	roll(1, 0);

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b>>c;
    Cout(min(a*b,c));
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

q_b = aa[:N]
q_a = list(map(lambda x: -x, aa[2*N:]))

sum_b = [sum(q_b)]
sum_a = [sum(q_a)]

heapq.heapify(q_b)
heapq.heapify(q_a)

sum = sum_b[0]
for i in range(N,2*N):
	push = aa[i]
	pop = heapq.heappushpop(q_b,push)
	sum = sum - pop + push
	sum_b.append(sum)

sum = sum_a[0]
for i in range(2*N-1,N-1,-1):
	push = -aa[i]
	pop = heapq.heappushpop(q_a,push)
	sum = sum - pop + push
	sum_a.append(sum)

ans = -INF
for i in range(N+1):
	ans = max(ans,sum_b[i] + sum_a[N-i])

print(ans)

Measured memory_bytes: 39760
n,k = map(int, input().split())
ans = 0
a = list(map(int, input().split()))
 
#各数字が何個あるかの辞書{}
cnt_a = {}
for i in a:
  if i in cnt_a:
    cnt_a[i] += 1
  else:
    cnt_a[i] = 1

#含まれている文字数を大きい順にソート    
v = sorted(list(cnt_a.values()), reverse=True)

# K+1番目以降の文字数を変更する必要があるので数える
ans = sum(v[k:])
print(ans)

Measured memory_bytes: 32184
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    VI a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));      
    int ans=0;
    REP(i,k) ans+=a[i];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3660
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

idx = 0
best = 10e9
for i, h in enumerate(H):
    t = T - h * 0.006
    res = abs(A - t)
    if (best > res):
        best = res
        idx = i + 1

print(idx)


Measured memory_bytes: 38256
N, K = map(int, input().split())
a_array = [int(i) for i in input().split()]

countR=0
countA=0

for i in range(N):
    for j in range(i+1, N):
        if a_array[i] > a_array[j]:
            countR += 1

    for j in range(N):
        if a_array[i] > a_array[j]:
            countA += 1

print(int((countR * K + countA * K * (K-1) // 2)%(10**9+7)))


Measured memory_bytes: 41964
N,K=map(int,input().split())
H=list(map(int,input().split()))

dp = [float('inf')]*(N+1)
dp[0]=0
dp[1]=0
    

for i in range(N):
    if i!=0:
        for k in range(K):
            if i-k>=1:
                dp[i+1] = min ( dp[i+1] ,dp[i-k] + abs(H[i]-H[i-(k+1)]) )
print(int(dp[N]))
# print(dp)

Measured memory_bytes: 57312
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

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



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


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

    vector<int> c(n), s(n), f(n);
    for (int i = 0; i < n; ++i) cin >> c[i] >> s[i] >> f[i];

    for (int i = 0; i < n; ++i) {
        int ans = 0;
        for (int j = i; j < n - 1 ; ++j) {
            int k = max(0, (ans - s[j] + f[j] - 1) / f[j]);
            ans = s[j] + f[j] * k + c[j];
        }
        cout << ans << endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int r, g, b, n,tmp=0;
	ll cnt = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; i<=3000; i++) {
		for (int j = 0; j<=3000; j++) {
			tmp = n - (r * i + j * g);
			if (tmp >= 0 && tmp % b == 0)cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3620
from collections import deque
def bfs(sl, visited, sy, sx, gy, gx, h, w):
    q = deque([[sy,sx]])
    visited[sy][sx] = 0
    qn = deque([[sy,sx]])

    while q:
        # print('---q')
        while q:
            y, x = q.popleft()
            qn.append([y,x])
            if [y, x] == [gy, gx]:
                return visited[gy][gx]
            for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
                ny, nx = y+j, x+k
                if ny >= h or nx >= w or ny < 0 or nx < 0:
                    continue
                if sl[ny][nx] == '.' and visited[ny][nx] == -1:
                    visited[ny][nx] = visited[y][x]
                    q.append([ny,nx])
                    qn.append([ny,nx])
        #     print(q)
        #     print(qn)
        #     print()
            
        # print('---------qn')
        next_qnl = []
        while qn:
            y, x = qn.popleft()
            # q.append([y,x])
            for j in range(-2,3):
                for k in range(-2,3):
                    ny, nx = y+j, x+k
                    if ny >= h or nx >= w or ny < 0 or nx < 0: continue
                    if sl[ny][nx] == '.' and visited[ny][nx] == -1:
                        visited[ny][nx] = visited[y][x] + 1
                        # qn.append([ny,nx])
                        q.append([ny,nx])
            # print(q)
            # print(qn)
            # print()

    return -1


h, w = map(int, input().split()) 
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
sl = [list(input()) for _ in range(h)]
visited = [ [-1]*w for i in range(h)]
ans = bfs(sl,visited,ch-1,cw-1,dh-1,dw-1,h,w)
print(ans)

Measured memory_bytes: 171000
#include <stdio.h>

int main() {
	int n, k, ans = 0;
	scanf("%d%d", &n, &k);

	int x;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &x);
		ans += (x < k - x) ? x : k - x;
	}

	printf("%d", ans*2);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int ans;
  int c=0;
  for(int i=0;i<5;i++)
  {
    int val;
    c++;
    cin>>val;
    if(val==0)
    {
    	cout<<c;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
int main(){
    ll N, M;
    cin >> N >> M;
    vector<vector<P>> v(N);
    for(ll i = 0; i < M; i++){
        ll p, y;
        cin >> p >> y;
        v[p - 1].push_back(P(y, i));
    }
    for(auto &u : v) sort(u.begin(), u.end());
    vector<pair<ll, string>> ans;
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < v[i].size(); j++){
            string ue, shita;
            ue = to_string(i + 1);
            while(ue.size() < 6) ue = '0' + ue;
            shita = to_string(j + 1);
            while(shita.size() < 6) shita = '0' + shita;
            ans.push_back(pair<ll, string>(v[i][j].second, ue + shita));
        }
    }
    sort(ans.begin(), ans.end());
    for(auto e : ans) cout << e.second << endl;
    return 0;
}


Measured memory_bytes: 13168
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N = int(input())
    S_lsit = [input() for i in range(N)]

    counter_list = [0, 0, 0, 0]
    for S in S_lsit:
        if S == "AC":
            counter_list[0] += 1
        elif S == "WA":
            counter_list[1] += 1
        elif S == "TLE":
            counter_list[2] += 1
        elif S == "RE":
            counter_list[3] += 1
    print("AC x {}".format(counter_list[0]))
    print("WA x {}".format(counter_list[1]))
    print("TLE x {}".format(counter_list[2]))
    print("RE x {}".format(counter_list[3]))

if __name__ == "__main__":
    main()



Measured memory_bytes: 16172
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

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

	int INF=1<<28;
	double EPS=1e-12;

	String s;

	void run(){
		for(;;){
			s=sc.nextLine();
			if(s.equals("#")){
				break;
			}
			solve();
		}
	}

	void solve(){
		int n=s.length();
		boolean[] f=new boolean[n];
		boolean[] v=new boolean[n];
		match("[ksthp]y?([iu])[ksthp]", f);
		match("[ksthp]y?([iu])$", f);
		match("[ksthp]y?([ao])[ksthp]y?\\1", f);
		match("([aiueo])", v);
		// debug(f);
		// debug(v);
		int p=-1;
		String ans="";
		for(int i=0; i<n; i++){
			String next=s.charAt(i)+"";
			if(v[i]){
				if(f[i]&&(p==-1||!f[p])){
					next="("+next+")";
				}else{
					f[i]=false;
				}
				p=i;
			}
			ans+=next;
		}
		println(ans);
	}

	void match(String pattern, boolean[] f){
		int start=0;
		for(Matcher m=Pattern.compile(pattern).matcher(s); m.find(start);){
			for(int i=0; i<=m.groupCount(); i++){
				// debug(m.group(i), m.start(i), m.end(i));
			}
			start=m.start(0)+1;
			f[m.start(1)]=true;
			// debug();
		}
	}

	boolean hit(char c, String pattern){
		return pattern.indexOf(c)>=0;
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 34784
#include <cstdio>
#include <cassert>
#include <cctype>
#include <vector>
#include <algorithm>
#include <string>

int apply(int lhs, char op, int rhs) {
  if (op == '*') return std::min(lhs, rhs);
  if (op == '+') return std::max(lhs, rhs);
  assert(false);
}

int parse(
    const std::string &s, size_t &i, const std::vector<int> &vars, 
    const std::vector<std::string> &ops={"+*"}, size_t preced=0) {

  if (preced == ops.size()) {
    if (s[i] == '(') {
      int res=parse(s, ++i, vars, ops, 0);
      assert(s[i] == ')');
      ++i;
      return res;
    }
    if (s[i] == '-') {
      ++i;
      return 2-parse(s, i, vars, ops, preced);
    }
    if (isalpha(s[i])) {
      return vars[s[i++]-'P'];
    }
    if (isdigit(s[i])) {
      return s[i++]-'0';
    }
  }
  int res=parse(s, i, vars, ops, preced+1);
  while (i < s.length()) {
    char op=s[i];
    if (!std::count(ops[preced].begin(), ops[preced].end(), op)) break;
    int tmp=parse(s, ++i, vars, ops, preced+1);
    res = apply(res, op, tmp);
  }
  return res;
}

int testcase_ends() {
  char buf[128];
  scanf("%s", buf);
  std::string s=buf;
  if (s == ".") return 1;
  int res=0;
  std::vector<int> vars(3);
  for (int p=0; p<3; ++p) {
    vars[0] = p;
    for (int q=0; q<3; ++q) {
      vars[1] = q;
      for (int r=0; r<3; ++r) {
        vars[2] = r;
        size_t i=0;
        if (parse(s, i, vars) == 2)
          ++res;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2800
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	x := [100000]int{}
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		x[a-1] += b
	}
	c := 0
	for i := 0; i < 100000; i++ {
		c += x[i]
		if c >= k {
			fmt.Println(i + 1)
            break
		}
	}
}


Measured memory_bytes: 6272
#include<stdio.h>
#include<stdbool.h>

int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}

int main(void){
    int n,m,count=0;
    scanf("%d %d",&n,&m);
    if(n!=1&&n!=0){
        int x = nCr(n,2);
        count += x;
    }
    if(m!=1&&m!=0){
        int y = nCr(m,2);
        count += y;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int main()
{
  char buf[4];
  for (int i = 0; i < 3; i++) {
    char ch = getchar();
    if (ch == '1') {
      buf[i] = '9';
    } else {
      buf[i] = '1';
    }
  }
  buf[3] = '\0';
  puts(buf);
  return 0;
}


Measured memory_bytes: 128