akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <bitset>
using namespace std;
typedef long long ll;
const ll inf = 4e18;
const ll mod = 1e9+7;
#define print(X) cout << X << endl
#define vec vector
#define pb push_back
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define removeV(x,val) x.erase(x.remove(x.begin(), x.end(), val), x.end());
#define rep(i, n) for (ll (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define repd(i, m, n) for (ll (i) = (m); (i) > (n); --(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;
inline string YesNo(bool cond) { return cond ? "Yes" : "No"; }
inline string YESNO(bool cond) { return cond ? "YES" : "NO"; }

template <class T>
string join(const vector<T>& v, const char* delim = 0) {
  string s;
  if (!v.empty()) {
    s += v[0];
    for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
      if (delim) s += delim;
      s += v[i];
    }
  }
  return s;
}
//---------------------------------------------------------------------------
int main(void)
{
  ll N,M;
  ll ans=0;
  cin>>N>>M;

  // 1x1
  //
  //   1

  // 1x2
  //
  //   2  2

  // 1xn
  //
  //   2  3  ... 3  2

  // 2x2
  //
  //   4  4
  //
  //   4  4

  // 2xn
  //
  //   4  6  ... 6  4
  //
  //   4  6  ... 6  4

  // 3x3

  //   4  6  ... 6  4
  //
  //   6  9  ... 9  6
  //
  //   6  9  ... 9  6
  //
  //   4  6  ... 6  4

  if ((N==1) && (M==1)) {
    print(1);
  }
  else if ((N==1) || (M==1)) {
    ll a = max(N,M);
    print(a-2);
  }
  else {
    print((N-2)*(M-2));
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    vvll a(n, vll(m));
    REP(i, n) REP(j, m) {
        cin >> a[i][j];
        a[i][j]--;
    }
    V<bool> used(m, true);
    ll ans = HIGHINF;
    REP(_, m-1) {
        vll nspo(m, 0);
        REP(i, n) REP(j, m) {
            if (used[a[i][j]]) {
                nspo[a[i][j]]++;
                break;
            }
        }
        ll tmp = 0, maxs=0;
        REP(i, m) {
            if (nspo[i] > tmp) {
                tmp = nspo[i];
                maxs = i;
            }
        }
        chmin(ans, tmp);
        used[maxs] = false;
    }
    if (m == 1) cout << n << '\n';
    else cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define link(x) for(edge *j=h[x];j;j=j->next)
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,r,l) for(int i=r;i>=l;i--)
const int MAXN=3e5+10;
const double eps=1e-8;
const int mod=1e9+9;
#define ll long long
using namespace std;
struct edge{int t,v;edge*next;}e[MAXN<<1],*h[MAXN],*o=e;
void add(int x,int y,int vul){o->t=y;o->v=vul;o->next=h[x];h[x]=o++;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return x*f;
}




int main(){
    ll x=read();ll sum=100;
    int cnt=0;
    while(sum<x){
	cnt++;
	sum+=(sum/100);
    }
    printf("%d\n",cnt);
    return 0;
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if (a>0 || (b<0 && (b-a+1)%2==0))
        cout<<"Positive"<<endl;
    else if (a<=0 && b>=0)
        cout<<"Zero"<<endl;
    else
        cout<<"Negative"<<endl;
}


Measured memory_bytes: 256
//IN THE NAME OF GOD

#include <iostream>
using namespace std;
typedef long long int ll;
const int maxn=200;
int n,a[maxn];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++){
        int k=i;
        while(k && a[k]<a[k-1]){
            swap(a[k],a[k-1]);
            k--;
        }
        for(int j=0;j<n;j++){
            cout<<a[j];
            if(j<n-1)
                cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import sys 
from math import gcd
from functools import reduce
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
A, B = map(int, readline().split())
AB = []
AB.append(A)
AB.append(B)
lcm = reduce(lambda x,y:x*y//gcd(x,y),AB)
print(lcm)


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


N = int(input())
lst_A = [int(input()) for _ in range(N)]
srt_A = sorted(lst_A, reverse=True)
m1 = srt_A[0]
m2 = srt_A[1]


for v in lst_A:
    print(m2 if v == m1 else m1)

Measured memory_bytes: 14112
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;
use std::collections::HashSet;

fn main() {
    let mut a=input_vector::<usize>();
    a.sort();
    a.reverse();
    p(a[0]*10+a[1]+a[2]);
}


Measured memory_bytes: 4352
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var act = new Array(N);
	for(var i = 0; i < N; i++){
		act[i] = new Set();
	}
	if(list[N - 2] < list[N - 1]){
		act[N - 1].add("sell");
	}
	var money = 1000;
	var kabu = 0;
	for(var i = 0; i < N - 1; i++){
		if(act[i].size == 0){
			var max = list[i];
			var maxIndex = i;
			for(var j = i + 1; j < N; j++){
				if(max < list[j]){
					max = list[j];
					maxIndex = j;
					act[j].add("no");
				}else{
					break;
				}
			}
			if(maxIndex != i){
				act[maxIndex].delete("no");
				act[i].add("buy");
				act[maxIndex].add("sell");
			}
		}
	}
	var isOK = false;
	for(var i = 0; i < N; i++){
		if(act[i].has("sell")){
			isOK = true;
		}
	}
	if(!isOK){
		myout(money);
		return;
	}
	myerr(act);
	//底と、高いところの間で売買する。
	for(var i = 0; i < N; i++){
		if(act[i].has("sell")){
			money += kabu * list[i];
			kabu = 0;
		}
		if(act[i].has("buy")){
			var count = Math.floor(money / list[i]);
			money -= list[i] * count;
			kabu = count;
		}
	}
	myout(money);
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> data(N, vector<int>(2));
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data.at(i).at(j);
    }
  }
  
  int sum = 0;
   for (int i = 0; i < N; i++) {
      int num = data.at(i).at(1) - data.at(i).at(0) +1;
      sum += num;
  }
 cout << sum << endl;
}

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

typedef long long ll;

int main() { 
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	int ans = INT_MAX;
	for (int i = 0; i < n; ++i) {
		int p = 0;
		while (v[i] % 2 == 0) {
			p++;
			v[i] /= 2;
		}
		ans = min(ans,p);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    if (n % 2)
        return cout << "No", 0;
    for (int i = 0; i < n; ++i)
    {
        char c = s[i];
        if (i % 2)
        {
            if (c != 'i')
                return cout << "No", 0;
        }
        else
        {
            if (c != 'h')
                return cout << "No", 0;

        }
    }
    cout << "Yes";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char sa[101], sb[101], sc[101];
	int i = 0, j = 0, k = 0;
	int l, m, n;
	scanf("%s", sa);
	scanf("%s", sb);
	scanf("%s", sc);
	l = strlen(sa), m = strlen(sb), n = strlen(sc);
	char ch = sa[i];
	i++;
	while(i <= l && j <= m && k <= n){
		if(ch == 'a'){
			ch = sa[i];
			i++;
		}else if(ch == 'b'){
			ch = sb[j];
			j++;
		}else if(ch == 'c'){
			ch = sc[k];
			k++;
		}
	}
	if(i == l + 1) printf("A\n");
	else if(j == m + 1) printf("B\n");
	else printf("C\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, S[2 << 18];
int M;
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
    map<int, int> cnt;
    rep(i, 0, M) cnt[S[i]]++;
    vector<pair<int,int>> v;
    fore(p, cnt) v.push_back(p);
    sort(all(v), greater<pair<int, int>>());

    priority_queue<int> connection;
    connection.push(M);
    fore(p, v)
    {
        int cnt = p.second;
        if(connection.size() < cnt)
            return no;

        vector<int> buf;
        rep(i, 0, cnt) {
            buf.push_back(connection.top());
            connection.pop();
        }

        fore(c, buf) {
            c /= 2;
            while (0 < c)
            {
                connection.push(c);
                c /= 2;
            }
        }
    }

    return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    M = 1;
    rep(i, 0, N) M *= 2;
    rep(i, 0, M) cin >> S[i];

    cout << solve() << endl;
}



Measured memory_bytes: 16624
#include <stdio.h>

int main(void) {
int a, b, c, sum=0;
scanf("%d %d %d", &a, &b, &c);
while (1){
	if (c%a == 0)
		sum = sum+1;
	if (a == b)
		break;
	a++;
}
printf("%d\n", sum);

return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <ios>
#include <iomanip>
#include <limits>
#include <algorithm>
#include <sstream>
#include <bitset>
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, s, n) for(int i=s; i<n; i++)

using namespace std;

int main(){
    int N; cin >> N;
    int tmpN = N;
    int ans = 0;
    int minans = 1e9;
    FOR(i, 1, (N/2)+1){
        tmpN = N - i;
        ans = 0;
        while(tmpN != 0){
            int tmp;
            tmp = tmpN % 10;
            ans += tmp;
            tmpN = tmpN / 10;
        }
        tmpN = i;
        while(tmpN != 0){
            int tmp;
            tmp = tmpN % 10;
            ans += tmp;
            tmpN = tmpN / 10;
        }
        minans = min(minans, ans);
    }
    cout << minans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
import math
n=int(input())
a=list(map(int,input().split()))
ans=math.factorial(n-1)%(10**9+7)

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

c=0
for i in range(1,n):
    c+=(a[-1]-a[i-1])*modinv(i, mod=10**9+7)
print(ans*c%(10**9+7))


Measured memory_bytes: 62576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP2(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

int main(){
    int N, M;
    cin >> N >> M;
    cout << (N*(N-1) + M*(M-1))/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  string S;
  ll K;
  cin >> S >> K;
  ll cnt = 0;
  char start = S[0];
  ll start_i = 0;
  char end = S[S.length() - 1];
  ll end_i = 0;
  REP(i, S.length()) {
    if(S[i] != start) {
      start_i = i;
      break;
    }
  }
  for(int i = S.length() - 1; i >= 0; i--) {
    if(S[i] != end) {
      end_i = i;
      break;
    }
  }

  bool eq = false;
  for(int i = start_i + 1; i <= end_i; i++) {
    if(!eq && S[i] == S[i - 1]) {
      cnt++;
      eq = true;
    } else {
      eq = false;
    }
  }

  ll end_num = S.length() - end_i - 1;
  ll ans;
  dump(start_i, end_num, cnt);
  if(end_i == 0 && start_i == 0) {
    ans = (ll)S.length() * K / 2;
  } else if(start == end) {
    ans = cnt * K + start_i / 2 + (end_num) / 2 + (start_i + end_num) / 2 * (K - 1);
  } else {
    ans = (cnt + start_i / 2 + (end_num) / 2) * K;
  }
  cout << ans << endl;
}


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

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

        if(n==0){
            break;
        }
        int a[n];
        int max=0;
        double ave=0;
        for(int i=0; i<n; i++){
            cin>>a[i];
            max += a[i];
        }
        ave = max/n;

        int cnt = 0;
        for(int i=0; i<n; i++){
            if(a[i]<=ave){
                cnt++;
            }
        }

        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char str[N];
int main()
{
    scanf("%s",str);
    int len=strlen(str);
    int a=0;
    int b=0;
    for(int i=0;i<=1;i++)
        a=a*10+str[i]-'0';
    for(int i=2;i<=3;i++)
        b=b*10+str[i]-'0';
    if(a>=1&&a<=12&&b>=1&&b<=12)
        printf("AMBIGUOUS\n");
    else if(a>=1&&a<=12)
        printf("MMYY\n");
    else if(b>=1&&b<=12)
        printf("YYMM\n");
    else
        printf("NA\n");
        //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;

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

	ll X;
	cin >> X;

	
	ll hyaku = 100;
	while (1) {
		hyaku += hyaku / 100;
		ans++;
		if (hyaku >= X) {
			cout << ans << endl;
			return 0;
		}
		
	}


	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
int main() {
    int N;
    cin >> N;
    int X;
    double Y = N / 1.08;
    for(int i=1;i<=50000;i++){
        X = i;
        if(( (X-(1/1.08)) < Y)&&( Y <= X ) ) {
            cout << X << endl;
            break;
        }
        else if(i==50000){
            cout <<":(" << endl;
        }
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, W, w, v, wn;
  cin >> n >> W;
  
  vector<vector<ll>> info(4, vector<ll>(0));


  cin >> w >> v;
  info[0].emplace_back(v);
  for (int i = 1; i < n; i++){
    cin >> wn >> v;
    info[wn - w].emplace_back(v);
  }
  sort(info[0].begin(), info[0].end(), greater<ll>());
  sort(info[1].begin(), info[1].end(), greater<ll>());
  sort(info[2].begin(), info[2].end(), greater<ll>());
  sort(info[3].begin(), info[3].end(), greater<ll>());
  vector<vector<ll>> sum(4, vector<ll>(0));
  for (int i = 0; i < 4; i++){
    sum[i].emplace_back(0);
    for (int j = 0; j < info[i].size(); j++){
      sum[i].emplace_back(sum[i][j] + info[i][j]);
    }
  }


  ll res = 0;
  for (int i = 0; i <= info[0].size(); i++){
    for (int j = 0; j <= info[1].size(); j++){
      for (int k = 0; k <= info[2].size(); k++){
        if (w*i + (w+1)*j + (w+2)*k > W)
          break;
        else {
          ll t = (W - (w*i + (w+1)*j + (w+2)*k)) / (w + 3);
          ll a = min((ll)info[3].size(), t);
          res = max(res, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][a]);
        }
      }
    }
  }
  

  cout << res << endl;
  

  return 0;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN,"%d",$n);
  $count = 0;
  sichigosan(0,$n);
  echo($count);

  function check($x){
    $keta = strlen($x);
    $f = array_fill(0,10,0);
    for($i=0;$i<$keta;$i++){
      $num = substr(strval($x),$i,1);
      $f[$num] = 1;
    }
    if($f[3]==1 and $f[5]==1 and $f[7]==1 and array_sum($f)==3){
      return true;
    }else{
      return false;
    }
  }

  function sichigosan($x){
    global $n;
    global $count;
    $num = $x*10+3;
    if($num<=$n){
      if(check($num))$count++;
      sichigosan($num);
    }
    $num = $x*10+5;
    if($num<=$n){
      if(check($num))$count++;
      sichigosan($num);
    }
    $num = $x*10+7;
    if($num<=$n){
      if(check($num))$count++;
      sichigosan($num);
    }

  }


Measured memory_bytes: 3576
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-20 08:32:35
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#include<vector>
const int N=60,inf=12345678;
int T,n,ans,a[N][N],b[N][N],fa[N],fb[N],w[N],d[N],q[N],l,r;
std::vector<int> e[N];
void dfs(int u)
{
	fr(v,1,n) if(a[u][v]&&v!=fa[u])
	{
		w[v]=w[u]&&b[u][v]; fa[v]=u; dfs(v);
	}
}
void Dfs(int u)
{
	fr(v,1,n) if(b[u][v]&&v!=fb[u]){ fb[v]=u; Dfs(v); }
}
int solve(int u)
{
	fr(i,1,n)
	{
		e[i].clear(); fa[i]=fb[i]=0; w[i]=d[i]=0;
	}
	w[u]=1; dfs(u); Dfs(u);
	int ans=0;
	fr(i,1,n) ans+=!w[i];
	fr(i,1,n) if(i!=u&&!w[fa[i]]){ e[i].push_back(fa[i]); d[fa[i]]++; }
	fr(i,1,n) if(i!=u&&!w[fb[i]]){ e[fb[i]].push_back(i); d[i]++; }
	l=1; r=0;
	fr(i,1,n) if(!w[i]&&d[i]==0) q[++r]=i;
	while(l<=r)
	{
		int i=q[l++];
		fr(j,0,e[i].size()-1)
		{
			d[e[i][j]]--;
			if(!d[e[i][j]]) q[++r]=e[i][j];
		}
	}
	return ans==r?ans:inf;
}
int main()
{
	T=read();
	while(T--)
	{
		n=read();
		fr(i,1,n) fr(j,1,n) a[i][j]=b[i][j]=0;
		fr(i,1,n-1)
		{
			int u=read(),v=read();
			a[u][v]=a[v][u]=1;
		}
		fr(i,1,n-1)
		{
			int u=read(),v=read();
			b[u][v]=b[v][u]=1;
		}
		ans=inf;
		fr(i,1,n) ans=std::min(ans,solve(i));
		fr(i,1,n)
		{
			int d=0;
			fr(j,1,n) d+=a[i][j];
			if(d!=1) continue;
			fr(j,1,n) if(a[i][j])
				fr(k,1,n) if(k!=i&&k!=j)
				{
					a[i][j]=a[j][i]=0; a[i][k]=a[k][i]=1;
					ans=std::min(ans,solve(i)+1);
					a[i][j]=a[j][i]=1; a[i][k]=a[k][i]=0;
				}
		}
		printf("%d\n",ans==inf?-1:ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    double w,h,x,y;
    std::cin>>w>>h>>x>>y;
    std::cout<<w*h/2<<" ";
    if(2*x==w&&2*y==h){
        std::cout<<1<<'\n';
    }else{
        std::cout<<0<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    import scala.io.StdIn._
    val n = readInt
    val st = scala.collection.mutable.Set[Long]()
    for (i <- 0 until n) {
      val a = readLong
      if(st.contains(a)) st.remove(a) else st.add(a)
    }

    println(st.size)
  }
}

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

int main() {
    string s[3];
    for (int i = 0; i < 3; i++)
    {
        cin >> s[i];
    }
    cout << s[0][0] << s[1][1] << s[2][2] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
string s;
int main()
{
	int a,b;
	cin>>a>>b;
	cin>>s;
	bool flag=true;
	if(s.size()!=a+b+1) flag=false;
	for(int i=0;i<a;i++)
	{
		if(s[i]<'0'||s[i]>'9')
		{
			flag=false;
			break;
		}
	}
	if(s[a]!='-') flag=false;
	for(int i=a+1;i<s.size();i++)
	{
		if(s[i]<'0'||s[i]>'9')
		{
			flag=false;
			break;
		}
	}
	if(flag==true) cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    ll ans = 0;
    int count = 1;
    int index = n-1;
    while(count < n){
        ans += a[index - (count/2)];
        count++;
    }

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

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

int K, T;
vector<int> A;

signed main()
{
    cin >> K >> T;
    A.assign(T, 0);
    REP(i, T) {
        cin >> A[i];
    }
    if(T == 1) {
        printf("%lld\n", A[0] - 1);
        return 0;
    }
    sort(A.begin(), A.end(), greater<int>());
    while(A[1] != 0) {
        A[0] -= A[1];
        A[1] = 0;
        sort(A.begin(), A.end(), greater<int>());
    }
    printf("%lld\n", (A[0] == 1 || A[0] == 0) ? 0 : A[0] - 1);

    return 0;
}


Measured memory_bytes: 256
from pprint import pprint
h, w = map(int, input().split())

s = []
for i in range(h):
    s.append([1 if i == "#" else 0 for i in list(input())])
cost = [[0]*w for _ in range(h)]
cost[0][0] = s[0][0]

for i in range(1, h):
    if s[i-1][0] == 0 and s[i][0] == 1:
        cost[i][0] = cost[i-1][0] + 1
    else:
        cost[i][0] = cost[i-1][0]
for i in range(1, w):
    if s[0][i-1] == 0 and s[0][i] == 1:
        cost[0][i] = cost[0][i-1] + 1
    else:
        cost[0][i] = cost[0][i-1]

for i in range(1, h):
    for j in range(1, w):
        if s[i-1][j] == 0 and s[i][j] == 1:
            cost_down = cost[i-1][j] + 1
        else:
            cost_down = cost[i-1][j]
        if s[i][j-1] == 0 and s[i][j] == 1:
            cost_right = cost[i][j-1] + 1
        else:
            cost_right = cost[i][j-1]
        cost[i][j] = min(cost_down, cost_right)

print(cost[h-1][w-1])

Measured memory_bytes: 3700
#define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
do {\
std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
debug_impl(__VA_ARGS__);\
std::cerr << std::noboolalpha;\
} while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}


bool check(vector<ll>& A, ll N, ll M, ll V, ll P, int pos, vector<ll>& B)
{
    debug("*******check********");
    // first, make A[pos] high
    ll base = A[pos] + M;
    if (A[P-1]>base) return false;

    // get left votes
    if (V<=(N-pos)+(P-1)) return true;
    ll k = V-(N-pos)-(P-1);
    debug(pos, P-1, k);

    ll sum = B[pos] - B[P-1];
    debug(sum, M);
    debug(base * (pos-P+1), base, pos-(P-1));
    debug(sum + k*M);
    return base * (pos-P+1) >= sum + k*M;
    // return que.size()==0;
}

int main()
{
    // read input
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    rep(i, 0, N)  cin >> A[i];
    
    // rsort
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    vector<ll> B(N+1, 0);
    rep(i, 0, N) B[i+1] = B[i] + A[i];
    debug(A, B);

    // binary search 
    ll low = 0;
    ll high = N-1;
    while (low<high)
    {
        ll mid = (low+high+1)/2;
        // check
        bool is_ok = check(A, N, M, V, P, mid, B);
        
        if (is_ok)
            low = mid;
        else
            high = mid-1;
    }
    cout << low+1 << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{

    class ProgramC
    {
        static void Main(string[] args)
        {
            //入力
            string[] a = Console.ReadLine().Split(' ');
            int n = int.Parse(a[0]);
            int m = int.Parse(a[1]);
            long[] h = new long[n];
            long[] count = new long[n];

            string[] s = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                h[i] = long.Parse(s[i]);

            for (int i = 0; i < m; i++)
            {
                string[] pass = Console.ReadLine().Split(' ');
                if (h[long.Parse(pass[0]) - 1] > h[long.Parse(pass[1]) - 1])
                    count[long.Parse(pass[1]) - 1]++;

                if (h[long.Parse(pass[0]) - 1] < h[long.Parse(pass[1]) - 1])
                    count[long.Parse(pass[0]) - 1]++;

                if (h[long.Parse(pass[0]) - 1] == h[long.Parse(pass[1]) - 1])
                {
                    count[long.Parse(pass[0]) - 1]++;
                    count[long.Parse(pass[1]) - 1]++;
                }
                    
            }

            int ans = 0;

            for (int i = 0; i < n; i++)
            {
                if (count[i] == 0)
                    ans++;
                
            }

            Console.WriteLine(ans);


        }
    }
}


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

int main(){
  int W,H,x,y,r;

  cin >> W >> H >> x >> y >> r;

    if (0 <= x-r && r+x <= W && 0 <= y-r && r+y <= H){
      cout <<"Yes" << endl;
    } else cout << "No" << endl;
    
  

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i=0; i < N; i++){
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  int a = 0, b = 0;
  for (int j = 0; j < N; j++){
    if (j % 2 == 0){
      a += h.at(N-j-1);
    }else{
      b += h.at(N-j-1);
    }
  }
  int ans = a - b;
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<math.h>
#define PI 3.141592
int main(){
	int a,b,d;//d=?????°,a=?????¢?§?
	a=90;
	double x,y;
	x=0;
	y=0;
	while(1){
		scanf("%d,%d",&d,&b);
		if(d==0&&b==0)break;
		x+=d*cos((double)a*PI/180);
		y+=d*sin((double)a*PI/180);
		a+=b*(-1);
	}
	printf("%d\n",(int)x);
	printf("%d\n",(int)y);

	return 0;
}

Measured memory_bytes: 604
n=gets.chomp.to_i
a=Array.new(n+1) 
for i in 1..n
	a[i]=gets.chomp.to_i
end
x=1
sum=0
n.times{
	x=a[x]
	sum=sum+1
	if x==2
		puts sum
		exit(0)
	end
}
puts -1


Measured memory_bytes: 2684
isPrime :: Int -> Bool
isPrime num = null(filter (\x -> num `mod` x == 0) [2..floor(sqrt(fromIntegral num))])
 
main = do
    [x] <- map read . words <$> getLine
    let primeList = [a | a <- [2..2*x], isPrime a ]
    let ans = head [a | a <- primeList, a >= x]
    putStrLn $ show ans

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int v[100];
    int c[100];
    for(int i = 0;i < n;i++){
        cin >> v[i];
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
        cin >> c[i];
        v[i] -= c[i];
        if(v[i] > 0)ans += v[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

int A[200001];

int maxProductSubarrayOfSizeK(int n, int k)
{
    // sorting given input array
    sort(A, A + n);

    // variable to store final product of all element
    // of sub-sequence of size k
    int product = 1;

    // CASE I
    // If max element is 0 and
    // k is odd then max product will be 0
    if (A[n - 1] == 0 && (k & 1))
        return 0;

    // CASE II
    // If all elements are negative and
    // k is odd then max product will be
    // product of rightmost-subarray of size k
    if (A[n - 1] <= 0 && (k & 1)) {
        for (int i = n - 1; i >= n - k; i--) {
            product= ((product% mod) * (A[i]% mod))% mod;
        }
        return product;
    }

    // else
    // i is current left pointer index
    int i = 0;

    // j is current right pointer index
    int j = n - 1;

    // CASE III
    // if k is odd and rightmost element in
    // sorted array is positive then it
    // must come in subsequence
    // Multiplying A[j] with product and
    // correspondingly changing j
    if (k & 1) {
        product= ((product% mod) * (A[j]% mod))% mod;
        j--;
        k--;
    }

    // CASE IV
    // Now k is even
    // Now we deal with pairs
    // Each time a pair is multiplied to product
    // ie.. two elements are added to subsequence each time
    // Effectively k becomes half
    // Hence, k >>= 1 means k /= 2
    k >>= 1;

    // Now finding k corresponding pairs
    // to get maximum possible value of product
    for (int itr = 0; itr < k; itr++) {

        // product from left pointers
        int left_product = (A[i] * A[i + 1]);
        left_product= ((left_product));
        // product from right pointers
        int right_product = (A[j] * A[j - 1]);
        right_product= ((right_product));
        // Taking the max product from two choices
        // Correspondingly changing the pointer's position
        if (left_product > right_product) {
            product= ((product% mod) * (left_product% mod))% mod;
            i += 2;
        }
        else {
            product= ((product% mod) * (right_product% mod))% mod;
            j -= 2;
        }
    }

    // Finally return product
    return product;
}

void solve() {
        int n, k; cin >> n>> k;
        lp(i, n) cin >> A[i];
        cout << ((maxProductSubarrayOfSizeK(n, k) + mod)% mod);
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int[] num = new int[3];
		num[0] = sc1.nextInt();
		num[1] = sc1.nextInt();
		num[2] = sc1.nextInt();
		int ans = 0;

		num = sort(num);

		while (num[0] != num[1] || num[1] != num[2] ) {

			if (num[2] >= num[0] + 2) {
				num[0] += 2;
			}
			else {
				num [0] += 1;
				num [1] += 1;
			}
			ans++;
			num = sort(num);
			//System.out.println(num[0] + " " + num[1] + " " + num[2]);
		}

		System.out.println(ans);

		sc1.close();
	}

	static int[] sort(int[] num) {

		for (int i =0 ; i < 2 ; i++ ) {
			for (int index = 0; index < 2 ; index ++) {
				if (num[index] > num[index + 1]) {
					int a = num[index];
					int b = num[index+1];
					num[index] = b;
					num[index+1] = a;
				}
			}
		}

		return num;
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {

    int N;
    int ans = 0;
    int val = 0;

    cin >> N;

    vector<int> data(N);

    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
    }

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

    for (int i = 1; i < N; i++) {
        if (data[i-1] <= data[i]) val++;
        else val = 0;
        ans = max(ans, val);
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
/*********************************************************************
* AUTHOR : ANSHU KUMAR                                               *
* ABOUT :  IT DOESN'T MATTER HOW SLOW I GO, AS LONG AS I NEVER STOP  *
* INSTITUTION : IEM KOLKATA                                          *
**********************************************************************/

//try to think at least 30min(with full concentration).

#include <bits/stdc++.h>

using namespace std;

#define int             long long
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define MOD             1000000007
#define INF             1e18
#define PI              3.1415926535897932384626433832795
#define sp(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define endl            '\n'
#define da(arr,type,n)  type *arr=new type[n];


/********** Euclidean Algorithm for GCD **********/
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



/********** Fast Power Exponentiation ***********/
int power(int a, int b) {
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res % MOD * a % MOD) % MOD;
		a = (a % MOD * a % MOD) % MOD;
		b >>= 1;
	}
	return res;
}



/********** FAST I/O ************/
void fastIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}



/********** PROGRAM START ***********/

int32_t main()
{
	fastIO();
	int x, n;
	cin >> x >> n;
	int a[102] = {0};
	for (int i = 0; i < n; i++)
	{
		int ans;
		cin >> ans;
		a[ans] = 1;
	}
	if (n == 0)
	{
		cout << x << endl;
	}
	else
	{
		for (int i = x, j = x;; i--, j++)
		{
			if (a[i] == 0)
			{
				cout << i << endl;
				break;
			}
			else if (a[j] == 0)
			{
				cout << j << endl;
				break;
			}
		}
	}
	return 0;
}

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

Measured memory_bytes: 128
while True:
    a, b = map(int,input().split())
    X = 0
    Y = 0
    n = 0
    
    if a == 0 and b == 0:
        break

    if a >= b:
        X = a
        Y = b
    else:
        X = b
        Y = a

    while Y != 0:
        X,Y = Y,X%Y
        n += 1
    
    print(X,n)


Measured memory_bytes: 5604
#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int n;
    int res = 0;
    scanf("%d",&n);

    if(n >= 105 && n < 135) res = 1;
    else if(n >= 135 && n < 165) res = 2;
    else if(n >= 165 && n < 189) res = 3;
    else if(n >= 189 && n < 195) res = 4;
    else if(n >= 195) res = 5;

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,sum=0;
    cin>>a>>b;
    for(i=0; i<a; i++)
    {
        sum=sum+500;

    }
    if(sum>=b)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
import sys

N=int(input())
A=list(map(int,input().split()))
dict={}

for a in A:
  if a in dict.keys():
    dict[a] = dict[a] + 1
  else:
    dict[a] = 1

if len(list(dict.keys())) > 3:
  print('No')
  sys.exit()
elif len(list(dict.keys()))==1:
  keys=list(dict.keys())
  if keys[0]==0:
    print('Yes')
    sys.exit()
  else:
    print('No')
    sys.exit()
elif len(list(dict.keys()))==2:
  keys=list(dict.keys())
  a0=keys[0]
  a1=keys[1]
  a2=''
  b0=bin(a0)[2:]
  b1=bin(a1)[2:]
  if len(b0)<len(b1):
    b0,b1=b1,b0
  b1=b1.zfill(len(b0))
  for s0,s1 in zip(b0,b1):
    a2 = a2 + str( int(s0)^int(s1) )
  a2=int(a2,2)
  #print(a0,a1,a2)
  if a2==a0 or a2==a1:
    vals=list(dict.values())
    if vals[0]/2==vals[1] or vals[0]==vals[1]/2:
      print('Yes')
      sys.exit()
    else:
      print('No')
      sys.exit()
  
keys=list(dict.keys())
vals=set(dict.values())

if len(vals)> 1:
  print('No')
  sys.exit()
  
a0=keys[0]
a1=keys[1]
a2=''
b0=bin(a0)[2:]
b1=bin(a1)[2:]
if len(b0)<len(b1):
  b0,b1=b1,b0
b1=b1.zfill(len(b0))
for s0,s1 in zip(b0,b1):
  a2 = a2 + str( int(s0)^int(s1) )
a2=int(a2,2)

if a2!=keys[2]:
  print('No')
  sys.exit()

print('Yes')

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

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

    std::vector< int > ws(n);
    for (auto &w: ws) std::cin >> w;

    const int inf = 1001001001;
    int min_w = inf;
    for (auto w: ws) {
        min_w = std::min(min_w, w);
    }

    std::vector< int > ps(n);
    for (int i = 0; i < n; ++i) {
        ps[i] = i;
    }

    std::sort(ps.begin(), ps.end(), [ws](int a, int b) { return ws[a] < ws[b]; });

    int ans = 0;
    std::vector< bool > used(n);
    for (int i = 0; i < n; ++i) {
        if (used[i]) continue;

        used[i] = true;
        int min_c = ws[i];
        int sum_c = ws[i]; 
        int cnt = 1;
        for (int j = ps[i]; j != i; j = ps[j]) {
            min_c = std::min(min_c, ws[j]);
            sum_c += ws[j];
            cnt++;
            used[j] = true;
        }

        ans += (sum_c - min_c) + std::min((cnt - 1) * min_c, (cnt + 1) * min_w + 2 * min_c);
    }

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




Measured memory_bytes: 3240
#include<iostream>
#include<cstring>
using namespace std;
int main(){
int n,a[100001]={0},ans=0,minn=1111111111;
cin>>n;
for(int i=1;i<=n;i++){
	cin>>a[i];
	ans+=a[i];
	if(a[i]%10!=0&&a[i]<minn)minn=a[i];
}
if(minn!=1111111111&&ans%10==0)cout<<ans-minn;
else if(ans%10!=0)cout<<ans;
else cout<<0; 
}

Measured memory_bytes: 640
A, B, C, X, Y = map(int, input().split())

result = 0
if A + B > 2 * C:
    t = min(X, Y)
    result += t * 2 * C
    X, Y = X - t, Y - t
else:
    t = min(X, Y)
    result += t * A + t * B
    X, Y = X - t, Y - t
if X > 0:
    if A > 2 * C:
        result += X * 2 * C
    else:
        result += X * A
else:
    if B > 2 * C:
        result += Y * 2 * C
    else:
        result += Y * B
print(result)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
  int n;
  char card;
  while(1){
    cin >> n;
    if(n == 0) break;
    int cou=0,ba=0;
    int now[11]={0};
    for(int i=0;i<100;i++){
      cin >> card;
      if(card == 'M'){
    now[cou]++;
      }
      else if(card == 'L'){
    now[cou] += ba + 1;
    ba=0;
      }
      else{
    ba += now[cou]+1;
    now[cou] = 0;
      }
      cou++;
      if(cou == n){
    cou = 0;
      }
    }
    sort(now,now+n);
    for(int i=0;i<n;i++){
      cout << now[i] << " ";
    }
    cout << ba << endl;
  }
}

Measured memory_bytes: 1180