akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
using namespace std;
 
int main() {
long long a,b,c,d;
cin >> a>>b>>c>>d;
long long ac = a*c;
long long ad = a*d;
long long bc = b*c;
long long bd = b*d;
cout << max(max(ac,ad),max(bc,bd)) << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

string s;
int m[100000];

int main()
{
    ciosup;
    int n, q;
    cin >> n >> q;
    cin >> s;
    int l[q], r[q];
    REP(i, q)
        cin >> l[i] >> r[i];
    
    int lab = 0;
    FOR(i, 1, n)
    {
        if (s[i-1] == 'A' && s[i] == 'C')
        {
            m[i] = ++lab;
        }else{
            m[i] = lab;
        }
    }
    REP(i,q){
        cout << m[r[i]-1] - m[l[i]-1] << endl;
    }
}

Measured memory_bytes: 2256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		
		// 計算
		String result = "ABC";
		if(x >= 1200) result = "ARC";
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong N, D;

	cin >> N >> D;
	cout << N/(2*D+1) + (N%(2*D+1) ? 1 : 0) << endl;

	return 0;
}

Measured memory_bytes: 256
fun main() {
    var (n, k) = readLine()!!.split(" ").map{it.toInt()}
    var a = readLine()!!.split(" ").map{it.toInt()}

    a = a.sorted()
    var c = 0
    for(i in 0 until k) {
        c += a[i]
    }
    println(c)
}

Measured memory_bytes: 40576
#include <bits/stdc++.h>
using namespace std ;
int dp[100005];
int main()
{
    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n;i++) cin >> arr[i];
    for(int stones = 1; stones <= k; stones++) {
    	for(int x : arr) {
    		if(stones - x >= 0 && !dp[stones - x]) dp[stones] = true;
    	}
    }    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0 ;	
}

Measured memory_bytes: 640
lst = list(map(int,input().split()))

if lst[1] != 1 and lst[0] > lst[1] :
    print('Alice')
elif lst[0] != 1 and lst[0] < lst[1]:
    print('Bob')
elif lst[1] == 1 and lst[0] != 1:
    print('Bob')
elif lst[0] == 1 and lst[1] != 1:
    print('Alice')
else:
  print('Draw')

Measured memory_bytes: 9192
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
using ll=long long;
int main() {
	vector<int> P, Q;
	ll N;
	cin >> N;
	int g;
	for (int i = 0; i < N; i++) {
		cin >> g;
		P.push_back(g);
	}
	for (int i = 0; i < N; i++) {
		cin >> g;
		Q.push_back(g);
	}

	ll x = 1;
	ll y[9] = { 1,1,1,1,1,1,1,1,1 };
	ll countP = 0;
	ll countQ = 0;
	//階乗
	for (int i = 0; i < N; i++) {
		x *= i + 1;


	}
	y[0] = 0;
	for (int i = 0; i < 1; i++) {
		y[1] *= i + 1;


	}
	for (int i = 0; i < 2; i++) {
		y[2] *= i + 1;


	}
	for (int i = 0; i < 3; i++) {
		y[3] *= i + 1;


	}
	for (int i = 0; i < 4; i++) {
		y[4] *= i + 1;

	}
	for (int i = 0; i < 5; i++) {
		y[5] *= i + 1;

	}
	for (int i = 0; i < 6; i++) {
		y[6] *= i + 1;

	}
	for (int i = 0; i < 7; i++) {
		y[7] *= i + 1;

	}
	for (int i = 0; i < 8; i++) {
		y[8] *= i + 1;

	}

	int count = 1;
	for (ll i = 0; i < N - 1; i++) {
		count = 1;
		for (int j = 1; j < N - i; j++) {
			if (P[i] > P[i + j]) {

				count++;
			}
		}
		countP += (count - 1) * y[N - 1 - i];
	}
	for (ll i = 0; i < N - 1; i++) {
		count = 1;
		for (int j = 1; j < N - i; j++) {
			if (Q[i] > Q[i + j]) {

				count++;
			}
		}
		countQ += (count - 1) * y[N - 1 - i];

	}

	
	cout << abs(countQ - countP);

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, T; cin >> n >> T;
  V<> c(n), t(n); for (int i = 0; i < n; i++) cin >> c[i] >> t[i];
  const int inf = 1e9;
  int res = 1e9;
  for (int i = 0; i < n; i++) {
    if (t[i] <= T) res = min(res, c[i]);
  }
  if (res == inf) cout << "TLE" << '\n';
  else cout << res << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    auto get_num = [](char ch) -> int {
        if(ch == 'U')   return 0;
        else if(ch == 'R')  return 1;
        else if(ch == 'D')  return 2;
        else    return 3;   // ch == 'L'
    };
    vector<int> X(N), Y(N), dir(N);
    for(int i = 0; i < N; ++i){
        char ch;
        cin >> X[i] >> Y[i] >> ch;
        dir[i] = get_num(ch);
    }
    int ans = INF;
    for(int loop = 0; loop < 4; ++loop){
        map<int, vector<P>> mp, manhattan_mp;
        for(int i = 0; i < N; ++i){
            if(~dir[i] & 1) mp[X[i]].emplace_back(Y[i], dir[i]);
            if(dir[i] < 2)  manhattan_mp[X[i] + Y[i]].emplace_back(Y[i], dir[i]);
        }
        for(auto& it : mp){
            vector<P> table = it.second;
            sort(table.begin(), table.end());
            int prev_u = -1;
            for(auto& p : table){
                if(!p.second)   prev_u = p.first;
                else if(prev_u != -1)   chmin(ans, (p.first - prev_u) * 5);
            }
        }
        for(auto& it : manhattan_mp){
            vector<P> table = it.second;
            sort(table.begin(), table.end());
            int prev_u = -1;
            for(auto& p : table){
                if(!p.second)   prev_u = p.first;
                else if(prev_u != -1)   chmin(ans, (p.first - prev_u) * 10);
            }
        }
        swap(X, Y);
        for(int i = 0; i < N; ++i){
            Y[i] = -Y[i];
            if(++dir[i] == 4)   dir[i] = 0;
        }
    }
    if(ans == INF)  cout << "SAFE\n";
    else    cout << ans << '\n';
}

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

int input(int []);
void reversal_output(int nums, int numbers[]);
char *getsn(char *s, int n);

int main(void)
{
	int numbers[100];
	int nums;
	nums = input(numbers);
	reversal_output(nums, numbers);
	
	return 0;
}
char *getsn(char *s, int n){
	if(fgets(s, n, stdin) == NULL) return NULL;
	char *ln = strchr(s, '\n');
	if(ln) *ln = 0;
	else
	while(1){
		int c = getchar();
		if(c == '\n' || c == EOF) 
			break;
	}
	return s;
}

void reversal_output(int nums, int numbers[])
{
	while(1){
		if(nums > 0){
			printf("%d", numbers[--nums]);
			if(nums > 0) printf(" ");
		}else
			break;
	}
	printf("\n");
}

int input(int numbers[])
{

	char str_nums[500];
	char a_number[4];
	int num = 0;
	char c;


	getsn(a_number, 4);
	sscanf(a_number, "%d", &num);
	
	getsn(str_nums, 500);

	int j=0;
	
	for(int i=0; i<num; i++){
		for(int numi = 0;; numi++){
			c = str_nums[j];
			if (c == ' ' || c == 0){
				a_number[numi] = 0;
				sscanf(a_number, "%d", numbers+i);
				j++;
				break;
			}else{
				a_number[numi]=c;
				j++;
			}
		}
	}
		
	return num;

}



Measured memory_bytes: 2052
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

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

        String s1 = br.readLine();
        String s2 = br.readLine();

        int n = s1.length();
        int count = 0;
        for(int i=0 ; i<n ; i++) {
            if(s1.charAt(i) == s2.charAt(i)) {
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 21332
use std::cmp::*;
use std::io::*;

fn dp(k: usize, wv: &Vec<(usize, usize)>, dp: &mut Vec<Vec<usize>>) {
    for i in 0..wv.len() {
        for j in 0..k {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if j + wv[i].0 <= k {
                dp[i + 1][j + wv[i].0] = max(dp[i + 1][j + wv[i].0], dp[i][j] + wv[i].1);
            }
        }
    }
}

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let mut wv: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    let mut dp1 = vec![vec![0; k + 1]; n + 1];
    let mut dp2 = vec![vec![0; k + 1]; n + 1];
    dp(k, &wv, &mut dp1);
    wv.reverse();
    dp(k, &wv, &mut dp2);
    wv.reverse();

    let mut ans = 0;
    for i in 0..n {
        for j in 0..k {
            // i番目を使わずk-1, 最後にiを使う
            ans = max(ans, dp1[i][j] + dp2[n - i - 1][k - 1 - j] + wv[i].1);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 176380
# frozen_string_literal: true

k, n = gets.split(' ').map(&:to_i)
a = gets.split(' ').map(&:to_i)
b = (1..(n - 1)).map do |i|
  a[i] - a[i - 1]
end
b << (k - a[n - 1]) + a[0]
puts k - b.max


Measured memory_bytes: 17084
array = [ list(map(int,input().split())) for _ in range(3) ]
number = []
N = int(input())
for _ in range(N):
  number += [ int(input()) ]
for i in range(3):
  for t in range(3):
    if array[i][t] in number:
      array[i][t] = 0
for i in range(1):
  if array[i][0] == array[i+1][0] == array[i+2][0]:
    print('Yes')
    exit()
  elif array[i][1] == array[i+1][1] == array[i+2][1]:
    print('Yes')
    exit()
  elif array[i][2] == array[i+1][2] == array[i+2][2]:
    print('Yes')
    exit()
  elif array[i][0] == array[i][1] == array[i][2]: 
    print('Yes')
    exit()
  elif array[i+1][0] == array[i+1][1] == array[i+1][2]:
    print('Yes')
    exit()
  elif array[i+2][0] == array[i+2][1] == array[i+2][2]:
    print('Yes')
    exit()
    
if array[0][0] == array[1][1] == array[2][2] or array[0][2] == array[1][1] == array[2][0]:
  print('Yes')
else:
  print('No')


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

int a[100001],b[100001];
bool vis[100001];
struct UF{
	int p[100001],sz[100001];
	void I(int n){
		for(int i=0;i<n;i++)
			sz[p[i]=i]=1;
	}
	int F(int x){return x==p[x]?x:p[x]=F(p[x]);}
	bool U(int x,int y){
		x=F(x),y=F(y);
		if(x==y)	return false;
		if(sz[x]<sz[y])
			swap(x,y);
		p[y]=x;
		sz[x]+=sz[y];
		return true;
	}
}D;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> A,B;
	for(int i=1;i<=n;i++)
		cin>>a[i],a[0]^=a[i],A.emplace_back(a[i]);
	A.emplace_back(a[0]);
	for(int i=1;i<=n;i++)
		cin>>b[i],b[0]^=b[i],B.emplace_back(b[i]);
	B.emplace_back(b[0]);
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	if(A!=B)	return cout<<-1<<endl, 0;
	A.resize(unique(A.begin(),A.end())-A.begin());
	map<int,int> M;
	for(int i=0;i<A.size();i++)
		M[A[i]]=i;
	D.I((int)A.size());
	int ans = -1;
	for(int i=1;i<=n;i++)
		if(a[i]!=b[i]){
			vis[M[a[i]]]=true;
			vis[M[b[i]]]=true;
			D.U(M[a[i]],M[b[i]]);
			ans++;
		}
	vis[M[a[0]]]=true;
	vis[M[b[0]]]=true;
	for(int i=0;i<A.size();i++)
		if(vis[i])
			if(i==D.F(i))
				ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 7416
#include <iostream>
#include <vector>
#include <map>

using namespace std;
using i64 = long long int;
using P = pair<i64, i64>;

i64 gcd(i64 a, i64 b){
    //
    // Euclidean Algorithm (かっこいい) O(logN)
    // i64 a, b: GCDを求める数 a > b を仮定している
    //
    if(a % b == 0) return b;
    else return gcd(b, a % b);
}

i64 lcm(i64 a, i64 b){
    //
    // a * b / gcd(a, b) O(logN)
    //
    return a * b / gcd(a, b);
}

i64 modpow(i64 x, i64 n){
    //
    // 繰り返し二乗法 O(logN)
    // i64 x, n: x^n mod 1e9+7 を求める modの値の変え忘れに注意(modを渡すべき?)
    //
    const i64 mod = 1000000007;
    i64 res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

map<i64, i64> prime_factorize(i64 n){
    map<i64, i64> mp;
    for(i64 i = 2;  i * i <= n; ++i){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

void NTL_1_A(){
    i64 n;
    cin >> n;
    auto factors = prime_factorize(n);
    cout << n << ':';
    for(auto f : factors){
        for(int i = 0; i < f.second; ++ i){
            cout << ' ' << f.first;
        }
    }
    cout << endl;
}

void NTL_1_B(){
    i64 m, n;
    cin >> m >> n;
    cout << modpow(m, n) << endl;
}

void NTL_1_C(){
    i64 n;
    cin >> n;
    vector<i64> a(n);
    i64 ans = 1;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        ans = lcm(ans, a[i]);
    }
    cout << ans << endl;
}

int main(){
    /* NTL_1_A(); /* https://onlinejudge.u-aizu.ac.jp/status/users/kobaryo222/submissions/1/NTL_1_A/judge/3892592/C++14 */
    /* NTL_1_B(); /* https://onlinejudge.u-aizu.ac.jp/status/users/kobaryo222/submissions/1/NTL_1_B/judge/3892552/C++14 */
    NTL_1_C();
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int n; cin >> n;
  vector<vector<bool>> g(n, vector<bool>(n));
  bool ng = true;
  REP(i, n) {
    REP(j, n) {
      char c; cin >> c;
      g[i][j] = c == '#';
      ng &= !g[i][j];
    }
  }
  if(ng) {
    cout << -1 << endl;
    return 0;
  }

  // 黒い行があるかチェック
  REP(i, n) {
    bool ok = true;
    REP(j, n) {
      ok &= g[i][j];
    }
    if(ok) {
      int ans = 0;
      REP(j, n) {
        bool wh = false;
        REP(i, n) {
          wh |= !g[i][j];
        }
        ans += wh;
      }
      cout << ans << endl;
      return 0;
    }
  }

  vector<bool> bl(n);
  REP(j, n) {
    REP(i, n) {
      if(g[i][j]) {
        bl[j] = true;
        break;
      }
    }
  }

  int mi = INF;
  REP(i, n) {
    int now = 0;
    if(!bl[i]) now++;
    REP(j, n) {
      if(g[i][j]) {
        bool wh = false;
        REP(k, n) {
          wh |= !g[k][j];
        }
        now += wh;
      } else {
        now += 2;
      }
    }
    chmin(mi, now);
  }

  cout << (mi == INF ? -1 : mi) << endl;


}
























Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_N (1<<19)
#define INF 100000000
#define MOD 1000000007
#define RANK 1000000000
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> IP;

struct segtree{
    int n, dat[2*MAX_N-1]; //(1<<17) = 130000
    int add[2*MAX_N-1];

    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        for(int i = 0; i < 2*n-1; i++) dat[i] = 0;
        for(int i = 0; i < 2*n-1; i++) add[i] = 0;
    }

    void Add(int a, int b, int k, int l, int r, int v){
        if(a >= r || b <= l) return;
        if(a <= l && r <= b){
            add[k] += v;
            return;
        }
        Add(a,b,k*2+1,l,(r+l)/2,v);
        Add(a,b,k*2+2,(r+l)/2,r,v);
        dat[k] = min(dat[k*2+1]+add[k*2+1],dat[k*2+2]+add[k*2+2]);
    }

    //(a,b,0,0,seg.n)??§?????¶
    int query(int a, int b, int k, int l, int r, int v){
        if(k >= n-1) return k-(n-1);
        v += add[k];
        if(dat[k*2+2]+v < 0) return query(a,b,k*2+2,(l+r)/2,r,v);
        else return query(a,b,k*2+1,l,(l+r)/2,v);
    }
} seg;

int n, q;
string s;
priority_queue<int, vector<int>, greater<int> > que;
int bla[300000];

int main(){
    cin >> n >> q;
    seg.init(n);
    cin >> s;
    rep(i,n){
        if(s[i] == ')'){
            que.push(i);
            bla[i]++;
        }
    }
    int cnt = 0;
    for(int i = n-1; i >= 0; i--){
        if(s[i] == ')') cnt++;
        else cnt--;
        seg.Add(i,i+1,0,0,seg.n,cnt);
    }
    rep(i,q){
        int x; cin >> x;
        x--;
        if(s[x] == '('){
            s[x] = ')';
            seg.Add(0,x+1,0,0,seg.n,2);
            que.push(x);
            bla[x]++;
            while(true){
                int p = que.top();
                que.pop();
                if(bla[p] > 0){
                    s[p] = '(';
                    seg.Add(0,p+1,0,0,seg.n,-2);
                    bla[p]--;
                    cout << p+1 << endl;
                    break;
                }
            }
        } else{
            s[x] = '(';
            bla[x]--;
            seg.Add(0,x+1,0,0,seg.n,-2);
            int y = seg.query(0,n,0,0,seg.n,0);
            s[y] = ')';
            bla[y]++;
            que.push(y);
            seg.Add(0,y+1,0,0,seg.n,2);
            cout << y+1 << endl;
        }
    }
}

Measured memory_bytes: 14996
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long cnt = 0;
            long maxCnt = 0;
            long maxValue = 0;
            for(int i = 1; i <= N; i++)
            {
                long stock = saiki(i, cnt);
                if (maxCnt < saiki(i, cnt))
                {
                    maxCnt = stock;
                    maxValue = i;
                }
            }
            if(maxCnt == 0)
            {
                Console.WriteLine(1);
                return;
            }
            Console.WriteLine(maxValue);
        }
        static long saiki(long N,long cnt)
        {
            if(N % 2 == 0)
            {
                cnt++;
                return saiki(N / 2,cnt);
            }
            return cnt;
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);

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

namespace ABC
{
    class Program
    {
        public static void Main(string[] args)
        {
			var n = 0;
			var s = Console.ReadLine();

			for (var i = 0; i < s.Length; i++) {            
				if(s[i] == '-')
				{
					n = n - 1;
				}
				else if (s[i] == '+')
				{
					n = n + 1;
				}
            }

			Console.WriteLine(n);
		}
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main{

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



		for(int i = 1;i <= 10000;i++) {
			int x = sc.nextInt();
                        if(x == 0) {
				break;
			}
	                System.out.println("Case " + i + ": "+ x);
                }
	                        sc.close();
        }	                
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> cnt(N);
  rep(i,K){
    int d;
    cin >> d;
    rep(j,d){
      int a;
      cin >> a;
      a--;
      cnt.at(a)++;
    }
  }
  int total = 0;
  rep(i,N){
    if(0 == cnt.at(i)) total++;
  }
  cout << total << endl;
}

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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  string ans = "No";
  
  if (N == 1) {
    ans = "No";
  }
  else if (N%2 == 0) {
    int M = N/2;
    if (S.substr(0,M) == S.substr(M,M)) ans = "Yes";
  }
  else {
    ans = "No";
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

map<ll,ll> a;
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a[-x]++;
	}
	ll ans1=0,ans2=0,ans3=0;
    for(auto itr = a.begin(); itr != a.end(); itr++) {
        ll key= itr->first;
        ll val=itr->second;
        if(val>=4){
        	ans3=max(ans3,key*key);
        }
        if(val>=2){
        	if(ans1==0){
        		ans1=key;
        	}
        	else{
        		ans2=max(ans2,ans1*key);
        	}
        }
    }
   
    cout << max(ans3,ans2);
    // your code goes here
	return 0;
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
  string s, t;
  cin >> s;

  reverse(s.begin(), s.end());
  for(int i=0; i<4; ++i)reverse(divide[i].begin(), divide[i].end());


  bool can = true;
  for(int i=0; i<s.size();){
    bool can2 = false; 
    for(int j=0; j<4; ++j){
      string d = divide[j];
      if(s.substr(i, d.size()) == d){
        can2 = true;
        i+= d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }

  if(can) cout << "YES";
  else cout << "NO";

  
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int C = Integer.parseInt(tokens[2]);

		in.close();

		if (A < C && C < B) {
			System.out.println("Yes");
		} else if (B < C && C < A) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22996
#include<cstdio>
#include<algorithm>
using namespace std;

int main(void){
  int n,h;
  int a[100000],b[100000];

  scanf("%d %d",&n,&h);

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

  sort(a,a+n);
  sort(b,b+n);

  int amax = a[n-1];
  int ans=0;
  int j = n-1;
  while(b[j]>amax&&h>0&&j>=0){
    h-=b[j];
    ans++;
    j--;
  }
  while(h>0){
    h-=amax;
    ans++;
  }

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

  return 0;
}



Measured memory_bytes: 896
#include <stdio.h>
#define N 100

int main(void){
    int n, i, y, m, d;
    scanf("%d", &n);
    int rest[N] = {};
    for(i = 0; i < n; i++){
        scanf("%d %d %d", &y, &m, &d);
        if(y % 3 == 0){
            rest[i] += (20 - d) + 1;
            rest[i] += (10 - m) * 20;
        }else if(m % 2 == 0){
            rest[i] += (19 - d) ;
            rest[i] += (10 - m) * 39 / 2 + 1;
        }else{
            rest[i] += (20 - d);
            rest[i] += (10 - m) * 39 / 2 + 1;
        }

        if(y % 3 == 0){
            rest[i] += (1000 - y - 1) * 590 / 3;
        }else if(y % 3 == 2){
            rest[i] += (1000 - y - 2) * 590 / 3 + 200;
        }else{
            rest[i] += (1000 - y - 3) * 590 / 3 + 395;
        }
        printf("%d\n", rest[i]);
    }
    return 0;
}


Measured memory_bytes: 2144
using System;

namespace abc168_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());

            if (a % 10 == 2 || a % 10 == 4 || a % 10 == 5 ||
               a % 10 == 7 || a % 10 == 9)
            {
                Console.WriteLine("hon");
            }
            else if (a % 10 == 0 || a % 10 == 1 || a % 10 == 6 ||
               a % 10 == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("bon");
            }
            Console.Read();
        }
    }
}


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

public class Main {
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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

        public long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }
    static final int mod = 1000000007;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long n = sc.nextInt();
        long sum = 1;
        for (long i = 1; i <= n; i++) {
            sum = ((sum % mod) * (i % mod))%mod;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 32676
mod = 1000000007
n = int(input())

ab00 = 0
abx0 = 0
ab0x = 0
p = []
m = []

from math import gcd
for _ in range(n):
    i, j = map(int, input().split())
    if i == 0:
        if j == 0:
            ab00 += 1
        else:
            ab0x += 1
        continue
    elif j == 0:
        abx0 += 1
        continue
    k = gcd(i, j)
    i //= k
    j //= k
    if i > 0:
        if j > 0:
            p.append((i, j))
        else:
            m.append((-j, i))
    elif j > 0:
        m.append((j, -i))
    else:
        p.append((-i, -j))

m.sort()
p.sort()

ans = pow(2, ab0x, mod) + pow(2, abx0, mod) - 1
ans %= mod

mi = 0
pi = 0
while mi < len(m) and pi < len(p):
    if m[mi] == p[pi]:
        mi += 1
        mnum = 1
        while mi < len(m) and m[mi] == m[mi-1]:
            mi += 1
            mnum += 1
        pi += 1
        pnum = 1
        while pi < len(p) and p[pi] == p[pi-1]:
            pi += 1
            pnum += 1
        ans *= pow(2, mnum, mod) + pow(2, pnum, mod) - 1
        ans %= mod

    elif m[mi] < p[pi]:
        mi += 1
        mnum = 1
        while mi < len(m) and m[mi] < p[pi]:
            mi += 1
            mnum += 1
        ans *= pow(2, mnum, mod)
        ans %= mod
    
    else:
        pi += 1
        pnum = 1
        while pi < len(p) and p[pi] < m[mi]:
            pi += 1
            pnum += 1
        ans *= pow(2, pnum, mod)
        ans %= mod

ans *= pow(2, len(p) - pi, mod)
ans %= mod
ans *= pow(2, len(m) - mi, mod)
ans %= mod
ans = (ans - 1 + ab00) % mod
print(ans)

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

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

const int MAXN = 2e5 + 5;

int a[MAXN];

vector<pii> ans;

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d", &a[i]);
	}
	int ind = 0;
	REP(i, 1, n) {
		if (abs(a[i]) > abs(a[ind])) {
			ind = i;
		}
	}
	if (a[ind] < 0) {
		if (ind != n - 1) {
			ans.pb(mp(ind + 1, n));
			ans.pb(mp(ind + 1, n));
		}
		for(int i = n - 1; i >= 1; i--) {
			ans.pb(mp(i + 1, i));
			ans.pb(mp(i + 1, i));
		}
	} else {
		if (ind != 0) {
			ans.pb(mp(ind + 1, 1));
			ans.pb(mp(ind + 1, 1));
		}
		REPN(i, 1, n - 1) {
			ans.pb(mp(i, i + 1));
			ans.pb(mp(i, i + 1));
		}
	}
	printf("%d\n", SZ(ans));
	REP(i, 0, SZ(ans)) {
		printf("%d %d\n", ans[i]._1, ans[i]._2);
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int dfs(int N, int a, int b, int c, const VEC<int> &L, VEC<char> g) {
  if ((int)g.size() == N) {
    int A, B, C;
    A = B = C = -10;
    int la, lb, lc;
    la = lb = lc = 0;
    REP(i, 0, g.size()) {
      if (g[i] == 'A') {
        A += 10;
        la += L[i];
      } else if (g[i] == 'B') {
        B += 10;
        lb += L[i];
      } else if (g[i] == 'C') {
        C += 10;
        lc += L[i];
      }
    }
    A = max(0, A);
    B = max(0, B);
    C = max(0, C);
    if (la > 0 && lb > 0 && lc > 0) {
      int ans = A + abs(a - la) + B + abs(b - lb) + C + abs(c - lc);
    //   DUMP(g, ans, A, B, C, la, lb, lc);
      return ans;
    }
    return 1<<30;
  } else {
    int mi = 1 << 30;
    REP(i, 0, 4) {
      VEC<char> tmp = g;
      tmp.push_back('A' + i);
      int cand = dfs(N, a, b, c, L, tmp);
      mi = min(mi, cand);
    }
    return mi;
  }
}

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  VEC<int> L(N);
  REP(i, 0, N) cin >> L[i];
  VEC<char> tmp;
  int ans = dfs(N, A, B, C, L, tmp);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<string>
#include<iterator>
#include<iomanip>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>

using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}

int main() {

	ll();

	int r, g , b,sum=0;
	cin >> r >> g >> b;
	r *= 100;
	g *= 10;
	sum = r + g + b;
	if (sum % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

		

}

Measured memory_bytes: 3612
/*Bismillahir Rahmanir Raheem*/

#include <bits/stdc++.h>
using namespace std;

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;

// defined for taking input
#define gl(x) getline(cin, x)
#define sf scanf
#define sfi(x) scanf("%d", &x)
#define sfc(x) scanf("%c", &x)
#define sfl(x) scanf("%lld", &x)
#define sflu(x) scanf("%llu", &x)
#define sfii(x, y) scanf("%d %d", &x, &y)
#define sfll(x, y) scanf("%lld %lld", &x, &y)
#define sfiii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sflll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)

//defined for printing
#define pf printf
#define pfn pf("\n")
#define pfcas pf("Case %d: ", cas)
#define pfyes pf("YES");
#define pfno pf("NO");
#define pfi(x) pf("%d", x)
#define pfl(x) pf("%lld", x)

//defined for loop

//increament
#define loopi(i, j, k) for (int i = j; i < k; i++)
#define loopl(i, j, k) for (ll i = j; i < k; i++)
#define loopc(i, j, k) for (char i = j; i < k; i++)
#define looplu(i, j, k) for (ull i = j; i < k; i++)
//decreament
#define loopri(i, j, k) for (int i = j; i > k; i--)
#define looprl(i, j, k) for (ll i = j; i > k; i--)
#define looprlu(i, j, k) for (ull i = j; i > k; i--)
#define looprc(i, j, k) for (char i = j; i > k; i--)
#define wa(t) while (t--)

//testcases
#define testc(t) for (char cas = 1; cas <= t; cas++)
#define testi(t) for (int cas = 1; cas <= t; cas++)
#define testl(t) for (ll cas = 1; cas <= t; cas++)

//some cmd
#define pb push_back
#define ppb pop_back
#define mp make_pair

//code start

int main()
{
    // freopen("/home/grimfirefly/Programming/input.txt","r",stdin);
    // freopen("/home/grimfirefly/Programming/output.txt","w",stdout);
    ull a;
    sflu(a);
    ull ans = a ? 1 : 0, div = 1;
    while (a / 2)
    {
        ans += div = (div << 1);
        a /= 2;
    }
    pf("%llu\n", ans);
    return 0;
}

Measured memory_bytes: 256
require 'prime'

class MyPrime
  def self.divisions(num)
    divs = Prime.prime_division(num)
    divisions = [1]
    divs.each do |div|
      ds = [*(0..div[1])].map { |power| div[0]**power }
      divisions = divisions.product(ds)
                           .map { |prod, d| prod * d }
    end
    divisions.sort
  end

  def self.true_divisions(num)
    MyPrime.divisions(num) - [num]
  end

  def self.amicable_number?(num)
    amecable = MyPrime.true_divisions(num).sum
    return false if amecable == num || amecable.zero?
    num == MyPrime.true_divisions(amecable).sum
  end

  def self.abundant_number?(num)
    num < true_divisions(num).sum
  end

  def self.deficient_number?(num)
    num > true_divisions(num).sum
  end
end

N, K = gets.chomp.split.map(&:to_i)
AS = gets.chomp.split.map(&:to_i)

sum = AS.inject(0, &:+)
divisions = MyPrime.divisions(sum)

divisions.reverse.each do |n|
  div = AS.map { |a| a % n }.sort
  k = 0
  until div.empty?
    a = div.shift
    k += a
    while a > 0
      if n - div[-1] > a
        div[-1] += a
        a = 0
      else
        a -= n - div[-1]
        div.pop
      end
    end
  end

  if k <= K
    puts n
    exit
  end
end

puts "no answer"




Measured memory_bytes: 4344
#include <stdio.h>
#define N 100000
#define inf 2000000
#define WHITE 1
#define BLACK 2 
void dij();

int n,u,e,v,c[100][N],d[N],pi[N],color[N];
int main(){
  int i,k,j;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      c[i][j]=inf;}}
  for(i=0;i<n;i++){
    scanf("%d%d",&e,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&c[i][v]);
    }
    
  }
  dij();
  
  for(i=0;i<n;i++)
    printf("%d %d\n",i,d[i]);

  return 0;
}

void dij(){
  int mincost,k,h,i,y;
  for(u=0;u<n;u++){
    d[u]=inf;
    pi[u]=-1;
    color[u]=0;
  }
  d[0]=0;

  while(1){
    mincost=inf;
    
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==inf){
      break;
    }
    color[u]=BLACK;
    for(k=0;k<n;k++){
      if(color[k]!=BLACK && d[u]+c[u][k]<d[k]){
	pi[k]=u;

       d[k]=d[u]+c[u][k];

      }
      
    }
   
  }
  
    
      
    
  }

Measured memory_bytes: 37496
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;

    return 0;
}

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

const int N = 2e5 + 100;

int n, a[N];
bool b[N];

bool ok(int c) {
	for (int i = 0; i < 2 * n - 1; i++)
		b[i] = (a[i] >= c);
	for (int d = 0; d < n; d++)
		if (b[n - 1 - d] == b[n - d])
			return b[n - d];
		else if (b[n - 1 + d - 1] == b[n - 1 + d])
			return b[n - 1 + d];
	return b[0];
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < 2 * n - 1; i++)
		cin >> a[i];
	int l = 1, r = 2 * n;
	while (r - l > 1) {
		int c = (l + r) >> 1;
		if (ok(c))
			l = c;
		else
			r = c;
	}
	cout << l;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<ll>>v;
ll r,c,k;
ll dp[3005][3005][10];
ll dfs(ll i,ll j,ll cp){
    if(i>r || j>c)return 0;
    if(dp[i][j][cp]!=-1)return dp[i][j][cp];
    ll ans=0;
    if(v[i][j]!=0 && cp>0){
        ll ans1=v[i][j]+dfs(i,j+1,cp-1);
        ll ans2=v[i][j]+dfs(i+1,j,3);
        ans=max(ans1,ans2);
    }
    ll ans1=dfs(i,j+1,cp);
    ll ans2=dfs(i+1,j,3);
    ans=max(ans,max(ans1,ans2));
    return dp[i][j][cp]=ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>r>>c>>k;
    vector<vector<ll>>V(r+1,vector<ll>(c+1,0));
    for(ll i=0;i<k;i++){
        ll x,y,z;
        cin>>x>>y>>z;
        V[x][y]=z;
    }
    v=V;
    memset(dp,-1,sizeof(dp));
    ll ans=dfs(1,1,3);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 849748
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		boolean[] is_prime = new boolean[10001];
		
		for(int i = 2; i < 10001; i++){
			is_prime[i] = true;
		}
		
		for(int i = 2; i <= 100; i++){
			if(is_prime[i]){
				for(int j = 2*i; j <= 10000; j += i){
					is_prime[j] = false;
				}
			}
		}
		
		while(sc.hasNext()){
			final int n = sc.nextInt();
			
			int count = 0;
			
			for(int i = 1; i <= n; i++){
				if(is_prime[i] && is_prime[n + 1 - i]){
					count++;
				}
			}
			
			System.out.println(count);
		}

	}

}

Measured memory_bytes: 12000
N = int(input())
A = list(map(int,input().split()))
T = set()
def counter(array):
    from collections import Counter
    return Counter(array)
c = counter(A)
for x in A:
    T.add(x)
cnt = 0
maxi = max(A)
for x in sorted(A):
    i = 2
    while x * i <= maxi:
        if x * i in T:
            T.remove(x*i)
        i += 1
ans = 0
for x in T:
    if c[x] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 44260
#include <stdio.h>
int main(void){
    
    int a , b , c;    
    scanf("%d %d %d",&a,&b,&c);    
    if (a <= b && b <= c){        
        printf("%d %d %d\n", a, b, c);    
    }    
    else if (b <= c && c <= a){        
        printf("%d %d %d\n", b ,c, a);    
    }    
    else if (c <= a && a <= b){        
        printf("%d %d %d\n", c, a, b);    
    }    
    else if (a <= c && c <= b){        
        printf("%d %d %d\n", a, c, b);    
    }    
    else if (c <= b && b <= a){        
        printf("%d %d %d\n", c, b, a);    
    }    
    else if (b <= a && a <= c){       
        printf("%d %d %d\n", b, a, c);    
    }    
    return 0;
    
}
    



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

int main() {
	int N, Y;
	cin >>N >>Y;
	int x, y, z;
	for (x=0; x<=N; x++) {
		int S=x*10000;
		if (S>Y)
			break;
		for (y=0; y<=N-x; y++) {
			if (S+y*5000>Y)
				break;
			z=N-x-y;
			if (Y==S+y*5000+z*1000) {
				cout <<x <<" " <<y <<" " <<z <<endl;
			 	return 0;
			}
		}
	}
	cout <<"-1 -1 -1" <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
    
    int a,b,x,y;
    
    scanf("%d %d",&a,&b);
    
    if(a<1||a>100||b<1|b>100) return 0;
    
    else{
        
        x=a*b;
        y=2*a+2*b;
        
        printf("%d %d\n",x,y);
        
        return 0;
        
    }
    
}


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

def main():
    N = int(input())
    MOD = int(1e9) + 7
    if N == 1:
        print(1)
        exit()
    primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
    count = [0] * len(primes)
    for i in range(2, N+1):
        for j in range(len(primes)):
            while i%primes[j] == 0:
                count[j] += 1
                i //=primes[j]
    # print(count)
    ans = 1
    for i in range(len(count)):
        if count[i] > 0:
            ans *= count[i]+1
            ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			long a = array[0];
			long b = array[1];
			double div = (double)a / b;

			Console.WriteLine($"{a / b} {a % b} {div:f5}");

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 18480
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


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

int main() {
	long long n;
	cin >> n;
	string s;
	cin >> s;
	long long r=0,g=0,b=0;
	for(long long i=0;i<n;i++){
		if(s[i]=='R') r++;
		else if(s[i]=='G') g++;
		else b++;
	}
	long long ans=r*g*b;
	for(long long i=1;i<=n/2;i++){
		for(long long j=0;j+i*2<n;j++){
			if(s[j]!=s[j+i]&&s[j+i]!=s[j+2*i]&&s[j]!=s[j+2*i]) ans--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>

using namespace std;

int main() {
	long long i, j, N, K, sum=1;

	cin >> N >> K;

	for (i = 0; i < N; i++) {
		if (i == 0) {
			sum *= K;
		}
		else {
			sum *= (K - 1);
		}


	}

	cout << sum << endl;



	return 0;
}


Measured memory_bytes: 256