akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        a--;
    }
    return ans;
}
int main(){
    double w,h;
    double x,y;
    cin >> w >> h >> x >> y;
    double ans = w*h/2;
    CST(10);
    cout << ans << endl;
    double a=w/2,b=h/2;
    if(x==a&&y==b){
        cout << 1 << endl;
        return 0;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
A,B=map(int,input().split())

data=[0 for i in range(40)]
if 10>B-A>=1:
    lst=[i for i in range(A,B+1)]
else:
    lst=[]
    if A%2==1:
        lst.append(A)
        A+=1
    for i in range((B-A+1)%4):
        lst.append(B-i)

    #print(lst)
for num in lst:
    for i,s in enumerate(list(reversed(bin(num)[2:]))):
        data[i]=(data[i]+int(s))%2

while data:
    if data[-1]==0:
        data.pop()
    else:
        break

value=0
for i in range(len(data)):
    if data[i]:
        value+=2**(i)
if data:
    print(value)
else:
    print(0)


Measured memory_bytes: 38512
#include<iostream>
#include<vector>
using namespace std;

struct Point
{
	Point(int x, int y):x(x),y(y),z(0){}
	Point():x(0),y(0),z(0){}
	int x,y,z;
};
inline bool isLeft( Point &p, Point &a, Point &b ){
	return ( (b.x-a.x)*(p.y-a.y) - (b.y-a.y)*(p.x-a.x) ) > 0;
}
bool isInside( Point &p, vector<Point> &vp ){
	bool bCond = isLeft( p, vp[0], vp[1] );
	for(unsigned int i = 1; i < vp.size(); ++i){
		if( bCond != isLeft( p, vp[i-1], vp[i] ) )
			return false;
	}
	return bCond == isLeft( p, vp[vp.size()-1], vp[0] );
}

int main()
{
	int n;
	cin >> n;
	for(int X = 0; X < n; ++X ){
		Point A, B, C, ken, ori;
		bool  bKenInside = false, bOriInside = false;
		vector<Point> triangle;
		cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> ken.x >> ken.y >> ori.x >> ori.y;
		triangle.push_back(A);triangle.push_back(B);triangle.push_back(C);

		bKenInside = isInside( ken, triangle );
		bOriInside = isInside( ori, triangle );
		if( bKenInside ^ bOriInside )
			cout << "OK\n";
		else
			cout << "NG\n";
	}
	return 0;
}

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

int n;
set<int> st;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		st.insert(x);
	}
	cout<<(st.size()==n?"YES":"NO")<<endl;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <vector>
#include <algorithm>

int main() {
  int N;
  scanf("%d", &N);

  std::vector<int> a(N);
  intmax_t sum=0;
  for (int i=0; i<N; ++i) {
    scanf("%d", &a[i]);
    sum += a[i];
  }

  intmax_t res=std::abs(sum-=2*a[0]);
  for (int i=1; i<N-1; ++i)
    res = std::min(res, std::abs(sum-=2*a[i]));

  printf("%jd\n", res);
  return 0;
}


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

int main(){
    std::vector<int> num(3);
    for(int i = 0; i < 3; ++i){
        std::cin >> num.at(i);
    }

    std::sort(num.begin(), num.end());

    int ans = num.at(2) - num.at(1) + (num.at(1) - num.at(0))/2;
    if(1 == (num.at(1)- num.at(0)) % 2){
        ans += 2;
    }

    std::cout << ans << std::endl;

    return 0;
}

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

int main() {
        int n, a, b;
        scanf("%d%d%d", &n, &a, &b);
        vector<int> pos(n);
        rep(i, n) {
                int p;
                scanf("%d", &p);
                p --;
                pos[p] = i;
        }
        const long long inf = 1e18;
        vector<vector<long long>> cur(n + 1, vector<long long> (2));
        rep(i, n) {
                vector<vector<long long>> next(n + 1, vector<long long> (2));
                vector<long long> mi0(n + 1), mi1(n + 1);
                mi0[0] = cur[0][0];
                rep(j, n + 1) if (j) {
                        mi0[j] = min(mi0[j - 1], cur[j][0]);
                }
                mi1[0] = cur[0][1];
                rep(j, n + 1) if (j) {
                        mi1[j] = min(mi1[j - 1], cur[j][1]);
                }

                // rep(j, n + 1) cerr << mi0[j] << ' '; cerr << endl;
                // rep(j, n + 1) cerr << mi1[j] << ' '; cerr << endl;

                rep(j, n + 1) {
                        next[j][0] = inf;
                        next[j][1] = inf;
                        int cost = 0;
                        if (j < pos[i]) cost = b;
                        if (j > pos[i]) cost = a;
                        // hei
                        if (j != n + 1) {
                                if (j > 0) next[j][0] = min(next[j][0], mi0[j - 1] + cost);
                                if (j > 0) next[j][0] = min(next[j][0], mi1[j - 1] + cost);
                                /*
                                rep(k, j) {
                                        next[j][0] = min(next[j][0], cur[k][0] + cost);
                                        next[j][0] = min(next[j][0], cur[k][1] + cost);
                                }
                                */
                                next[j][0] = min(next[j][0], cur[j][1] + cost);
                        }
                        // kai
                        if (j == pos[i]) cost = b;
                        if (j > 0) next[j][1] = min(next[j][1], mi0[j - 1] + cost);
                        /*
                        rep(k, j) {
                                next[j][1] = min(next[j][1], cur[k][0] + cost);
                        }
                        */
                        next[j][1] = min(next[j][1], mi1[j] + cost);
                        /*
                        rep(k, j + 1) {
                                next[j][1] = min(next[j][1], cur[k][1] + cost);
                        }
                        */
                }
                // rep(j, n + 1) cerr << next[j][0] << ' '; cerr << endl;
                // rep(j, n + 1) cerr << next[j][1] << ' '; cerr << endl;
                cur.swap(next);
        }      
        long long ans = inf;
        rep(i, n + 1) {
                ans = min(ans, cur[i][0]);
                ans = min(ans, cur[i][1]);
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 944
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! chmax {
    ($x:expr, $e:expr) => {
        if $x < $e {
            $x = $e;
        }
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        if $x > $e {
            $x = $e;
        }
    };
}

const INF: i64 = 1 << 60;

fn gcd(a: usize, b: usize) -> usize {
    match (a, b) {
        (a, 0) => a,
        (a, b) => gcd(b, a%b),
    }
}
fn lcm(a: usize, b: usize) -> usize {
    a * b / gcd(a, b)
}

fn main() {
    input!{
        A: usize,
        B: usize,
    }
    println!("{}", lcm(A, B));
}


Measured memory_bytes: 4352
N,K = map(int,input().split())
S = input()
cnt01 = []
for i,s in enumerate(S):
    if i == 0:
        if s == "0":
            cnt01.append([1,0])
        cnt01.append([s,1])
    else:
        if cnt01[-1][0] == s:
            cnt01[-1][1] += 1
        else:
            cnt01.append([s,1])
if len(cnt01) <= 2*K+1:
    ans = sum([cnt[1] for cnt in cnt01])
    print(ans)
    exit()
else:
    ans = [sum([cnt[1] for cnt in cnt01[0:2*K+1]])]
    pos = 2
    while True:
        temp = ans[-1] - cnt01[pos-2][1] - cnt01[pos-1][1]
        if len(cnt01)-1 >= (pos + 2*K -1):
            temp += cnt01[pos+2*K-1][1]
        else:
            break
        if len(cnt01)-1 >= (pos + 2*K):
            temp += cnt01[pos+2*K][1]
        else:
            ans.append(temp)
            break
        ans.append(temp)
        pos += 2
print(max(ans))


Measured memory_bytes: 15284
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    ll y = 0;
    for(int i = 0; i < N; ++i){
        cin >> v[i];
        y += v[i];
    }
    ll x = 0;
    ll ans = INFL;
    for(int i = 0; i < N-1; ++i){
        x += v[i];
        y -= v[i];
        ans = min(ans, llabs(x-y));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void)
{
  string str;
  int N;
  int count = 0;

  cin >> N >> str;

  for (int i = 0; i < N - 2; i++) {
    if (str[i] == 'A' && str[i + 1] == 'B' && str[i + 2] == 'C') {
      count++;
      i += 2;
    }
  }

  cout << count;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
int main(void) {
	std::string s;
	std::cin >> s;
	int a = 0, b = 0;
	int c = s.size();
	//std::cout << c << std::endl;
	for (int i = 0; i < c; i++) {
		if (i % 2 == 0) {
			if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
				a++;
			}
		}
		else {
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
				b++;
			}
		}
	}
	//std::cout << a << " " << b << std::endl;
	if (c == a + b) { std::cout << "Yes" << std::endl; }
	else { std::cout << "No" << std::endl; }
	return 0;
}

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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  long N;
  cin >> N;
  long ans = 0;
  for (long a = 1; a <= N; a++) {
    for (long b = 1; b <= N / a; b++) {
      if (a * b < N) ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  list<int> l;
  rep(i,N)cin >> v[i];
  bool first = false;
  if(N&1) first = !first;
  rep(i,N){
    if(first) l.push_front(v[i]);
    else l.push_back(v[i]);
    first = !first;
  }
  for( auto &e : l ) cout << e SPF;
  cout << endl;
  return 0;
}


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

int main(){
    int n;
    string s;
    cin >> s;
    n = s.size();
    for(int i=0;i<n;i++){
        if(i%2 == 0){
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
#include <functional>	
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 9 && b < 9) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
using System;

public class Program
{
    private long H;
    public void Solve()
    {
        var sc = new Scanner();
        H = sc.NextLong();
        Console.WriteLine(C(H));
    }

    private long C(long n)
    {
        if (n == 1) return 1;
        else return C(n / 2) * 2 + 1;
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.util.Collections.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// Divide the Water
// 2012/12/15
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;

	int n;
	int[] a;

	void run(){
		n=sc.nextInt();
		a=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
		}
		solve();
	}

	int[] sum;
	int[][] memo;

	void solve(){
		sum=new int[n+1];
		for(int i=0; i<n; i++){
			sum[i+1]=sum[i]+a[i];
		}
		memo=new int[n+1][n+1];
		for(int i=0; i<=n; i++){
			fill(memo[i], -1);
		}
		println(rec(0, n)+"");
	}

	int rec(int i, int j){
		if(memo[i][j]>=0){
			return memo[i][j];
		}
		if(j-i<=1){
			return memo[i][j]=j-i;
		}
		int res=INF;
		for(int k=i+1; k<j; k++){
			res=min(res, rec(i, k)+rec(k, j));
			if(sum[k]-sum[i]==sum[j]-sum[k]&&rec(i, k)==1&&rec(k, j)==1){
				res=min(res, 1);
			}
		}
		return memo[i][j]=res;
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
/*
 * test.cpp
 *
 *
 *      Author: Fireworks
 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cmath>
#include<bitset>
#include<set>
#include<iomanip>
#include<fstream>
#include<bitset>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<list>
#include<sstream>

using namespace std;

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
long long mod = 1000000007LL;
long long base = 10000007;
long long large = 1000000000000000000LL;




int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<int> > adj(n,vector<int>(0,0));
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	bool flag = true;
	queue<int> q;
	vector<int> dis(n,1000000000);
	dis[0] = 0;
	q.push(0);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int j=0;j<(int)adj[u].size();j++){
			int v = adj[u][j];
			if(dis[v]==1000000000){
				dis[v]=dis[u]+1;
				q.push(v);
			}else{
				if(dis[v]==dis[u]){
					flag = false;
				}
			}
		}
	}

	if(!flag){
		cout<<1LL*n*(n-1)/2-m<<endl;
	}else{
		int l = 0;
		int r = 0;
		for(int i=0;i<n;i++){
			if(dis[i]%2){
				r++;
			}else{
				l++;
			}
		}
		cout<<1LL*l*r-m<<endl;
	}



	return 0;
}


Measured memory_bytes: 6144
#include <cstdio>
#include <vector>
#include <complex>
#include <cmath>
#include <algorithm>
using namespace std;
typedef complex<double> P;
static const double EPS = 1e-6;
static const double PI = acos(-1.0);
namespace std {
  bool operator<(const P& a, const P& b)
  {
    if (fabs(a.real() - b.real()) < EPS) {
      return a.imag() < b.imag() - EPS;
    } else {
      return a.real() < b.real() - EPS;
    }
  }
};
inline double dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

void move_to_origin(vector<P>& ps)
{
  P p(0, 0);
  for (vector<P>::const_iterator it = ps.begin(); it != ps.end(); ++it) {
    p += *it;
  }
  p /= ps.size();
  for (vector<P>::iterator it = ps.begin(); it != ps.end(); ++it) {
    *it -= p;
  }
}

vector<P> rot(const vector<P>& ps, double theta)
{
  const P p = polar(1.0, theta);
  vector<P> ans;
  for (vector<P>::const_iterator it = ps.begin(); it != ps.end(); ++it) {
    ans.push_back(*it * p);
  }
  sort(ans.begin(), ans.end());
  return ans;
}

bool equal(const vector<P>& ps, const vector<P>& qs)
{
  const int N = ps.size();
  for (int i = 0; i < N; i++) {
    if (abs(ps[i] - qs[i]) > EPS) {
      return false;
    }
  }
  return true;
}

int main()
{
  int N;
  while (scanf("%d", &N) != EOF && N != 0) {
    vector<P> ps, qs;
    for (int i = 0; i < N; i++) {
      double x, y;
      scanf("%lf %lf", &x, &y);
      ps.push_back(P(x, y));
    }
    for (int i = 0; i < N; i++) {
      double x, y;
      scanf("%lf %lf", &x, &y);
      qs.push_back(P(x, y));
    }

    move_to_origin(ps);
    move_to_origin(qs);
    sort(ps.begin(), ps.end());
    double ans = 100;
    for (int i = 0; i < N; i++) {
      const double theta = fmod(arg(ps[0]) + 2*PI, 2*PI) - fmod(arg(qs[i]) + 2*PI, 2*PI);
      const vector<P> rs = rot(qs, theta);
      if (equal(ps, rs)) {
        const double t = fabs(theta);
        ans = min(ans, min(t, 2*PI-t));
      }
    }
    printf("%.7f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 960
N = int(input())
A = list(map(int, input().split()))

num_of_minus = sum([a < 0 for a in A])
abs_A = [abs(a) for a in A]
ans = sum(abs_A)

if num_of_minus % 2 == 0:
  print(ans)
else:
  print(ans - 2 * min(abs_A))

Measured memory_bytes: 14412
import sys,heapq,math
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int,ins()))
def lin(): return list(input())
def iin(): return map(int,ins())

n,m=iin()
a=list(map(lambda x:-int(x),ins()))
heapq.heapify(a)
tmp = heapq.heappop(a)
for i in range(m):
    tmp = heapq.heappushpop(a,math.ceil(tmp/2))
print(-(sum(a)+tmp))

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, M;
  cin >> N >> M;
  vector<tuple<int, int, int>> lrc;
  rep(i, M) {
    int l, r, c;
    cin >> l >> r >> c;
    lrc.emplace_back(l, r, c);
  }
  vi64 dist(M);
  vector<vi32> adds(N);
  vector<vi32> rems(N);
  rep(i, M) {
    int l, r, c;
    tie(l, r, c) = lrc[i];
    l--, r--;
    adds[l].emplace_back(i);
    rems[r].emplace_back(i);
  }
  i64 ans = 0;
  set<pair<i64, int>> se;
  rep(i, N) {
    if (i != 0) {
      if (se.size() == 0) {
        cout << -1 << endl;
        return;
      }
      ans = se.lower_bound(make_pair(0, 0))->first;
    }
    each(j, adds[i]) {
      int l, r, c;
      tie(l, r, c) = lrc[j];
      se.emplace(ans + c, j);
      dist[j] = ans + c;
    }
    each(j, rems[i]) {
      se.erase(make_pair(dist[j], j));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 13044
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/


int main(){
    int N,M; cin >> N >> M;
    priority_queue<ll> pq;
    for (int i = 0; i < N; i++){
        ll a; cin >> a;
        pq.push(a);
    }
    for (int i = 0; i < M; i++){
        ll now = pq.top();
        pq.pop();
        now /= 2;
        pq.push(now);
    }
    ll ans = 0;
    while (pq.size()){
        ll now = pq.top();
        ans += now;
        pq.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
s = raw_input().split()
[X, Y] = s
o = [0,0]
o[0] = int(X)
o[1] = int(Y)
#print A, B

p = 0
for i in range(2):
    if o[i] == 1:
        p += 300000
    elif o[i] == 2:
        p += 200000
    elif o[i] == 3:
        p += 100000

if o[0] == 1 and o[1] == 1:
    p += 400000

print p


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for (int i = 0; i < n; i++){
		cin>>a[i];
		a[i]--;
	}
	for (int i = 0; i < n; i++){
		cin>>b[i];
	}
	for (int i = 0; i < n-1; i++){
		cin>>c[i];
	}

	int sum=0;
	for (int i = 0; i < n; i++){
		sum+=b[a[i]];
		if(i!=0 && a[i]-a[i-1]==1)sum+=c[a[i-1]];
	}

	cout<<sum<<endl;


	return 0;
}


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

int main() {
    //
    long long num;
    long long waru = 1000000007;
    long long power = 1;

    cin >> num;

    for (int i = 1; i <= num; i++) power = (power * i) % waru;

    cout << power;

    //
}

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

int solve() {
    int N;
    int prev=0;
    int left_pos = 0;
    int right_pos = 0;
    int counter = 0;
    cin >> N;
    if(N==0) return 0;
    for(int i=0; i<N; i++) {
        string command;
        cin >> command;
        if(command=="lu") {
            left_pos=1;
        } else if(command=="ru") {
            right_pos=1;
        } else if(command=="ld") {
            left_pos=0;
        } else if(command=="rd") {
            right_pos=0;
        }

        if(right_pos==1&&left_pos==1 &&prev==0) {++counter; prev=1;}
        if(right_pos==0&&left_pos==0 &&prev==1) {++counter; prev=0;}
    }
    cout << counter << endl;
    return 1;
}

int main() { while(solve()){}}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define LARB 1
#define RARB 30000
#define inf 1e18
#define zeros(x) ((x^(x-1))&x)
#define endl '\n'
#define eps 1e-9
#define mod 1000000007
#define NMAX 300

using namespace std;

typedef long long ll;
typedef long double ld;

ll d, c, tot, sum, n;
vector<pair<ll, ll> > Init;

ll norm(ll &sum)
{
    ll nr = 0, steps = 0;
    while (sum)
    {
        nr+=sum%10;
        steps++;
        sum/=10;
    }
    ll ans = steps-1;
    if (nr>=10)
        ans += norm(nr);
    sum = nr;
    return ans;
}

ll compute(pair<ll, ll> pr, ll& sum);

ll group(pair<ll, ll> pr, ll& sum, ll grsize, ll nxt)
{
    if (pr.second % grsize == 0)
        return (grsize-1)*(pr.second/grsize) + pr.second/grsize + compute({nxt, pr.second/grsize}, sum);
    else
    {
        ll def = 0;
        if (sum == 0)
        {
            def = pr.second % grsize - 1;
        }
        else
        {
            def = pr.second % grsize;
        }

        sum += (pr.second % grsize) * pr.first;
        if (sum > 9)
            def += norm(sum);

        return (grsize-1)*(pr.second/grsize) + pr.second/grsize + def + compute({nxt, pr.second/grsize}, sum);
    }
}

ll compute(pair<ll, ll> pr, ll& sum)
{
    if (pr.second == 0)
        return 0;

    ll base = pr.second - (sum == 0);
    if (pr.first == 0)
        return base;

    if (pr.first == 1)
        return group(pr, sum, 10, 1);

    if (pr.first == 2)
        return group(pr, sum, 5, 1);

    if (pr.first == 3)
        return group(pr, sum, 4, 3);

    if (pr.first == 4)
        return group(pr, sum, 3, 3);

    if (pr.first == 5)
        return group(pr, sum, 2, 1);

    if (pr.first == 6)
        return group(pr, sum, 2, 3);

    if (pr.first == 7)
        return group(pr, sum, 2, 5);

    if (pr.first == 8)
        return group(pr, sum, 2, 7);

    if (pr.first == 9)
        return group(pr, sum, 2, 9);

    assert(false);
}

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);


    cin>>n;
    for (ll i=1; i<=n; i++)
    {
        cin>>d>>c;
        Init.push_back({d, c});
    }

    ll sum = 0;
    for (auto i : Init)
    {
        tot += compute(i, sum);
    }
    cout<<tot;
    return 0;
}

Measured memory_bytes: 6256
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long k = scan.nextLong();
		if(n % k == 0) {
			System.out.println(0);
			return;
		}
		n %= k;
		System.out.println(Math.min(n, k - n));
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


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

int main(){
  long long A, B;
  cin >> A >> B;
  long long C=max(A, B);
  long long D=min(A, B);
  long long r=C%D;
  while(r!=0){
    C=D;
    D=r;
    r=C%D;
  }
  long long ans=A*B/D;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int K = sc.nextInt();
        char[] alpha = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
        int count = 0;
        String answer = new String();
//        double start = System.currentTimeMillis();
        for(int i = 0; i < alpha.length; i++){
            char c = alpha[i];
            int[] idx_tmp = new int[5000];
            int[] idx;
            int idxidx = 0;
            boolean nozero_flag = false;
            for (int j = 0; j < str.length(); j++) {
                if(c == str.charAt(j)){
                    idx_tmp[idxidx] = j;
                    idxidx++;
                    nozero_flag = true;
                }
            }
            idx = new int[idxidx];
            if(nozero_flag) {
                HashSet<String> substr = new HashSet<>();
                idx[0] = idx_tmp[0];
                for (int l = 1; l < idxidx; l++) {
                    if (idx_tmp[l] != 0) {
                        idx[l] = idx_tmp[l];
                    } else {
                        break;
                    }
                }
                for (int j = 0; j < idx.length; j++) {
                    int index = idx[j];
                    for (int k = 0; k < K; k++) {
                        if (index + k < str.length()) {
                            substr.add(str.substring(index, index + k + 1));
                        }
                    }
                }
                int prev_count = count;
                count += substr.size();
                List<String> sorted_substr = substr.stream().sorted().collect(Collectors.toList());
                if (count >= K) {
                    answer = sorted_substr.get(K - prev_count - 1);
                    break;
                }
            }
        }
        System.out.println(answer);
//        double end = System.currentTimeMillis();
//        System.out.println("Time taken: "+ (end - start) + "ms");
    }
}


Measured memory_bytes: 28372
n, k = list(map(int, input().split()))
d = {}

for i in range(1, n + 1):
    d[i] = []

for k in range(1, k + 1):
    input()
    for i in map(int, input().split()):
        d[i].append(k)

count = 0
for i in range(1, n + 1):
    if len(d[i]) == 0:
        count += 1
print(count)


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

int n, a[100100], dp[100100];

int main() {
	int k;
	cin>>n>>k;
	for(int i = 0; i < n; i++) {
		cin>>a[i];
		if(i) dp[i] = 1e9;
		for(int j = i-k; j < i; j++) {
			if(j >= 0) dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD=998244353;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[200020], invf[200020];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int n, m, k; cin>>n>>m>>k;
    fac(n);
    ll ans=0, p=powmod(m-1, n-k-1);
    for(int i=n-k; i<=n; i++){
        (ans+=m*p%MOD*comb(n-1, i-1))%=MOD;
        (p*=(m-1))%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6764
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

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

typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define uint(n) ((unsigned int)(n))
#define int64(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define dl(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const int64 LINF=4557430888798830399;
const dl eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define rep1(i,n) for(int i=1;i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

const int maxn=55;

string s,t,ans;

int main()
{
	cin>>s>>t;
	int n=SZ(s),m=SZ(t);

	for(int i=0;i<n-m+1;i++)
	{
		bool f=1;
		for(int j=i;j<i+m;j++) if(s[j]!='?'&&s[j]!=t[j-i]) f=0;

		if(!f) continue;

		string buf=s;
		for(int j=i;j<i+m;j++) buf[j]=t[j-i];
		for(int j=0;j<n;j++) if(buf[j]=='?') buf[j]='a';
		
		if(ans=="") ans=buf; else ans=min(ans,buf);
	}

	cout<<(ans==""?"UNRESTORABLE":ans);

	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair

ll a[1001],dp[101][100002];

int main(){
	int n,i,j,k;
	ll m = 1000000007;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(i=0;i<=k;i++)
		dp[0][i]=0;
	for(i=0;i<=n;i++)
		dp[i][0]=1;
	for(i=1;i<=n;i++){
		for(j=1;j<=k;j++){
			dp[i][j]=dp[i-1][j] + dp[i][j-1];
			dp[i][j]=dp[i][j]%m;
			if(j>a[i]){
				dp[i][j] -= dp[i-1][j-a[i]-1];
				if(dp[i][j]<m)
					dp[i][j]+=m;
			}
			dp[i][j]=dp[i][j]%m;
		}
	}

	printf("%lld\n",dp[n][k] );
	return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[]point = br.readLine().split(" ");
		double x1 = Double.parseDouble(point[0]);
		double x2 = Double.parseDouble(point[1]);
		double y1 = Double.parseDouble(point[2]);		
		double y2 = Double.parseDouble(point[3]);
		
		double length = y1 - x1;
		double height = y2 - x2;
		System.out.println(Math.sqrt((length * length) + (height * height)));
	}
}

Measured memory_bytes: 24324
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    X = II()

    while 1:
        for i in range(2, X):
            if X % i == 0:
                break
        else:
            print(X)
            return

        X += 1



if __name__ == '__main__':
    solve()


Measured memory_bytes: 3316
/*{{{*/
#include "bits/stdc++.h"
using namespace std;

#define MT make_tuple
#define all(x) begin(x), end(x)
#define putchar(x) cout << (x)
static int fastio = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(17); return 0; }();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename ...T> string format(const string& fmt, T&&... args) {
    size_t sz = snprintf(nullptr, 0, fmt.c_str(), args...) + 1;
    unique_ptr<char[]> buf(new char[sz]);
    snprintf(buf.get(), sz, fmt.c_str(), args...);
    return string(buf.get(), buf.get() + sz - 1);
}

template<class T> struct rge { T b, e; auto begin() const { return b; } auto end() const { return e; } };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
template<class T> auto dud(T* x) -> decltype(cerr << *x, 0);
template<class T> char dud(...);

struct debug {
#ifdef LOCAL
    debug(int line) {
        if(line) cerr << "LINE(" << line << ") -> ";
    }
    template<class T> typename enable_if<sizeof dud<T>(0) != 1, debug&>::type operator<<(T i) {
        cerr << boolalpha << i; return * this;
    }
    template<class T> typename enable_if<sizeof dud<T>(0) == 1, debug&>::type operator<<(T i) {
        return *this << range(begin(i), end(i));
    }
    template<class T, class U> debug& operator<<(pair<T, U> d) {
        return *this << "(" << d.first << ", " << d.second << ")";
    }
    debug& operator<<(tuple<>&) { return *this << "()"; };
    template<class ...T> debug& operator<<(tuple<T...> d) {
        *this << "("; debug_tuple<sizeof...(T), 0>(d);
        return *this << ")";
    }
    template<size_t L, size_t I, class T> void debug_tuple(const T& t) {
        *this << (I == 0 ? "" : ", ") << get<I>(t);
        if(I + 1 < L) debug_tuple<L, (I + 1) % L>(t);
    }
    template<class T> debug & operator <<(rge<T> d) {
        *this << "[";
        for(auto it = d.b; it != d.e; ++it)
            *this << (it != d.b ?  ", " : "") << *it;
        return *this << "]";
    }
    debug& operator<<(ostream&(*pf)(std::ostream&)) {
        cerr << pf; return *this;
    }
#else
    debug(int) {}
    template<class T> debug& operator<<(T&&) { return *this; }
    debug& operator<<(ostream&(*)(std::ostream&)) { return *this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "] "

#define debug0()  debug(__LINE__)
#define debug1(x) debug(0)
#define GET_MACRO(_0, _1, NAME, ...) NAME
#define debug(...) GET_MACRO(_0, ##__VA_ARGS__, debug1, debug0)(__VA_ARGS__)
/*}}}*/
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

void solve(int) {
    int X, N;
    cin >> X >> N;
    vector<bool> a(200, false);
    for(int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        a[p] = true;
    }
    int best = -1;
    for(int i = 0; i <= 200; ++i) {
        if(not a[i] and abs(i - X) < abs(best - X)) {
            best = i;
        }
    }
    cout << best << endl;
}

int main() {
    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; ++i) {
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3648
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort compare a;
    let rec loop i acc =
        if i = n then acc else
            if acc = 0 then 0 else
                if a.(i) > 1_000_000_000_000_000_000 / acc then -1
                else loop (i + 1) (acc * a.(i))
    in
    loop 1 a.(0) |> Printf.printf "%d\n"
)

Measured memory_bytes: 6692
#include<cstdio>
#include<algorithm>
#define MAXN 100006
#define INF 23333333333333333
using namespace std;
int n,r[MAXN];
long long a[MAXN],sum[MAXN],ans=-INF;
char op[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		if(i==1) scanf("%lld",&a[i]);
		else scanf(" %c %lld",&op[i],&a[i]);
	}
	int last=n+1;
	for(int i=n;i>=1;i--)
	{
		sum[i]=sum[i+1]+a[i];
		r[i]=last;
		if(op[i]=='-') last=i;
	}
	long long sumlast=a[1];
	for(int i=2;i<=n;i++)
	{
		if(op[i]=='-') ans=max(ans,sumlast+sum[r[i]]*2-sum[i]);
		if(op[i]=='+') sumlast+=a[i];
		else sumlast-=a[i];
	}
	printf("%lld",max(ans,sumlast));
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back

#define N 100010
#define MOD 1000000007
#define mod 998244353

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int n;
	cin >> n;
	int a[n], sum = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for(int i = 0; i < n; ++i)
	{
		for(int j = i + 1; j < n; ++j)
			sum += a[i] * a[j];
	}
	cout << sum << "\n";
	return 0;	 
}



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

int main()
{
	int n;
	cin >> n;
	int t,A;
	cin >> t >> A;
	double a[n + 1];
	for(int i = 1;i <=n ;i++){
		scanf("%lf",&a[i]);
		a[i] = t - 0.006 * a[i];
	}
	double INF = 10000000;
	double minn = INF;
	int tmp;
	for(int i = 1;i <= n;i++){
		if(abs(A - a[i]) < minn){
			minn = abs(A - a[i]);
			tmp = i;
		}
	}
	cout << tmp << endl;
	return 0;
}//121221323

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> r(n);
    vector<pair<int, int>> b(n);
    rep(i, n) {
        cin >> r[i].first >> r[i].second;
    }
    rep(i, n) {
        cin >> b[i].first >> b[i].second;
    }

    sort(all(r)); sort(all(b));
    vector<bool> used(n, false);
    int ans = 0;
    rep(i, n) {
        int bx = b[i].first, by = b[i].second;
        int index = -1;
        int my = -1;
        rep(j, n) {
            int rx = r[j].first, ry = r[j].second;
            if(!used[j] && rx < bx && ry < by && my < ry) {
                my = ry;
                index = j;
            }
        }
        if(index != -1) {
            used[index] = true;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
S = str(input())

f, r = map(int, (S[:2], S[2:]))
ans = ''
if 1 <= f <= 12 and 1 <= r <= 12:
  ans = 'AMBIGUOUS'
elif 1 <= f <= 12:
  ans = 'MMYY'
elif 1 <= r <= 12:
  ans = 'YYMM'
else:
  ans = 'NA'

print(ans)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)
	D := make([]int, 0)
	for i := 100; i >= 1; i-- {
		if A%i == 0 && B%i == 0 {
			D = append(D, i)
		}
	}
	fmt.Println(D[K-1])
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=5e5+2;
int n;
int dp[maxn];
char str[maxn];
void DP(){
	int last;
	for (int i=3;i<=n;i++){
		if (str[i]=='0') last=0;
		dp[i]=dp[i-1];
		if (str[i-2]=='1'&&str[i-1]=='0'&&str[i]=='1'){
			last=i;
			for (int j=i-2;j&&str[j]!='0';j--) dp[i]=max(dp[i],dp[j-1]+i-j-1);
		}
		if (last) dp[i]=max(dp[i],dp[last-3]+i-last+1);
	}
}
int main(){
	scanf("%d%s",&n,str+1);
	DP();
	printf("%d",dp[n]);
	return 0;
}

Measured memory_bytes: 2560
"use strict";

function Main(input) {
    input=input.replace("\n","").split(" ").map(Number);
    for(var sum=0,i=input[0];i<=input[1];i++)
        if(!(input[2]%i))
            sum++;
    console.log(sum);
}
    
function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15612