akhauriyash/Code-Regression huggingface dataset:
h,w,kk=map(int,input().split())
G=[[0]*w for i in range(h)]
for i in range(h):
  G[i]=list(input())
for i in range(h):
  for j in range(w):
    G[i][j]=int(G[i][j])
ans=10**5
for i in range(2**(h-1)):
  s=format(i,'12b')
  A=[-1]
  for j in range(h-1):
    if s[-1-j]=="1":
      A.append(j)
  A.append(h-1)
  ans1=len(A)-2
  B=[0]*(len(A)-1)
  c=0
  i=0
  while i<w:
    j=0
    while j<len(A)-1:
      for k in range(A[j]+1,A[j+1]+1):
        B[j]+=G[k][i]
      if B[j]>kk:
        c=c+1
        B=[0]*(len(A)-1)
        j=0
        if c>1010:
          j=100
          i=10000
      else:
        j=j+1
    i=i+1
  if ans1+c<ans:
    ans=ans1+c
print(ans)

Measured memory_bytes: 45660
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

typedef long long ll;

ll solve(ll b, ll n) {
	ll res = 0;
	if (b == 1) return n;
	
	while (n) {
		res += n % b;
		n /= b;
	}
	return res;
}

int main() {
	ll n, s;
	cin >> n >> s;
	
	ll ans = INF;
	if (n > s) {
		for (int i = sqrt(n); i >= 2; i--) {
			if (solve(i, n) == s)
				ans = min(ans, (ll)i);
		}
		
		for (int i = sqrt(n); i >= 1; i--) {
			ll b = (n - s) / i + 1;
			if (solve(b, n) == s)
				ans = min(ans, b);
		}
		
	}
	else {
		if (n == s) ans = n + 1;
	}
	if (ans == INF) ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
read = sys.stdin.read

n, k = map(int, read().split())


def count(d, k):
  if k == 0:
    return 1
  elif k == 1:
    return d
  elif k == 2:
    return d * (d - 1) // 2
  else:
    return d * (d - 1) * (d - 2) // 6


def solve(n, k):
  digit = len(str(n))
  if digit == 0 and k > 0:
    return 0
  if k == 0:
    return 1
  res = 0
  if digit > k:
    res += count(digit - 1, k) * (9 ** k)
  a = 10 ** (digit - 1)
  d, mod = n // a, n % a
  res += count(digit - 1, k - 1) * (9 ** (k - 1)) * (d - 1)
  res += solve(mod, k - 1)
  return res


print(solve(n, k))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
ll mod=1000000007;

signed main(){
    string s;
    while (getline(cin, s)) {
        for(int j=0 ; j<26 ; j++){
            for(int i=0 ; i<s.size() ; i++){
                if(s[i]>='a' && s[i]<='z' ) s[i] = (s[i]=='z')? 'a' : s[i] + 1;
            }
            if( s.find( "the" ) != string::npos || s.find( "this" ) != string::npos || s.find( "that" ) != string::npos){
                cout << s << endl;
            }
        }
    }
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=2e5+100;
vector <pii> a[20];
int32_t main(){
    ll n;

    cin >> n;
    for (int i=0;i<n;i++){
        ll k;
        cin >> k;
        for (int j=0;j<k;j++){
            ll x,y;
            cin >> x >> y;
            a[i].pb({x,y});
        }
    }
    ll ans=0;
    for (int i=0;i<(1<<n);i++){
        vector <int> bit;
        ll k=i;
        ll t=0;
        while(k){
            bit.pb(k%2);
            if (k%2) t++;
            k/=2;
        }
        while(bit.size()<n){
            bit.pb(0);
        }
        ll p1=0;
        for (int j=0;j<n;j++){
            if (!bit[j]) continue;
            for (int k=0;k<a[j].size();k++){
                ll x=a[j][k].F;
                x--;
                if (bit[x]!=a[j][k].S){
                    p1=1;
                }
            }
        }
        if (!p1){
            ans=max(ans,t);
        }
    }
    cout << ans << endl;
}


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

int main(){
    int a[6];

    int l,i=0;
    while(cin>>l){
        a[i] = l;
        i++;
    }

    int k = a[5];
    for(i = 0; i < 4; i++){
        for(int j = 1; j < 5; j++){
            l = a[j] - a[i];
            if(l > k){
                cout<<":("<<endl;
                return 0;
            }
        }
    }
    cout<<"Yay!"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int a,b,c,k;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	if(k<=a)
		printf("%d\n",k);
	else if(a+b>=k)
		printf("%d\n",a);
	else
		printf("%d\n",2*a+b-k);
	return 0;
}


Measured memory_bytes: 1728
package main

import "fmt"


func main() {
	var n int
  	fmt.Scanf("%d", &n)
  	
  	sup := n%10
  
  if sup == 3 {
    fmt.Println("bon")
  }else if (sup ==2 || sup == 4 || sup == 5 || sup == 7 || sup == 9 ) {
    fmt.Println("hon")
  }else {
    fmt.Println("pon")
  }
}

Measured memory_bytes: 1820
#include<iostream>
#include<algorithm>
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int n;
ll k;
ll a[100010];
int one[50],kone[50];
ll fast_pow(ll x,ll n){
  ll res=1;
  while(n>0){
    if(n&1) res*=x;
    x*=x;
    n>>=1;
  }
  return res;
}
int main(){
  scan(n);scan(k);
  rep(i,n)scan(a[i]);
  memset(one,0,sizeof(one));
  memset(kone,0,sizeof(kone));
  rep(i,41){
    rep(j,n){
      if(a[j]&1){
	one[i]++;
      }
      a[j]=a[j]>>1;
    }
  }
  rep(i,41){
    if(k&1){
      kone[i]++;
    }
    k=k>>1;
  }
  ll res=0,suma=0;
  rep(i,41){
    if(kone[40-i]&1){
      ll sumb=fast_pow(2,40-i)*one[40-i];
      rep(j,40-i){
	sumb+=fast_pow(2,j)*max(one[j],n-one[j]);
      }
      res=max(res,suma+sumb);
      suma+=fast_pow(2,40-i)*(n-one[40-i]);
    }
    else suma+=fast_pow(2,40-i)*one[40-i];
  }
  res=max(res,suma);
  prin(res);
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
int main(){
	long int a, b, product;

  	while (std::cin >> a >> b) {
    	product = a * b;
		std::vector<long int> v = {a, b};
    	while (v.at(0) != v.at(1)) { 
      		std::sort(v.begin(), v.end(), std::greater<long int>());
      		v.at(0) = v.at(0) - v.at(1);
		}	
    	std::cout << v.at(0) << " " << product/v.at(0) << std::endl;	
  	}
	return 0;
}

Measured memory_bytes: 1208
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  	var c1 = input[0].split("");
  var c2 = input[1].split("");
  
  if(c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]){
     console.log("YES");
     }else{
     console.log("NO");
     }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
	ios::sync_with_stdio(false);
	
	long long n,s;
	long long ans=-1;
	cin>>n>>s;
	long long r=(long long)sqrt(n)+1LL;
	
	for(long long i=2;i<r;i++)
	{
		long long cp=n;
		long long temp=0;
		while(cp!=0)
		{
			temp+=cp%i;
			cp/=i;
		}
		if(temp==s)
		{
			ans=i;
			break;
		}
	}
	
	if(ans==-1)
	{
		long long mm=1e15-1;
		
		for(long long p=1;p<r;p++)
		{
			long long q=s-p;
			long long i=(n-q)/p;
			if(i<r)
				continue;
			long long cp=n;
			long long temp=0;
			
			while(cp!=0)
			{
				temp+=cp%i;
				cp/=i;
			}
			if(temp==s)
				mm=min(i,mm);
		}
		if(mm<1e15-1)
			ans=mm;
	}
	
	if(s==n&&ans==-1)
		ans=n+1;
	if(s==1&&ans==-1)
		ans=n;
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())

for i in range(n):
    b = int(input())
    for j in a:
        if b in j:
            j[j.index(b)]=0

if (a[0][1]==a[0][2]==a[0][0] or
    a[1][0]==a[1][1]==a[1][2] or
    a[2][0]==a[2][1]==a[2][2] or
    a[0][0]==a[1][0]==a[2][0] or
    a[0][1]==a[1][1]==a[2][1] or
    a[0][2]==a[1][2]==a[2][2] or
    a[0][0]==a[1][1]==a[2][2] or
    a[0][2]==a[1][1]==a[2][0]):
    print('Yes')
else:
    print('No')


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

int main()
{
    int n;
    map<long long int,long long int> add,sub;
    cin>>n;

    for(int i=1;i<=n;i++)
    {
        int temp;
        cin>>temp;
            add[temp+i]++;
            sub[i-temp]++;
    }
   long long int ans=0;
    for(auto i:add)
    {
        ans+=(sub[i.first]*i.second);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 37928
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  ll a; string b; cin >> a >> b;
  ll ans=a*(b[0]-'0')*100+a*(b[2]-'0')*10+a*(b[3]-'0');
  cout << ans/100 << endl;
  
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
  int a[3], x;

  scanf("%d%d%d", &a[0], &a[1], &a[2]);

  if (a[0] > a[1]) {
    x = a[0];
    a[0] = a[1];
    a[1] = x;
  }

  if (a[0] > a[2]) {
    x = a[0];
    a[0] = a[2];
    a[2] = x;
  }

  if (a[1] > a[2]) {
    x = a[1];
    a[1] = a[2];
    a[2] = x;
  }

  printf("%d %d %d\n", a[0], a[1], a[2]);

  return 0;
}


Measured memory_bytes: 2060
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
fn main() {
    solve();
}
#[allow(dead_code)]
fn solve() {
    input! {
        a: isize,
        b: isize,
    }
    let ans;
    if a * b <= 0{
        ans = "Zero";
    } else if a > 0 && b > 0{
        ans = "Positive";
    } else {
        if (b - a + 1) % 2 == 0 {
            ans = "Positive";
        } else {
            ans = "Negative";
        }
    }
    println!("{}", ans);
}

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

public class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);

      for(int i = 0; i < 5; i++){
          if(sc.nextInt() == 0){
              System.out.println(i+1);
              break;
          }
      }
    }
}

Measured memory_bytes: 35596
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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()
{
    int64_t N;
    cin >> N;
    map<int64_t,int64_t>d;
    for (int64_t i=0; i<N; i++) {
        int64_t n;
        cin >> n;
        if (d.count(n) > 0) {
            d[n] = d[n] + 1;
        } else {
            d[n] = 1;
        }
    }

    int64_t max_count = 0;
    for (auto s : d) {
        int64_t b_v = 0;
        if (d.count(s.first-1) > 0) {
            b_v = d[s.first-1];
        }

        int64_t a_v = 0;
        if (d.count(s.first+1) > 0) {
            a_v = d[s.first+1];
        }

        int64_t count = a_v + b_v + s.second;
        if (count > max_count) {
            max_count = count;
        }
    }

    cout << max_count << endl;
    return 0;
}

Measured memory_bytes: 7356
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<typename T> vector<T> make_vector(size_t sz, T t){
        return vector<T>(sz, t);
    }

    template<typename T,typename... Ts>
    auto make_vector(size_t sz, Ts... ts){
        return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } return os ;
    }
}
using namespace utils;

class solver{

public:
    void run(istream &is, ostream& os){
        ll W, H, x, y;
        is >> W >> H >> x >> y;
        if(!is) return;
        double m = W / 2. * H;
        cout << m << ' ';
        if(x*2 == W and y *2 == H){
            cout  << 1 << endl;
        }
        else{
            cout << 0 << endl;
        };


    }
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_C.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        solver().run(fs, cout);
    }
    cout << "------#" << endl;
    if(lp <= 1) {
        while(cin) solver().run(cin, cout);
    }
#else
    solver().run(cin, cout);
#endif
    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> MakeVector2D(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n, k;
  vector<int> scores(3);
  cin >> n >> k >> scores[0] >> scores[1] >> scores[2];

  string t;
  cin >> t;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    if (t[i] == 'r') {
      xs[i] = 2;
    } else if (t[i] == 's') {
      xs[i] = 0;
    } else {
      xs[i] = 1;
    }
  }

  vector<vector<int>> mod_xs(k);
  for (int i = 0; i < n; i++) {
    mod_xs[i % k].push_back(xs[i]);
  }

  int ans = 0;
  for (int mod = 0; mod < k; mod++) {
    const vector<int>& ys = mod_xs[mod];
    int m = ys.size();
    vector<vector<int>> dp = MakeVector2D(m + 1, 3, 0);
    for (int i = 0; i < m; i++) {
      for (int j1 = 0; j1 < 3; j1++) {
        for (int j2 = 0; j2 < 3; j2++) {
          if (j1 == j2) continue;
          int d = 0;
          if (j2 == ys[i]) d = scores[j2];
          UpdateMax(dp[i + 1][j2], dp[i][j1] + d);
        }
      }
    }
    ans += max(dp[m][0], max(dp[m][1], dp[m][2]));
  }

  cout << ans << endl;
}


Measured memory_bytes: 6600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

void solve() {
	int n, k; cin >> n >> k;
	vector<ll> v(n);
	for (ll &i : v)cin >> i;
	sort(v.begin(), v.end());
	int l = 0, r = n - k;
	while (l < r && r < n - 1) {
		if (1ll * v[l]*v[l + 1] >= v[r]*v[r + 1] * 1ll) {l += 2; r += 2;}
		else break;
	}
	if ((k & 1) && v.back() < 0) {
		l = 0;
		r = n - k;
	}
	ll ans = 1;
	for (int i = 0; i < l; i++)ans = 1ll * ans * ((v[i] % mod) + mod) % mod;
	for (int i = r; i < n; i++)ans = 1ll * ans * ((v[i] % mod) + mod) % mod;
	cout << ans;
}

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

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 4748
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if(s == u) a--;
	else b--;
	cout << a << " " << b << endl;
	return 0;
}

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


#define int long long

signed main(){
    int n;
    cin >> n;
    int ans = 0;

    for(int i = 1;i < n;i++){
        int r = n/i+1;
        int l = n/(i+1)+1;
        if(r == l){
            break;
        }

        while(r-l > 1){
            int mid = (r+l)/2;
            if(n % mid >= i) l = mid;
            else r = mid;
        }

        if(n % l == n / l) ans+=l;

    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sum = 0
pre = -2
for a in A:
    sum += B[a-1]
    if (pre+1) == a:
        sum += C[pre-1]
    pre = a

print(sum)

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

int main() {
    int s;
    cin >> s;
    int ans=0;
    while(s!=1 && s!=2 && s!=4){
        ans++;
        if(s%2==0){
            s=s/2;
        }
        else{
            s=3*s+1;
        }

        
    }
    cout << ans+4 << endl;
}

Measured memory_bytes: 256
def solve
  while true
    total = 0

    n, m = gets.split.map(&:to_i)
    break if n <= 0

    pn = gets.split.map(&:to_i).sort {|a, b| b <=> a }

    while pn.count > 0
      t = []
      m.times do
        t.push pn.shift
        break if pn.count <= 0
      end
      t.pop if t.count == m
      t.each { |price| total += price }
    end
    puts total
  end
end

solve

Measured memory_bytes: 9512
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n,a,b;
    string s;
    cin >> n >> a >> b;
    cin >> s;
    int tuuka=0;
    int kaigai=0;
    rep(i,s.length()){
        if(s[i]=='a'){
            if(tuuka<a+b){
                cout << "Yes" << endl;
                tuuka++;
            }else{
                cout << "No" << endl;
            }
        }
        else if(s[i]=='b'){
            if(tuuka<a+b && kaigai<b){
                cout << "Yes" << endl;
                tuuka++;
                kaigai++;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cctype>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <cmath>

using namespace std;

int main(){
  int n,maxh,minh,i,k;
  int ans = 0;
  cin >> n;
  maxh = (n + 1) / 1.08;
  minh = n / 1.08;
  for(i = minh; i <= maxh; i++){
    k = i*1.08;
    if(k == n){
      ans = 1;
      break;
    }
  }
  if(ans == 1){
    cout << i;
  }else{
    cout << ":(";
  }
}


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

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

template <class T> using max_heap = priority_queue<T>;
template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U> void chmax(T &a, U b) {
    if (a < b)
        a = b;
}
template <class T, class U> void chmin(T &a, U b) {
    if (b < a)
        a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

int dp[101][2][4];

void solve(string N, long long K) {
    dp[0][0][0] = 1;
    rep(i, N.size()) {
        const int D = N[i] - '0';
        rep(j, 2) {
            rep(k, K) {
                rep(d, (j ? 10 : D + 1)) {
                    // int _k = k;
                    if (d != 0)
                        dp[i + 1][j || (d < D)][k + 1] += dp[i][j][k];
                    else
                        dp[i + 1][j || (d < D)][k] += dp[i][j][k];

                    // cout << "(" << i << "," << j << "," << k << ")";
                    // cout << " -> ";
                    // cout << "(" << i + 1 << "," << (j || (d < D)) << ","
                    //      << k + 1 << ")";

                    // cout << i + 1 << " " << (j || (d < D)) << " " << k + 1
                    //      << " " << d << " " << dp[i + 1][j || (d < D)][k + 1]
                    //      << endl;
                    // cout << i << " " << j << " " << k << " " << d << " "
                    //      << dp[i + 1][j || (d < D)][_k] << endl;

                    // debug(dp[i + 1][j || (d < D)][_k])
                }
            }
        }
    }
    int sum = 0;
    rep(i, N.size() + 1) rep(j, 2) { sum += dp[i][j][K]; }
    cout << sum << endl;
    // cout << dp[N.size()][0][K] + dp[N.size()][1][K] << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string N;
    cin >> N;
    long long K;
    cin >> K;
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

const int INF = 1e9 + 5;

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

    int N;
    cin >> N;
    vector<int> A(N + 2, 0);

    for (int i = 1; i <= N; i++)
        cin >> A[i];

    map<int, int> dp = {{0, 0}};

    for (int i = 0; i <= N; i++) {
        map<int, int> next_dp;

        for (auto &p : dp) {
            int x1 = p.first, dp_x1 = p.second;
            int y1 = A[i] - x1;

            auto &&attempt = [&](int x2) {
                if (0 <= x2 && x2 <= A[i + 1]) {
                    int y2 = A[i + 1] - x2;
                    int value = dp_x1 + (x1 > x2 ? 1 : 0) + (y1 < y2 ? 1 : 0);
                    int previous = next_dp.find(x2) == next_dp.end() ? INF : next_dp[x2];
                    next_dp[x2] = min(previous, value);
                }
            };

            // Interesting x2 values: 0, x1 (leads to x1 == x2), A[i + 1] - y1 (leads to y1 == y2)
            attempt(0);
            attempt(x1);
            attempt(A[i + 1] - y1);

            // for (int x2 = 0; x2 <= A[i + 1]; x2++) {
            //     int y2 = A[i + 1] - x2;
            //     next_dp[x2] = min(next_dp[x2], dp[x1] + (x1 > x2 ? 1 : 0) + (y1 < y2 ? 1 : 0));
            // }
        }

        int minimum = INF;
        auto it = next_dp.begin();

        while (it != next_dp.end())
            if (it->second >= minimum) {
                it = next_dp.erase(it);
            } else {
                minimum = min(minimum, it->second);
                it++;
            }

        dp = next_dp;
    }

    cout << dp[0] << '\n';
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
  val (N, K) = readLine()!!.split(" ").map(String::toInt)
  val P = readLine()!!
  			.split(" ")
  			.map(String::toInt)
  			.map(fun(a) = (1 + a) / 2.0)
  
  var s = 0.0
  var res = 0.0
  for (i in 0..N - 1) {
    s += P[i]
    if (i >= K) {
    	s -= P[i - K]
    }
    if (res < s) {
    	res = s
    }
  }
  println(res)
}

Measured memory_bytes: 64032
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int A, B; std::cin >> A >> B;
  std::cout << (A-1)*(B-1) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int	collatz(int a, int n)
{
	int	tmp;

	if (n == 1)
		return (a);
	tmp = collatz(a, n - 1);
	if (tmp % 2)
		return (3 * tmp + 1);
	else
		return (tmp / 2);
}

int	main(void)
{
	int	s, i, j, m, flag = 0;
	int	data[1000001];

	scanf("%d", &s);
	i = 0;
	while (1)
	{
		data[i] = collatz(s, i + 1);
		for (j = 0; j < i; j++)
		{
			if (data[i] == data[j])
			{
				m = i + 1;
				flag = 1;
				break ;
			}
		}
		if (flag)
			break ;
		i++;
	}
	printf("%d\n", m);
	return (0);
}

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

void solve(){
	
	int n,m ;
	cin>>n>>m ;

	int l=1 ;
	int r=n ;	

	rep(i,m){
		int x,y ;
		cin>>x>>y ;
		l=max(l,x) ;
		r=min(r,y) ;
 	}	

 	int count=0 ;
 	for(int i=l;i<=r;i++)
 	{
 		count++ ;
 	}

 	cout<<count ;
}



int main(){

	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int b, r, g, c, s, t;
	while (scanf("%d%d%d%d%d%d", &b, &r, &g, &c, &s, &t), b|r|g|c|s|t)
		printf("%d\n", 100 - 3*(t-s-5*b-3*r)
			+ 13*(5*b+3*r) + 15*(b+r) + 7*g + 2*c);

	return 0;
}

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

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

int main(void){
  SPEEDUP
  cout << setprecision(15);
  bool sat = true;
  string s;cin >> s;
  set<char>st;
  rep(i,s.length()){
    if(st.count(s[i])) sat = false;
    st.insert(s[i]);
  }
  yesno(sat);
  return 0;
}


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

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

ll n;
ll a[mnx];
ll b[mnx];

int main(){

cin>>n;

for(int i=1; i<=n; i++){
    cin>>a[i]>>b[i];
}

ll add = 0;

for(int i=n; i>0; i--){
    a[i] += add;
    if(a[i] % b[i] != 0) add += b[i] - a[i] % b[i];
}

cout<<add<<'\n';

return 0;

}














Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int a,b;
	cin >> a >> b;
	if((b-a)%2){
		cout << "IMPOSSIBLE";
	}else{
		cout << (b+a)/2 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];

  vector<int> a(n);
  rep(i, n) a[i] = x[i];
  sort(a.begin(), a.end());

  rep(i, n) {
    cout << (x[i] <= a[n / 2 - 1] ? a[n / 2] : a[n / 2 - 1]) << endl;
  }


  
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>
using namespace std;

int main(void){
    int a;
    string str;
    cin >> a >> str;

    if(a >= 3200){
    cout << str << endl;
    } else {
    cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=1000000000000000003;
const int32_t LOG=21;
const int MOD=MOD2; 
int dp[40];
int comb[40];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
          int n,k;
          cin>>n>>k;
          int div=n/k;
          n-=div*k;
          int min1=n;
          n=(abs(n-k));
          min1=min(min1,n);
          cout<<min1<<endl;   
      }
      return 0;                         
}

/*
 TIPS(FOR ME):
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  #define int long long
  int N,K,ans=1e9;
  cin>>N>>K;
  vector<int> A(N);
  int MA=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    MA=max(MA,A.at(i));
  }
  int left=1,right=MA;
  while(left<=right){
    int mid=left+(right-left)/2;
    int count=0;
    for(int i=0;i<N;i++){
      if(mid>=A.at(i)){
        continue;
      }
      int answer_for_i=1e9;
      int L=1,R=A.at(i);
      while(L<=R){
        int M=L+(R-L)/2;
        if(A.at(i)<=mid*M){
          answer_for_i=min(answer_for_i, M-1);
          R=M-1;
        }
        else{
          L=M+1;
        }
      }
      count+=answer_for_i;
    }
    if(count<=K){
      right=mid-1;
      ans=min(ans,mid);
    }
    else{
      left=mid+1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4816
#include <stdio.h>
int main(void){
   int n;
   scanf("%d", &n);
   int a[n + 1];

   for(int i = 0; i < n + 1; i++){
       a[i] = 0;
   } 

   for(int i = 1; i < n; i++){
       int x;
       scanf("%d", &x);
       a[x] += 1;
   }

   for(int i = 1; i < n + 1; i++){
       printf("%d\n", a[i]);
       
   }

   return 0;
}

Measured memory_bytes: 2508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100005;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a == 1){
        if(b == 2){
            cout << 3 << endl;
        }
        else cout << 2 << endl;
    }
    else{
        if(a == 2){
            if(b == 1){
                cout << 3 << endl;
            }
            else cout << 1 << endl;
        }
        else{
            if(b == 2){
                cout << 1 << endl;
            }
            else cout << 2 << endl;
        }
    }
    return 0;
}


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

        using namespace std;
        #define sd(x) scanf("%d",&x);
        #define sdl(x) scanf("%lld",&x);
        #define pr(x) printf("%d\n",x);
        #define prl(x) printf("%lld\n",x);
    
    long long int mod=1000000007;

    long long int gcd(long long int a,long long int b)
    {
        if (b<a)return gcd(b,a);
        else if (b%a==0)return a;
        else return gcd(b%a,a);

    }

    long long fast_exp(long long a,long long n,long long mod1)
    {

    if (n==0)return 1;
    else if (n==1)return a;
    if (n%2==0)return fast_exp((a*a)%mod1,n/2,mod1);
    else return (a*fast_exp((a*a)%mod1,n/2,mod1))%mod1;
    }
    bool is_square(long long  a)
    {
    long long int b=sqrt(a);
    if (b*b==a)return true;
    else return false;
    }
    long long n_fact[1000001];
    void calc_fact(int n) // calculates the factorial % mod and stores in n_fact upto n 
    {
        n_fact[0]=1;
        for (int c(1);c<=n;c++)
            n_fact[c]=(c*n_fact[c-1])%mod;
        return ;
    }
    long long calc_inverse_mod(long long x,long long mod)
    {
        return fast_exp(x,mod-2,mod);

    }
    bool n_primes[100001]={false};
    void calc_primes(int n)
    {
        for (int c(2);c<=100000;c++)
        {
            if (n_primes[c]==true)continue;
            for (int c1(c+c);c1<=100000;c1=c1+c)
                n_primes[c1]=true;
        }
        return ;
    }
bool is_palindrome(string a)
{
    string b=a;
    reverse(b.begin(),b.end());
    if (b==a)
        return true;
    else return false;
}
    int main ()
    {
    
        ios_base::sync_with_stdio(false);
        int t;
        //cin >> t;
        t=1;
        for (int tt=0;tt<t;tt++)
        {
            string s;
            cin >> s;
            string s1="",s2="";
            int n=s.size();
            for (int c=0;c<(n-1)/2;c++)
                s1+=s[c];
            for (int c=(n+3)/2-1;c<s.size();c++)
                s2+=s[c];
            if (is_palindrome(s)&&is_palindrome(s1)&&is_palindrome(s2))
                cout << "Yes" << endl;
            else 
                cout << "No" << endl;

            
        }
        


        
            
        
    return 0;




        
    }


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

long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}

long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}

long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}

bool isprime(int n) {
    if(n < 2) return false;
    for(int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

void dfs(const vector<vector<int>> &G, int v, vector<int> &seen) {
    seen[v] = true;

    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}

void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}



int main() {
  
  int n, m, tmp; cin >> n >> m;
  vector<int> a(m); 
  for(int i = 0; i < m; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  
  int sum = accumulate(a.begin(), a.end(), 0);
  
  if(n-sum >= 0) cout << n-sum;
  else cout << "-1";

}

Measured memory_bytes: 3708
n = int(input())
lis = list(map(int,input().split()))
ans = []
for i in range(n):
  count = 0
  while 1:
    if lis[i] %2 == 0:
      lis[i] = lis[i]/2
      count +=1
    else:
      ans.append(count)
      break
print(min(ans))

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

int mdis(const pair<int, int> a, const pair<int, int> b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
}

int main() {
    int N, M, a, b, c, d;
    cin >> N >> M;
    auto students = vector<pair<int, int>>(N);
    auto checkpoints = vector<pair<int, int>>(M);
    for (int i=0; i<N; i++) {
        cin >> a >> b;
        students[i] = {a, b};
    }
    for (int j=0; j<M; j++) {
        cin >> c >> d;
        checkpoints[j] = {c, d};
    }
    
    auto res = vector<int>(N);
    for (auto i=0; i<N; i++) {
        int distance = INT_MAX, index = -1;
        for (auto j=0; j<M; j++) {
            auto cur_dis = mdis(students[i], checkpoints[j]);
            if (cur_dis < distance) {
                distance = cur_dis;
                index = j;
            }
        }
        res[i] = index + 1;
    }
    for (auto i=0; i<N; i++) 
        cout << res[i] << endl;

    return 0;
}


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

int main() {
  int h,w;cin>>h>>w;
  rep(i,w+2) cout << "#"; cout<<endl;
  rep(i,h) {
    string s;cin>>s;
    cout << "#" << s << "#" << endl;    
  }
  rep(i,w+2) cout << "#"; cout<<endl;
}


Measured memory_bytes: 256
A = []
for i in range(4):
    A.append(int(input()))
if A[0] >= A[1]:
    temp = A[1]
else:
    temp = A[0]
if A[2] >= A[3]:
    temp2 = A[3]
else:
    temp2 = A[2]
print(temp + temp2)

Measured memory_bytes: 3060
N = input()
_1 = N[:-1]
_2 = N[1:]

ans = 'No'
if _1[0] == _1[1]:
  if _1[1] == _1[2]:
    ans = 'Yes'

if _2[0] == _2[1]:
  if _2[1] == _2[2]:
    ans = 'Yes'

print(ans)

Measured memory_bytes: 3060
N=int(input())
T,A=map(int,input().split())
H=[int(i) for i in input().split()]
tlist=[]
for i in range(N):
    tlist.append(float(T-H[i]*0.006))
ans=1
for i in range(1,N):
    if abs(tlist[i]-A)<abs(tlist[ans-1]-A):
        ans=i+1
    if tlist[i]-A==0:
        break

print(ans)

Measured memory_bytes: 3444
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        a: usize, b: usize,
    }

    let mut count = 0;
    for i in a..=b {
        if i / 10000 == i % 10 && i / 1000 % 10 == i % 100 / 10 {
            count += 1;
        }
    }
    println!("{}", count);
}


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll n,m;
    cin >> n >> m;
    vll a(n);
    ll sum = 0;
    for(ll i=0;i<n;i++) {
    	cin >> a[i];
    	sum += a[i];
    }
    sort(all(a));
    ll sl = a[n-m];
    if(sl*4*m < sum) {
    	cout << "No\n";
    } else {
    	cout << "Yes\n";
    }
}	

int main()
{
    FAST_IO;
    // #ifndef ONLINE_JUDGE 
      // OC;
    // #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int c=sc.nextInt();
  int d=sc.nextInt();
  double x=c*30;
  double y=d*6;
  x+=d*0.5;
  x=(x-y)*Math.PI/180;
  System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(x)));
}
}


Measured memory_bytes: 35764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int a,b,c;
	int ans=0;
	
	cin>>a>>b>>c;
	if(c>=a && c<=b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const d = parseInt(input)

    if(d === 25){
        console.log('Christmas')
        return 
    }
    if(d === 24){
        console.log('Christmas Eve')
        return 
    }
    if(d === 23){
        console.log('Christmas Eve Eve')
        return 
    }
    if(d === 22){
        console.log('Christmas Eve Eve Eve')
        return 
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int max=-1000000000,res,min;
        int n=sc.nextInt();
        int num[]=new int[n];
        for(int i=0;i<n;i++){
            num[i]=sc.nextInt();
        }
        min=num[0];
        for(int i=1;i<n;i++){
            res=num[i]-min;
            if(res>max){
                max=res;
            }
            if(min>num[i]){
                min=num[i];
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 71504
#include <stdio.h>

int main(void) {
    int a;
	scanf("%d", &a);
	int temp=1;
	int b, c,d;
	int max_1=1, max_2=1;
	int mmm=1, end=1;
	for(b=1; b<=100; b++) {
		max_1=1;
		temp=1;
		for (c=2; c<=100; c++) {
			max_1=1;
	    	temp =1;
			d=c;
	    	while (d) {
	    		temp *=b;
		    	d--;
		
	    	}
			if(temp==a) {max_1=temp; break;}
			else if (temp>a) {max_1= temp/b; break; }
		}
		if (max_1==a && max_1!=b) {max_2=max_1; break;}
		else if (max_2<max_1 && max_1!=b) max_2 =max_1;
		
	}   
	printf("%d", max_2);
}

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

int main()
{
	int N,temp;
	int m = 0;
	int sum = 0;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> temp;
		sum += temp;
		m = max(m,temp);
	}

	if (m < sum-m) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a[55],b[55],c[55],d[55],x[11];
int n,m,q;
int score(){
    int ans=0;
    for(int i=0;i<q;i++){
        if(x[b[i]]-x[a[i]]==c[i]){
            ans+=d[i];
        }
    }
    return ans;
}
void dfs(int& max_score,const int num){
    if(num==n){
        max_score=max(max_score,score());
        return;
    }
    for(int i=x[num];i<=m;i++){
        x[num+1]=i;
        dfs(max_score,num+1);
    }
}

int main(){
    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    x[1]=1;
    int ans=0;
    dfs(ans,1);
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

int main() {
    int n,m;
    cin>>n>>m;
    const int nmmax=50;
    char A[nmmax][nmmax],B[nmmax][nmmax];

    rep(y,n){
        rep(x,n){
            cin>>A[y][x];
        }
    }

    rep(y,m){
        rep(x,m){
            cin>>B[y][x];
        }
    }

    bool exist=false;

    rep(ly,n){
        rep(lx,n){
            if(ly+m-1>=n || lx+m-1>=n) continue;

            bool match=true;
            rep(y,m){
                rep(x,m){
                    if(A[ly+y][lx+x]!=B[y][x]) match=false;
                }
            }
            if(match) exist=true;
        }
    }

    if(exist) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;
public class Program{
    public static void Main(string[] args){
        var nxt = ReadLine().Split(' ');
        var n = double.Parse(nxt[0]);
        var x = int.Parse(nxt[1]);
        var t = int.Parse(nxt[2]);
        System.Console.WriteLine((int)(Math.Ceiling(n / x) * t));
    }
}

Measured memory_bytes: 27516