akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a, b;

cin >> a >>b;
  double x = a; double y = b;
long c = a/b;
long d = a%b;
long double e = x/y;
cout << c << ' ' << d << ' ' << fixed << setprecision(10)<< e << endl;
}


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


int main(){
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    rep(i, a, b+1){
        string k = to_string(i);
        int s = k.size();
        bool match = 1;
        rep(j, 0, s/2){
            if (k[j] != k[s-1-j]){
                match = 0;
                break;
            }
        }
        if (match) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,a[1001],ans;
	cin>>n;
	for(int i=1;i<=n;i++)
	  {
	  	cin>>a[i];
	  }
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++)
	  {
	  	ans+=a[i];
	  }
	ans+=a[n]/2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
let modulo = 2019
let ( *% ) a b = (a * b) mod modulo

exception Zero
        
let () =
  let (l, r) = Scanf.sscanf (input_line stdin) "%d %d" (fun a b -> (a, b)) in
  let rec loop_l i min_i =
    if min_i = 0 then raise Zero
    else if i >= r then min_i else
      let rec loop_r j min_j =
        if min_j = 0 then raise Zero 
        else if j > r then min_j
        else loop_r (j + 1) (min (i *% j) min_j) in
      loop_l (i + 1) (min (loop_r (i + 1) 2019) min_i) 
  in
  let ans = try (if l - r > 2019 then 0
                 else loop_l l 2019)
            with Zero -> 0 
  in
  print_int ans;
  print_newline ()


Measured memory_bytes: 384
//Author: Suifeng0214
//2020.6.30 19.03
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[100010][4];
int arr[100010][4];
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> arr[i][1] >> arr[i][2] >> arr[i][3]; 
	}
	for (int i = 1 ; i <= 3; i++){
		dp[0][i] = arr[0][i];
	}
	for (int i = 1; i < n; i++){
		dp[i][1] = max(dp[i-1][2] + arr[i][1], dp[i-1][3] + arr[i][1]);
		dp[i][2] = max(dp[i-1][1] + arr[i][2], dp[i-1][3] + arr[i][2]);
		dp[i][3] = max(dp[i-1][1] + arr[i][3], dp[i-1][2] + arr[i][3]);
	}
	
	cout << max(dp[n-1][1], max(dp[n-1][2], dp[n-1][3]));
} 

Measured memory_bytes: 9796
def find_next_prime(n):
    return find_prime_in_range(n, 2*n)

def find_prime_in_range(a, b):
    for p in range(a, b):
        for i in range(2, p):
            if p % i == 0:
                break
        else:
            return p
    return None

def main():
    X = int(input())
    
    print(find_next_prime(X))

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import Data.List
import Data.Array.IO
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BC8

type Arr = IOUArray Int Int

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- newListArray (0, n - 1) =<< (sort . map (fst . fromJust . BC8.readInt) . BC8.words) <$> BC8.getLine :: IO Arr
  bs <- (sort . map (fst . fromJust . BC8.readInt) . BC8.words) <$> BC8.getLine :: IO [Int]
  cs <- newListArray (0, n - 1) =<< (sort . map (fst . fromJust . BC8.readInt) . BC8.words) <$> BC8.getLine :: IO Arr
  print =<< solve as bs cs n

solve :: Arr -> [Int] -> Arr -> Int -> IO Int
solve as bs cs n = do
  -- bList <- getElems bs
  counts <- forM bs $ \b -> solveB as b cs n
  return $ sum counts

solveB :: Arr -> Int -> Arr -> Int -> IO Int
solveB as b cs n = do
  upperA <- upperBound as b n
  lowerC <- lowerBound cs b n
  -- putStrLn $ printf "b = %d, upperA = %d, lowerC = %d" b upperA lowerC
  return ((upperA + 1) * (n - lowerC))

upperBound :: Arr -> Int -> Int -> IO Int
upperBound arr k n = _upperBound (-1) n
  where
    _upperBound :: Int -> Int -> IO Int
    _upperBound left right
      | right - left <= 1 = return left
      | otherwise = do
          let center = (left + right) `div` 2
          cVal <- readArray arr center
          if cVal < k
            then _upperBound center right
            else _upperBound left center

lowerBound :: Arr -> Int -> Int -> IO Int
lowerBound arr k n = _lowerBound (-1) n
    where
      _lowerBound :: Int -> Int -> IO Int
      _lowerBound left right
        | right - left <= 1 = return right
        | otherwise = do
            let center = (left + right) `div` 2
            cVal <- readArray arr center
            if cVal <= k
              then _lowerBound center right
              else _lowerBound left center

Measured memory_bytes: 34940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
ll a[N];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n, k, s;
	cin >> n >> k >> s;
	for (int i = 1; i <= k; i++) {
		a[i] = s;
	}
	if (n - k < s) {
		for (int i = k + 1; i <= n; i++) {
			a[i] = 1;
		}
	} else {
		for (int i = k + 1; i <= n; i++) {
			a[i] = min(s + 1, (ll) 1e9);
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 2176
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  REP(i,n) cin >> s[i];
  sort(s.begin(),s.end());
  REP(i,n) cout << s[i];
  cout << endl;
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

int main(int argc, char** argv) {
  string s;
  cin >> s;

  vector<int> cnts(27, 0);
  int len = s.size();
  rep(i, len) {
    int idx = s[i] - 'A';
    cnts[idx] += 1;
  }

  // For Debug
  // rep(i, cnts.size()) {
  //   cout << (char)('A' + i) << ": " << cnts[i] << ", ";
  // }

  int cnts_len = cnts.size();
  rep(i, cnts_len) {
    if ((cnts[i] == 0) || cnts[i] == 2) { // OK
      continue;
    } else { // No
      cout << "No";
      return 0;
    }
  }

 cout << "Yes";
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s, ans;
  ll n;
  cin >> s;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  if(s.back() == '2' or s.back() == '4' or s.back() == '5' or s.back() == '7' or s.back() == '9') ans = "hon";
  else if(s.back() == '0' or s.back() == '1' or s.back() == '6' or s.back() == '8') ans = "pon";
  else ans = "bon";
  cout << ans << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";

}

Measured memory_bytes: 3652
n, m, c = (int(i) for i in input().split())
B = [int(i) for i in input().split()]
A = [input() for j in range(n)]

import numpy as np

b = np.array(B)

num = 0
for i in range(n):
    aa = np.array([int(j) for j in A[i].split()])
    if np.sum(aa.dot(b)) + c > 0:
         num += 1
print(num)

Measured memory_bytes: 12300
#include <stdio.h>
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right+1;
  pivot = left;   // 先頭要素をpivotとする


  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--;  } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
 //printf("   ");
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);


/*
while(i<j){
    while(array[i]<array[pivot]){i++;}
    while(array[j]>array[pivot]){j--;}
    if(i<j){swap(&array[i],&array[j]);}
}
*/
  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
      //printf("Q");
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}
int main(void){
    int N,i,mochi[100];
    int total=1;
    scanf("%d",&N);
    for(i=0;i<N;i++)scanf("%d",&mochi[i]);
    
    quick_sort(mochi,0,N-1);
    
    for(i=1;i<N;i++){
        if(mochi[i]>mochi[i-1])total++;
    }
    printf("%d",total);
    
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int n, t, a;
string S, T;
main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> S >> T;
		t += (S>T)*3 + (S==T);
		a += (S<T)*3 + (S==T);
	}
	cout << t << " " << a << endl;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define uy q.front()
#define SIZE (ll)(1e6)
#define mod (ll)(1e9+7)
using namespace std;
typedef long long  ll;
int main(){
int n;cin>>n;
int ar[n][3],dp[n][3];
for(int i=0;i<n;i++){
  for(int j=0;j<3;j++)
   { cin>>ar[i][j];
  }
}



dp[0][0]=ar[0][0];
dp[0][1]=ar[0][1];
dp[0][2]=ar[0][2];
int cnt=0;
for(int i=1;i<n;i++){
 
for(int j=0;j<3;j++){
  
    dp[i][j]=max((dp[i-1][(j+1)%3]+ar[i][j]),(dp[i-1][(j+2)%3]+ar[i][j]));
  }}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));return 0;}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int N; cin >> N;
    int B[110] = {0}; REP(i, N - 1) cin >> B[i];
    ll res = B[0];

    if(N == 2) res += B[0];
    else{
        REP(i, N - 1){
        res += min(B[i], B[i + 1]);
        }
        res += B[N - 2];
    }
    cout << res << endl;
}

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

double dis(double x,double y){
  return sqrt(x*x+y*y);
}

int main(){
  int n;

  while(cin >> n , n != -1){
    double x = 1.0,y = 0.0;
    for(int i = 0 ; i < n-1 ; i++){
      double nx = -y / dis(x,y);
      double ny = x / dis(x,y); 
      x += nx;
      y += ny;
    }
    printf("%.5f %.5f\n" ,x ,y);
  }

  return 0;
}

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

int main()
{
  int N;
  int res=0;
  cin >> N;

  rep(i,N) {
    int l,r;
    cin >> l>>r;
    res += r-l+1;
  }

  cout << res << endl;
}


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

int n, k;
vector<int> a;

int ans;
vector<vector<int>> G;

int dfs(int v = 0) {
  int res = 0;
  for (auto &to : G[v]) {
    res = max(res, dfs(to));
  }

  if (a[v] && res == k - 1) {
    res = -1;
    ans++;
  }
  return res + 1;
}

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

  a.resize(n);
  for (auto &i : a) cin >> i, i--;

  if (a[0] != 0) {
    a[0] = 0;
    ans++;
  }

  G.resize(n);
  for (int i = 1; i < n; ++i) {
    G[a[i]].push_back(i);
  }

  dfs();

  cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int main() {
	int a, b;
	cin >> a >> b;
	double ret = 0.0;

	for (int i = 1; i <= a; i++) {
		double tmp = 1.0 / a;
		int now = i;
		while (now < b) {
			now *= 2;
			tmp /= 2;
		}
		ret += tmp;
	}

	cout << fixed << setprecision(12) << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
using namespace std;
using ll = long long;
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; }

map<char,char> tsa,tsb;

int main() {
  string S,T;
  cin >> S >> T;
  bool flug = true;

  FOR(i,0,S.size()-1){
    char s = S[i], t = T[i];
    if(tsa.count(s)) if(tsa[s] != t) flug = false;
    if(tsb.count(t)) if(tsb[t] != s) flug = false;
    tsa[s] = t; tsb[t] = s;
  }

  if(flug == true) cout << "Yes" << endl;
  else cout << "No" << endl;

}



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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

ll mk;

bool cnt(int target, vi& arr) {
    int n = arr.size(); 
    ll res = 0;
    FOR(i, 0, n) {
        int lo = 0, hi = n - 1, r = -1;
        while(lo <= hi) {
            int mid = (lo + hi) >> 1;
            if(arr[i] + arr[mid] >= target) {
                r = max(r, mid);
                lo = mid + 1;
            } else hi = mid - 1;
        }

        if(r >= 0) {
            res += (r + 1);
        }
    }
    return (res >= mk);
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;cin>>n>>mk;
    vi arr(n);
    FOR(i, 0, n) cin>>arr[i];
    sort(all(arr), greater<int>());
    int lo = arr[n - 1] + arr[n - 1], hi = arr[0] + arr[0];
    int m = 0;
    while(lo <= hi) {
        int mid = (lo + hi) >> 1;
        if(cnt(mid, arr)) {
            m = max(mid, m);
            lo = mid + 1;
        } else hi = mid - 1;
    }
    // deb(m);
    ll res = 0; ll counter = 0;
    vll cumsum(n, 0);
    FOR(i, 0, n) {
        cumsum[i] = ((i) ? cumsum[i - 1] : 0) + 1LL * arr[i];
    }
    FOR(l, 0, n) {
        int lo = 0, hi = n - 1, r = -1;
        while(lo <= hi) {
            int mid = (lo + hi) >> 1;
            if(arr[l] + arr[mid] >= (m + 1)) {
                r = max(r, mid);
                lo = mid + 1;
            } else hi = mid - 1;
        }

        if(r >= 0) {
            counter += (r + 1);
            res += 1LL * cumsum[r] + (r + 1) * 1LL * arr[l];
        }
    }
    // deb(counter);
    assert(counter <= mk);
    res += (mk - counter) * 1LL * m;
    cout << res;
    return 0;
}

Measured memory_bytes: 4512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b;
    string x;
    cin >> a >> b;
    for (int i=0;i<a;++i){
        for (int j=0;j<b;++j){
            cin >> x;
            if (x=="snuke"){
                cout << (char)('A'+j) << i+1 << endl;
                break;
            }
        }
    }
    return 0;
}


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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,k,cnt=0;
    cin >> n >> k;
    while(n) {
    	cnt++;
    	n/=k;
    }
    cout << cnt << "\n";
    return 0;
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

d=False#単調減少
u=False#単調増加

cnt=0

for i in range(0,n-1):
  l=a[i];r=a[i+1]
  if l<r:u=True
  elif l>r:d=True
    
  if u and d:
    cnt+=1
    u=False;d=False
print(cnt+1)
  

Measured memory_bytes: 14252
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
int m, n, ru1, ru2;
set<int>sete;
    bool dale = true;
int main()
{
	cin>>n>>m;
	vector<int>num (n, -1);
	for(int i = 0; i<m;i++){
	    cin>>ru1>>ru2;
	    ru1--;
	    if((ru1 == 0 && ru2 == 0 && n != 1) || (num[ru1] != -1 && ru2 != num[ru1])){
	        dale = false;
	        break;
	    }else{
	        num[ru1] = ru2;
	    }
	}
	for(int i = 0; i<n;i++){
	    if(i == 0 && num[i] == -1){
	        if(n == 1 && m == 0){
	            num[i] = 0;
	        }else{
	            num[i] = 1;
	        }
	    }else if(num[i] == -1){
	        num[i] = 0;
	    }
	}

	if(dale){
	    for(int i = 0; i<n;i++){
	        cout<<num[i];
	    }
	    cout<<"\n";
	}else{
	    cout<<"-1\n";
	}
    return 0;
}
/*
a b c
d e f
g h i
/**/

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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++)
        cin >> p[i];
    vector<int> sum(N + 1);
    for (int i = 0; i < N; i++)
        sum[i + 1] = sum[i] + p[i];
    int ma = 0;
    for (int i = K; i <= N; i++) {
        ma = max(ma, sum[i] - sum[i - K]);
    }
    printf("%lf\n", (K + ma) * 0.5);
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
typedef vector<iii> viii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

void solve() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

void querySolve() {
    int n;
    cin >> n;
    while (n--) {
        solve();
    }
}

int main() {
    //querySolve();
    solve();
    
}


Measured memory_bytes: 3568
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)

ans=n*a.max
[0,1].repeated_permutation(n).to_a.each do |bit|
    curr=0
    b=[a[0]]
    curr_max=a[0]
    count=1
    1.upto(n-1) do |i|
        if bit[i]==1 && a[i]<=curr_max
            curr+=curr_max+1-a[i]
            b<<curr_max+1
            curr_max+=1
            count+=1
        else
            b<<a[i]
            if a[i]>curr_max
                curr_max=a[i]
                count+=1
            end
        end
    end
    if count>=k
        ans=curr if curr<ans
    end
end
puts ans


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

sum=0

for i in range(N-1):
  if((X[i+1]-X[i])*A>=B):
    sum+=B
  else:
    sum+=A*(X[i+1]-X[i])
    
print(sum)

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

using namespace std;

using ll = long long;

struct IsFriend {
    template<class TPair>
    constexpr bool operator()(const TPair &x, const TPair &y) {
        return x.first < y.first && x.second < y.second;
    }
};

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

    std::vector<std::pair<int, int>> reds(N);

    std::vector<std::pair<int, int>> blues(N);

    for (int i = 0; i < N; ++i) {
        cin >> reds[i].first >> reds[i].second;
    }

    std::sort(reds.begin(), reds.end(), [](const auto &x, const auto &y) {
        return x.second > y.second;
    });

    for (int b = 0; b < N; ++b) {
        cin >> blues[b].first >> blues[b].second;
    }
    std::sort(blues.begin(), blues.end(), [](const auto &x, const auto &y) {
        return x.first < y.first;
    });

    std::set<std::pair<int, int>> set_red;

    ll ans = 0;
    for (const auto &b : blues) {
        for (const auto &r : reds) {
            if (IsFriend()(r, b)) {
                if (set_red.find(r) == set_red.cend()) {
                    set_red.emplace(r);
                    ++ans;
                    break;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++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 all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  VEC(A,N);
  rep(i,N)
    cin>>A[i];
  sort all(A);
  cout<<A[N-1]-A[0]<<endl;

}
  






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

int main()
{
    bool Flg = true;

    int N, M;
    cin >> N >> M;

    int range_l = pow(10, N-1);
    if (range_l == 1) range_l = 0;
    int range_h = pow(10, N);

    int s[M];
    int c[M];
    for(int i = 0; i < M; i++){
        cin >> s[i] >> c[i];
    }

    for(int i = range_l; i < range_h; i++){
        int x = i;
        int num[N];
        for (int n = 0; n < N; n++){
            num[n] = -1;
        }

        int count = 0;
        Flg = true;

        while(true){
            int r = x % 10;
            int q = x / 10;

            num[count] = r;
            x = q;
            if(q == 0) break;
            ++count;
        }

        int a = num[0];
        num[0] = num[N-1];
        num[N-1] = a;

        for(int j = 0; j < M; j++){
            if(num[s[j]-1] != c[j]) Flg = false;
        }
        
        if (Flg) {
            cout << i << endl;
            break;
        }
    }

    if(!Flg) cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from typing import List


if __name__ == "__main__":
    heap: List[int] = []

    while True:
        op, *value = input().split()
        if "end" == op:
            break
        if "insert" == op:
            heappush(heap, - int(value[0]))
        else:
            print(- heappop(heap))



Measured memory_bytes: 46820
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define pb push_back
#define mp make_pair
#define re return
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF=1e9;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef queue <int> qi;
int a[100100],n,m;
int sumn=0;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>a[i];
		sumn+=a[i];
	}
	cout<< (sumn>=n? "Yes":"No");
	return 0;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll a=in(),b=in(),c=in(),k=in();
    ll i,j;
    for(i=0;b<=a;++i)b<<=1;
    for(j=0;c<=b;++j)c<<=1;
    cout<<(i+j<=k?"Yes":"No")<<endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

void solve(long long N, std::vector<std::string> S){
    map<string, ll > rec;
    REP(i, N){
        rec[S[i]]++;
    }
    vector<pair<ll, string> > a;
    for(auto x: rec){
        a.push_back(make_pair(-x.second, x.first));
    }
    sort(ALL(a));
    ll ans = -a[0].first;
    //cout<<ans<<endl;
    set<string> b;
    for(auto t: a){
        if(t.first == -ans){
            b.insert(t.second);
        }
        else{ break;}
    }
    for(auto x: b){
        cout<<x<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

int main(){
	double w,h,x,y;
	cin >> w >> h >> x >> y;
	bool f[2] = {false,false};
	if(fabs(w/2-x)<DBL_EPSILON) f[0] = true;
	if(fabs(h/2-y)<DBL_EPSILON) f[1] = true;
  cout << fixed << setprecision(10) << w*h/2 << " ";
  if(f[0]&&f[1]){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

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

#define ll long long
#define MD 1000000007
#define mod(n) ((n%MD+MD)%MD)
#define max(x, y) (x>y? x : y)
#define min(x, y) (x<y? x : y)
#define mul3(x, y, z) (mod(mod(x*y)*z)) 

ll modpow(ll x, ll y){
    ll res = 1;
    while(y>0){
        if(y&1) res = mod(res*x);
        x = mod(x*x);
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return modpow(n, MD-2);
}

ll memo_fact[1000000*2] = {0};
ll fact(ll n){
    if(memo_fact[n]) return memo_fact[n];
    ll m = n;
    memo_fact[0] = 1;
    while(memo_fact[m]==0) m--;
    for(ll i=m+1;i<=n;i++) memo_fact[i] = memo_fact[i-1]*i%MD;
    return memo_fact[n];
}

ll comb(ll n, ll r){
    return mul3(fact(n), inv(fact(r)), inv(fact(n-r)));
}


int main(){
    ll K;
    char S[1000000];
    scanf("%lld%s", &K, S);
    // end input

    ll s_len = 0;
    for(;s_len<(ll)1e6;s_len++){
        if(!S[s_len]) break;
    }

    ll ans = 0;
    for(ll i=K;i>=0;i--){
        ll t = mul3(comb(s_len+i-1, i), modpow(25, i), modpow(26, K-i));
        ans = mod(ans + t);
    }
    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 18240
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
int n;
int main() {
	cin >> n;
	ll per[n];
	ll sum = 0, mx = -1;	
	for(ll& x : per) cin >> x;
	for(int i = 0; i < n; ++i) {
		mx = max(mx, per[i]);
		sum += (mx - per[i]);		
	}
	cout << sum;
  return 0;
}

Measured memory_bytes: 5096
H, W = map(int, input().split())
S = [input() for _ in range(H)]
for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      continue
    b = 0
    if i > 0 and S[i-1][j] == '#':
      b += 1
    if i > 0 and j < W-1 and S[i-1][j+1] == '#':
      b += 1
    if j < W-1 and S[i][j+1] == '#':
      b += 1
    if i < H-1 and j < W-1 and S[i+1][j+1] == '#':
      b += 1
    if i < H-1 and S[i+1][j] == '#':
      b += 1
    if i < H-1 and j > 0 and S[i+1][j-1] == '#':
      b += 1
    if j > 0 and S[i][j-1] == '#':
      b += 1
    if i > 0 and j > 0 and S[i-1][j-1] == '#':
      b += 1
    #print(S[i])
    if j == 0:
      S[i] = str(b) + S[i][j+1:]
    elif j == W-1:
      S[i] = S[i][:j] + str(b)
    else:
      S[i] = S[i][:j] + str(b) + S[i][j+1:]
    #print(S[i])

for i in range(H):
  print("".join(S[i]))


Measured memory_bytes: 3064
n = input()
A = input().split(' ')
A.sort()
A.reverse()
q = input()
M = input().split(' ')

A = list(map(int,A))
M = list(map(int,M))
A.sort()

A_sum = [0]
for a in A:
    A_sum.append(a+A_sum[-1])
A_sum.pop(0)

A.reverse()
A_sum.reverse()


#memo = [True]*(len(A))

def search(base, m, n):
    if base == m:
        return True
    if len(A)-1 < n or m - base > A_sum[n]:
        return False
    result = False
    for i in range(len(A)-1,n-1,-1):
        if base + A[i] <= m: # and memo[i]:
#           memo[i] = False
#           print(str(A[i]) + ',' + str(base+A[i]) + ',')
            if search(base+A[i], m, i+1):
                return True
#           memo[i] = True
    return result

def print_yn(result):
    if result:
        print('yes')
    else:
        print('no')

for m in M:
#   print(str(m)+':')
    print_yn(search(0,m,0))

Measured memory_bytes: 7788
#include <cstdio>
#include<iostream>
#include<string>

using namespace std;
   
int main(void){

	int botto[10];
	string inp;

	while(cin>>inp){
		for(int i=0;i<10;i++){
			botto[i]=inp[i]-'0';
		}
		for(int i=0;i<10-1;i++){
			for(int j=0;j<10-i-1;j++){
				botto[j]=(botto[j]+botto[j+1])%10;
			}
		}
		cout<<botto[0]<<endl;
	}

    return 0;
}

Measured memory_bytes: 1180
t=int(input())
f=[]
for i in range(t):
    s=input()
    f.append(s)
print("AC"+' '+'x'+' '+str((f.count("AC"))))
print("WA"+' '+'x'+' '+str((f.count("WA"))))
print("TLE"+' '+'x'+' '+str((f.count("TLE"))))
print("RE"+' '+'x'+' '+str((f.count("RE"))))


Measured memory_bytes: 79136
#include <cstdio>
#include <vector>
#include <algorithm>
#define INF 100000000
using namespace std;
typedef pair<int,int> P;

int n,m;
int d[101][101];

int main(){
  while(scanf("%d %d",&n,&m),n){
    for(int i=1; i<=n; i++)
      for(int j=1; j<=n; j++)
	d[i][j] = i==j?0:INF;

    for(int i=0; i<m; i++){
      int a,b,c;
      scanf("%d %d %d",&a,&b,&c);
      d[a][b]=d[b][a]=c;
    }

    vector<P> hoge;
    for(int i=1; i<=n; i++)
      for(int j=1; j<=n; j++)
	for(int k=1; k<=n; k++){
	  if(i==k||j==k) continue;
	  if((d[i][k]<INF)&&(d[k][j]<INF)){
	    hoge.push_back(P(i,j));
	    break;
	  }
	}

    for(int k=1; k<=n; k++)
      for(int i=1; i<=n; i++)
	for(int j=1; j<=n; j++)
	  d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

    int ans=INF;
    for(int i=0; i<hoge.size(); i++)
      ans=min(ans,d[1][hoge[i].first]+d[hoge[i].second][n]);
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 884
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0) {
		cout << "Possible" << endl;
			return 0;
	}

	if (b % 3 == 0) {
		cout << "Possible" << endl;
		return 0;
	}

	if ((a+b) % 3 == 0) {
		cout << "Possible" << endl;
		return 0;
	}
	
	cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N; cin >> N;
    vector<int> vec(N+1);
    rep2(i, 2, N+1) {
        int tmp = i;
        for (int j = 2; j*j <= tmp; j++) {
            while (tmp%j == 0) {
                vec[j]++;
                tmp/=j;
            }
        }
        if (tmp != 1) vec[tmp]++;
    }
    sort(ALL(vec));
    int cnt75 = vec.end() - lower_bound(ALL(vec), 74);
    int cnt25 = (vec.end() - lower_bound(ALL(vec), 24)) * max(0, (int)(vec.end() - lower_bound(ALL(vec), 2) - 1));
    int cnt15 = (vec.end() - lower_bound(ALL(vec), 14)) * max(0, (int)(vec.end() - lower_bound(ALL(vec), 4) - 1));
    int cnt5 = (vec.end() - lower_bound(ALL(vec), 4)) * max(0, (int)(vec.end() - lower_bound(ALL(vec), 4) - 1)) / 2 * max(0, (int)(vec.end() - lower_bound(ALL(vec), 2) - 2));
    int ans = cnt75 + cnt25 + cnt15 + cnt5;
    cout << ans << endl;
    //rep(i, N) cout << vec[i+1] << " ";
    //cout << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,x,i,j,k,m=0,p;
    cin >> a >> b >> c >> x;
    
    for(i=0;i<=a;i++)
    {

        for(j=0;j<=b;j++)
        {

           for(k=0;k<=c;k++)
           {
               p=(i*500)+(j*100)+(k*50); 
               if(p==x)
               {
                    m++;
               }  
           }   
        }
    }          

    cout << m << endl;
 
    return 0;

}


Measured memory_bytes: 3544
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int N=sc.nextInt(),res=0;
        HashMap<Integer,Integer> c=new HashMap<>();
        for(int i=0;i<N;i++){
            int t=sc.nextInt();
            for(int j=-1;j<=1;j++){
                if(!c.containsKey(t+j)){
                    c.put(t+j,1);
                }else{
                    c.put(t+j,c.get(t+j)+1);
                }
            }
        }
        for(int i:c.keySet()){
            res=Math.max(res,c.get(i));
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 65904
#include <bits/stdc++.h> 
#include <iostream>
#include <cmath>

using namespace std;
int main() {
  long long n;
  cin >> n;
  long long ans = n - 1;
  for(long long i = 1; i <= sqrt(n); i++) {
    if(n % i == 0) {
      ans = min(ans,(n / i)+ i - 2);
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  int B;
  int C;
  int D;
  cin >>A>>B>>C>>D;
 int x=max(A,C);
  int y=min(B,D);
  cout<<max(y-x,0)<< endl;
}

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

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n, k;
  long long sol = 0;
  cin >> n >> k;
  for (long long i=k; i<n+2; ++i)
    sol+=(i*n-i*i+i+1) % MOD;
  cout << sol%MOD;
}

Measured memory_bytes: 3664
n = int(input())
s = input()
ans = 0
for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = s.find(str(j),a+1)
        if b == -1:
            continue
        for k in range(10):
            if s.find(str(k),b+1) != -1:
                ans += 1
print(ans)

Measured memory_bytes: 9280
# Aizu Problem 0064: Secret Number
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N = 0
while True:
    try:
        string = input().strip()
    except EOFError:
        break
    string = ''.join([s if '0' <= s <= '9' else ' ' for s in string ])
    for k in string.split():
        N += int(k)
print(N)

Measured memory_bytes: 7824
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		if (k == 1) {
			System.out.println(0);
		} else {
			int out = n - k;
			System.out.println(out);
		}

	}
}

Measured memory_bytes: 23892
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         long sum = 0L;
         for(int i=1; i <= N; i++)
            if(i%3 != 0 && i%5 != 0)
               sum += i;
         System.out.println(sum);
      }
   }

Measured memory_bytes: 32800
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	double max_density = 0.0;
	int ans_w, ans_s;
	for(int i = 0; i <= 30; i++){
		for(int j = 0; j <= 30; j++){
			int w = (a * i + b * j) * 100;
			int lim_s = (a * i + b * j) * e;
			for(int k = 0; k <= 100; k++){
				for(int l = 0; l <= 100; l++){
					int s = c * k + d * l;
					double density = (double)s / ((double)s + (double)w);
					if(density >= max_density && s <= lim_s && w + s <= f){
					max_density = density;
					ans_w = w;
					ans_s = s;
					}
				}
			}
		}
	}
	printf("%d %d\n", ans_w + ans_s, ans_s);
	return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 1e5;
ll N;
ll A[MAX_N], B[MAX_N];

int main(){
  ll N; scanf("%lld", &N);
  REP(i, N) scanf("%lld%lld", &A[i], &B[i]);
  ll ans = 0;
  for(ll i = N - 1; i >= 0; i--){
    ans += residue(-(A[i] + ans),B[i]);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){

  int H,W,h,w;
  cin >> H >> W >> h >> w;

  cout << H*W-(W*h)-(w*(H-h)) << endl;


}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);
const int iINF = (1 << 31)-1;
const double dINF = 1000000000000000000.0;
const int MAX_N = 1 << 17;
typedef pair<pii, int> EDGE;

int main(){
	int n, k; cin >> n >> k;
	int ans = k;
	for (int i = 1; i < n; i++) {
		ans *= k - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var (
	sc = bufio.NewReader(os.Stdin)
)

func main() {
	S := scanStr()
	count := 0
	maxC := 0
	last := true
	for _, s := range S {
		if s == 'R' {
			count++
			if maxC == 0 {
				maxC = 1
			}
			if last {
				if maxC < count {
					maxC = count
				}
			}
			last = true
		} else {
			last = false
			count = 0
		}
	}
	fmt.Println(maxC)
}

func absInt(a int) int      { return int(math.Abs(float64(a))) }
func scan(a ...interface{}) { _, err := fmt.Fscan(sc, a...); pnc(err) }
func scanStr() (s string)   { scan(&s); return }
func scanInt() int          { i, err := strconv.Atoi(scanStr()); pnc(err); return i }
func scanFloat() float64    { f, err := strconv.ParseFloat(scanStr(), 64); pnc(err); return f }
func pnc(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 1840
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>

#define REP(i,n) for(int i=0; i < n; ++i)
#define EACH(it,c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); ++it)

using namespace std;

int main() {
	std::ios::sync_with_stdio();

	int m;
	cin >> m; 
	REP(i,m) {
		int firstMoney, year, n;
		cin >> firstMoney;
		cin >> year;
		cin >> n;
		
		int result = 0;
		REP(j,n) {
			int type, addition;
			double percent;
			cin >> type >> percent >> addition;

			// calc
			int tmpMoney = firstMoney;
			int benefit = 0;
			if(type) {
				REP(k, year) {
					tmpMoney = tmpMoney * (1.0 + percent) - addition;
				}
				result = max(result, tmpMoney);
			} else {
				REP(k, year) {
					benefit += tmpMoney * percent;
					tmpMoney -= addition;
				}
				result = max(result, tmpMoney + benefit);
			}
		}
		cout << result << endl; 
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(i * j == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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


public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        String[] s=reader.readLine().split(" ");
        int n=Integer.parseInt(s[0]);
        int m=Integer.parseInt(s[1]);
        String[] s1=reader.readLine().split(" ");
        int[] days=new int[m];
        int count=0;
        for (int i = 0; i <m ; i++) {
            days[i]=Integer.parseInt(s1[i]);
            count+=days[i];
        }
        if (count<=n)
            System.out.println(n-count);
        else if (count>n)
            System.out.println(-1);

    }

}

Measured memory_bytes: 34352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	long long BA,BB,BC,AA,AB,AC;
	cin>>BA>>BB>>BC;
	if(BA==BB&&BB==BC&&BA%2==0&&BC%2==0&&BB%2==0)
	{
		cout<<-1<<endl;
		return 0;
	}
	else
	{
		long long count=0;
		while(BA%2==0&&BB%2==0&&BC%2==0)
		{
			AA=BB/2+BC/2;
			AB=BA/2+BC/2;
			AC=BA/2+BB/2;
			BA=AA;BB=AB;BC=AC;
			count+=1;
		}
		cout<<count<<endl;
	}
}

Measured memory_bytes: 256
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

fn main() {
    let (n, sd) = readl!(usize, i64);
    let d = readlvec!(i64);
    let qn = readl!(usize);
    let q = readlvec!(usize);
    let mut xs = vec![0; n+1];
    xs[n] = 1;
    for i in (0..n).rev() {
        if xs[i+1] <= d[i]/2 {
            xs[i] = xs[i+1];
        } else {
            xs[i] = xs[i+1]+d[i];
        }
    }
    // debug!(xs);

    use std::cmp::{min, max};
    let mut ans = Vec::with_capacity(n);
    let mut p = sd;
    for i in 0..n {
        // debug!(i); debug!(p);
        ans.push(xs[i+1] <= p);
        p = min(p, (p-d[i]).abs());
    }

    // debug!(ans);
    let mut s = String::new();
    for &q in &q {
        // debug!(q);
        if ans[q-1] {
            s.push_str("YES\n");
        } else {
            s.push_str("NO\n");
        }
    }
    print!("{}", s);

    // let sd = sd as usize;
    // let mut dp = vec![false; sd+1];
    // dp[0] = true;
    // for &d in d.iter().rev() {
    //     let mut nex = vec![false; sd+1];
    //     for i in 0..sd+1 {
    //         nex[i] = dp[min(i, max(i as i64 - d, d - i as i64) as usize)];
    //     }
    //     dp = nex;
    //     debug!(d);
    //     for &v in &dp {
    //         if v {
    //             print!("1 ");
    //         } else {
    //             print!("0 ");
    //         }
    //     }
    //     println!("");
    // }
}



Measured memory_bytes: 21404