akhauriyash/Code-Regression huggingface dataset:
class Time

  # 1分の秒表記
  MINUTE_SECOND = 60

  #1時間の秒表記
  HOUR_SECOND = 3600

  def initialize(second)
    self.convertTimeFromSecond(second)
  end

  # 秒数を時・分・秒に変換してフィールドに格納します。
  def convertTimeFromSecond(second)

    # 渡された秒から時の計算をして余りを取得
    @hour = second / HOUR_SECOND
    surplus = second % HOUR_SECOND

    # 時計算の余りから分の計算をして余りを取得
    @minute = surplus / MINUTE_SECOND
    surplus = surplus % MINUTE_SECOND

    # 分計算の余りを秒に設定
    @second = surplus
  end

  def getHour()
    return @hour
  end

  def getMinute()
    return @minute
  end

  def getSecond()
    return @second
  end

end

timeInstance = Time.new(gets.chomp.to_i)
puts timeInstance.getHour.to_s + ":" + timeInstance.getMinute.to_s + ":" + timeInstance.getSecond.to_s

Measured memory_bytes: 6096
#include <iostream>

using namespace std;

int main(){

    int n;
    cin >> n;

    int nums[n];
    for (int i = 0; i < n; i++) cin >> nums[i];


    int mx = nums[0];
    int res = 1;

    for (int i = 1; i < n; i++){
        if (nums[i] >= mx){
            mx = nums[i];
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  ll num;
  cin >> num;
  rep(i,n-1){
    ll t;
    cin >> t;
    ll GCD = gcd(num, t);
    ll a = num / GCD;
    ll b = t / GCD;
    num = GCD * a * b;
  }
  print(num);
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int> ans(n+10,-1);
	bool flag=true;
	rep(i,m){
		int s,c;
		cin>>s>>c;
		if(n>=2 && s==1 && c==0) flag=false;
		if(ans[s]==-1){
			ans[s]=c;
		}else{
			if(ans[s]!=c) flag=false;
		}
	}
	if(flag){
		FOR(i,1,n+1){
			if(ans[i]==-1){
				if(i==1){
					if(n==1) cout<<0;
					else cout<<1;
				}else{
					cout<<0;
				}
			}
			else cout<<ans[i];
		}
		cout<<endl;	
	}else{
		cout<<-1<<endl;
	}
}

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

signed main(void)
{
	int n;
	cin >> n;
	vector<ll> a(n);
	ll ans;
	rep(i, n) 
	{
		cin >> a[i];
		if (a[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	ans = 1;
	rep(i, n)
	{
		if (a[i] > 1000000000000000000 / ans)
		{
			cout << -1 << endl;
			return 0;
		}
		ans *= a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4068
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,sum,ans=1e18;
ll a[200010],b[200010],c[200010];
 int main()
{
    scanf("%lld%lld",&n,&m);
    for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for (int i=2;i<=n;i++) 
	{
        int l=a[i-1],r=a[i];
        if (l==r) continue;
        if (l<r) b[l+1]++,b[r+1]--,c[r+1]-=r-l;
        else b[l+1]++,b[r+m+1]--,c[r+m+1]-=r+m-l;
    }
    for (int i=1;i<=2*m;i++) b[i]+=b[i-1];
    for (int i=1;i<=2*m;i++) c[i]+=c[i-1]+b[i];
    for (int i=1;i<=m;i++) b[i]+=b[i+m],c[i]+=c[i+m],sum+=b[i];
    for (int i=1;i<=m;i++) ans=min(ans,sum-c[i]+b[i]);
    printf("%lld\n",ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, M, ans = 1;
    cin >> N >> M;
    if (abs(N - M) > 1) {
        cout << 0 << endl;
        return 0;
    }
    int n = N, m = M;
    while (n > 0) {
        ans = ans * n % 1000000007;
        n--;
    }
    while (m > 0) {
        ans = ans * m % 1000000007;
        m--;
    }
    if (N == M) {
        ans = ans * 2 % 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, ans;
	cin >> n;
	vector<int> a(n + 1), s(n + 1, 0);
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		s[i] = s[i - 1] + a[i];
	}
	ans = s[n];
	for (i = 1; i < n; i++) {
		ans = min(ans, abs(s[i] - (s[n] - s[i])));
	}

	cout << ans << "\n";

	return 0;
}


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

int main(void){
	int arr[5]={0,};
	for(int i=0;i<3;i++){
		int x,y; scanf("%d %d",&x,&y);
		arr[x]++; arr[y]++;
	}
	int ans = 0;
	for(int i=1;i<=4;i++){
		if(arr[i]%2==1) ans++;
	}
	if(ans==2 || ans==0) printf("YES");
	else printf("NO");
	return 0;
}

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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Read();
            var chk = int.Parse(N.Substring(N.Length - 1, 1));
            if (chk == 3) Console.WriteLine("bon");
            else if (chk == 0 || chk == 1 || chk == 6 || chk == 8) Console.WriteLine("pon");
            else Console.WriteLine("hon");

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static string[] ReadArrayString() { return Read().Split(' '); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}


Measured memory_bytes: 27552
import java.util.*

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }

    val ans = ArrayDeque<Int>()
    var reversed = false

    repeat(n) {
        if (reversed) {
            ans.addFirst(aa[it])
        } else {
            ans.addLast(aa[it])
        }
        reversed = !reversed
    }

    if (reversed) {
        println(ans.reversed().joinToString(separator = " "))
    } else {
        println(ans.joinToString(separator = " "))
    }
}



Measured memory_bytes: 101780
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

// modを取らないnCkの計算
// 全体としてはオーバーフローしないはずでも、先に分子だけ計算したときに
// オーバーフローする可能性があることに注意                                                                                            
long long NCK[54][54];
void init(int n=54)	{
  for (int i=0; i<n; i++) {
    for (int j=0; j<=i; j++) {
      if (j==0 || j==i) {
        NCK[i][j] = 1;
      } else {
        // パスカルの三角形の性質 nCk = (n-1)C(k-1) + (n-1)Ck を利用
        NCK[i][j] = NCK[i-1][j-1] + NCK[i-1][j];
      }
    }
  }
  return;
}

struct edge {
  int cost;
  int x1;
  int y1;
  int x2;
  int y2;
};

bool MySort (const edge &p1, const edge &p2){
  return p1.cost > p2.cost;
}

int main() {
  int W, H;
  std::cin >> W >> H;
  std::vector<int > p(W), q(H);
  std::vector<std::pair<int, int> > cost;
  for (int i=0; i<W; i++) {
    std::cin>> p[i];
    cost.push_back(std::make_pair(p[i], 0));
  }
  for (int i=0; i<H; i++) {
    std::cin>> q[i];
    cost.push_back(std::make_pair(q[i], 1));
  }
  int a = W+1;
  int b = H+1;
  long long ans = 0;
  std::sort(cost.begin(), cost.end());
  for (int i=0; i<cost.size(); i++) {
    int c = cost[i].first;
    int type = cost[i].second;
    if (type==0) {
      ans += (long long)b * c;
      a--;
    } else {
      ans += (long long)a * c;
      b--;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 5744
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K;
  cin>>N>>K;
  N %= K;
  cout<<min(N, abs(N-K))<<endl;
}



Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>

void getCurve(double l[2], double r[2], int i){
	if( i <= 0 ){ return; }
	double s[2], t[2], u[2];
	s[0] = l[0] + (r[0]-l[0])/3;
	s[1] = l[1] + (r[1]-l[1])/3;
	t[0] = l[0] + (r[0]-l[0])*2/3;
	t[1] = l[1] + (r[1]-l[1])*2/3;
	double dx = t[0]-s[0], dy = t[1]-s[1];
	u[0] = s[0] + dx * cos(M_PI/3) - dy * sin(M_PI/3);
	u[1] = s[1] + dx * sin(M_PI/3) + dy * cos(M_PI/3); 
	getCurve(l, s, i-1);
	printf("%.8lf %.8lf\n", s[0], s[1]);
	getCurve(s, u, i-1);
	printf("%.8lf %.8lf\n", u[0], u[1]);
	getCurve(u, t, i-1);
	printf("%.8lf %.8lf\n", t[0], t[1]);
	getCurve(t, r, i-1);
	return;
}

int main(){
	double l[2] = {0.0, 0.0}, r[2] = {100.0, 0.0};
	int n;
	scanf("%d", &n);
	printf("%.8lf %.8lf\n", l[0], l[1]);
	getCurve(l, r, n);
	printf("%.8lf %.8lf\n", r[0], r[1]);
	return 0;
}

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

int main() {
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  if(K==0){
    cout<<0<<endl;
  }
  else{
    if(A>=K){
      cout<<K<<endl;
    }
    else{
      if((A+B)>=K){
        cout<<A<<endl;
      }
      else{
        cout<<A-(K-A-B)<<endl;
      }
    }
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> a(n+1), b(n), c(n);
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> b[i];
    REP(i,n-1) cin >> c[i];
    REP(i,n){
        ans += b[a[i]-1];
        if(a[i+1] == a[i]+1){
            ans += c[a[i]-1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,n,v,line[900][4],max,set;
char row[500];

void check(int x,int y,int v){
	if(v==0)line[x][y]=0;
	else line[x][y]++;
	if(line[x][y]>max)max=line[x][y];
}

int main(){
	while(scanf("%d",&n)*n){
		max=0;
		for(i=0;i<2*n;i++){
			for(j=0;j<4;j++){
				line[i][j]=0;
			}
		}
		for(i=0;i<n;i++){
			scanf("%s",row);
			for(j=0;j<n;j++){
				v=row[j]-'0';
				check(i,0,v);
				check(j,1,v);
				check(i-j+n,2,v);
				check(i+j,3,v);
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 612
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        os.println(C + " " + A + " " + B);
    }
}

Measured memory_bytes: 23124
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	if n % 111 == 0 {
		fmt.Println(n)
	} else {
		d := (n / 111) + 1
		fmt.Println(100 * d + 10 * d + d)
	}
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

bool IsPrime(int);

/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  cout << n*n;
  cout << "\n";
  return 0;
}
/***** MAIN *****/

bool IsPrime(int a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(int i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}

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

int main(){
	string w,t;
	int counter=0;
	cin>>w;
	for(int i=0;i<w.length();i++){
		if(islower(w[i])) w[i]=toupper(w[i]);
	}
	while(cin>>t){
		if(t=="END_OF_TEXT"){
			cout<<counter<<endl;
			break;
		}
		for(int i=0;i<t.length();i++){
			if(islower(t[i])) t[i]=toupper(t[i]);
		}
		if(t==w) counter++;
	}

	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	int V=1;
	while(N/2){
		V<<=1;
		N>>=1;
	}
	out(V);
	return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  vector<int64_t> count(N);
  for(int i = 0; i < N; i++){
    cin >> count.at(i);
    count.at(i) = count.at(i) * 1000000 + i;
  }
  sort(count.begin(),count.end());
  for(int i = 0; i < N; i++){
    cout << count.at(i) % 1000000 + 1;
    if(i < N - 1){
      cout << " ";
    }
  }
}

Measured memory_bytes: 1536
#!/usr/bin/env python3
l = [input() for _ in range(5)]
m = 11
ans = 0
for i in range(len(l)):
    n = int(l[i][-1])
    if n == 0: n = 10
    if n < m:
        m = n
        ind = i
for t in range(len(l)):
    if t == ind:
        ans += int(l[t])
    else:
        n = int(l[t][-1])
        if n == 0: n = 10
        ans += (int(l[t]) + 10 - n)
print(ans)


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

int main(){
	lint n,k;
	cin>>n>>k;
	vector<lint> h(n),dp(n);
	rep(i,n) cin>>h.at(i);
	rep(i,n) dp.at(i)=INF;
	rep(i,n){
		if(i==0) dp.at(i)=0;
		rep(j,k+1){
			if(j==0) continue;
			if(n<=i+j) continue;
			lint ret=dp.at(i)+abs(h.at(i)-h.at(i+j));
			if(ret<dp.at(i+j)) dp.at(i+j)=ret;
		}
	}
	cout<<dp.at(n-1)<<endl;
}



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

int bubble(int *r, int n){
    int flag=1;
    int tmp;
    while(flag){
        flag=0;
        for(int i=n-1;i>0;i--){
            if(r[i]<r[i-1]){
                tmp=r[i];
                r[i]=r[i-1];
                r[i-1]=tmp;
                flag=1;
               
            }
        }
    }

    //for(int k=0;k<n;k++){
      //  if(k!=n-1) cout<<r[k]<<' ';
        //else cout<<r[k]<<endl;
    //}
    return 0;

}

int main(){
    int n,m,a[100000],sum=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }

    bubble(a, n);
    double k=sum/(4.0*m);
    if(a[n-m]>=k)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

//double rat;
L A[Mx+5],B[Mx+5];

char str[Mx];

vector<L>V,V1;
set<L>S;
map<L,L>Mp;
priority_queue<L>Pq;

int main()
{
    scanf("%lld%lld",&n,&m);
    for(L i=0;i<=n;i++){
        if((i*4+(n-i)*2)==m){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


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

int main(){

int i,j;
int n,d;
cin>>n>>d;
ll a[n+1];
ll b[n+1];
ll de[n+1];
de[0]=d;
for(i=1;i<=n;i++)
    cin>>a[i];
    ll x=d;
for(i=1;i<=n;i++)
{

    if((2*x)<=(a[i]))
       {
           de[i]=x;
        continue;}
    else
    {
        ll o=x-a[i];
        if(o<0)
            o=o*(-1);
        de[i]=o;

        x=de[i];

    }
    }

    b[n]=1;
    for(i=n-1;i>=1;i--){
        if((b[i+1])<=(a[i+1]/2))
            b[i]=b[i+1];
        else
            b[i]=b[i+1]+a[i+1];

}

int q;
cin>>q;
for(i=1;i<=q;i++){


    int o;
    cin>>o;
    if(de[o-1]==0)
        cout<<"NO"<<endl;
    else
    {if(b[o]<=de[o-1])
    cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;



    }

}






return 0;}


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

public class Main {
    public static void main(String[] args) throws IOException {
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        FastReader in = new FastReader();
        test a=new test();
        a.solve(in,out);
        out.close();
    }
}
class test{
    public void solve(FastReader in, PrintWriter out){
       long x=in.nextLong();
       long b =100;
       long c=0;
       while(true){
           long i=b/100;
           b+=i;
           c++;
           if(b>=x){
               out.println(c);
               break;
           }
       }
    }
    public boolean src(int a[],int b[],int k,int l){
        for(int i=0;i<a.length;i++){
            if(a[i]==k && b[i]==l){
                return true;
            }
        }
        return false;
    }
    public int search(ArrayList<Integer> my){
        int max=my.get(0);
        int k=0;
        for(int i=1;i<my.size();i++){
            if(my.get(i)>max){
                max=my.get(i);
                k=i;
            }
        }
        return k;
    }
}

class FastReader{
    BufferedReader br;
    StringTokenizer st;

    public FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next(){
        while(st==null || !st.hasMoreElements()){
            try{
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e){
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt(){
        return Integer.parseInt(next());
    }

    Long nextLong(){
        return Long.parseLong(next());
    }

    double nextDouble(){
        return Double.parseDouble(next());
    }
    String nextLine(){
        String str="";
        try{
            str=br.readLine();
        }
        catch(IOException e){
            e.printStackTrace();
        }
        return str;
    }
}



Measured memory_bytes: 32520
import fractions

A, B, C, D = (int(abcd) for abcd in input().split())
lcm_CD = C*D // fractions.gcd(C, D)
in_B = B - ((B//C + B//D) - B//lcm_CD)
in_under_A = (A-1) - (((A-1)//C + (A-1)//D) - (A-1)//lcm_CD)
print(in_B - in_under_A)

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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(c,element) (c.find(element)!=c.end())
#define cpresent(c,element) (find(c,element)!=c.end())
#define foo(i,a,b) for(int i=a;i<int(b);i++)
#define tr(i,a) for(auto i:a)
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
const double PI=acos(-1);
const ll mod=1e9+7;



int32_t main()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

int test=1;
//cin>>test;
while(test--)
{
		
	int n,k;
	cin>>n>>k;
	set<int> a;
	int dp[k+1]={0};
	foo(i,0,n)
	{
		int x; cin>>x;
		a.insert(x);
		dp[x]=1;
	}
	
	int nim=*min_element(all(a));
	foo(i,0,k+1)
	{
		if(i>nim&&(!present(a,i)))
		{
				for(auto it:a)
				{
					if(i>=it&&dp[i-it]==0)
					{
						dp[i]=1;
						break;
					}
				}
			
		}
	}
	if(dp[k])cout<<"First\n";
	else cout<<"Second\n";	

	
}
return 0;
}










Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
SS ss;
#define debug ss
#endif

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int w,h;
string c[30];
vpint vp;
int dis[20][20];

int d(int i,int j){
	int d[30][30];
	rep(a,30)rep(b,30)d[a][b]=INF;
	priority_queue<pair<int,pint>,vector<pair<int,pint> >,greater<pair<int,pint> > > que;
	que.push(MP(0,MP(vp[i].first,vp[i].second)));
	while(!que.empty()){
		pair<int,pint> now=que.top();
		que.pop();
		int x=now.second.second;
		int y=now.second.first;
//cout<<x<<" "<<y<<" "<<now.first<<endl;
		if(x<0)continue;
		if(x>=w)continue;
		if(y<0)continue;
		if(y>=h)continue;
		if(d[y][x]<=now.first)continue;
		if(c[y][x]=='x')continue;
		d[y][x]=now.first;
		rep(k,4){
//cout<<now.first+1<<" "<<y+dy[k]<<" "<<x+dx[k]<<endl;
			que.push(MP(now.first+1,MP(y+dy[k],x+dx[k])));
		}
	}
//PUTLINE
	return d[vp[j].first][vp[j].second];
}

int main() {
	IL{
		cin>>w>>h;
		if(w==0&&h==0)break;
		rep(i,h)cin>>c[i];
		vp.clear();
		rep(i,h)rep(j,w)if(c[i][j]=='o')vp.PB(MP(i,j));
		rep(i,h)rep(j,w)if(c[i][j]=='*')vp.PB(MP(i,j));
		int n=sz(vp)-1;
		rep(i,n+1)rep(j,n+1){
			dis[i][j]=d(i,j);
//debug<<i<<" "<<j<<" "<<dis[i][j]<<endl;
		}
		vint per;
		rep(i,n)per.PB(i+1);
		int res=INF;
		do{
//PUTLINE
//debug<<n<<endl;
			int m=dis[0][per[0]];
			if(m==INF)continue;
			int i;
			rep0(i,n-1){
				if(dis[per[i]][per[i+1]]==INF)break;
				m+=dis[per[i]][per[i+1]];
			}
			if(i<n-1)continue;
			chmin(res,m);
		}while(next_permutation(all(per)));
		if(res<INF)cout<<res<<endl;
		else cout<<-1<<endl;
	}
	return 0;
}

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

int main(){
    int A,B;
    int fee;
    cin >> A >> B ;
    if(A>=13){
        fee = B;
    }
    else if(A<6){
        fee = 0;
    }
    else{
        fee = B/2;
    }
    // 出力
    cout << fee << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007

using namespace std;

bool cmp(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.second < right.second;
}

lli f[1000000], rf[1000000];
lli inv(lli x) {
    lli res = 1;
    lli k = MOD - 2;
    lli y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    rep1(i, 1000000) f[i] = (f[i - 1] * i) % MOD;
    rep0(i, 1000001) rf[i] = inv(f[i]);
}
lli C(lli n, lli k) {
    lli a = f[n]; // = n!
    lli b = rf[n-k]; // = (n-k)!
    lli c = rf[k]; // = k!

    lli bc = (b * c) % MOD;

    return (a * bc) % MOD;
}

void dfs(lli ed, lli num, vector<map<lli,lli>>& vec){
    lli n=1;
    for(auto e: vec[num]){
        if(n == ed)n++;
        if(e.second != -1)continue;
        vec[num][e.first] = n;
        vec[e.first][num] = n;   
        dfs(n, e.first, vec);
        n++;
    }
}

lli gcd(lli a, lli b){
    if(a < b)return gcd(b, a);
    lli temp;
    while((temp = a%b)){
        a=b;
        b=temp;
    }
    return b;
}

int main(){
    lli a ,b, k;
    cin >> a ;
    vector<lli> vec;
    for(int i=2; i <= sqrt(a); i++){
        bool frag = true;
        for(auto e: vec){
            if(i%e==0){
                frag = false;
                break;
            }
        }        
        if(frag){
            vec.push_back(i);
        }
    }
    for(int i = a; i < a*2; i++ ){
        bool frag = true;
        for(auto e: vec){
            if(i%e==0){
                frag =false;
                break;
            }
        }
        if(frag){
            cout << i;
            return 0;
        }
    }
}

Measured memory_bytes: 256
text = input().split()
d = (int)(text[0])
n = (int)(text[1])
if (d == 0 and n < 100):
    print(n)
elif(d == 0 and n == 100):
  print(101)
elif(d == 1 and n < 100):
    print(n * 100)
elif(d == 1 and n == 100):
  print(10100)
elif(d == 2 and n < 100):
    print(n * 10000)
elif(d == 2 and n == 100):
  print(1010000)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int k = Integer.parseInt(sl[1]);

    RemRing rr = new RemRing(1000000007);
    long[] fact = new long[2001];
    long[] ifact = new long[2001];

    fact[0] = 1;
    ifact[0] = rr.inv(1);
    for(int i = 1; i <= 2000; i++)
    {
      fact[i] = rr.prod(fact[i - 1], i);
      ifact[i] = rr.inv(fact[i]);
    }

    for(int i = 1; i <= k; i++)
    {
      if(k < i || n - k < i - 1)
      {
        System.out.println(0);
      }
      else
      {
        long t = rr.prod(fact[k - 1], fact[n - k + 1]);
        t = rr.prod(t, ifact[k - i]);
        t = rr.prod(t, ifact[i - 1]);
        t = rr.prod(t, ifact[n - k + 1 - i]);
        t = rr.prod(t, ifact[i]);
        System.out.println(t);
      }
    }

  }



}

class RemRing
{
  long module;
  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while(b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if(u < 0) u += this.module;
    return u;
  }
}

Measured memory_bytes: 22612
n=int(input())
num=[]
for i in range(n):
    x,l=map(int,input().split())
    num.append([x,l,x+l])
str1= lambda val: val[2]
num.sort(key=str1)
ans=n
num1=num[0][2]
for i in range(n-1):
    if num1>num[i+1][0]-num[i+1][1]:
        ans-=1
    else:
        num1=num[i+1][2]
print(ans)


Measured memory_bytes: 30052
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[5];
    long n,i=0,j=0,k=0,l=0;
    cin>>n;
    while(n--){
        cin>>a;
        if(a[0]=='A')i++;
        if(a[0]=='W')j++;
        if(a[0]=='T')k++;
        if(a[0]=='R')l++;
    }

    cout<<"AC x "<<i<<endl;
    cout<<"WA x "<<j<<endl;
    cout<<"TLE x "<<k<<endl;
    cout<<"RE x "<<l<<endl;
    return 0;

}

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a+1==c&&d==1){
    printf("1");
  }
  else if(a==12&&c==1){
    printf("1");
  }

  else{
    printf("0");
  }
    return 0;
}




Measured memory_bytes: 128
import sys
l = []
for x in sys.stdin:
  l.append(sorted(list(int(y) for y in x.split() )))
  if l[-1] == [0,0]:
    break
  
for ll in l:
  if ll == [0,0]:
    break
  print("{} {}".format(ll[0], ll[1]))


Measured memory_bytes: 5984
use std::io::{self, Write};

fn main() {
    let len: usize = read_line_as_value();
    // println!("{}", len);

    let mut input_iter = read_line_as_vector::<String>().into_iter();
    let s_str = input_iter.next().unwrap();
    let t_str = input_iter.next().unwrap();
    // println!("{} {}", s_str, t_str);

    let s_chars: Vec<char> = s_str.as_str().chars().collect();
    let t_chars: Vec<char> = t_str.as_str().chars().collect();

    for i in 0..len {
        print!("{}{}", s_chars[i], t_chars[i]);
    }
    print!("\n");
    io::stdout().flush().unwrap();
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}


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

int main(){
	int x,a,b;
	cin >> x >> a >> b;
	if (a - b >= 0){
		cout << "delicious" << endl;
	}else if (x >= abs(a - b)){
		cout << "safe" << endl;
	}else{
		cout << "dangerous" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i)>>B.at(i);
  }
  vector<int> C(M),D(M);
  for(int i=0;i<M;i++){
    cin>>C.at(i)>>D.at(i);
  }
  for(int i=0;i<N;i++){
    int small=1000000000;
    int ans;
    for(int j=0;j<M;j++){
      int dis=abs(A.at(i)-C.at(j))+abs(B.at(i)-D.at(j));
      if(dis<small){
        small=dis;
        ans=j;
      }
    }
    cout<<ans+1<<endl;
  }
}

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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            string w = Console.ReadLine().ToLower();
            List<string> words = new List<string>();

            while (true)
            {
                string temp = Console.ReadLine();
                if (temp.Contains("END_OF_TEXT"))
                {
                    break;
                }
                else
                {
                    words.AddRange(temp.Split(' '));
                }
            }

            int count = 0;

            foreach (string word in words)
            {
                if(word.ToLower() == w)
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 9724
import java.util.Scanner;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int v[] = new int[n];
        for(int i = 0; i < n; i++){
            v[i] = sc.nextInt();
        }
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                if(v[i] > v[j]){
                    int v0 = v[i];
                    v[i] = v[j];
                    v[j] = v0;
                }
            }
        }

        double x0 = (v[0] + (double)v[1]) / 2.0;
        for(int i = 2;i < n;i++){
            double x = (x0 + (double)v[i]) /2.0;
            x0 = x;
        }
        System.out.println(x0);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int maxn=300;
typedef long long ll;
int n,m,mod;
ll dp[maxn+5][maxn+5],sum[maxn+5][maxn+5],c[maxn+5][maxn+5];
void work(ll &a,ll b)
{
    a=(a+b)%mod;
    if(a<0) a+=mod;
}
int main()
{
    scanf("%d%d%d",&n,&m,&mod);
    c[0][0]=1;
    for(int i=1;i<=n+1;++i)
    {
        c[i][0]=1;
        for(int j=1;j<=i;++j) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
    }
    for(int i=0;i<=m;++i) dp[1][i]=1;
    sum[1][0]=1;
    for(int i=1;i<=m;++i) sum[1][i]=(sum[1][i-1]+dp[1][i])%mod;
    //for(int i=0;i<=m;++i) printf("%lld ",sum[1][i]);printf("\n");
    for(int i=2;i<=n+1;++i)
    {
        for(int j=0;j<=m;++j)
            for(int k=1;k<i;++k)
                work(dp[i][j],dp[i-k][j]*c[i-2][k-1]%mod*(sum[k][m]-sum[k][j])%mod);
        sum[i][0]=dp[i][0];
        for(int j=1;j<=m;++j) sum[i][j]=(sum[i][j-1]+dp[i][j])%mod;
        /*for(int j=0;j<=m;++j)
        {
            printf("%d %d : %lld\n",i,j,dp[i][j]);
        }*/
    }
    printf("%lld\n",dp[n+1][0]);
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
using namespace std;
int main(){
  int A;
  int B;
  cin>>A;
  cin>>B;
if (B%2 == 0)
    {
      if (A >= 13)
      {
        cout<< B;
      }
      else if(A <= 12 && A >= 6)
      {
        cout<< B/2;
      }
      else 
      {
        cout<<0;
      } 
    }

}


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

struct Cake {
	long long int x, y, z;
	int type;
	long long int sum(int i) const {
		long long int ret = 0;
		if (i & 4) ret += x;
		else ret -= x;
		if (i & 2) ret += y;
		else ret -= y;
		if (i & 1) ret += z;
		else ret -= z;
		return ret;
	}
};

bool func000(const Cake &c1, const Cake &c2) {
	return c1.sum(0) > c2.sum(0);
};
bool func001(const Cake &c1, const Cake &c2) {
	return c1.sum(1) > c2.sum(1);
};
bool func010(const Cake &c1, const Cake &c2) {
	return c1.sum(0b10) > c2.sum(0b10);
};
bool func011(const Cake &c1, const Cake &c2) {
	return c1.sum(0b11) > c2.sum(0b11);
};
bool func100(const Cake &c1, const Cake &c2) {
	return c1.sum(0b100) > c2.sum(0b100);
};
bool func101(const Cake &c1, const Cake &c2) {
	return c1.sum(0b101) > c2.sum(0b101);
};
bool func110(const Cake &c1, const Cake &c2) {
	return c1.sum(0b110) > c2.sum(0b110);
};
bool func111(const Cake &c1, const Cake &c2) {
	return c1.sum(0b111) > c2.sum(0b111);
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<Cake> cake(n);
	for (int i = 0; i < n; i++) {
		long long int x, y, z;
		int type = 0;
		cin >> x >> y >> z;
		if (x > 0) type += 4;
		if (y > 0) type += 2;
		if (z > 0) type += 1;
		cake[i] = Cake{x, y, z, type};
	}
	long long int ans = 0;
	for (int t = 0; t < 8; t++) {
		bool px = t & 4, py = t & 2, pz = t & 1;
		switch (t) {
		case 0: sort(cake.begin(), cake.end(), func000); break;
		case 1: sort(cake.begin(), cake.end(), func001); break;
		case 2: sort(cake.begin(), cake.end(), func010);break;
		case 3: sort(cake.begin(), cake.end(), func011);break;
		case 4: sort(cake.begin(), cake.end(), func100);break;
		case 5: sort(cake.begin(), cake.end(), func101);break;
		case 6: sort(cake.begin(), cake.end(), func110);break;
		case 7: sort(cake.begin(), cake.end(), func111);break;
		}
		long long int tmp = 0;
		for (int i = 0; i < m; i++) {
			tmp += cake[i].sum(t);
		}
		if (tmp > ans) ans = tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val factors = scala.io.StdIn.readLine.split(" ").map{_.toInt}
    var answer = (factors(0) - 1)/(factors(1) - 1)

    if((factors(0) - 1)%(factors(1) - 1) == 0) println(answer)
    else                                       println(answer + 1)
  }
}

Measured memory_bytes: 27340
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int h,w;
  cin >>h>>w;
  int c[10][10];
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin>>c[i][j];
      }
    }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        c[j][k]=min(c[j][k],c[j][i]+c[i][k]);
        }
      }
    }
  vector<int> a(10);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int t;
      cin >>t;
      if(t>=0){a[t]++;}
      }
    }
  int ans=0;
  for(int i=0;i<10;i++){
    ans+=a[i]*c[i][1];
    }
  cout <<ans<<endl;
  return 0;
  }

  

Measured memory_bytes: 256
import heapq

def solve():
  firstline = raw_input().split(' ')
  N = int(firstline[0])
  K = int(firstline[1])

  heap = []
  for i in range(N) :
    ar = raw_input().split(' ')
    a = int(ar[0])
    b = int(ar[1])
    heapq.heappush(heap, (a, b))

  count = 0
  while len(heap) > 0 :
    t = heapq.heappop(heap)
    count += t[1]
    if (count >= K) : return t[0]
  return -1

if __name__ == '__main__' :
  print solve()

Measured memory_bytes: 18560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    int l = 1, r = N;
    while(l < r){
        int n = (l+r)/2;
        bool able = true;
        map<int, int> mp;
        rep2(i, 1, N-1){
            if(A[i] > A[i-1]) continue;
            else{
                if(n == 1){able = false; break;}
                mp[A[i]] = 0;
                map<int, int>::iterator ite;;
                ite = mp.find(A[i]);
                while(ite != mp.end()) ite = mp.erase(ite);
                if(mp.count(A[i]-1)) mp[A[i]-1]++;
                else mp[A[i]-1] = 1;
                int j = A[i]-1;
                while(mp[j] >= n){
                    if(j == 0){able = false; break;}
                    mp.erase(j);
                    j--;
                    if(mp.count(j)) mp[j]++;
                    else mp[j] = 1;
                }
            }
        }
        if(able) r = n;
        else l = n+1;
    }
    cout << l << endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.math.*;
public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int[][] q = new int[2][60];
		for(int i = 0; i < n; i++) {
			long a = sc.nextLong();
			for(int j = 0; j < 60; j++) {
				int k = ((1L << j) & a) > 0? 1:0;
				q[k][j]++;
			}
		}
		long mod = 1000000007;
		BigInteger res = BigInteger.ZERO;
		for(int i = 0; i < 60; i++) {
			BigInteger curr = BigInteger.valueOf(q[0][i]).multiply(BigInteger.valueOf(q[1][i]));
			curr = curr.multiply(BigInteger.valueOf((1L << i)));
			res = res.add(curr).mod(BigInteger.valueOf(mod));
		}
		System.out.println(res);
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


Measured memory_bytes: 74444
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int x, y; cin >> x >> y;
	int gx = 0, gy = 0;
	if (x == 2)gx == 1;
	else if (x == 4 || x == 6 || x == 9 || x == 11) gx = 2;
	else gx = 3;

	if (y == 2)gy == 1;
	else if (y == 4 || y == 6 || y == 9 || y == 11) gy = 2;
	else gy = 3;

	if (gx == gy) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] p = new int[N];
        for(int n=0; n<N; n++){
            p[n]=sc.nextInt();
        }
        int ans=0;
        for(int n=1; n<N-1; n++){
            if((p[n-1]<p[n])^(p[n+1]<p[n])) ans++;
        }
        System.out.println(ans);
    }
}

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

    int a = N / 100;
    int b = N % 10;

    if (a ==b){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::BTreeMap;


fn main() {
  let a = read::<String>();
  let b = read::<String>();

  let mut a_vec: Vec<char> = a.chars().collect();
  let mut b_vec: Vec<char> = b.chars().collect();
  let mut ans = "Nutral";

  a_vec.sort();
  b_vec.sort_by(|a, b| b.cmp(a));

  // println!("a:{:?}, b:{:?}", a_vec, b_vec);

  let min_v = min(a_vec.len(), b_vec.len());

  for i in 0..min_v {
    if a_vec[i] > b_vec[i] {
      ans = "No";
      break;
    } else if b_vec[i] > a_vec[i] {
      ans = "Yes";
      break;
    } else {
      continue;
    }
  }

  if ans == "Nutral" {
    if a_vec.len() < b_vec.len() {
      ans = "Yes";
    } else {
      ans = "No";
    }
  }
  println!("{}", ans)
}



Measured memory_bytes: 4352