akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////




int main(){
    ll n,k;cin>>n>>k;
    ll a[n+1];rep(i,1,n)cin>>a[i];
    ll dp[n+1][k+2];memset(dp,0,sizeof(dp));
    rep(j,1,k+1)dp[0][j]=1;dp[0][0]=0;
    rep(i,1,n){
        rep(j,1,k+1){
            dp[i][j]=mod(dp[i-1][j]-dp[i-1][max(0,j-a[i]-1)]);
        }
        rep(j,1,k+1){
            Add(&dp[i][j],dp[i][j-1]);
        }
    }
    /*rep(i,0,n){
        rep(j,0,k+1){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    cout<<mod(dp[n][k+1]-dp[n][k])<<endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    int T=1;
    //cin >> T;
    while(T--){
        ll n;
        cin>>n;
       string s;
       cin>>s;
       int ans=0;
       for(int i=0; i<n; i++){
        if(s[i]!=s[i-1]) ans++;
        }
        cout<<ans<<el;
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3972
#!/usr/bin/env python3
import sys
from itertools import chain
import numpy as np


def solve(X: int):
    if X <= 2:
        return 2
    flags = np.array([True for i in range(3, X + 100, 2)])
    for i in range(len(flags)):
        if flags[i]:
            prime = i * 2 + 3
            flags[i::prime] = False
            if prime >= X:
                return prime




def main():
    X = int(input())  # type: int
    answer = solve(X)
    print(answer)


if __name__ == "__main__":
    main()


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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) int s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;
vector<lint> h;


int main() {
  int1(n);
  h.resize(n);
  vector<int> dp(n);
  repi(n){
    cin>>h[i];
    if(i==0){
      dp[0]=0;
    }else if(i==1){
      dp[1]=abs(h[0]-h[1]);
    }else{
      dp[i]=min(
                dp[i-1]+abs(h[i-1]-h[i]),
                dp[i-2]+abs(h[i-2]-h[i])
                );
    }
  }
  prln(dp[n-1])
  
}


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

map<int, double> memo;

double factorial (int n)
{
    double l = memo[n];
    if (l)
    {
        return l;
    } else
    {
        double r = 1;
        for (int i = 1; i<=n; i++)
        {
            r = r * i;
        }
        memo[n] = r;
        return r;
    }
}

long long int comb (int m)
{
    //double r = factorial(m) / (factorial(2) * factorial(m-n));
    //return factorial(m) / (2 * factorial(m-2));
    long long int r = 1;
    for (int i = 1; i <= 2; i++)
    {
        r = r * (m - i + 1) / i;
    }
    return r;
}

int main()
{
    int N = 0;
    cin >> N;
    int A[N];
    int f;
    long long int ans;
    int l, i = 0;
    while (cin >> l) {
        A[i] = l;
        i++;
        if (i >= N) {
            break;
        }
    }
    map<int, int> mp;
    
    for (int i = 0; i < N; i++)
    {
        mp[A[i]]++;
    }
    long long int tt = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        i = itr->second;
        if (i>=2)
        {
            tt = tt + comb(i);
        }
    }

    for (int i = 0; i < N; i++)
    {
        f = mp[A[i]];

        if (f>=3)
        {
            ans = tt - comb(f) + comb(f-1);
        } else if (f==2)
        {
            ans = tt - comb(f);
        } else
        {
            ans = tt;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 10112
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <list>
#include <vector>
#include <unistd.h>
#include <algorithm>
#define ll long long
using namespace std;
double A,B,C,D,E,F;
int main(){
	cin >> A >> B >> C >> D >> E >> F;
	double max_w = 0;
	double max_s = 0;
	for ( double a = 0 ; a <= 30 ; a ++ ){
		if ( a * A * 100 > F ) break;
		for ( double b = 0 ; b <= 30 ; b ++ ){
			if ( a * A * 100 + b * B * 100 > F ) break;
			for ( double c = 0 ; c <= 3000 ; c ++ ){
				if ( a * A * 100 + b * B * 100 + C * c > F ) break;
				if ( c * C > E * (a * A  + b * B) ) break;
				for ( double d = 0 ; d <= 3000 ; d ++ ){
					if ( a * A * 100 + b * B * 100 + C * c + d * D > F ) break;
					if ( c * C + d * D > E * (a * A  + b * B) ) break;
					if ( (max_w + max_s) * (c * C + d * D) >= (a * A * 100 + b * B * 100 + c * C + d * D) * (max_s) ){
						max_w = 100* a * A + 100 * b * B;
						max_s = c*C + d*D;
					}
				}
			}
		}
	}
	cout << max_w + max_s << " " << max_s << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools

def check(lis, a):
    return sum((i[3] for i in a if lis[i[1]-1]-lis[i[0]-1]==i[2]))
   
n, m, q = map(int, input().split())
a = tuple(tuple(int(i) for i in input().split(" ")) for j in range(q))
ans = 0
for i in itertools.combinations_with_replacement(range(m), n):
    ans = max(ans, check(i, a))
print(ans)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++) {
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

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

	vector<int> X(M);
	vector<int> Y(M);
	
	vector<int> a(N, 1);
	vector<bool> red(N, false);

	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		X[i] = x;
		Y[i] = y;
	}

	red[0] = true;

	rep (i, M) {
		int x = X[i];
		int y = Y[i];

		if (red[x]) {
			red[y] = true;
		}

		a[x] -= 1;
		a[y] += 1;
		if (a[x] == 0) {
			red[x] = false;
		}
	}

	int ans = 0;
	rep (i, N) {
		if(red[i]) ans++;
	}

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

vector<vector<double>> dp(3000, vector<double>(3000, 0));
//dp.at(i).at(j)はi枚投げたとき表がj回出ている確率

int main(){
  ll N;
  cin >> N;
  vector<double> p(N);
  rep(i, N){
    cin >> p.at(i);
  }
  dp.at(0).at(0) = 1;
  rep(i, N){
    rep(j, i+2){
      if(j == 0){
        dp.at(i+1).at(0) = (1 - p.at(i)) * dp.at(i).at(0);
      }
      else{
        dp.at(i+1).at(j) = p.at(i) * dp.at(i).at(j-1) + (1 - p.at(i)) * dp.at(i).at(j);
      }
    }
  }
  double ans = 0;
  rep2(i, N/2 + 1, N+1){
    ans += dp.at(N).at(i);
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    while(b!=0){
      int r = a%b;
      a = b;
      b = r;
    }
    return a;
  }
int main()
{
  int p,s=0,b,c,i;
  cin>>p;

  for ( i=1;i<=p;i++){
    for ( b=1;b<=p;b++){
      for ( c=1;c<=p;c++){
        s=s+gcd(gcd(i,b),c);
      }
    }
  }
  cout<<s<<endl;
  return 0;

}


Measured memory_bytes: 3604
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var xa = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            Console.WriteLine(xa[0]<xa[1]?0:10);
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>

using namespace std;
typedef long long llong;

#define MAX 200010

int main()
{
  int ans = 0;
  char S[MAX], T[MAX];

  scanf("%s", S);
  scanf("%s", T);

  int len = strlen(S);
  for (int i = 0; i < len; i++)
  {
    if (S[i] != T[i])
      ans++;
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
int main()
{
ios_base::sync_with_stdio(false);
int n;
cin>>n;
if(n<=999)
{
    cout<<"ABC";
}
else
{
    cout<<"ABD";
}
}

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

int main() {
	// A
	int input, a, b, c;
	cin >> input;
	a = input / 100;
	b = (input - a * 100) / 10;
	c = input - a * 100 - b * 10;
	cout << a + b + c << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
l = list(map(int, input().split()))

l.sort()

ans = 0
for a in range(0, n-2):
    for b in range(a+1, n-1):
        c = l[a] + l[b]
        ans += bisect.bisect_left(l, c) - b - 1

print(ans)

Measured memory_bytes: 68544
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		String S=sc.next();
		char[] c=sc.next().toCharArray();
		char[] a=new char[c.length];
		int k=0;
		for(int i=c.length-1;i>=0;i--) {
			a[k]=c[i];
			k++;
		}
		if(S.equals(String.valueOf(a)))System.out.println("YES");
		else System.out.println("NO");
	}
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	for(int i=0;i<m;i++)
	{
		int temp;
		cin>>temp;
		ans+=temp;
		}
	if(n-ans<0)
	cout<<"-1";
	else
	cout<<n-ans;
}


Measured memory_bytes: 3636
input()
A = list(map(int, input().split()))
q = int(input())
for _ in range(q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        print(min(A[query[1]:query[2]]))
    else:
        print(max(A[query[1]:query[2]]))


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

int main(){
    int debt = 100000;
    int week;
    
    cin >> week;
    
    for(int i = 0; i < week; ++i){
        debt *= 1.05;
        if(debt % 1000 != 0){
            debt = (debt + 999) / 1000;
            debt = debt * 1000;       
        }
    }

    cout << debt << endl;

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < (int)(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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define all(x) (x).begin(),(x).end()
#define print(x) printf("%d\n",x)
#define scan(x) scanf("%d",&(x))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int isPrime(int x){
    int i;
    if ( x == 2 ){
        return 1;
    }
    else if ( x < 2 || x % 2 == 0 ){
        return 0;
    }
        for( i = 3 ; i * i <= x ; i+=2 ){
            if( x % i == 0 ){
                return 0;
            }
                }
            return 1;
        }
         
    int main(void){
        int n,x,i;
        int ans = 0;
         
        scanf("%d",&n);
        for( i = 0 ; i < n ; i++ ){
            scanf("%d",&x);
            if ( isPrime(x) ){
                ans = ans + 1 ;
            }
        }
            printf("%d\n",ans);
             
            return 0;
             
        }

Measured memory_bytes: 3204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var k = Console.ReadLine().ToInt();
		int kisu = k/2;
		int gusu = k/2;
		if(k % 2 != 0)
		{
			kisu++;
		}
		Console.WriteLine(kisu*gusu);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static long Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
fun main() = abc166e()

@OptIn(ExperimentalStdlibApi::class)
fun abc166e() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }

    val appeared = mutableMapOf<Long, Long>().withDefault { 0 }
    var answer = 0L

    for ((index, a) in aList.withIndex()) {
        answer += appeared.getValue(index - a)
        appeared[a + index] = appeared.getValue(a + index) + 1
    }

    println(answer)
}


Measured memory_bytes: 82648
import sys
a,b = map(int,input().split())
c = 0
if (a+b) == 0:
    print("Zero")
    sys.exit()
elif a < 0 and b < 0:
    if  (a-b) % 2 == 1:
        print("Positive")
        sys.exit()
elif a < 0 and b >= 0:
    if a%2 == 0:
        print("Positive")
        sys.exit()
elif b < 0 and a >= 0:
    if b % 2 == 0:
        print("Positive")
        sys.exit()
if (a+b) > 0:
    print("Positive")
else:
    print("Negative")

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  long long N;
  long long result = 0;
  cin >> N;
  long long n_sqrt = (long long)floor(sqrt((double)N));
  for (long long p=1;p<=n_sqrt;p++) {
    if (N % p == 0) {
      long long l = N / p;
      if (l == 1) {
	continue;
      }
      if (p == l) {
	if (N % (l - 1) == p) {
	  result += l-1;
	}
      } else if (p > l) {
	break;
      } else {
	if (N % (l - 1) == p) {
	  result += l-1;
	}
      }
    }
  }
  cout << result << endl;
  return(0);
}


Measured memory_bytes: 888
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
A = sorted(readInts())
th = 10**18
if A[0] == 0:
    print(0)
else:
    ans = 1
    for i in range(n-1,-1,-1):
        ans *= A[i]
        if ans > th:
            print('-1')
            exit()
    print(ans)


Measured memory_bytes: 93932
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

ll N, num, A, B, C;
vector<ll> vec;

ll dfs(ll cur, ll a, ll b, ll c, ll s) {
    if (cur == N) {
        return (min({a, b, c}) > 0)? abs(a - A) + abs(b - B) + abs(c - C) + s - 30: LLONG_MAX;
    }
    ll ret0 = dfs(cur + 1, a, b, c, s);
    ll ret1 = dfs(cur + 1, a + vec[cur], b, c, s+10*(A>0));
    ll ret2 = dfs(cur + 1, a, b + vec[cur], c, s+10*(B>0));
    ll ret3 = dfs(cur + 1, a, b, c + vec[cur], s+10*(C>0));
    return min({ret0, ret1, ret2, ret3});
}

int main() {
    // input
    cin >> N >> A >> B >> C;
    REP(i, N) {
        cin >> num;
        vec.push_back(num);
    }
    
    // calculation
    cout << dfs(0, 0, 0, 0, 0) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
vector<bool> prime;
void make(int num){
    prime.resize(num,true);
    prime[0]=false;
    for(int i=0;i*i<num;i++){
        if(prime[i]){
            for(int j=2;(i+1)*j<=num;j++){
                prime[(i+1)*j-1]=false;
            }
        }
    }
}
int main(){
	make(300000);
	V<ll> dat;
	for(ll i=0;i<300000;i++){
		if(prime[i])dat.emplace_back(i+1);
	}
	while(1){
		ll n,m;
		cin>>n>>m;
		if(n==-1)return 0;
		int ind=upper_bound(all(dat),n)-dat.begin();
		V<ll> tmp;
		int l=0,r=1e6;
		while(r-l>1){
			int mid=(l+r)/2;
			ll cnt=0;
			for(int i=ind;i<dat.size();i++){
				if(mid-dat[i]<dat[i])break;
				int d=upper_bound(all(dat),mid-dat[i])-dat.begin()-i;
				if(d>0)cnt+=d;
				if(cnt>m)break;
			}
			if(cnt>=m)r=mid;
			else l=mid;
		}
		cout<<r<<"\n";
	}
}


Measured memory_bytes: 3208
# -*- coding:utf-8 -*-
a, b = map(int, input().split())
if a <= 0 and b >= 0:
    print('Zero')
elif a > 0 and b > 0:
    print('Positive')
else:
    if a == b or abs(b-a)%2 != 0:
        print('Positive')
    else:
        print('Negative')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int H, W, t[20][20];
int dy[] = {0, 1}, dx[] = {1,0}; // 横　縦

int judge(int y, int x){
  map<int, int>m;
  for(int i = -1; i < 1; i++){
    for(int j = -1; j < 1; j++){
      int ny = y+i, nx = x+j;
      if(ny < 0 || nx < 0 || t[ny][nx] == -1 || m.count(t[ny][nx])) continue;
      m[t[ny][nx]] = 1;
    }
  }
  if(m.size() < 4) return 1;
  return 0;
}

int dfs(int n){
  int i, j, res = 0;
  for(i = 0; i < H; i++) for(j = 0; j < W; j++) if(t[i][j] == -1) goto b;
 b:

  if(i == H && j == W) return 1;

  t[i][j] = n;
  rep(d, 2){
    int x = j+dx[d], y = i+dy[d];
    if(x < 0 || x >= W || y < 0 || y >= H || t[y][x] != -1) continue;
    t[y][x] = n;
    if(judge(i, j)) res += dfs(n+1);
    t[y][x] = -1;
  }
  t[i][j] = -1;

  return res;
}

int main(){
  while(scanf("%d%d", &H, &W) && H+W){
    memset(t, -1, sizeof(t));
    if(H%2 && W%2) puts("0");
    else if(H == W) puts("2");
    else printf("%d\n", dfs(0));
  }
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cassert>
#include <string>
#include <cstring>
#include <bitset>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31};

const int N = 1e2 + 5;
const int K = 1e5 + 5;

int n;
int dp [K][2];
int a [N];

int solve (int stones_left, int who) {
  if (stones_left <= 0) return who;
  int &res = dp[stones_left][who];
  if (~res) return res;
  if (who == 0) {
    // Maximize 
    res = -1e9;
    F0R (i, n) if (stones_left >= a[i]) res = max (res, solve (stones_left - a[i], who ^ 1));
  } else {
    // Minimize
    res = 1e9;
    F0R (i, n) if (stones_left >= a[i]) res = min (res, solve (stones_left - a[i], who ^ 1));
  }
  if (res < 0 || res > 1) {
    return res = who;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k;
  cin >> n >> k;
  F0R (i, n) cin >> a[i];
  memset (dp, -1, sizeof(dp));
  cout << (solve (k, 0) == 0 ? "Second" : "First") << '\n';
  return 0;
}


Measured memory_bytes: 8832
#include <stdio.h>
#include <stdlib.h>
int main(void){
char s[15];
  int sum;
  int count;
  int a;
  scanf("%s",s);
  for(count=0;s[count]!='\0';count++){
 sum=sum+(s[count]-'0');
  }
  a=atoi(s);
  if(a%sum==0){printf("Yes");}
  else {printf("No");}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

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

    vector<bool> P(56000, true);
    P[0] = false;
    P[1] = false;
    for (int i = 2; i < 56000; i++) {
        if(P[i] == false){
            continue;
        }
        else{
            for (int j = 2; i * j < 56000; j++) {
                P[i * j] = false;
            }
        }
    }
    vector<int> ans;
    for (int i = 1; i < 56000; i+=5) {
        if(P[i] == true){
            ans.push_back(i);
        }
    }
    for (int i = 0; i < N; i++) {
        printf("%d ", ans[i]);
    }
    printf("\n");

}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#define PI 3.14159265358979
using namespace std;
long double r;
int main() {
	while(cin >> r, r != 0.0L) {
		for(int i = 1; ; i++) {
			long double t = PI * i - (int)(PI * i);
			long double x = t / i;
			long double y = (1 - t) / i;
			if(x <= r) {
				printf("%d/%d\n", (int)(PI * i), i); break;
			}
			if(y <= r) {
				printf("%d/%d\n", (int)(PI * i) + 1, i); break;
			}
		}
	}
}

Measured memory_bytes: 3116
/* ITP1_7_D:Matrix Multiplication */
/* 20181123 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int n, m, l;
	int i, j, k;
	int A[100][100], B[100][100];
	long long C[100][100] = {0};

	scanf("%d %d %d", &n, &m, &l);
	for(i = 0; i < n; i++) {
		for(j = 0; j < m; j++) {
			scanf("%d", &A[i][j]);
		}
	}

	for(i = 0; i < m; i++) {
		for(j = 0; j < l; j++) {
			scanf("%d", &B[i][j]);
		}
	}

	for(i = 0; i < n; i++) {
		for(k = 0; k < l; k++) {
			for(j = 0; j < m; j++) {
				C[i][k]  +=  A[i][j] * B[j][k];
			}
		}	
	}

	for(i = 0; i < n; i++) {
		for(j = 0; j < l - 1; j++) {
			printf("%ld ", C[i][j]);
		}
		printf("%ld\n", C[i][j]);
	}

	return 0;
}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        double[] nums = new double[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextDouble();
        }
        System.out.println(Main.getHeadsSuperior(nums, n));
    }

    protected static double getHeadsSuperior(double[] nums, int n) {
        double[][] probabilities = new double[n + 1][n + 1];
        probabilities[0][0] = 0;
        for (int i = 0; i < probabilities.length; i++) {
            for (int j = 0; j < probabilities.length; j++) {
                if (i == 0) {
                    probabilities[i][j] = j == 0 ? 1 : 0;
                    continue;
                }
                probabilities[i][j] = 0;
                probabilities[i][j] += probabilities[i - 1][j] * (1 - nums[i - 1]);
                if (j > 0) {
                    probabilities[i][j] += probabilities[i - 1][j - 1] * nums[i - 1];
                }
            }
        }
        double result = 0.0;
        for (int i = n / 2 + 1; i <= n; i++) {
            result += probabilities[n][i];
        }
        return result;
    }
}


Measured memory_bytes: 123260
s = input()
n = len(s)
if n % 2 == 1:
    print("No")
    exit(0)
for i in range(n):
    if i % 2 == 0:
        if s[i] != "h":
            print("No")
            break
    elif s[i] != "i":
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 61784
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
            int l,r,d,k=0;
            cin>>l>>r>>d;
            REP(i,l,r){
                if(i%d==0) k++;
            }
            cout<<k;
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>

using namespace std;

int main() {
    int a,b,c,x;
    cin >> a >> b >> c >> x;

    int ans = 0;
    for (int i=0; i<=a; i++) {
        for (int j=0; j<=b; j++) {
            int nc = (x - 500*i - 100*j) / 50;
            if (nc < 0 || c < nc) continue;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,p[25],count=0;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>p[i];
  }
  for(int i=1; i<n-1; i++){
    if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i+1]<p[i] && p[i]<p[i-1])){
      count++;
    }
  }
  cout<<count<<'\n';
  return 0;
}


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

vector< bool > prime( MAX*2+1, true);

void get_prime(int n){
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  
  for(int i = 2; i * i <= n; i++){
    if(prime[i]){
      for(int j = i + i; j <= n; j += i) prime[j] = false;
    }
  }
}

int main(){
  get_prime(MAX*2+1);
  int n;
  while(cin >> n , n){
    int ans = 0;
    for(int i=n+1;i<=2*n;i++){
      if(prime[i]) ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>

using namespace std;
using namespace boost::numeric;

typedef long long ll;
#define FOR(i,n) for(int i=0; i<int(n); i++)
#define FOR1(i,m,n) for(int i=int(m); i<int(n); i++)

const int MAXN=1e9;
const int MAXM=1e5;
const int MOD=1e9+7;
int N, M, IDX=0;
int X;
ublas::matrix<ll> mat1(3,3), mat2(3,3);
ublas::vector<ll> vec(3);
ublas::matrix<ll> accum=ublas::identity_matrix<ll>(3);

ublas::matrix<ll> pow(ublas::matrix<ll> base, int exponent) {
    ublas::matrix<ll> ans;
    if (exponent == 0)
        ans = ublas::identity_matrix<ll>(3);
    else if (exponent % 2 == 1)
        ans = ublas::prod(base, pow(base, exponent-1));
    else {
        ublas::matrix<ll> tmp = pow(base, exponent / 2);
        ans = ublas::prod(tmp, tmp);
    }

    transform(ans.data().begin(), ans.data().end(),
              ans.data().begin(), [](ll x){return x%MOD;});
    return ans;
}

// ublas::vector<ll> dp(int n) {
//     if (IDX == M) {
//         accum = ublas::prod(accum, pow(mat1, N-n));
//         transform(accum.data().begin(), accum.data().end(),
//                   accum.data().begin(), [](ll x){return x%MOD;});
//         return ublas::prod(accum, vec);
//     }
//     else if (IDX < M && X[IDX] > n) {
//         int exponent = X[IDX]-n;
//         accum = ublas::prod(accum, pow(mat1, exponent));
//         transform(accum.data().begin(), accum.data().end(),
//                   accum.data().begin(), [](ll x){return x%MOD;});
//         return dp(X[IDX]);
//     }
//     else {
//         IDX++;
//         accum = ublas::prod(accum, mat2);
//         transform(accum.data().begin(), accum.data().end(),
//                   accum.data().begin(), [](ll x){return x%MOD;});
//         return dp(n+1);
//     }
// }

int main(int argc, char *argv[])
{
    int init1[3][3] = {{1,2,1},
                       {0,1,1},
                       {1,2,2}};
    int init2[3][3] = {{1,2,1},
                       {0,1,1},
                       {0,0,1}};
    int init3[3] = {0,0,1};
    ublas::vector<ll> ans;
    
    FOR(i,3) {
        FOR(j,3) {
            mat1(i,j) = init1[i][j];
            mat2(i,j) = init2[i][j];
        }
        vec(i) = init3[i];
    }

    cin >> N >> M;
    int n=0;
    FOR(i,M) {
        cin >> X;
        int exponent = X-n;
        accum = ublas::prod(accum, pow(mat1, exponent));
        accum = ublas::prod(accum, mat2);
        transform(accum.data().begin(), accum.data().end(),
                  accum.data().begin(), [](ll x){return x%MOD;});
        n = X+1;
    }
    accum = ublas::prod(accum, pow(mat1, N-n));
    transform(accum.data().begin(), accum.data().end(),
              accum.data().begin(), [](ll x){return x%MOD;});
    ans = ublas::prod(accum, vec);
    cout << ans[0] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

 
int vector_finder(std::vector<int> vec, int number) {
  size_t index = std::distance( vec.begin(), std::find(vec.begin(), vec.end(), number) );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}


int main()
{
	int A,B,C;
	cin >> A >> B >> C;

	if((A<=C&&C<=B)||(B<=C&&C<=A)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

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

#ifdef DEBUG
const int N = 20;
#else
const int N = 2e6;
#endif
int n, m, k;
string s, t;

auto naive() {
  vector<int> res(N);
  for(int i = 0; i < N; i++) {
    res[i] = ((s[i] - '0') << 1) + (t[i] - '0');
  }
  for(int t = 0; t < k; t++) {
    for(int i = 0; i < N; i++) {
      int inc = 0;
      if(res[i] == 3) res[i] = 0, inc = 3;
      for(int j = i - 1; j >= 0 && inc; j--) {
        int old = res[j];
        res[j] ^= inc;
        inc &= old;
      }
    }
  }
  return res;
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n >> m >> k;
  cin >> s >> t;
  s = string(N - s.size(), '0') + s;
  t = string(N - t.size(), '0') + t;
  vector<int> data(N);
  stack<int> st;
  for(int i = 0; i < N; i++) {
    data[i] = ((s[i] - '0') << 1) + (t[i] - '0');
    int z = k;
    int inc = 0;
    if(z && data[i] == 3) inc = 3, data[i] = 0, z--;
    int now = i - 1;
    vector<int> v;
    if(data[i] == 1 || data[i] == 2) v.emplace_back(i);
    while(inc && now >= 0) {
      int nx = -1;
      if(st.size()) {
        nx = st.top();
        st.pop();
        // assert(data[nx] == 1 || data[nx] == 2);
      }
      // assert(nx <= now);
      if(inc == 3) {
        int useZ = min(z, now - nx);
        z -= useZ;
        if(useZ == now - nx) {
          // assert(nx >= 0);
          inc = data[nx];
          data[nx] ^= 3; // inc
          v.emplace_back(nx);
          now = nx - 1;
        } else {
          data[now - useZ] = 3; // inc
          stack<int>().swap(st);
          break;
        }
      } else {
        if(now == nx) {
          // assert(nx >= 0);
          int old = data[nx];
          data[nx] = old ^ inc;
          if(z && data[nx] == 3) inc = 3, data[nx] = 0, z--;
          else {
            inc = old & inc;
          }
          if(data[nx] == 1 || data[nx] == 2) v.emplace_back(nx);
          now = nx - 1;
        } else {
          data[now] = inc;
          if(nx >= 0) st.push(nx);
          st.push(now);
          break;
        }
      }
    }
    reverse((v).begin(), (v).end());
    for(int e : v) st.push(e);
  }
  int g = 0;
  for(int i = 0; i < N; i++) {
    int a;
    g |= a = !!(data[i] & 0b10);
    if(g) cout << a;
  }
  cout << endl;
  g = 0;
  for(int i = 0; i < N; i++) {
    int a;
    g |= a = (data[i] & 0b01);
    if(g) cout << a;
  }
  cout << endl;
#ifdef DEBUG
  assert(data == naive());
#endif
  return 0;
}


Measured memory_bytes: 18928
w,h,n=map(int,input().split())
w1=0
w2=w
h1=0
h2=h
for i in range(n):
    a,b,c=map(int,input().split())
    if c==1:
        w1=max(a,w1)
    elif c==2:
        w2=min(a,w2)
    elif c==3:
        h1=max(b,h1)
    elif c==4:
        h2=min(b,h2)
if w2<=w1 or h2<=h1:
    print(0)
else:
    print(max(0,(w2-w1)*(h2-h1)))

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        int time = scan.nextInt();
        int h = time / 3600;
        int m = (time - 3600*h) / 60;
        int s = (time - 3600*h - 60*m);
        
        if(s >= 60){
            s = 59;
        }
        if(m >= 60){
            m = 59;
        }
        System.out.println(h +":"+ m +":"+ s);
    }
}


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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long int ll;
vector<int> ve(3006, 0);
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	long long int a, b, c;
	cin >> a >> b >> c;
	ll mx = 0, ans = 0;
	ll x = min(b - 1, c);
	ll t = floor((double)(a * x / b)) - a * floor((double)(x / b));
	cout << t;

}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    long long int x;
    scanf("%lld",&x);

    int ans = 0; 
    long long int s = 100;

    while(s < x)
    {
        s = s*1.01;
        ans ++;
    }

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

Measured memory_bytes: 1732
#include <iostream>
using namespace std;
int main(){
    int a, b,c;
    cin >>a >> b>> c;

    if(1<=a && b && c <=9){

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


    }


   return 0;
 }


Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define int long long
#define US unsigned
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define nin(ary, n) for (int i = 0; i < (n); i++) cin >> ary[i]
#define nnin(ary, h, w) for (int i = 0; i < (h); ++i) for (int j = 0; j < (w); ++j) cin >> ary[i][j]
#define OPT(conditions, a, b) cout << ((conditions) ? #a : #b) << endl
using namespace std;
const double PI = acos(-1.0);
const int MOD = 1e9 + 9;

int max_n(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_o(int ary[], int length) {
	int max;
	max = max_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_n(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_o(int ary[], int length) {
	int min;
	min = min_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while (k != 0);
	return result;
}

int gcm_n(int ary[], int length) {
	int g = ary[0];
	for (int i = 0; i < length; i++)
		g = gcm(g, ary[i]);
	return g;
}

int lcm(int a, int b) {
	int g, n;
	g = gcm(a, b);
	n = gcm(a, g);
	a = a / n;
	b = b / (g / n);
	return a*b;
}

int lcm_n(int ary[], int length) {
	int l = ary[0];
	for (int i = 0; i < length; i++)
		l = lcm(l, ary[i]);
	return l;
}

signed main() {
	string n;
	cin >> n;
	OPT(n[0] == n[2], Yes, No);
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int MAXN=100005,MOD=1000000007;

int PowMod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)
			ret=(1LL*ret*a)%MOD;
		a=(1LL*a*a)%MOD;
		b>>=1;
	}
	return ret;
}
int Inv(int a)
{return PowMod(a,MOD-2);}

int tmp1[MAXN],tmp2[MAXN];

int main()
{
	int H,W,A,B;
	scanf("%d%d%d%d",&H,&W,&A,&B);
	
	tmp1[1]=1;
	for(int i=2;i<=H-A;i++)
		tmp1[i]=1LL*tmp1[i-1]*(B-2+i)%MOD*Inv(i-1)%MOD;
	
	tmp2[1]=1;
	for(int i=2;i<=H;i++)
		tmp2[i]=1LL*tmp2[i-1]*(W-B-2+i)%MOD*Inv(i-1)%MOD;
		
	int ans=0;
	for(int i=1;i<=H-A;i++)
		ans=(ans+1LL*tmp1[i]*tmp2[H-i+1]%MOD)%MOD;
	
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 896
import java.util.*;
public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int input = sc.nextInt();
		int n[] = new int [input];
		for (int i=0 ; i<input ; i++ ){
			int v = sc.nextInt();
			n[i]=v;
		}
		int count = 0;
		int max = 0;
		for (int i=0 ; i<input ; i++ ){
			if(max<=n[i]){
				max = n[i];
				count +=1;
			}
		}
		System.out.println(count);
		
	}

}

Measured memory_bytes: 23124
N,M=map(int,input().split())
A=list(map(lambda x:int(x)*(-1),input().split()))

from heapq import heappop,heappush,heapify

heapify(A)
for _ in range(M):
    a=heappop(A)*(-1)
    a//=2
    heappush(A,a*(-1))

print(sum(A)*(-1))

Measured memory_bytes: 14252
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>

const int64_t cc = pow( 10, 9 ) + 7;

bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.second > another.second;
}

int main()
{
    int64_t a,b,c,d;
    std::cin>> a;
    std::vector< std::pair< std::string, int64_t > > list;

    for( int i = 0; i < a; i++ )
    {
        std::pair< std::string, int64_t > aa;
        std::cin>> aa.first;
        std::cin >> aa.second;
        list.push_back( aa );
    }

    std::string bb;
    std::cin>> bb;

    c = 0;
    bool ss = false;
    
    for( int i = 0; i < a; i++ )
    {
        if( ss )
        {
            c += list[i].second;
        }
        else if( bb == list[i].first )
        {
            ss = true;
        }
    }

    std::cout<< c;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
priority_queue<double>p;
int main (void) {
	int n;
	cin >> n;
	int a;
	for(int i = 1; i <= n; i++) {
		cin >> a;
		p.push(-a);
	}
	for(int i = 1; i < n; i++) {
		double x=-p.top();
		p.pop();
		double y=-p.top();
		p.pop();
		p.push(-(x+y)/2);
	}
	cout << -p.top();
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
using namespace std;

typedef long long int64;

const int INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 10;

int64 a[MAXN];
int64 sum[MAXN];
int64 v[MAXN];

#include <cctype>
#include <cstdio>

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) {
        X = (X << 3) + (X << 1) + (ch ^ 48);
        ch = getchar();
    }
    return w ? -X : X;
}

int64 ans;
int64 tmp[MAXN];
void merge_sort(int l, int r) {
    if (l == r) return;
    int mid = (l + r) >> 1;
    merge_sort(l, mid);
    merge_sort(mid + 1, r);
    int i = l, j = mid + 1;
    int k = l;
    while (i <= mid && j <= r) {
        if (v[i] <= v[j]) {
            tmp[k++] = v[i++];
            ans += r - j + 1;
        } else {
            tmp[k++] = v[j++];
        }
    }
    while (i <= mid) {
        tmp[k++] = v[i++];
    }
    while (j <= r) {
        tmp[k++] = v[j++];
    }
    for (int i = l; i <= r; i++) {
        v[i] = tmp[i];
    }
}

int main() {
    int n = read();
    int64 k = read();
    for (int i = 2; i <= n + 1; i++) {
        a[i] = read();
        sum[i] = sum[i - 1] + a[i];
        v[i] = sum[i] - k * (i - 1);
    }
    merge_sort(1, n + 1);
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int x[45][4];
int n, p[45][2], a, minx, cnt;
int main() {
	while (true) {
		memset(x, 127, sizeof(x));
		minx = 1000000000;
		cin >> n;
		if (n == 0) { break; }
		for (int i = 1; i <= n; i++) {
			cin >> p[i][0] >> p[i][1];
		}
		x[0][0] = 0;
		for (int i = 1; i <= n; i++) {
			cnt = 0;
			for (int j = 0; j < 4; j++) {
				if (x[i - 1][j] < 10000000) {
					a = abs(p[i][0] - p[i - 1][0]);
					if ((j + 1)*a <= p[i][1] - p[i - 1][1] && j < 3) {
						x[i][j + 1] = min(x[i][j + 1], x[i - 1][j] + a);
						cnt++;
					}
					a = p[i - 1][0] * (j + 1) + p[i][0];
					if (a <= p[i][1] - p[i - 1][1]) {
						x[i][1] = min(x[i][1], x[i - 1][j] + p[i - 1][0] + p[i][0]);
						cnt++;
					}
				}
			}
			if (cnt == 0) {
				cout << "NG " << i << endl;
				goto E;
			}
		}
		minx = 100000000;
		for (int i = 0; i < 4; i++) {
			minx = min(minx, x[n][i]);
		}
		cout << "OK " << minx + p[n][0] << endl;
	E:;
	}
}

Measured memory_bytes: 1160