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

int main(){
    ll n;
    cin >> n;
    vector<ll> L(n);
    for (ll i = 0; i < n; i++){
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    reverse(L.begin(),L.end());
    int counter = 0;
    for (ll i = 0; i < n-2; i++){
        for (ll j = i+1; j < n-1; j++){
            for (ll k = j+1; k<n; k++){
                if (L[i] != L[j] && L[i] != L[k] && L[j] != L[k]){
                    if (L[i]-L[j] < L[k]){
                        counter++;
                    }
                }
            }
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 3624
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(String);

    if s.chars().zip(s.chars().skip(1)).all(|(c1,c2)| c1 == c2) {
        println!("0");
        return;
    }
    let set = s.chars().collect::<BTreeSet<_>>();

    let mut mn = std::usize::MAX;
    for c in set {
        let mut s = s.chars().collect::<Vec<_>>();
        let mut count = 0;
        loop {
            count += 1;
            let mut tmp = vec!['a'; s.len()-1];
            for i in 0..s.len()-1 {
                tmp[i] = if s[i] == c || s[i+1] == c {
                    c
                } else {
                    s[i]
                };
            }
            if tmp.iter().all(|&e| e == c) {
                break;
            }
            s = tmp;
        }
        mn = min!(mn, count);
    }
    println!("{}", mn);
}


Measured memory_bytes: 8572
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a==b)cout<<"a"<<" == "<<"b"<<endl;
    if(a>b)cout<<"a"<<" > "<<"b"<<endl;
    if(a<b)cout<<"a"<<" < "<<"b"<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include <map>
#include <vector>
#include <iostream>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



map<int,int> ma;
int N;




int main() {
  while (cin >> N) {
      ma.clear();
      for (int i = 0; i < N; ++i) {
          int a; cin >> a;
          ma[a]++;
      }
      int res = 0;
      for (map<int,int>::iterator it = ma.begin(); it != ma.end(); ++it) {
          int add = 0;
          if (it->second >= it->first) add = (it->second - it->first);
          else add = it->second;
          res += add;
      }
      cout << res << endl;
  }
}


















Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;

int main() {
	int n;
	cin >> n;
	vi s(n);
	int a = 0;
	rep(i, 0, n) {
		cin >> s[i];
		a += s[i];
	}
	sort(all(s));
	vi dp(n + 1);
	dp[0] = 0;
	rep(i, 0, n) {
		int sum = a - s[i];
		if (sum % 10 == 0) {
			sum = 0;
		}
		dp[i + 1] = max(dp[i], sum);
	}
	if (a % 10 == 0) {
		a = 0;
	}
	cout << max(dp[n], a) << endl;
	return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n; scan(n);
      Int res = 0;
      for(Int i = 0; i < n; ++i) {
         Int x, y; scan(x, y);
         res += y - x + 1;
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
    cin>>n;
    int ans=0;
    for(int i=0;i*i<=n;i++)
    {
        if(i*i<=n)
        ans=i*i;
        else break;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
  int ap,bp,cp;
  int x,y;
  int max,min;
  int kane;
  cin >> ap >> bp >> cp >> x >> y;
  bool a,b,c;
  a = ap > 2 * cp;
  b = bp > 2 * cp;
  c = ap + bp > 2 * cp;

  if(x > y){
      max = x;
      min = y;
  }else{
      max = y;
      min = x;
  }

  if(a && b){
      kane = (2 * max) * cp;
  }else if(a){
      if(max == x){
          kane = (2 * max) * cp;
      }else if(max = y){
          kane = (2 * min) * cp + (max - min) * bp;
      }
  }else if(b){
      if(max == y){
          kane = (2 * max) * cp;
      }else if(max == x){
          kane = (2 * min) * cp + (max - min) * ap;
      }
  }else if(c){
      if(max == y){
          kane = (2 * min) * cp + (max - min) * bp;
      }else if(max == x){
          kane = (2 * min) * cp + (max - min) * ap;
      }
  }else{
      kane = x * ap + y * bp;
  }
  cout << kane << endl;
  }

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

int main() {
    string s;
    cin >> s;
    bool flag = false;
    for (int i = 0; i+1 < s.size(); i++) {
        if (s[i] == 'A' && s[i+1]== 'C') {
            flag = true;
            break;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

r = [0] * (n+1)
g = [0] * (n+1)
b = [0] * (n+1)
for i, c in enumerate(reversed(s), 1):
    if c == 'R':
        r[i] += r[i-1] + 1
    else:
        r[i] += r[i-1]
    
    if c == 'G':
        g[i] += g[i-1] + 1
    else:
        g[i] += g[i-1]
    
    if c == 'B':
        b[i] += b[i-1] + 1
    else:
        b[i] += b[i-1]

r = r[:-1][::-1]
g = g[:-1][::-1]
b = b[:-1][::-1]

ans=0
for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        se = set('RGB') - set(s[i] + s[j])
        c = se.pop()
        if c == 'R':
            ans += r[j]
            if 2*j-i < n and s[2*j-i] == 'R':
                ans -= 1
        elif c == 'G':
            # print('j=',j,'g[j]=',g[j])
            ans += g[j]
            if 2*j-i < n and s[2*j-i] == 'G':
                ans -= 1
        elif c == 'B':
            ans += b[j]
            if 2*j-i < n and s[2*j-i] == 'B':
                ans -= 1
        # print('i=',i,'j=',j,'c=',c, 'ans=',ans)
print(ans)

Measured memory_bytes: 74496
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int x,y; cin >> x >> y;
    
  // 前処理
    COMinit();
/*
    // 計算例
    cout << COM(100000, 50000) << endl;  
*/
  if((x+y)%3 != 0){
    cout << 0 << endl;
    return 0;
  }
  
  int n = (2*y-x)/3, m = (2*x-y)/3;
  cout << COM(n+m,n) << endl;
  
  return 0;
}

Measured memory_bytes: 23680
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int n, k, pl[3], ans = 0;
	int be[100005];
	cin >> n >> k >> pl[0] >> pl[1] >> pl[2];
	string s;
	cin >> s;
	rep(i, n) {
		int wi;
		if (s[i] == 'r') wi = 2;
		else if (s[i] == 's') wi = 0;
		else wi = 1;
		if (i < k) {
			ans += pl[wi];
			be[i] = wi;
		}
		else {
			if (be[i - k] == wi) be[i] = -1;
			else {
				be[i] = wi;
				ans += pl[wi];
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1280
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
from bisect import insort
sys.setrecursionlimit(10**9)

def main():
    N = int(input())

    ans = 0
    if N % 2 == 0:
        max = math.ceil(math.log(10**18/2,5))
        for i in range(1,max):
            ans += N // (pow(5,i) * 2)

    print(ans)


if __name__ == "__main__":
  main()


Measured memory_bytes: 13704
import java.util.*;

public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int D = sc.nextInt();
      int range = 2 * D + 1;
      int numGuard =  (int)Math.ceil(N / (double)range);
      System.out.println(numGuard);
    }
}

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

using ll = long long; using vi = vector<int>; using vll = vector<ll>;
using vvi = vector<vi>; using vvll = vector<vll>;
const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll INF_MAX = numeric_limits<ll>::max();

int main() {
  int n;
  cin >> n;
  vll arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr.rbegin(), arr.rend());
  ll max1 = 0;
  ll max2 = 0;
  for (int i = 0; i < arr.size() - 1; ++i) {
    if (arr[i] == arr[i + 1]) {
      if (max1 == 0) {
        max1 = arr[i];
        ++i;
      } else {
        max2 = arr[i];
        break;
      }
    }
  }
  cout << max1 * max2 << endl;
}


Measured memory_bytes: 1024
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;

    namespace ConsoleApp2
    {
        class Program
        {


            static void Main(string[] args)
            {
            var N = long.Parse(Console.ReadLine());
            //var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var task = new Tuple<long,long>[N];
            for (int i = 0; i < N; i++)
            {
                var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                task[i] = new Tuple<long, long>(AB[1],AB[0]);
            }
            Sort(task);

            var sum = 0L;
            var ans = true;
            for (int i = 0; i < N; i++)
            {
                sum += task[i].Item2;
                if(sum > task[i].Item1)
                {
                    ans = false;
                }
            }
                Console.WriteLine(ans ? "Yes" : "No");
            }
        }
    }


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

using ll = long long int;
#define int ll

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

struct Read {
	int operator()(void) {
		int d;
		std::cin >> d;
		return d;
	}
}read;
struct ReadReal {
	double operator()(void) {
		double d;
		std::cin >> d;
		return d;
	}
}readReal;
struct ReadString {
	std::string operator()(void) {
		std::string s;
		std::cin >> s;
		return s;
	}
}readString;
struct ReadEof {
	bool operator()(void) {
		return std::cin.eof();
	}
}readEof;

struct Print {
	void operator()(double d, int digit) {
		std::cout << std::fixed << std::setprecision(digit) << d;
	}
	template <typename T>
	void operator()(T t) {
		std::cout << t;
	}
	template <typename T>
	void operator()(const std::vector<T> &v, const std::string &sep = " ") {
		if (v.empty()) return;
		Print()(v[0]);
		for(int i = 1;  i < v.size(); ++i) {
			Print()(sep);
			Print()(v[i]);
		}
		return;
	}
	template <typename T>
	void operator()(T begin, T end, const std::string &sep = " ") {
		if (begin == end) return;
		Print()(*begin);
		for(auto it = ++begin;  it != end; ++it) {
			Print()(sep);
			Print()(*it);
		}
		return;
	}
}print;
struct Println {
	void operator()(void) {
		std::cout << std::endl;
	}
	void operator()(double d, int digit) {
		print(d, digit);
		Println()();
	}
	template <typename T>
	void operator()(T t) {
		print(t);
		Println()();
	}
	template <typename T>
	void operator()(const std::vector<T> &v, const std::string &sep = " ") {
		print(v, sep);
		Println()();
	}
	template <typename T>
	void operator()(T begin, T end, const std::string &sep = " ") {
		print(begin, end, sep);
		Println()();
		return;
	}
}println;

constexpr int kStackMax = 100;
class Stack {
public:
	Stack():m_Index(0), m_Stack() {
	}
	void Push(int c) {
		if (m_Index > kStackMax) return;
		m_Stack[m_Index] = c;
		m_Index++;
	}
	int Pop(void) {
		if (m_Index <= 0) return '\0';
		m_Index--;
		return m_Stack[m_Index];
	}
	bool isEmpty() const {
		return m_Index <= 0 ? true : false;
	}
private:
	int m_Index;
	int m_Stack[kStackMax];
};
int ReversePolishNotaion(void) {
	auto p = Stack();
	for(auto s = readString(); !readEof(); s = readString()) {
		if (isdigit(s[0])) {
			p.Push(stoll(s));
		} else {
			int rhs = p.Pop();
			int lhs = p.Pop();
			int result = 0;
			switch ((s[0])) {
			case '+':
				result = lhs + rhs;
				break;
			case '-':
				result = lhs - rhs;
				break;
			case '*':
				result = lhs * rhs;
				break;
			}
			p.Push(result);
		}
	}
	return p.Pop();
}
signed main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int result = ReversePolishNotaion();
	println(result);
	return 0;
}



Measured memory_bytes: 3216
#include <iostream>

using namespace std;
int main(int argc, const char * argv[]) {
    int a,b;
    cin >> a >> b;
    if(((a*b) % 2) == 0){
        cout << "Even" << endl;
    } else{
        cout << "Odd" << endl;
    }
    
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

	ll N;
	cin >> N;

	ll ans = powl(10,13.0);

	for(ll i=2;i*i<=N;i++){
		if(N%i != 0) continue;
		ll j = N/i;
		ans = min(ans, (i+j-2));
	}
	if(ans == powl(10,13.0)) ans = N-1;

	cout << ans << "\n";

return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <queue>
#include <cmath>
#include <array>

typedef long long ll;

int main(int argc, char *argv[])
{
    int n;
    std::vector<int> a;

    std::cin >> n;

    a.resize(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    ll cash = 1000;
    ll stocks = 0;
    ll price;

    stocks = cash / a[0];
    price = a[0];
    cash = cash % price;

    for (int i = 1; i < n; i++) {
        const ll current_price = a[i];

        if (price < current_price) {
            price = current_price;
        } else if (price > current_price) {
            // 売る
            cash += price * stocks;
            // 買う
            price = current_price;
            stocks = cash / price;
            cash = cash % price;
        }
    }
    cash += price * stocks;

    std::cout << cash << std::endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

bool same(vector<pair<ll, ll>> &A) {
    rep(i, A.size()){
        if(A[i].first != A[i].second) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<pair<ll, ll>> A(N);
    rep(i, N) cin >> A[i].first >> A[i].second;
    if(same(A)){
        output(0);
        return 0;
    }
    ll mi = inf;
    ll sum = 0;
    rep(i, N) {
        sum += A[i].first;
        if(A[i].first > A[i].second) mi = min(mi, A[i].second);
    }
    output(sum - mi);
    
    
    return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, M, Q = ZZ()
    lr = sorted([ZZ() for _ in range(M)])
    query = [ZZ() for _ in range(Q)]
    p = [[0] * (N+1) for _ in range(N+1)]
    for l, r in lr: p[l][r] += 1
    for i in range(1, N+1)[::-1]:
        for j in range(1, N+1):
            if j+1 <= N: p[i][j+1] += p[i][j]
            if 0 <= i-1: p[i-1][j] += p[i][j]
            if j+1 <= N and 0 <= i-1: p[i-1][j+1] -= p[i][j]
    for a, b in query: print(p[a][b])

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 54508
#include<stdio.h>

int main(void)
{
 int a,b,c,m;
 scanf("%d %d %d",&a,&b,&c);
 if(a>b){
  m=a;
  a=b;
  b=m;
  if(b>c){
   m=b;
   b=c;
   c=m;
  }
 }else{
  if(b>c){
   m=b;
   b=c;
   c=m;
  }
 }
 if(a>b){
  m=a;
  a=b;
  b=m;
 }

 printf("%d %d %d\n",a,b,c);
}

Measured memory_bytes: 2740
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	int lr[1000][1000];
	rep(i, 0, N + 1) {
		rep(j, 0, N + 1) {
			lr[i][j] = 0;
		}
	}
	rep(i, 0, M) {
		int l, r;
		cin >> l >> r;
		++lr[l][r];
	}
	rep(i, 1, N + 1) {
		rep(j, 1, N + 1) {
			lr[i][j] += lr[i][j - 1]; 
		}
	}
	rep(i, 1, N + 1) {
		rep(j, 1, N + 1) {
			lr[j][i] += lr[j - 1][i]; 
		}
	}
	rep(i, 0, Q) {
		int p, q;
		cin >> p >> q;
		cout << lr[q][q] - lr[p-1][q] - lr[q][p-1] + lr[p-1][p-1] << endl;
	}
}


Measured memory_bytes: 3712
A, B, M = [int(x) for x in input().split()]

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
XYC = [[int(x) for x in input().split()] for _ in range(M)]

ans = min(a) + min(b)

for x, y, c in XYC:
    ans = min(ans, a[x - 1] + b[y - 1] - c)

print(ans)



Measured memory_bytes: 32496
import sys
input = sys.stdin.readline

import math
cos60 = math.cos(math.radians(60))
sin60 = math.sin(math.radians(60))

n =  int(input())

def koch(d, p, q):#p,qはリストでp[0]がx座標、p[1]がy座標
    if d == 0:
        return
    s=[0,0]
    t=[0,0]
    u=[0,0]
    s[0] = (2 * p[0] + q[0]) / 3
    s[1] = (2 * p[1] + q[1]) / 3
    t[0] = (p[0] + 2 * q[0]) / 3
    t[1] = (p[1] + 2 * q[1]) / 3
    u[0] = (t[0] - s[0]) * cos60 - (t[1] - s[1]) * sin60 + s[0]
    u[1] = (t[0] - s[0]) * sin60 + (t[1] - s[1]) * cos60 + s[1]
    
    koch(d-1, p, s)
    print(s[0], s[1])
    koch(d-1, s, u)
    print(u[0], u[1])
    koch(d-1, u, t)
    print(t[0], t[1])
    koch(d-1, t, q)

a = [0, 0]
b = [100, 0]

print(a[0], a[1])
koch(n, a, b)
print(b[0], b[1])


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
const ll mod = 998244353l;
ll pow(ll a, ll n) {
	if (n == 0)return 1;
	ll d = pow(a, n / 2);
	if (n & 1)return a * d%mod*d%mod;
	return d * d%mod;
}
vl fact, rfact;
ll comb(ll n, ll k) {
	return fact[n] * rfact[k] % mod*rfact[n - k] % mod;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b, k;
	cin >> n >> a >> b >> k;
	ll ans = 0;
	fact.resize(n + 1);
	rfact.resize(n + 1);
	fact[0] = 1;
	REP(i, n) {
		fact[i + 1] = fact[i] * (i + 1) % mod;
	}
	REP(i, n + 1) {
		rfact[i] = pow(fact[i], mod - 2);
	}

	REP(i, n + 1) {
		ll cnt = i * a;
		ll rem = k - cnt;
		if (rem < 0)break;
		if (rem%b != 0||rem/b>n)continue;
		//cout << comb(n, i) << " " << comb(n, rem / b) << endl;
		ans += comb(n, i)*comb(n, rem / b) % mod;
		ans %= mod;
	}
	//cout << comb(n, n) << endl;
	cout << ans << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}

int R, G, B, N;
int32_t main(){_

   cin>>R>>G>>B>>N;
      
   int ans = 0;
   for (int r = 0; r <= N; ++r)  
   {
      for (int g = 0; g <= N; ++g)
      {
         int sum = r*R + g*G;
         int rem = N - sum;
         if (rem < 0){
            continue;
         }
         if (rem % B){
            continue;
         }
         ans++;
      }
   }

   cout<<ans;

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 100000000;

int n, dp[3][10002], t;
bool input[2][10002];
int cost[3][3][4] = {
  {{1, 2, 4, 4},{2, 2, 3, 3},{3, 3, 3, 3}},
  {{2, 2, 3, 3},{1, 2, 2, 3},{2, 3, 2, 3}},
  {{3, 3, 3, 3},{2, 3, 2, 3},{1, 4, 2, 4}}
};

main(){
  cin >> t;
  while(t--){
    cin >> n;
    fill(input[0], input[2], false);
    for(int i=0;i<2;i++){
      for(int j=0;j<2*n;j++){
        char c;
        cin >> c;
        if(c == 'Y') input[i][(j+1)/2] = true;
      }
    }
    fill(dp[0], dp[3], INF);
    for(int i=0;i<3;i++) dp[i][0] = i;
    for(int j=0;j<=n;j++){
      for(int i=0;i<3;i++){
        int s;
        if(input[0][j] && input[1][j]) s = 3;
        else if(input[0][j]) s = 1;
        else if(input[1][j]) s = 2;
        else s = 0;
        for(int k=0;k<3;k++){
          dp[k][j+1] = min(dp[k][j+1], dp[i][j] + cost[i][k][s]);
        }
      }
    }
    cout << dp[0][n+1]-1 << endl;
  }
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
  int N;
  while(cin>>N,N){
	int sum[1024], st[1024];
	fill(sum, sum+1024, 0);
	fill(st, st+1024, -1);

	REP(i,N){
	  int M,D,h,m,id; char ch;
	  scanf("%d/%d %d:%d %c %d", &M, &D, &h, &m, &ch, &id);
	  int t = h * 60 + m;
	  if(ch == 'I')
		st[id] = t;
	  else{
		if(id == 0){
		  FOR(j,1,1024){
			if(st[j] > 0){
			  sum[j] += t - max(st[0], st[j]);
			}
		  }
		  st[id] = -1;
		}
		else{
		  if(st[0] > 0)
			sum[id] += t - max(st[0], st[id]);
		  st[id] = -1;
		}
	  }
	}
	int ans = 0;
	REP(i,1024) ans = max(ans, sum[i]);
	cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  string S;
  cin >> S;
  int a = 0;
  ll ans = 0;
  rep(i, S.size())
  {
    if (S[i] == 'B')
    {
      ++a;
    }
    else
    {
      ans += a;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 644
import java.util.*;

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

        int N = sc.nextInt();

        for(int i=1; i<10; i++){
            if(N%i==0 && N/i<10){
                System.out.println("Yes");
                break;
            }
            if(i==9){
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };
ll n, a;
signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> n >> a;
	cout << n*n - a<<endl;

	return 0;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string t,p;
  cin>>t>>p;
  for(int i=0;i<((int)t.size())-((int)p.size())+1;i++){
    if(t.substr(i,p.size())==p) cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 3228
#include<stdio.h>
#define M 100000

int A[M];

int partition(int A[],int r){
	int x=A[r];
	int i=0;
	for(int j=0;j<r;j++){
		if(A[j]<=x){
			int tmp=A[i];
			A[i]=A[j];
			A[j]=tmp;
			i++;
		}
	}
	int temp=A[i];
	A[i]=A[r];
	A[r]=temp;
	return i;
}

int main(){
	int i,n,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	j=partition(A,n-1);
	for(i=0;i<j;i++) printf("%d ",A[i]);
	printf("[%d]",A[i]);
	for(i++;i<n;i++) printf(" %d",A[i]);
	printf("\n");
}


Measured memory_bytes: 3076
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

const int NIL = -1;
struct Node {
    int left;
    int right;
};

Node T[500000];
int root = NIL;

void printInOrder(int i) {
    if (i == NIL) {
        return;
    }
    printInOrder(T[i].left);
    printf(" %d", i);
    printInOrder(T[i].right);
}

void printPreOrder(int i) {
    if (i == NIL) {
        return;
    }
    printf(" %d", i);
    printPreOrder(T[i].left);
    printPreOrder(T[i].right);
}

void insert(int i) {
    //??°???????????\???????????????????????????NIL
    T[i].left = T[i].right = NIL;
    //??????????????£???
    if (root == NIL) {
        root = i;
        return;
    }
    //x??§dig??????
    int y;
    int x = root;
    while (x != NIL) {
        y = x;
        if (i < x) {
            x = T[x].left;
        }
        else {
            x = T[x].right;
        }
    }
    if (i < y) {
        T[y].left = i;
    }
    else {
        T[y].right = i;
    }
}

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

    string com;
    int key;
    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            cin >> key;
            insert(key);
        }
        else {
            printInOrder(root);
            printf("\n");
            printPreOrder(root);
            printf("\n");
        }
    }

    return 0;
}

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

int main(){
    int x[101],y[101];
    int n,i;
    double dist1=0.0;
    double dist2=0.0;
    double dist3=0.0;
    double disti=0.0;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&y[i]);
    }
    
    /*case:p=1*/
    
    for(i=0;i<n;i++){
        dist1+=fabs((double)x[i]-y[i]);
    }
    
    /*case:p=2*/
    
    for(i=0;i<n;i++){
        dist2+=pow(fabs((double)x[i]-y[i]),2);
    }
    
    /*case:p=3*/
    
    for(i=0;i<n;i++){
        dist3+=pow(fabs((double)x[i]-y[i]),3);
    }
    
    /*case:p=inf*/
    for(i=0;i<n;i++){
        if(disti<abs(x[i]-y[i])) disti=abs(x[i]-y[i]);
    }

    printf("%lf\n%lf\n%lf\n%lf\n",dist1,sqrt(dist2),cbrt(dist3),disti);
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
inline ll mul(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll c=a*b;
  c=(c+MOD)%MOD;
  return c;
}
inline ll add(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll ans=(a+b);
  ans=(ans+MOD)%MOD;
  return ans;
}

ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=mul(ans,a);
    }
    a=mul(a,a);
    b=b/2;
  }
  return ans;
}
inline ll max(ll a,ll b){return a>b?a:b;}
inline ll min(ll a,ll b){return a<b?a:b;}
int main()
{
  ll n; cin>>n;
  ll a[n];for(int i=0;i<n;++i)cin>>a[i];
  ll dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;++i){
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1];
  return 0;
}

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

using namespace std;

const int LIM = 2010;

vector<long long> a(LIM), buf(LIM);
long long ans = 1e+18;

int main() {
  int n;
  long long x;
  cin >> n >> x;
  for (int i = 0; i < n; ++i)
    cin >> a[i];

  for (int shift = 0; shift < n; ++shift) {
    long long cur = x * shift;

    for (int i = 0; i < n; ++i) {
      cur += a[i];
      buf[i] = min(a[i], a[(i + n - 1) % n]);
    }
    swap(buf, a);
    ans = min(ans, cur);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int n;
  cin>>n;
  vector<ll> v(n+1);
  map<ll,ll> mp;
  for(int i=1;i<=n;i++)
  {
    cin>>v[i];
    if(mp.find(i-v[i])==mp.end())
      mp[i-v[i]]=1;
    else
    mp[i-v[i]]++;
  }
  ll ans=0;
  for(int i=1;i<=n;i++)
  {
    ll sum=(i+v[i]);
    if(mp.find(sum)!=mp.end())
    ans+=mp[sum];
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 16244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 100005;

int N;

// dp[0] is no flip, [1] is flip
ll dp[MX][2];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N;
    vector<ll> a(N);
    for (auto& i : a) cin >> i;
    
    dp[0][0] = a[0], dp[0][1] = -a[0];
    for (int i = 1; i < N; i++) {
		dp[i][0] = max(dp[i - 1][0] + a[i], dp[i - 1][1] + -a[i]);
		dp[i][1] = max(dp[i - 1][0] + -a[i], dp[i - 1][1] + a[i]);
		// cout << dp[i][0] << " " << dp[i][1] << "\n";
	}
    
    cout << dp[N - 1][0];
    return 0;
}


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

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "E869120") {
      ans++;
    }
  }

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


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll n;
  cin>>n;

  auto is_prime = [](ll x){
    for(ll p=2;p*p<=x;++p){
      if(x%p==0)return false;
    }
    return true;
  };

  for(ll x=n;;++x){
    if(is_prime(x)){
      cout<<x<<endl;
      return 0;
    }
  }

}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [[0 for i in range(m)] for j in range(n)]
b = [0 for i in  range(m)]
c = [0 for i in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))
for j in range(m):
    b[j] = int(input())
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
for i in range(n):
    print (c[i])


Measured memory_bytes: 5968
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(((a == b && c == 7) || (b == c && a == 7) || (c == a && b == 7)) && a + b + c == 17){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        Deque<Integer> list = new ArrayDeque<>();

        for (int i = 0; i < n; i++) {
            String sp = br.readLine();
            if (sp.startsWith("insert")) {
                list.addFirst(Integer.parseInt(sp.substring(sp.indexOf(" ") + 1)));
            } else if (sp.equals("deleteFirst")) {
                list.removeFirst();
            } else if (sp.equals("deleteLast")) {
                list.removeLast();
            } else {
                list.remove(Integer.parseInt(sp.substring(sp.indexOf(" ") + 1)));
            }
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringBuilder ans = new StringBuilder();
        ans.append(list.poll());
        for (Integer s : list) {
            ans.append(" ");
            ans.append(s);
        }
        bw.write(ans.toString());
        bw.newLine();
        bw.close();
        br.close();
    }
}



Measured memory_bytes: 124872
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int num1 = scan.nextInt();
		
		scan.close();
		int sum = 0;
		int sum_base = 1;
		int output = 0;
		
		sum = num1 * num1;
		output = sum / sum_base;
		
		System.out.println(output);
		
	}
}


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

long long _abs(long long a) {
	return a<0 ? -a : a;
}
int main() {
	long long x,y;
	scanf("%lld%lld",&x,&y);
	if(_abs(x-y)<=1) puts("Brown");
	else puts("Alice");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
 
  while(x->left!=NIL){
    x = x->left;
    return x;
  }
 
}
 
Node treeMaximum(Node x){
 
  while(x->right!=NIL){
    x = x->right;
    return x;
  }
 
}
 
Node treeSearch(Node u, int k){
 
  if(u==NIL || k==u->key){
    return u;
      }
  if(k<u->key){
    return treeSearch(u->left,k);
    }
    else{
      return treeSearch(u->right,k);
    }
}
 
Node treeSuccessor(Node x){
  Node y;
 
  if(x->right !=NIL){
    return treeMinimum(x->right);
  }
  y=x->parent;
 
  while(y!=NIL && x!=y->right){
    x=y;
    y=y->parent;
  }
  return y;
 
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
 
 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
    z->parent=y;
 
    if(y==NIL) root = z;
    else if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right=z;
    }
  }
 
 
void inorder(Node u){
  if(u!=NIL){
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
 }
}
  
   
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL)preorder(u->left);
  if(u->right!=NIL) preorder(u->right);
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

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

#define all(v)  begin(v), end(v)
#define endl    '\n';
#define int     long long
#define pii     pair<int, int>
#define sz(x)   (int) x.size()

void test_case() {
    string s; cin >> s;
    int n = sz(s);

    vector<int> pos;
    for (int i = 0; i <= n-2; i++) {
        if (s[i] == 'R' && s[i+1] == 'L') 
            pos.push_back(i);
    }
    vector<int> cnt(n, 0);
    for (int i = 0; i < n; i++) {
        auto it = lower_bound(all(pos), i);
        if (s[i] == 'L') {
            it = upper_bound(all(pos), i);
            it--;
        }
        cnt[*it + (abs(i - *it) & 1)]++;
    }
    for (int& x : cnt)
        cout << x << ' ';
    cout << endl;
}

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

    int t = 1;
    // cin >> t;

    while (t--) { 
        test_case();
    }
    return 0;
}


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

long long min_vec(long long* p, int n){
    long long min = 1000000;
    for (int j=0; j<n; j++) if (*(p+j) < min) min = *(p+j);
    return min;
}

long long max_vec(long long* p, int n){
    long long max = -1000000;
    for (int j=0; j<n; j++) if (*(p+j) > max) max = *(p+j);
    return max;
}

long long sum_vec(long long* p, int n){
    long long sum = 0;
    for (int j=0; j<n; j++) sum += *(p+j);
    return sum;
}

int main(){
    int n;
    cin >> n;
    vector<long long> vec(n);
    for (int i=0;i<n;i++) cin >> vec.at(i);
    cout << min_vec(&vec.at(0),n) << " "
         << max_vec(&vec.at(0),n) << " "
         << sum_vec(&vec.at(0),n) << endl;
/*    cout << *min_element(vec.begin(),vec.end()) << " "
         << *max_element(vec.begin(),vec.end()) << " "
         << accumulate(vec.begin(),vec.end(),0) << endl;*/
}


Measured memory_bytes: 3172