akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i ,n) cin >> a[i];
    int q; cin >> q;
    rep(i ,q){
        int com, b , e;
        int _min , _max;
        cin >> com >> b >> e;
        if( com == 0 ) {
            _min = 1000000001;
            auto itr = a.begin() + b;
            while( itr != a.begin() + e ){
                if( *itr < _min ) _min = *itr;
                ++itr;
            }
            /*if( _min == 1000000001 ) cout << a[b] << endl;
            else*/ cout << _min << endl;
        } else if ( com == 1 ){
            _max = -1000000001;
            auto itr = a.begin() + b;
            while( itr != a.begin() + e ){
                if( *itr > _max) _max = *itr;
                ++itr;
            }
            /*if( _max == -1000000001 ) cout << a[e-1] << endl;
            else*/ cout << _max << endl;
        }
    }
}


Measured memory_bytes: 3112
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P)
{
    int i = 0;
    for (int j = 0; j < k; j++)
    {
        llong s = 0;
        while (s + T[i] <= P)
        {
            s += T[i];
            i++;
            if (i == n)
                return n;
        }
    }
    return i;
}

int solve()
{
    llong left = 0;
    llong right = 100000 * 10000;
    llong mid;

    while (right - left > 1)
    {
        mid = (left + right) / 2;
        int v = check(mid);
        if (v >= n)
            right = mid;
        else
            left = mid;
    }

    return right;
}

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> T[i];
    llong ans = solve();
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,y;
    cin >> n >> y;
    bool flag = false;
    int a,b;
    for(int i = 0;i <= ceil(y / 10000.0);i++)
    {
        for(int j = 0;j <= ceil(y / 5000.0);j++)
        {
            int left = y - (10000 * i + 5000 * j);
            int right = 1000 * (n - (i + j));
            if(left == right && n >= (i + j))
            {
                flag = true;
                a = i;
                b = j;
                break;
            }
        }
    }
    if(flag)
    {
        cout << a << " " << b << " " << n - (a + b) << "\n";
    }
    else
    {
        cout << "-1 -1 -1\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
H=0
W=0
i=0
while i<n-1:
    if a[i]==a[i+1]:
        if H==0:
            H=a[i]
            i+=2
        else:
            W=a[i]
            break
    else:
        i+=1
print(H*W)

Measured memory_bytes: 20008
import java.util.*;
	import java.lang.Math;
    public class Main
	{
		public static void main(String args[])
		{
			Scanner scan = new Scanner(System.in);
			int a = scan.nextInt();
			int b = scan.nextInt();
			int[] arr1= new int[100];
			int[] arr2= new int[100];
			for(int i=0;i<a;i++)
			{
				arr1[i]=arr1[i]+b;
			}
			
			for(int i=0;i<b;i++)
			{
				arr2[i]=arr2[i]+a;
			}
			if(b<a){
			for(int i=0;i<a;i++)
			{
				System.out.print(""+arr1[i]+"");
			}
			}
			else{
			for(int i=0;i<b;i++)
			{
				System.out.print(""+arr2[i]+"");
			}
			}
		}
    }

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int n,k,a,b,p[107],s,i,j;
int main(){
    for(cin>>n>>k,i=0;i++<k;)
        for(cin>>a,j=0;j++<a;) cin>>b, p[b]=1;
    for(i=s=0;i<n;) s+=(!p[++i]);
    cout<<s;
}

Measured memory_bytes: 3180
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdint.h>

using namespace std;

int main () {

  long N, a;
  cin >> N;
  vector<int> top, middle, bottom;

  for (int i = 0; i < N; ++i){
    cin >> a;
    top.push_back(a);
  }

  for (int i = 0; i < N; ++i){
    cin >> a;
    middle.push_back(a);
  }

  for (int i = 0; i < N; ++i){
    cin >> a;
    bottom.push_back(a);
  }

  sort(top.begin(), top.end());
  sort(bottom.begin(), bottom.end());

  long num = 0;

  for (int i = 0; i < N; ++i) {
    num += distance(top.begin(), lower_bound(top.begin(), top.end() , middle[i]))
    * (N - distance(bottom.begin(), upper_bound(bottom.begin(), bottom.end() , middle[i])));
  }

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("modulo.in","r",stdin);
	//freopen("modulo.out","w",stdout);
	int n,i;
	int a=0,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		ans+=a;
	}
	printf("%d",ans-n);
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
import  math

while True:
    n=int(input())
    if n==0:
        break

    score=list(map(int,input().split()))
    m=float(sum(score)/n)
    er=[(score[i]-m)**2 for i in range(n)]
    var=sum(er)/n
    sigma=math.sqrt(var)
    print(sigma)


Measured memory_bytes: 5712
#include <stdio.h>

int main(void) {
  char n[3], i;

  for(i = 0;i < 3;i++) {
    n[i] = getchar();
  }
  if(n[0] == n[2]) {
    printf("Yes\n");
    return(0);
  }
  else {
    printf("No\n");
    return(0);
  }
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	v[0]--;
	for(int i=1;i<n;i++){
		if(v[i]<v[i-1]) return cout<<"No", 0;
		if(v[i]==v[i-1])  continue;
		v[i]--;
	}
	cout<<"Yes";
}

Measured memory_bytes: 640
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const __int128 INF = 1e18;
__int128 n, x, res;

__int128 read() {
    __int128 x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
void print(__int128 x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

int main() {
  init_ios();
  res = 1;
  n = read();
  bool fl = false;
  while (n--) {
    x = read();
    if (x == 0)
      fl = true;
    if (res == -1)
      continue;
    res *= x;
    if (res > INF)
      res = -1;
  }
  if (fl)
    res = 0;
  print(res);
}

Measured memory_bytes: 3620
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x)
	l,r = 1, length(a)
	while l <= r
		m = l+div(r-l,2)
		if a[m] < x
			l = m+1
		else
			r = m-1
		end
	end
	return(l-1)
end

function main()
	n = parseInt(readline())
	a = parseMap(split(readline()))
	a = sort(a)
	b = parseMap(split(readline()))
	b = sort(b)
	bb = Int[]
	c = parseMap(split(readline()))
	cc = Int[]
	for i in 1:n
		push!(cc, bsearch(b,c[i]))
	end
	push!(bb, bsearch(a,b[1]))
	for i in 2:n
		push!(bb, bsearch(a,b[i])+bb[length(bb)])
	end
	sum = 0
	for i in 1:length(cc)
    	if cc[i] > 0
			sum += bb[cc[i]]
    	end
    end
	print(sum)
end

main()

Measured memory_bytes: 137988
#include<iostream>
#include<algorithm>
#include<string>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int h, w, dp[110][110];
char map[110][110];
signed main() {
	cin >> h >> w;
	for1(i, h)for1(j, w) {
		cin >> map[i][j];
		if (i == 1 && j == 1);
		else if (i == 1)dp[i][j] = dp[i][j - 1] + (map[i][j] != map[i][j - 1]);
		else if (j == 1)dp[i][j] = dp[i - 1][j] + (map[i][j] != map[i - 1][j]);
		else dp[i][j] = min(dp[i][j - 1] + (map[i][j] != map[i][j - 1]), dp[i - 1][j] + (map[i][j] != map[i - 1][j]));
	}
	if (map[1][1] != map[h][w])cout << (dp[h][w] + 1) / 2 << endl;
	else if (map[1][1] == '#')cout << dp[h][w] / 2 + 1 << endl;
	else cout << dp[h][w] / 2 << endl;
}

Measured memory_bytes: 384
#[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 (n,m) = get!(isize, isize);
    println!("{}", n*(n-1)/2+m*(m-1)/2);
}


Measured memory_bytes: 8572
//int -> ll
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define REP(i,sss,eee) for(int i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
/*****************default********************/
vi inp;
int lnds(vi &v){//Longest nondecreasing Sequence
	int n=v.size();
	if(n==0){return 0;}
	vi tail;tail.resize(n,0);
	int len=1;
	tail[0]=v[0];
	REP(i,1,n-1){
		if(v[i]>=tail[len-1]){
			tail[len++]=v[i];
		}
		else{
			auto it=upper_bound(tail.begin(),tail.begin()+len,v[i]);
			(*it)=v[i];
		}
	}
	return len;
}
int main(){
    speed
	int n;cin>>n;
	vector<int> inp(n+1);
	for(int i=1;i<=n;++i){cin>>inp[i];}
	vector<bool> sol(n+1,0);
	int tot=0;
	for(int i=n;i>=1;--i)
	{
		int pres=2*i;
		int sum=0;
		while(pres<=n)
		{
			sum+=(sol[pres]==1);
			pres+=i;
		}
		if(sum%2!=inp[i])
		{
			sol[i]=1;++tot;
		}
	}
	cout<<tot<<"\n";
	for(int i=1;i<=n;++i)
	{
		if(sol[i]){cout<<i<<" ";}
	}
}

Measured memory_bytes: 1792
using System;

namespace _0057
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int a = 1;
                string st = Console.ReadLine();
                if (st == null) { break; }
                int b = int.Parse(st);
                for (int i = 1; i <= b; i++)
                {
                    a += i;
                }
                Console.WriteLine(a);
            }
        }
    }
}

Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<(int)n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define maxn 100000
int dp[3][maxn];
int arr[3][maxn];
int main(){
    IOS;
    int n;
    cin>>n;
    rep(i,n)
        rep(j,3)
            cin>>arr[j][i];
    rep(i,3)
        dp[i][0]=arr[i][0];
    rep1(i,n){
        dp[0][i]=max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]=max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]=max(dp[0][i-1],dp[1][i-1]);
        rep(j,3)
            dp[j][i]+=arr[j][i];
    }
    cout<<max({dp[0][n-1],dp[1][n-1],dp[2][n-1]})<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _overload3(_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(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

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

  ll n,k;
  cin >> n >> k;
  n = n % k;
  ll ans = min(abs(n - k), n);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <queue>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
#define debug(x) cout << #x << ": " << x << endl

int W, H;

int solve(int x, int y, const vector<string> &table)
{
    queue<pair<int, int>> que;
    que.push(make_pair(y, x));
    vector<vector<int>> used(H, vector<int>(W, 0));
    used[y][x] = 1;
    int res = 0;
    while(que.size())
    {
        pair<int, int> p = que.front(); que.pop();
        res++;
        for(int i = 0; i < 4; i++)
        {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(nx < 0 or ny < 0 or nx >= W or ny >= H) continue;
            if(table[ny][nx] == '#' or used[ny][nx]) continue;
            used[ny][nx] = 1;
            que.push(make_pair(ny, nx));
        }
    }
    return res;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> W >> H, W or H)
    {
        vector<string> table(H);
        int sx, sy;
        for(int i = 0; i < H; i++)
        {
            cin >> table[i];
            for(int j = 0; j < table[i].size(); j++)
            {
                if(table[i][j] == '@') sx = j, sy = i;
            }
        }
        cout << solve(sx, sy, table) << endl;
    }
    return 0;
}




Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {

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

		int n = scan.nextInt();
		int i,j;
		int[] list = new int[n];

		for(i=0;i<n;i++) {
			list[i]=scan.nextInt();
		}
		for(j=1;j<=n;j++) {
			if(j==1) {
				System.out.print(list[list.length-j]);
			}else {
				System.out.print(" "+list[list.length-j]);
			}
		}
		System.out.println();
		scan.close();
	}
}



Measured memory_bytes: 26320
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...) std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template <typename T>
auto make_vector_impl(size_t sz, T t) {return std::vector<T>(sz, t);}

template <size_t N, typename T, typename U, std::enable_if_t<N == 1, std::nullptr_t> = nullptr>
auto make_vector(size_t sz, U u) {return make_vector_impl(sz, T(u));}

template <size_t N, typename T, std::enable_if_t<N == 1, std::nullptr_t> = nullptr>
auto make_vector(size_t sz) {return std::vector<T>(sz);}

template <size_t N, typename T, typename... Args, std::enable_if_t<N != 1, std::nullptr_t> = nullptr>
auto make_vector(size_t a, Args... args) {return make_vector_impl(a, make_vector<N - 1, T>(args...));}

template <typename T, typename Size_t>
auto& at(T& t, Size_t i) {return t.at(i);}

template <typename T, typename Size_t, typename... Args>
auto& at(T& t, Size_t i, Args... args) {return at(t.at(i), args...);}

template <typename T>
std::istream& operator>> (std::istream& is, std::vector<T>& v)
{
  for (auto & x : v) is >> x;
  return is;
}

template <typename T>
std::ostream& operator<< (std::ostream& os, const std::vector<T>& v)
{
  auto n = v.size();
  os << "{";
  for (size_t i = 0; i < n; i++)
    os << (i > 0 ? "," : "") << v[i];
  return os << "}";
}

int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int h, w; std::cin >> h >> w;
  auto cal = [&] (auto&& a, auto&& b)
  {
    auto cost = make_vector<2, int>(h + 1, h + 1, 0);
    for (int i = h - 1; i >= 0; i--) {
      for (auto j = h - 1; j >= 0; j--)
      {
        at(cost, i, j) = at(cost, i + 1, j + 1)
          + (at(a, h - i - 1) == at(b, h - j - 1));
      }
    }
    // debug(cost);
    constexpr int inf = 1 << 30;
    auto dp = make_vector<2, int>(h + 1, h + 1, inf);
    at(dp, 0, 0) = 0;
    rep(i, 0, h + 1) rep(j, 0, h + 1)
    {
      if (i > 0) cmn(at(dp, i, j), at(dp, i - 1, j) + at(cost, i - 1, j));
      if (j > 0) cmn(at(dp, i, j), at(dp, i, j - 1) + at(cost, i, j - 1));
    }
    // debug(dp);
    return at(dp, h, h);
  };
  auto c = make_vector<2, char>(w, h);
  rep(i, 0, h) rep(j, 0, w)
  {
    std::cin >> at(c, j, i);
  }
  auto ret = 0;
  rep(j, 0, w - 1)
    ret += cal(c.at(j), c.at(j + 1));
  std::cout << ret << std::endl;
  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, m, a[2000], b[2000], c[2000];
LL d[1000];
LL const INF = -2e12;

int main() {
	cin >> n >> m;
	inc(i, m) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
	}
	
	inc(i, n) { d[i] = INF; }
	d[0] = 0;
	
	bool inf = false;
	inc(q, n * 2) {
		bool cont = false;
		inc(i, m) {
			bool flag = false;
			if(d[ a[i] ] != INF) {
				flag = setmax(d[ b[i] ], d[ a[i] ] + c[i]);
				cont |= flag;
			}
			if(flag && q >= n && b[i] == n - 1) { inf = true; cont = false; break; }
		}
		if(! cont) { break; }
	}
	
	if(inf) { cout << "inf" << endl; }
	else { cout << d[n - 1] << endl; }
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int h,w,i,j,k,c,ny,nx,d[110][110]={};
  int Y[]={1,0};
  int X[]={0,1};
  char s[110][110]={};
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++)scanf("%s",s[i]);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++)d[i][j]=1e9;
  }
  if(s[0][0]=='#')d[0][0]=1;
  else            d[0][0]=0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      for(k=0;k<2;k++){
	ny=i+Y[k];
	nx=j+X[k];
	if(s[ny][nx]==0)continue;
	c=0;
	if(s[i][j]=='.'&&s[ny][nx]=='#')c=1;
	d[ny][nx]=MIN(d[ny][nx],d[i][j]+c);
      }
    }
  }
  printf("%d\n",d[h-1][w-1]);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=100005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

int n;
vl a;

int main(){
	Init();
	cin>>n;
	a=vl(n);
	a[0]=F[n];
	for(int i=1;i<n;i++) a[i]=(Div(F[n],i+1)+a[i-1])%mod;
	ll res=0;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		(res+=x*(a[i]+a[n-i-1]-a[0]+mod))%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<ll, ll>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<< "\n";
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    MAT(int, c, 3, 3);
    REP(i, 101) REP(j, 101) REP(k, 101){
        if(c[0][0] - i == c[1][0] - j && c[0][0] - i == c[2][0] - k &&
           c[0][1] - i == c[1][1] - j && c[0][1] - i == c[2][1] - k &&
           c[0][2] - i == c[1][2] - j && c[0][2] - i == c[2][2] - k){
                Yes; RET;
            }
    }
    No;
RET;}


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

bool isprime(int x){
  if(x==2) return true;
  else if(x<2||x%2==0) return false;

  for(int i=3;i<=sqrt(x);i+=2){
    if(x%i==0) return false;
  } 
  return true;
}

int main(){

  int n, x, cnt=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    if(isprime(x)) cnt++;
  }

  cout<<cnt<<endl;

  return 0;
}

Measured memory_bytes: 3092
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

    int N;

    cin >> N;

    vector<int> B(N - 1);

    for(int i = 0; i < N - 1; i++) {
        cin >> B[i];
    }

    int count = B[0];

    for(int i = 1; i < N - 1; i++) {
        int a = B[i];
        if(a > B[i - 1]) {
            a = B[i - 1];
        }
        count += a;
    }

    count += B[N - 2];

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n,m; cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}


Measured memory_bytes: 256
def main():
    water_a, water_b, sugar_c, sugar_d, max_sugar, max_mass = map(int, input().split())
    op_a = 30 // water_a
    op_b = 30 // water_b
    op_c = 3000 // sugar_c
    max_concentration = [water_a * 100, 0]
    for times_a in range(op_a + 1):
        for times_b in range(op_b + 1):
            for times_c in range(op_c + 1):
                now_water = water_a * times_a + water_b * times_b
                now_sugar_lim = now_water * max_sugar
                now_water *= 100
                now_sugar = sugar_c * times_c
                now_mass = now_water + now_sugar
                if max_mass < now_mass or now_water == 0 or now_sugar_lim < now_sugar:
                    break
                add = (min(max_mass - now_mass, now_sugar_lim - now_sugar) // sugar_d) * sugar_d
                now_mass += add
                now_sugar += add
                if now_mass * max_concentration[1] < sum(max_concentration) * now_sugar and now_sugar <= now_sugar_lim:
                    max_concentration = [now_water, now_sugar]
    print(sum(max_concentration), max_concentration[1])


if __name__ == '__main__':
    main()


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

int main(){
  int N, K;
  vector<int> X(4);

  for(int i = 0; i < 4; i++)
    cin >> X[i];

  sort(X.begin(), X.end());

  if(X[0]==1&&X[1]==4&&X[2]==7&&X[3]==9)
  cout << "YES" << endl;
  else
  {
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e6+3)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

vector<ll> kaijo;
ll modpow(ll x, ll n) {
    if(n==0){
        return 1;
    }else if(n%2==0){
        ll h = modpow(x,n/2);
        return h * h % MOD;
    } else {
        return x * modpow(x,n-1) % MOD;
    }
}

int main(void){
	int q;
	cin>>q;
	ll x,d,n;
	vector<ll> X,D,N;
	rep(i,q){
		cin>>x>>d>>n;
		X.push_back(x);
		D.push_back(d);
		N.push_back(n);
	}

	kaijo.push_back(1);
	reps(i,MOD){
		kaijo.push_back((kaijo[i-1] * i)%MOD);
	}

	rep(i,q){
		x = X[i]; d = D[i]; n = N[i];
		if(d == 0){
			cout<<modpow(x,n)%MOD<< endl;
			continue;
		}else{
			//  (x/d) * (x/d + 1) * ... * (x/d + n - 1) の　%MOD
			//= (x/d)の%MOD * (x/d + 1)の%MOD * ... * (x/d + n - 1)の%MOD
			//= (x/d)の%MOD * ((x/d)の%MOD + 1)%MOD * ... * ((x/d)の%MOD + n - 1)%MOD
			ll first = (x * modpow(d, MOD-2))%MOD;
			ll last = (x * modpow(d, MOD-2)%MOD + n - 1)%MOD;
			//cout<<"first: " << first<<", last: "<<last<<endl;

			if(first > last || n >= MOD || first == 0){
				//first > last : 1 * 2 * ... * last * first * first+1 * ... * MOD-1 * MOD(=0)
				cout << 0 << endl;	
			}else{
				cout << kaijo[last] * modpow(kaijo[first - 1], MOD-2) %MOD * modpow(d,n) %MOD << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 12888
#include <algorithm>
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

const auto MOD = static_cast<ll>(1e9 + 7);

ll N = 0, S = 0, ans = 0;
vector<ll> A, B, C;

int main() {
    cin >> N;
    A.resize(N); B.resize(N); C.resize(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        ll j = ceil(1.0 * A[i] / B[i]);
        C[i] = B[i] * j - A[i];
    }

    for (ll i = N - 1; i >= 0; i--) {
        ll j = ceil(1.0 * (S - C[i]) / B[i]);
        ans += C[i] - S + B[i] * j;
        S += C[i] - S + B[i] * j;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin>>n;
    if(n%1000)
    cout<<1000 - n%1000;
	else
	cout<<"0";

	return 0;
}

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

int main() {
    string s;
    cin>>s;
    string d,m,y;
    for(int i=0;i<4;i++)y+=s[i];
    for(int i=5;i<7;i++)m+=s[i];
    for(int i=8;i<10;i++)d+=s[i];
    int x,t,z;
    int f=0;
    x=stoi(d);
    t=stoi(m);
    z=stoi(y);
    if(z==2019){
        if(t<4)f=1;
        else if(t==4){
            if(x<=30)f=1;
        }else f=0;
    }else if(z<2019)f=1;
    if(f==1)cout<<"Heisei";
    else cout<<"TBD";
}

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

using namespace std;

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

   int count =1;
   int num = 0;

   while(count<B){
      count--;
      count += A;
      num++;
   }

   cout << num << endl;
}



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

int a, b, c, d;

int main() {
  cin >> a >> b >> c >> d;
  if(a + b > c + d)
    cout << "Left" << endl;
  else if(a + b < c + d)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c = map(int, input().split())
    cnt = 0

    t = min(c, a)
    cnt += t
    c -= t
    a -= t

    t = min(c, b)
    cnt += t * 2
    c -= t
    b -= t

    cnt += b
    cnt += min(c, 1)

    print(cnt)


main()


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  ll sum;
  rep(i, n){
    cin >> a[i];
    sum += a[i];
  }

  vector<ll> b(n, sum);
  ll sum2 = 0;
  rep(i, n){
    sum2 += a[i];
    b[i] -= sum2;
    b[i] %= (1000000000+7);
  }

  int ans = 0;
  rep(i, n-1){
    //ans += (a[i] * b[i]);
    ans += (a[i] * b[i]) % (1000000000+7);
    ans %= (1000000000+7);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
long long ipow(long long a, int b)
{
    if(b==1) return a;
    long long x = ipow(a, b/2);
    x = x*x%MOD;
    if(b%2==1) x = x*a%MOD;
    return x;
}

long long fact[101010];
long long invfact[101010];
long long arr[101010];
long long C(int a, int b)
{
    if(a<b) return 0;
    return fact[a]*invfact[b]%MOD*invfact[a-b]%MOD;
}
int main()
{
    fact[0] = 1;
    for(int i=1; i<101010; ++i)
        fact[i] = i*fact[i-1]%MOD;    
    for(int i=0; i<101010; ++i)
        invfact[i] = ipow(fact[i], MOD-2);
    int N, K; scanf("%d%d", &N, &K);
    for(int i=0; i<N; ++i) scanf("%lld", arr+i);
    sort(arr, arr+N);
    long long ans = 0;
    for(int i=0; i<N; ++i)
    {
        ans += arr[i]*C(i, K-1);
        ans -= arr[i]*C(N-i-1, K-1);
        ans %= MOD;
    }
    ans += MOD; ans %= MOD;
    cout << ans << endl;
    
}

Measured memory_bytes: 2560
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def lcm(n, m):
    return n * m // gcd(n, m)

LCM = 1
for a in A:
    LCM = lcm(LCM, a)

LCM %= MOD
ans = 0
for a in A:
    ans += LCM * pow(a, MOD - 2, MOD)
print(ans % MOD)


Measured memory_bytes: 4084
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-9;
using vi = vector <int>;
using vvi = vector <vi>;

int combination(int n, int k)
{
  if(k < 0 || n < k) return (0);
  int ret = 1;
  for(int i = 1; i <= k; ++i) {
    ret *= n--;
    ret /= i;
  }
  return (ret);
}

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	int v[n];
	map <int, int> mp;
	rep(i, n) {
		cin >> v[i];
		mp[v[i]]++;
	}

	sort(v, v + n);
	reverse(v, v + n);

	long double ans = 0;
	int combi = 0;
	for (int i = a; i <= b; i++) {
		long double sum = 0;
		int cnt = 1;
		for(int j = 0; j < i; j++) {
			sum += v[j];
			if(j != 0 && v[j - 1] == v[j]) {
				cnt++;
			} else {
				cnt = 1;
			}
		}
		if(ans <= sum / i + EPS) {
			if(abs(ans - sum / i) > EPS) {
				combi = 0;
			}
			ans = sum / i;
			combi += combination(mp[v[i - 1]], cnt);
		}
	}
	printf("%.10Lf\n%lld\n", ans, combi);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int isp[110000] = {}; isp[0] = isp[1] = 1;
	vector<int> p;
	map<int, int> mp;
	int cnt = 0;
	for (int i = 2; i < 110000; i++) {
		if (isp[i] == 0) {
			p.push_back(i); mp[i] = cnt; cnt++;
			for (int j = 2 * i; j < 110000; j += i)isp[j] = 1;
		}
	}
	int n, k;
	while (cin >> n>>k) {
		if (n == -1)break;
		vector<int> a;
		n++;
		while (isp[n] == 1)n++;
		for (int i = 0; i < k; i++) {
			for (int j = i; j < k; j++) {
				int sum = p[mp[n] + i] + p[mp[n] + j];
				a.push_back(sum);
			}
		}
		sort(a.begin(), a.end());
		cout << a[k - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;



int main() {
    int h, w;
    cin >> h >> w;
    vstr a(h);
    rep(i, h) cin >> a[i];

    queue<P> q;
    vvint d(h, vint(w, INF));
    rep(i, h) rep(j, w) {
        if (a[i][j] == '#') {
            d[i][j] = 0;
            q.push(make_pair(i, j));
        }
    }

    vint dx = {-1, 0, 1, 0};
    vint dy = {0, 1, 0, -1};
    while (!q.empty()) {
        P p = q.front();
        q.pop();
        rep(i, 4) {
            int nx = p.fi+dx[i];
            int ny = p.se+dy[i];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (d[nx][ny] != INF) continue;
            d[nx][ny] = d[p.fi][p.se]+1;
            q.push(make_pair(nx, ny));
        }
    }

    int ans = 0;
    rep(i, h) rep(j, w) {
        ans = max(ans, d[i][j]);
    }

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

Measured memory_bytes: 13456
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,m,v,p;
vi a;
int thres;

bool det(int i){
    if (a[i] >= thres) return true;
    int maxi = a[i] + m;
    if (maxi < thres) return false;
    int waste = (p-1 + n-i-1 + 1) * m;
    
    int sat = 0;
    FOR(j,p-1,i){
        sat += maxi - a[j];
    }
    return waste + sat >= v * m;
}


signed main(){
    cin >> n >> m >> v >> p;
    a.resize(n);
    REP(i,n) cin >> a[i];

    sort(all(a), greater<int>());
    thres = a[p-1];

    int hi = n;
    int lo = p-1;
    while(hi-lo > 1){
        int mid = (hi+lo)/2;
        // cerr << mid << " " << det(mid) << endl;
        (det(mid) ? lo : hi) = mid;
    }
    cout << lo+1 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>

using namespace std;
string S;
int gg,pp;
int main(){
	cin >> S;
	int n = S.size();
	for(int i =0;i<n;i++){
		if(S[i] == 'g') gg = gg+1;
		if(S[i] == 'p') pp = pp+1;
	}
	cout << n/2-pp << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	int a,sum,i,j;
	while (scanf("%d",&a) != EOF){
		sum = 0;
		j = 600 / a;
		for (i = 1; i < j; i++){
			sum = sum + i * i * a * a * a; 
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 596
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)



typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////



ll SOLVE(){
    ll a,b;cin>>a>>b;
    cout<<a*b;
    
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}


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

template <size_t N>
struct TransformationMonoid{
  using value_type = std::array<int, N>;

  inline static value_type id(){
    value_type ret;
    for(int i = 0; i < (int)N; ++i) ret[i] = i;
    return ret;
  }

  inline static value_type op(const value_type &a, const value_type &b){
    value_type ret;
    for(int i = 0; i < (int)N; ++i) ret[i] = a[b[i]];
    return ret;
  }
};

template <typename M, typename value_type = typename M::value_type>
value_type times(value_type a, int64_t p){
  auto ret = M::id();

  while(p > 0){
    if(p & 1) ret = M::op(ret, a);
    a = M::op(a, a);
    p >>= 1;
  }

  return ret;
}

constexpr int MAX = 200000;

using M = TransformationMonoid<MAX>;
using Arr = typename M::value_type;

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

  int64_t N, K; std::cin >> N >> K;

  Arr A = M::id();
  for(int i = 0; i < N; ++i){
    int a; std::cin >> a;
    A[i] = a-1;
  }

  auto res = times<M>(A, K);

  std::cout << res[0] + 1 << std::endl;
  
  return 0;
}


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



void testcase(){
    int n, w;
    cin >> n >> w;

    vector<long long> values(n), weights(n);
    for(int i = 0; i < n; i++){
        cin >> weights[i] >> values[i];
    }

    vector<long long> dp(w + 1);
    for(int i = 0; i < n; i++){
        for(int j = w ; j >= 0; j--){
            if(j - weights[i] >=0){
                dp[j] = max(dp[j], dp[j - weights[i]] + values[i]);
            }
        }
    }
    cout << *max_element(dp.begin(), dp.end());
}

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

#ifdef AKP
    freopen("in.txt","r", stdin);
#endif

    int t = 1;
    //cin >> t;
    while(t--){
        testcase();
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 1024
DMAX=17

def func(x,n)
    return if n==1
    gcds=[]
    (n/2).times do |i|
        gcds[i]=x[-1][2*i].gcd(x[-1][2*i+1])
    end
    x << gcds
    func(x,n/2)
end

def func2(x,i,level,temp)
    return if level==DMAX
    t=(i>>DMAX-level-1) ^ 1
    temp << x[DMAX-level-1][t]
    func2(x,i,level+1,temp)
end


def func3(a,n)
    x1=Array.new
    x1 << a
    func(x1,2**DMAX)
    max=0
    n.times do |i|
        temp=[]
        func2(x1,i,0,temp)
        g=temp.inject(&:gcd)
        max=g if max<g
    end
    return max
end

N=gets.to_i
A=gets.split.map(&:to_i)
A2=Array.new(2**DMAX,0)
A.each_with_index do |a,i|
    A2[i]=a
end
puts func3(A2,N)

Measured memory_bytes: 19148