akhauriyash/Code-Regression huggingface dataset:
/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 8/18/2018, 9:08:51 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M, Q;

typedef tuple<int, int> que;

vector<int> seg[510];
vector<que> X[510];
int imos[510][510];
int ans[100010];

int main()
{
  cin >> N >> M >> Q;
  for (auto i = 0; i < M; i++)
  {
    int l, r;
    cin >> l >> r;
    seg[r].push_back(l);
  }
  for (auto i = 0; i < Q; i++)
  {
    int l, r;
    cin >> l >> r;
    X[r].push_back(que(l, i));
  }
  fill(&imos[0][0], &imos[0][0] + 510 * 510, 0);
  for (auto r = 1; r <= N; r++)
  {
    for (auto x : seg[r])
    {
      imos[r][x]++;
    }
    for (int i = r - 1; i >= 0; i--)
    {
      imos[r][i] += imos[r][i + 1];
    }
    if (r > 0)
    {
      for (auto i = 0; i < r; i++)
      {
        imos[r][i] += imos[r - 1][i];
      }
    }
    for (auto x : X[r])
    {
      int l = get<0>(x);
      int ind = get<1>(x);
      ans[ind] = imos[r][l];
    }
  }
  for (auto i = 0; i < Q; i++)
  {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 4736
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int A;
    ll B,N;
    cin >> A >> B >>N;
    ll x;
    ll ans=0;
    if(B-1<=N){
        x=B-1;
    }else{
        x=N;
    }
    REP2(k,1,A){
        ans+=(ll)((double)x/(double)B+(double)k/(double)A);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    vector<vector<int>>vec(3,vector<int>(3));
      vector<vector<char>>bingo(3,vector<char>(3,'a'));
      for(int i=0;i<3;++i){
          for(int j=0;j<3;++j){
              cin>>vec.at(i).at(j);
          }
      }
      int N;
      cin >> N;
      vector<int>vecb(N);
      for(int i=0;i<N;++i){
          cin >> vecb.at(i);
          for(int j=0;j<3;j++){
              for(int k=0;k<3;k++){
                  if(vecb.at(i)==vec.at(j).at(k)){
                      bingo.at(j).at(k)='b';
                  }
              }
          }
      }
      
      for(int i=0;i<3;i++){
        if(bingo.at(i).at(0)=='b'&&bingo.at(i).at(1)=='b'&&bingo.at(i).at(2)=='b'){
             cout << "Yes" <<endl;
             return 0;
         }
         else if(bingo.at(0).at(i)=='b'&&bingo.at(1).at(i)=='b'&&bingo.at(2).at(i)=='b'){
             cout << "Yes" <<endl;
             return 0;
         }
      }
    if(bingo.at(0).at(0)=='b'&&bingo.at(1).at(1)=='b'&&bingo.at(2).at(2)=='b'){
           cout << "Yes" <<endl;
             return 0;
      }
     else if(bingo.at(0).at(2)=='b'&&bingo.at(1).at(1)=='b'&&bingo.at(2).at(0)=='b'){
           cout << "Yes" <<endl;
             return 0;
      }
      cout << "No"<<endl;
}

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

#ifdef LOCAL
#include "debug_print.hpp"
#else
#define debug(...) 0
#endif

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;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    ll ans = 1LL<<60;
    for(int bit=0; bit < (1<<N); bit++)
    {
        vector<bool> can_see(N, false);
        for(int i=0; i<N; i++)
        {
            if(bit & (1<<i))
            {
                can_see[i] = true;
            }
        }
        int num_see = 0;
        ll cost = 0;
        for(int i=0, height=-1; i<N; i++)
        {
            if(chmax(height, A[i])) num_see++;
            else if(can_see[i])
            {
                cost += height+1 - A[i];
                height++;
                num_see++;
            }
        }
        if(num_see >= K) chmin(ans, cost);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = s.indexOf('A');
		int z = s.lastIndexOf('Z');
		int result = z - a + 1;
		System.out.println(result);
	}
}

Measured memory_bytes: 26532
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define INFTY (1<<30)
#define MAX 100000000

using namespace std;

int lcs(string x, string y) {
	int m = x.size(), n = y.size();
	int c[1000+1][1000+1];
	x = ' ' + x; y = ' ' + y;
	for( int i = 0; i <= m; i++) c[i][0] = 0;
	for( int j = 0; j <= n; j++) c[0][j] = 0;
	for( int i = 1; i <= m; i++) {
		for( int j = 1; j <= n; j++) {
			if(x[i] == y[j]) c[i][j] = c[i-1][j-1] + 1;
			else if(c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
			else c[i][j] = c[i][j-1];
		}
	}
	return c[m][n];
}

int main(){
	int q;
	cin >> q;
	for( int i = 0; i < q; i++) {
		string s, t;
		cin >> s >> t;
		cout << lcs(s, t) <<endl;
	}

	return 0;
}

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

int main()
{

    int N, count=0, sum=0;
    cin >> N;

    for (int i = 1; i <= N;i++){
        if(i%2==0){

        }
        else{
            for (int j = i; j > 0;j--){
                if (i % j == 0)
                {
                    count++;
                }
            }

        }
        if(count==8){
            sum++;
        }
        count = 0;
    }
    cout << sum << endl;


}


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

using namespace std;

int p(int in)
{
	int ret = 1;
	for (int i = 0; i < in; ++i)
		ret *= 10;
	return ret;
}

int to10(vector<int>& in)
{
	int ret = 0;
	for (int i = 0; i < in.size(); ++i)
	{
		ret *= 10;
		ret += in.at(i);
	}

	return ret;
}

vector<int> toVec(int input, int L)
{
	vector<int> in;
	for (int i = 1; i <= L; ++i){
		in.push_back((input % p(i)) / p(i - 1));
	}

	reverse(in.begin(), in.end());

	return in;
}

int getLarge(vector<int> in)
{
	int ret = 0;
	while (!in.empty()){
		ret *= 10;
		auto it = max_element(in.begin(), in.end());
		ret += *it;
		in.erase(it);
	}
	return ret;
}

int getSmall(vector<int> in)
{
	int ret=0;
	while (!in.empty()){
		ret *= 10;
		auto it = min_element(in.begin(), in.end());
		ret += *it;
		in.erase(it);
	}
	return ret;
}

int main()
{
	while (1)
	{
		int input, L;
		cin >> input >> L;
		if (input == 0 && L == 0)
			break;

		vector<int> in;

		vector<int> ret = {input};
		int tmp;
		auto it = ret.begin();

		while (1)
		{
			in = toVec(input, L);
			tmp = getLarge(in) - getSmall(in);
			ret.push_back(tmp);
			if ((it = find(ret.begin(), ret.end(), tmp)) != (ret.end()-1))
			{
				cout << it - ret.begin() << " " << tmp <<" "<< (ret.end() - it) - 1 << endl;
				break;
			}
			input = tmp;
		}
		
	} 

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

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

int main() {
    int n, k;
    cin >> n >> k;
    vll p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]++;
    }
    
    int mx = 0;
    int tmp = 0;
    queue<int> q;
    rep(i, n) {
        tmp += p[i];
        q.push(p[i]);
        if(q.size() > k) {
            tmp -= q.front(); q.pop();
        } 
        if(q.size() == k) mx = max(mx, tmp);
    }

    double ans = mx;
    ans /= 2;
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
using namespace boost::multiprecision;

int main(void)
{
	unsigned long long a;
	string bstr;
	cin >> a >> bstr;
	int i;
	for (i = 0; i < bstr.size(); i++) {
		if (bstr[i] == '.') {
			break;
		}
	}
	bstr.erase(bstr.begin() + i);
	long long b = stoll(bstr);


	cout << (a*b)/100 << endl;
	return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
#define LL long long
using namespace std;
int n,m,v,p,a[N+5];LL s[N+5];
I bool cmp(CI x,CI y) {return x>y;}
int main()
{
	RI i;for(scanf("%d%d%d%d",&n,&m,&v,&p),i=1;i<=n;++i) scanf("%d",a+i);
	for(sort(a+1,a+n+1,cmp),i=1;i<=n;++i) s[i]=s[i-1]+a[i];
	for(i=n;i>p;--i) if(a[i]+m>=a[p])
		if(1LL*max(v-p-(n-i),0)*m<=1LL*(a[i]+m)*(i-p)-(s[i-1]-s[p-1])) break;
	return printf("%d",i),0;
}

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

/*
void toBit(int num){
  string str = "";
  while(num){
    if(num%2){
      str += "1";
    }
    else{
      str += "0";
    }
    num /= 2;
  }
  while(str.size() < 7)str += '0';
  reverse(str.begin(),str.end());
  cout << str << endl;
}

int test(){
  cout << "1" << endl;
  toBit(1);
  cout << "60" << endl;
  toBit(60);
  cout << "61" << endl;
  toBit(61);
  cout << "99" << endl;
  toBit(99);
  cout << "95" << endl;
  toBit(95);
  cout << "127" << endl;
  toBit(127);
}
*/

int func(int n,int d){
  if(n == 1)return d;
  int max_bit = 127;
  int new_bit = max_bit ^ d;
  return func(n-1,new_bit) + max_bit;
}

int main(){
  int T;
  cin >> T;
  for(int i = 0 ; i < T ; i++){
    int n,d;
    cin >> n >> d;
    cout << func(n,d) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

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

    for (int i = 0; i < q; i++){
      int a; cin >> a;
      if(a==1){
        swap(s, t);
      } else {
        int f;
        string c; cin >> f >> c;
          if (f==1){
            t += c;
          } else {
            s += c;
          }
      }
    }

    reverse(t.begin(), t.end());
    cout << t << s << endl;
    
    return 0;
    
}


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

using namespace std;
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define debug(a) cerr << #a << ": " << (a) << '\n';
#define debug_two(a, b) cerr << #a << ": " << (a) << ", " << #b << ": " << (b) << '\n';

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int INF = 1000000000 + 7;
const ll LL_INF  = 1ll * INF * INF;
const int MAX_N = 100000 + 7;

template <typename T>
inline void addmod(T& a, const ll& b, const int& MOD = INF) {
	a = (a + b) % MOD; if (a < 0) a += MOD;
}

inline void addEdge(int u, int v) {
  cout << u + 1 << ' ' << v + 1 << '\n';
}

void solve() {
	string s;
	cin >> s;
	int n = sz(s);
	if (s[n - 1] == '1' || s[0] == '0') {
		cout << -1;
		return;
	}
	for (int i = 0, j = n - 2; i <= j; ++i, --j) {
		if (s[i] != s[j]) {
			cout << -1;
			return;
		}
	}
	int last = 0;
	rep(i, 0, n - 1) {
		addEdge(last, i + 1);
		if (s[i] == '1')
			last = i + 1;
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
	const bool multiple_test = false;
	int test = 1;
	if (multiple_test)
		cin >> test;
	
	for(int i = 0; i < test; ++i) {
		//printf("Case #%d: ", i + 1);
		solve();
	}
#ifdef _LOCAL_
	cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 1616
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: i64 = itr.next().unwrap().parse().unwrap();
    let a: i64 = itr.next().unwrap().parse().unwrap();
    let b: i64 = itr.next().unwrap().parse().unwrap();
    let c: i64 = itr.next().unwrap().parse().unwrap();
    let d: i64 = itr.next().unwrap().parse().unwrap();

    for up in 0..n {
        let down = n - 1 - up;
        let max = a + d * up - c * down;
        let min = a + c * up - d * down;
        if min <= b && b <= max {
            println!("YES");
            return;
        }
    }
    println!("NO");
}


Measured memory_bytes: 4352
a,b,c = map(int, input().split())

ans1=a*b*abs(c//2 - (c-c//2))
ans2=b*c*abs(a//2 - (a-a//2))
ans3=a*c*abs(b//2 - (b-b//2))

print(min(ans1,ans2,ans3))

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1],t[LIMIT1];
  
  scanf("%lld",&n);
  scanf("%s",s);
  scanf("%s",t);
  for(i=n;i>=1;i--){
    if(strncmp(&s[n-i],t,i)==0) break;
  }
  printf("%lld",2*n-i);
  
  return 0;
}



Measured memory_bytes: 128
import math

N, W = map(int, input().split())

DP = [[math.inf] * 100001 for _ in range(N+1)]
DP[0][0] = 0
for i in range(1, N+1):
    w, v = map(int, input().split())
    for j in range(100001):
        if j >= v:
            DP[i][j] = min(DP[i-1][j], DP[i-1][j-v]+w)
        else:
            DP[i][j] = DP[i-1][j]

ans = 100000
while DP[N][ans] > W:
    ans -= 1
print(ans)


Measured memory_bytes: 248992
#include <iostream>
#include<bits/stdc++.h>
#define rep(k,i,n) for(long i=k;i<n;++i)
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    cin>>A>>B;
    int c=0,sum=1;
    while(sum<B){
        sum+=A-1;
        ++c;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#[cfg(debug_assertions)]
include! {"./debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
#[allow(deprecated)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

////////////////////////////////////////////////////////////////////////////////

fn main() {
    let (a, p) = read!(i32, i32);

    let ans = (a * 3 + p) / 2;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
    long long N, P;
    cin >> N >> P;

    // if(N == 1)
    // {
    //     cout << P << endl; return 0;
    // }

    map<long long, long long> m;

    for (long long i = 2; i * i <= P; i++)
    {
        while (P % i == 0)
        {
            m[i]++;
            P /= i;
        }
    }
    if(P != 1) m[P]++;
    
    long long ans = 1;

    for (auto i = m.begin(); i != m.end(); i++)
    {
        for (long long j = 0; j < i->second / N; j++)
        {
            ans *= i->first;
        }
        
    }    
    
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
typedef long long ll;
const int N=0;
int n,k,x,t;
string s;
vector<int>v;
int main(){

	char c;
	cin >>c;
	cout << (char)(c+1)	;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
	int l;
	std::cin >> l;
	while (l != 0) {
		int num = 0;
		for (int m, n, i = 1; i < 13; ++i) {
			std::cin >> m >> n;
			l -= m - n;
			if (l <= 0 && num == 0) {
				num = i;
			}
		}
		if (num == 0) {
			std::cout << "NA\n";
		}
		else {
			std::cout << num << "\n";
		}
		std::cin >> l;
	}
	return 0;
}

Measured memory_bytes: 1152
import itertools
import math

n = input()
if(int(n)<357):
    print(0)
    exit()

ans = 0

for i in range(3,len(n)+1):
    if len(n) == i:
        for v in itertools.product(['3','5','7'],repeat=i):
            if '3' in v and '5' in v and '7' in v:
                if int(''.join(v)) <= int(n):
                    ans += 1
    else:
        ans += 3 ** i - 2 ** i * 3 + 3
print(ans)

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A + B) > (C+ D)){
    cout << "Left" << endl;
  }
  if ((A + B) == (C+ D)){
    cout << "Balanced" << endl;
  }
  if ((A + B) < (C+ D)){
    cout << "Right" << endl;
  }
}

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

using namespace std;



int main() {

    int n;
    cin>>n;
    string word;
    int ac=0,tle=0,re=0,wa=0;
    while(n--){
        cin>>word;
        if(word[0]=='A'){
            ac++;
        }
        else if(word[0]=='R'){
            re++;
        }
        else if(word[0]=='T'){
            tle++;
        }
        else {
            wa++;
        }

    }

    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;


    return 0;
}


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

int main(void){
   
   int n,ans=0,tmp=1;
   cin>>n;
   int a[n];

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

   cout<<accumulate(a,a+n,0)-n;

}



Measured memory_bytes: 256
function isPrime(n) {
    if (n === 1)
        return false;
    if (n === 2)
        return true;
    if (n % 2 === 0)
        return false;
    var val = true;
    //   const iMax = Math.floor(n / 2);
    var iMax = Math.floor(Math.sqrt(n));
    for (var i = 2; i <= iMax; i++) {
        // if (isPrime(i)) {
        if (n % i === 0) {
            val = false;
            break;
        }
        // } else continue;
    }
    return val;
}
function countPrimeNumbers(ar) {
    var count = 0;
    ar.forEach(function (val) {
        if (isPrime(val))
            count += 1;
    });
    return count;
}
function main(input) {
    console.log(countPrimeNumbers(input
        .trim()
        .split("\n")
        .slice(1)
        .map(function (i) { return +i; })));
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 18084
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int N;
  long long D;
  std::cin >> N >> D;
  std::vector<long long > x(N), y(N);
  for (int i=0; i<N; i++) {
    std::cin >> x[i] >> y[i];
  }
  int ans = 0;
  for (int i=0; i<N; i++) {
    if (x[i]*x[i]+y[i]*y[i]<=D*D) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 6084
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  int H, W;
  vector<vector<char>> board;
  cin >> H >> W;
  board = vector<vector<char>>(H, vector<char>(W));
  int dot_count = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> board[i][j];
      if (board[i][j] == '.') {
        dot_count++;
      }
    }
  }

  int step = 0;
  board[0][0] = '*';
  queue<pair<int, int>> que;
  que.push(make_pair(0, 0));
  while (!que.empty()) {
    step++;
    queue<pair<int, int>> tmp;
    while (!que.empty()) {
      pair<int, int> pos = que.front();
      que.pop();
      int x = pos.first;
      int y = pos.second;

      if (x == H - 1 && y == W - 1) {
        cout << dot_count - step << endl;
        return 0;
      }

      if (x + 1 < H && board[x + 1][y] == '.') {
        board[x + 1][y] = '*';
        tmp.push(make_pair(x + 1, y));
      }
      if (y + 1 < W && board[x][y + 1] == '.') {
        board[x][y + 1] = '*';
        tmp.push(make_pair(x, y + 1));
      }
      if (0 <= x - 1 && board[x - 1][y] == '.') {
        board[x - 1][y] = '*';
        tmp.push(make_pair(x - 1, y));
      }
      if (0 <= y - 1 && board[x][y - 1] == '.') {
        board[x][y - 1] = '*';
        tmp.push(make_pair(x, y - 1));
      }
    }
    que.swap(tmp);
  }

  cout << "-1" << endl;

  return 0;
}

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

int Sosu(int *x)
{
  for(int i=2;i<*x;i++)
  {
    if(*x%i==0)
    {
      *x++;
      i=2;
      continue;
    }
    if(i==*x-1)
      return *x;
  }
}

int main()
{
  int x;
  cin>>x;
  
  for(int i=2;i<x;i++)
  {
    if(x%i==0)
    {
      x++;
      i=2;
      continue;
    }
  }
  
  cout<<x<<endl;
}
  
  

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

int main(){
  int N;
  cin >> N;
  vector<int> p(N),ori(N);
  int count=0;
  for(int i=0;i<N;i++){
    cin >> p.at(i);
    ori.at(i)=p.at(i);
  }
  sort(p.begin(),p.end());
  for(int i=0;i<N;i++){
    if(p.at(i)!=ori.at(i)){
      count++;
    }
  }
  if(count<=2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
      
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

a = sorted(a)

if n == 2:
    print(a[1] - a[0])
    exit()

res1 = a[n - 1] + a[n - 2] - (a[0] * 2)
p = n - 3
q = 1
mode = 0
while 1:
    #print(p, q, res1)
    if p < q:
        break
    elif p == q:
        if mode == 0:
            res1 += a[p + 2] - a[p]
        else:
            res1 += a[p] - a[p - 2]
        break
    else:
        if mode == 0:
            res1 += a[p + 1] + a[p + 2] - a[q] - a[q + 1]
            mode = 1
            q += 2
        else:
            res1 += a[p] + a[p - 1] - a[q - 1] - a[q - 2]
            mode = 0
            p -= 2

res2 = a[n - 1] * 2 - a[0] - a[1]
p = n - 2
q = 2
mode = 1
while 1:
    #print(p, q, res2)
    if p < q:
        break
    elif p == q:
        if mode == 0:
            res2 += a[p + 2] - a[p]
        else:
            res2 += a[p] - a[p - 2]
        break
    else:
        if mode == 0:
            res2 += a[p + 1] + a[p + 2] - a[q] - a[q + 1]
            mode = 1
            q += 2
        else:
            res2 += a[p] + a[p - 1] - a[q - 1] - a[q - 2]
            mode = 0
            p -= 2

print(max(res1, res2))

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

n = int(input())
l = list(map(int, input().split()))
l[0] -= 1
for i in range(1, n):
	if l[i] > l[i-1]:
		l[i] -= 1
if l == sorted(l):
	print("Yes")
else:
	print("No")


Measured memory_bytes: 59632
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
typedef long long ll;
const int N=500005;
int n,m,tim[N];
using namespace std;

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	scanf ("%d %d",&n,&m);
	int i,s,t,ans=0;
	for (i=1;i<=m;i++)
	scanf ("%d %d",&s,&t),tim[s]^=1,tim[t]^=1;
	for (i=1;i<=n;i++) if (tim[i]) break;
	if (i<=n) puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
using ll=long long;

int N_MAX=50;
int main(){
    int N,K,xt,yt,xmin,xmax,ymin,ymax,ct;
    int x[N_MAX],y[N_MAX];
    ll ans=4*1e18;
    cin>>N>>K;
    //cout<<N<<" "<<K<<endl;
    for(int i=0;i<N;i++){
        cin>>xt>>yt;
        x[i]=xt;
        y[i]=yt;
    }
    //for(int i =0;i<N;i++){
    //    cout<<x[i]<<" "<<y[i]<<endl;
    //}
    for(int i=0; i<N;i++){
        for(int j=0;j<N;j++){
            xmin=x[i];
            xmax=x[j];
            if(xmin>=xmax)
                continue;
            for(int k=0;k<N;k++){
                for(int l=0;l<N;l++){
                    ymin=y[k];
                    ymax=y[l];
                    if(ymin>=ymax)
                        continue;
                    ct=0;
                    for(int m=0;m<N;m++){
                        if(xmin<=x[m] && x[m]<=xmax && ymin<=y[m] && y[m]<=ymax)
                            ct++;
                        if(ct==K){
                            ans=min(ans,1ll *(xmax-xmin)*(ymax-ymin));
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	map<char, lint>MP;
	MP['I'] = 1;
	MP['V'] = 5;
	MP['X'] = 10;
	MP['L'] = 50;
	MP['C'] = 100;
	MP['D'] = 500;
	MP['M'] = 1000;
	string S;
	while (cin >> S) {
		reverse(S);
		lint Z = S.size();
		lint ans = 0;
		ans += MP[S[0]];
		for (lint i = 1; i < Z; i++) {
			if (MP[S[i]] >= MP[S[i - 1]]) {
				ans += MP[S[i]];
			}
			else {
				ans -= MP[S[i]];
			}
		}
		cout << ans << enld;
	}
}


Measured memory_bytes: 3152
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
  int n,m;
  cin>>n>>m;
  int h[100001];
  int ma[1000001];
  //string s[200000],a;
  
  for(int i=1;i<n+1;i++){
    cin>>h[i];
    ma[i]=0;
  }
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    ma[a]=max(ma[a],h[b]);
    ma[b]=max(ma[b],h[a]);
  }
  int ans=0;
  for(int i=1;i<n+1;i++){
    if(ma[i]<h[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using namespace std;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }

int main() {
    // input
    int a, b, c, d, e, f; scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
    // solve
    auto func = [&](int x, int y) {
        vector<bool> dp(f + 1);
        dp[0] = true;
        REP (i, f - x + 1) if (dp[i]) dp[i + x] = true;
        REP (i, f - y + 1) if (dp[i]) dp[i + y] = true;
        return dp;
    };
    vector<bool> dp1 = func(100 * a, 100 * b);
    vector<bool> dp2 = func(c, d);
    int p = 0, q = 100 * a;
    REP (x, f + 1) if (dp1[x]) {
        REP (y, f - x + 1) if (dp2[y]) {
            if (100 * y <= x * e) {
                if (p * (x + y) < y * q) {
                    p = y;
                    q = x + y;
                }
            }
        }
    }
    // output
    printf("%d %d\n", q, p);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>
#define sz(x) (int)((x).size())
#define int long long

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

const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 20;
const int NMAX = 1e4 + 11;
const ll INF64 = 3e18 + 1;
const double lil = 0.0000000000001;

//ifstream cin ("test.in");
//ofstream cout ("test.out");

int n, a[N][N], dp[(1 << N)];

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

    cin >> n;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }

    //create groups
    for(int mask = 0; mask < (1 << n); mask++){

        int ans = 0;

        for(int i = 0; i < n; i++){
            if(!(mask & (1 << i)))continue;
            for(int j = 0; j < i; j++){
                if(!(mask & (1 << j)))continue;
                ans += a[i][j];
            }
        }

        dp[mask] = ans;
    }

    for(int mask = 1; mask < (1 << n); mask++){
        for(int i = mask; i; i = (mask & (i - 1))){
            if(dp[mask] < dp[mask - i] + dp[i])dp[mask] = dp[mask - i] + dp[i];
        }
    }

    rc(dp[(1 << n) - 1]);
}


Measured memory_bytes: 768
//package atcoder.dpContest;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));

        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

            solve(1, in, out);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private static void solve(int q, FastScanner in, PrintWriter out) {
        for (int qq = 0; qq < q; qq++) {
            int N = in.nextInt();
            int[] a = new int[N];
            long sum = 0;
            for(int i = 0; i < N; i++) {
                a[i] = in.nextInt();
                sum += a[i];
            }
            long[][] dp = new long[N][N];    //dp[i][j]: the resulting max value of X for a[i,j]
            for(int i = 0; i < N; i++) {
                dp[i][i] = a[i];
            }
            for(int i = 0; i < N - 1; i++) {
                dp[i][i + 1] = Math.max(a[i], a[i + 1]);
            }
            for(int l = 3; l <= N; l++) {
                for(int left = 0; left <= N - l; left++) {
                    int right = left + l - 1;
                    dp[left][right] = Math.max(Math.min(dp[left + 2][right], dp[left + 1][right - 1]) + a[left],
                                                Math.min(dp[left][right - 2], dp[left + 1][right - 1]) + a[right]);
                }
            }
            out.println(dp[0][N - 1] * 2 - sum);
        }
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}




Measured memory_bytes: 131408
s = input()

yymm = mmyy = False

if int(s[:2]) <= 12 and int(s[:2]) >= 1:
    mmyy = True

if int(s[2:]) <= 12 and int(s[2:]) >= 1:
    yymm = True

res = ''
if yymm and mmyy:
    res = 'AMBIGUOUS'
elif yymm:
    res = 'YYMM'
elif mmyy:
    res = 'MMYY'
else:
    res = 'NA'

print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class BIT {
	int n;
	vector<ll> node;
public:
	BIT(int N) :n(N), node(N + 1) {}
	void add(int i, int x) {
		for (++i;i <= n;i += i & -i) node[i] += x;
	}
	ll sum(int i) {
		ll s = 0;
		for (i = min(i, n);i > 0;i -= i & -i) s += node[i];
		return s;
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	ll D, A;

	cin >> N >> D >> A;
	
	vector<pair<ll, ll>> XH(N);

	REP(i, N) {
		cin >> XH[i].first >> XH[i].second;
	}

	SORT(XH);

	vector<ll> X(N), H(N);
	REP(i, N) tie(X[i], H[i]) = XH[i];

	BIT bit(N);
	
	int r = 1;
	ll res = 0;
	for (int l = 0;l < N;++l) {
		H[l] -= bit.sum(l + 1);
		if (H[l] <= 0) continue;
		ll num = (H[l] + A - 1) / A;
		res += num;
		if (r <= l) r = l + 1;
		while (r < N && X[r] - X[l] <= 2 * D) ++r;
		bit.add(l, num * A);
		bit.add(r, -num * A);
	}
	cout << res << endl;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

const int N = 510;
char a[N][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    forn(i, 0, n) cin >> a[i];
    vector<int> to_fix;
    forn(j, 0, n) {
        forn(i, 0, n) {
            if (a[i][j] == '.') {
                to_fix.eb(j);
                break;
            }
        }
    }
    if (to_fix.empty()) {
        cout << "0\n";
        return 0;
    }
    set<int> can_fix;
    forn(i, 0, n) forn(j, 0, n) if (a[i][j] == '#') can_fix.insert(j);
    if (can_fix.empty()) {
        cout << "-1\n";
        return 0;
    }
    int ans = INF;
    forn(i, 0, n) {
        int loc = 0;
        forn(j, 0, n) if (a[i][j] == '.') ++loc;
        if (can_fix.count(i)) ans = min(ans, loc);
        else ans = min(ans, loc + 1);
    }
    cout << ans + to_fix.size() << '\n';
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	static class Pair {
		int x,y;

		public Pair(int x, int y) {
			this.x = Math.min(x, y);
			this.y = Math.max(x, y);
		}
		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		Pair[] v = new Pair[N];
		int min = Integer.MAX_VALUE;
		int max = 0;
		for(int i=0; i<N; i++) {
			v[i] = new Pair(sc.nextInt(), sc.nextInt());
			min = Math.min(min, v[i].x);
			max = Math.max(max, v[i].y);
		}
		
		long min1=Long.MAX_VALUE;
		long max1=0;
		long min2=Long.MAX_VALUE;
		long max2=0;
		for(int i=0; i<N; i++) {
			min1 = Math.min(min1, v[i].x);
			max1 = Math.max(max1, v[i].x);
			min2 = Math.min(min2, v[i].y);
			max2 = Math.max(max2, v[i].y);
		}
		long ans = (max1-min1)*(max2-min2);

		Arrays.sort(v, new Comparator<Pair>() {
			public int compare(Pair p1, Pair p2) {
				return p1.x-p2.x;
			}
		});
		long mindiff = v[N-1].x-v[0].x;
		
		long min3=Long.MAX_VALUE;
		long max3=0;
		for(int i=0; i<N; i++) {
			min3 = Math.min(min3, v[i].y);
			max3 = Math.max(max3, v[i].y);
			mindiff = Math.min(mindiff, i==N-1 ? max3-min3: Math.max(max3, v[N-1].x) - Math.min(min3, v[i+1].x));
		}
		
		ans = Math.min(ans, mindiff*(max-min));
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 105520
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N,M;
int k[15];
int s[15][15];
int p[15];
vector<int> ans;
signed main(){
    scanf("%lld %lld",&N,&M);
    rep(i,M){
        scanf("%lld",&k[i]);
        rep(j,k[i]){scanf("%lld",&s[i][j]);s[i][j]--;}
    }
    rep(i,M)scanf("%lld",&p[i]);
    int ans=0;
    rep(i,1<<N){//全てのスイッチの状態iについて
        rep(j,M){//Mこの電球について
            int sum=0;
            rep(sw,k[j]){//s番目のスイッチがオンかどうか調べる
                if((i>>s[j][sw])%2==1)sum++;
            }
            if(sum%2!=p[j])break;
            if(j==M-1)ans++;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int primeNumber(int);

int main(){
  int n, i, x, sum=0;
  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ ){
    scanf("%d",&x);
    if( primeNumber(x) ) sum++;
  }
  printf("%d\n", sum);
  return 0;
}

int primeNumber(int x){
  int i;
  if( x < 2 ) return 0;
  else if( x == 2 ) return 1;
  if( x % 2 == 0 ) return 0;
  for( i = 3 ; i*i <= x ; i+=2 ){
    if( x % i == 0 ) return 0;
  }
  return 1;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a,b;
    cin>>a>>b;
    ll p=(b-a)*(b-a+1);
    p/=2;
    p-=b;
    cout<<p<<endl;
}


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

int main() {
  int N, M;
  int s = 0;
  cin >> N >> M;
  for (int i=0; i<M; i++) {
    int tmp;
    cin >> tmp;
    s+=tmp;
  }
  if (N-s>=0) {
    cout << N-s;
  }
  else {
    cout << -1;
  }
}

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

int main(){
  int a1, a2, a3, a4, a5, a6, A1, A2, A3, b1, b2, b3, b4, b5, b6, B1, B2, B3, c1, c2, c3, c4, c5, c6, C1, C2, C3;
  cin>>a1>>a2>>a3>>a4>>a5>>a6>>b1>>b2>>b3>>b4>>b5>>b6>>c1>>c2>>c3>>c4>>c5>>c6;

  if(a6 < a3 && a5 <= a2){
    int A1 = -1 + a4 - a1;
    int A2 = 59 + a5 - a2;
    int A3 = 60 + a6 - a3;
    cout<<A1<<" "<<A2<<" "<<A3<<endl;
  }

  if(a6 < a3 && a5 > a2){
    int A1 = a4 - a1;
    int A2 = -1 + a5 - a2;
    int A3 = 60 + a6 - a3;
    cout<<A1<<" "<<A2<<" "<<A3<<endl;
  }

  if(a6 >= a3 && a5 < a2){
    int A1 = -1 + a4 - a1;
    int A2 = 60 + a5 - a2;
    int A3 = a6 - a3;
    cout<<A1<<" "<<A2<<" "<<A3<<endl;
  }

  if(a6 >= a3 && a5 >= a2){
    int A1 = a4 - a1;
    int A2 = a5 - a2;
    int A3 = a6 - a3;
    cout<<A1<<" "<<A2<<" "<<A3<<endl;
  }

  if(b6 < b3 && b5 <= b2){
    int B1 = -1 + b4 - b1;
    int B2 = 59 + b5 - b2;
    int B3 = 60 + b6 - b3;
    cout<<B1<<" "<<B2<<" "<<B3<<endl;
  }

  if(b6 < b3 && b5 > b2){
    int B1 = b4 - b1;
    int B2 = -1 + b5 - b2;
    int B3 = 60 + b6 - b3;
    cout<<B1<<" "<<B2<<" "<<B3<<endl;
  }

  if(b6 >= b3 && b5 < b2){
    int B1 = -1 + b4 - b1;
    int B2 = 60 + b5 - b2;
    int B3 = b6 - b3;
    cout<<B1<<" "<<B2<<" "<<B3<<endl;
  }

  if(b6 >= b3 && b5 >= b2){
    int B1 = b4 - b1;
    int B2 = b5 - b2;
    int B3 = b6 - b3;
    cout<<B1<<" "<<B2<<" "<<B3<<endl;
  }

  if(c6 < c3 && c5 <= c2){
    int C1 = -1 + c4 - c1;
    int C2 = 59 + c5 - c2;
    int C3 = 60 + c6 - c3;
    cout<<C1<<" "<<C2<<" "<<C3<<endl;
  }

  if(c6 < c3 && c5 > c2){
    int C1 = c4 - c1;
    int C2 = -1 + c5 - c2;
    int C3 = 60 + c6 - c3;
    cout<<C1<<" "<<C2<<" "<<C3<<endl;
  }

  if(c6 >= c3 && c5 < c2){
    int C1 = -1 + c4 - c1;
    int C2 = 60 + c5 - c2;
    int C3 = c6 - c3;
    cout<<C1<<" "<<C2<<" "<<C3<<endl;
  }

  if(c6 >= c3 && c5 >= c2){
    int C1 = c4 - c1;
    int C2 = c5 - c2;
    int C3 = c6 - c3;
    cout<<C1<<" "<<C2<<" "<<C3<<endl;
  }

  return 0;
}


  



Measured memory_bytes: 3104
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

int main(){
	int n,x;
	scanf("%d%*d%d",&n,&x);
	int l2,l1;
	rep(i,0,n){
		l2=l1;
		scanf("%d",&l1);
	}
	
	if(n==1)printf("%d\n",abs(l1-x));
	else printf("%d\n",max(abs(l1-x),abs(l2-l1)));
	return 0;
}

Measured memory_bytes: 128
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));
    return 0;
}
//.........

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        Arrays.sort(s);
        String sAsc = new String(s);
        char[] t = sc.next().toCharArray();
        Arrays.sort(t);
        String tAsc = new String(t);
        String tDesc = new StringBuilder(tAsc).reverse().toString();
        if(sAsc.compareTo(tDesc) < 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        sc.close();

    }

}


Measured memory_bytes: 25044
#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;
typedef double DOUBLE;
#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
#define j0 gray_cat_j0

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 ll LL_INF = 1e17 + 16;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	int n;
	cin >> n;
	int k = n / gcd(n, 360);
	int ans = 360 * k / n;
	cout << ans << endl;
}

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


Measured memory_bytes: 3620