akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int H, W;
map<char, int>mp;

int main(void)
{
	cin >> H >> W;
	for (int i = 0; i < H; ++i)
	{
		string S;
		cin >> S;
		for (char c : S)mp[c]++;
	}
	multiset<int>ms;
	for (auto p : mp)ms.insert(p.second);
	for (int i = 0; i < H / 2; ++i)
	{
		for (int j = 0; j < W / 2; ++j)
		{
			auto itr = ms.end();
			--itr;
			int b = *itr;
			if (b < 4)
			{
				cout << "No\n";
				return 0;
			}
			ms.erase(itr);
			if (b - 4)ms.insert(b - 4);
		}
	}
	if (W % 2)
	{
		for (int i = 0; i < H / 2; ++i)
		{
			auto itr = ms.end();
			--itr;
			int b = *itr;
			if (b < 2)
			{
				cout << "No\n";
				return 0;
			}
			ms.erase(itr);
			if (b - 2)ms.insert(b - 2);
		}
	}
	if (H % 2)
	{
		for (int i = 0; i < W / 2; ++i)
		{
			auto itr = ms.end();
			--itr;
			int b = *itr;
			if (b < 2)
			{
				cout << "No\n";
				return 0;
			}
			ms.erase(itr);
			if (b - 2)ms.insert(b - 2);
		}
	}
	if (W % 2 == 1 && H % 2 == 1)
	{
		if (ms.size() == 1 && *ms.begin() == 1)
		{}
		else
		{
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}


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

using namespace std;

void printShape(int y){
  for(int i=0; i<y+2; ++i){
    cout << "#";
  }
  cout << endl;
}

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for(int y=0; y<h; y++){
      cin >> a[y];
  }
  printShape(w);
  for(int i=0; i<h; i++){
    cout << "#";
    cout << a[i];
    cout << "#" << endl;
  }
  printShape(w);

  return 0;
}


Measured memory_bytes: 256
#Frog1
n=int(input())
h=list(map(int,input().split()))
Min=0
dp={}
for val in range(n):
    if(val==0):
        dp[val]=0
    if(val==1):
        dp[val]=abs(h[0]-h[1])
    elif(val>=2):
        dp[val]=min(abs(h[val]-h[val-1])+dp[val-1],abs(h[val]-h[val-2])+dp[val-2])
print(dp[n-1])
            

Measured memory_bytes: 23252
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        char[] c = sc.next().toCharArray();
        List<Integer> nums = new ArrayList<>();
        char now = '1';
        int count = 0;
        for (int i = 0 ; i < n ; i++) {
            if (c[i] == now) {
                count++;
            } else {
                nums.add(count);
                if (now == '0') {
                    now = '1';
                } else {
                    now = '0';
                }
                count = 1;
            }
        }
        nums.add(count);
        if (nums.size() % 2 == 0) {
            nums.add(0);
        }

        int[] a = new int[nums.size() + 1];
        int sum = 0;
        for (int i = 0 ; i < nums.size() ; i++) {
            sum += nums.get(i);
            a[i + 1] = sum;
        }

        int add = Math.min(nums.size(), 2 * k + 1);
        int max = 0;
        for (int i = 0 ; i < nums.size() + 1 ; i += 2) {
            if (i + add < nums.size() + 1) {
                max = Math.max(max, a[i + add] - a[i]);
            }
        }
        if (nums.size() == 1) {
            System.out.println(n);
        } else {
            System.out.println(max);
        }

    }

}


Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	ll sum=0;
	if(a>=k)
	{
		cout<<k<<"\n";
	}
	else
	{
		sum+=a;
		k-=a;
		if(b>=k)
		{
			cout<<sum<<"\n";
		}
		else
		{
			k-=b;
			sum-=k;
			cout<<sum<<"\n";
		}
	}
	return 0;
}

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

int main(){
  long N,p,a;
  cin>>N;
  p=1;
  a=pow(10,9)+7;
  for(int i=0;i<N;i++){
    p=p*(i+1);
    if(p>a){
      p=p%a;
    }
  }
  cout<<p<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
      lint n;
      cin>>n;
      lint a[n];
      rep(i,n)cin>>a[i];
      sort(a,a+n);
      lint ans=0;
      rep(i,n){
          repp(j,i+1,n){
              repp(k,j+1,n){
                  if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]){
                      if(a[i]+a[j]>a[k])ans++;
                  }
              }
          }
      }
      cout<<ans<<endl;


    }
      
    
  

Measured memory_bytes: 3676
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , m;
int occ[MAXN];
void solve() {
	cin >> n >> m;
	if( n & 1 ) {
		rep( i , 1 , m ) printf("%d %d\n",i,n - i);
	} else {
		int cur = n - 1;
		occ[n / 2] = 1;
		rep( i , 1 , m ) {
			if( occ[n - cur] ) -- cur;
			printf("%d %d\n",i,i + cur);
			occ[cur] = 1;
			cur -= 2; 
		}
	}
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int h, w;
vs table;
int DFS(vs t, ii start) {
	queue<ii> que;
	vvi depth(h, vector<int>(w, -inf));

	que.push(start);
	depth[start.first][start.second] = 0;

	while (!que.empty()) {
		ii now = que.front(); que.pop();

		rep(k, 4) {
			int y = now.first + dy[k];
			int x = now.second + dx[k];

			if (0 <= x && x < w && 0 <= y && y < h 
				&& depth[y][x] == -inf 
				&& t[y][x] == '.') {
				que.push({ y, x });
				depth[y][x] = depth[now.first][now.second] + 1;
			}
		}
	}

	int mx = 0;
	rep(i, h) {
		rep(j, w) {
			mx = max(mx, depth[i][j]);
		}
	}
	return mx;
}

int main() {
	cin >> h >> w;
	table.resize(h);

	rep(i, h) {
		cin >> table[i];
	}

	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			if (table[i][j] == '.') ans = max(ans, DFS(table, { i, j }));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
(let ((s (concatenate 'list (read-line))))
  (defun f (fl acc)
    (if (char= (car fl) #\Z)
      acc
      (f (cdr fl) (1+ acc))))

  (defun g (gl)
    (if (char= (car gl) #\A)
      gl
      (g (cdr gl))))

  (defun counter (lst)
    (let ((al (g lst)))
      (- (length al) (f (reverse al) 0))))

  (format t "~A~%"
          (counter s)))



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

int main() {
  ll N;cin>>N;ll V[N];cin>>V[0];ll a=0;ll b=0;ll c=0;ll s=0;
  for(int i=1;i<N;i++){
    cin>>V[i];
    if(V[i]<V[i-1]){
      a+=V[i-1]-V[i];V[i]=V[i-1];
    }
  }cout<<a<<endl;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
#define endl ("\n")
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define fr(i,n) for(i=0;i<n;i++)
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

ll expo (ll x, ll y) {ll res = 1; while (y) {if (y & 1)res = res * x; res %= MOD; y = y >> 1; x = x * x; x %= MOD;} return res;}

void solve()
{   
   ll i,j;
   ll n;
   cin>>n;
   ll A[n+1];
   ll dp[n+1];
  fr(i,n)
  cin>>A[i+1];
    fr(i,n)
    dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(A[2]-A[1]);
    dp[3]=min(dp[2]+abs(A[3]-A[2]),abs(A[3]-A[1]));
    for(i=4;i<=n;i++)
    dp[i]=min(dp[i-1]+abs(A[i-1]-A[i]),dp[i-2]+abs(A[i-2]-A[i]));
    cout<<dp[n]<<endl;
   
}

int main() 
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);
#endif
    fast;
    // Fuck Ratings, I'm in Love with Experience. 
    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }
    return 0;
}



Measured memory_bytes: 5148
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long

using namespace std;

int main(void){
    ll int a;
    long double b;
    cin >> a >> b;
    cout << (long long int)(a * b) << endl;
    return 0;
}

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

int main(){
    int N,na,nb,nc,nd,i=0;
    cin >> N;

    na = N/1000;
    N -= na*1000;
    nb = N/100;
    N -= nb*100;
    nc = N/10;
    N -= nc*10;
    nd = N;

    if(na == 2){
        i++;
    }
    if(nb == 2){
        i++;
    }
    if(nc == 2){
        i++;
    }
    if(nd == 2){
        i++;
    }

    cout << i << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    int a,b,cnt1,cnt2,cnt3;
    cnt1=cnt2=cnt3=0;
    cin>>n>>a>>b;
    vector<int> v(n);
    rep(i,n){
      cin>>v[i];
      if(v[i]<=a) cnt1++;
      else if(v[i]<=b) cnt2++;
      if(v[i]>b) cnt3++;
    }
    cout<<min(cnt1,min(cnt2,cnt3))<<endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }

int main()
{
	ll N, H[100000];
	bool flag = true;
	bool con = false;
	int j = 0;

	cin >> N;
	rep(i, N)
		cin >> H[i];

	rep(i, N - 1)
	{
		if (!con)
			j = i;

		if (H[j] == H[i + 1])
		{
			if (!con)
			{
				j = i;
				con = true;
			}
		}
		else if (H[j] - H[i + 1] > 1)
		{
			cout << "No" << endl;
			flag = false;
			break;
		}
		else if (H[j] - H[i + 1] == 1)
		{
			H[j]--;
			if (j != 0)
			{
				if (H[j] < H[j - 1])
				{
					cout << "No" << endl;
					flag = false;
					break;
				}
			}
			con = false;
		}
		else
			con = false;
	}
	if (flag)
		cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  
  for (int i =0; i<N; i++){
    if(ans*2 <= ans+K ){
      ans *= 2;
    }
    else{
      ans += K;
    }
  }
  cout << ans <<endl;
}
  

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

int judge(long long n)
{
  if(n<2)return 0;
  else if(n==2)return 1;
  if(n%2==0)return 0;
  for(int i=3;i<=n/i;i+=2){
    if(n%i==0)return 0;
  }
  return 1;
}

int main()
{
  long long n;

  cin>>n;
  cout<<n<<":";
  if(judge(n))cout<<" "<<n;
  else{
    for(int i=2;i<=n;i++){
      if(n%i==0){
	cout<<" "<<i;
	n/=i;
	i--;
      }
    }
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1168
use std::cmp::Reverse;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let x: i64 = sc.read();

    let blu = (0..n)
        .map(|_| (sc.read::<i64>(), sc.read::<i64>(), sc.read::<i64>()))
        .collect::<Vec<_>>();

    if blu.iter().all(|&(b, _, _)| b == 0) {
        println!("0");
        return;
    }
    let mut ng = 0;
    let mut ok = x * (n as i64);
    while ok - ng > 1 {
        let m = (ok + ng) / 2;
        if solve(m, &blu, x) {
            ok = m;
        } else {
            ng = m;
        }
    }
    println!("{}", ok);
}

fn solve(time: i64, blu: &[(i64, i64, i64)], x: i64) -> bool {
    let head = (time / x) as usize;
    let remain = time % x;
    let n = blu.len();
    if head >= n {
        return true;
    }

    let mut lower = 0;
    let mut effect = vec![];
    for i in 0..n {
        let (b, l, u) = blu[i];
        lower += b * l;
        let gain = x * u - b * (u - l);
        effect.push((gain, i));
    }
    effect.sort_by_key(|&(g, _)| Reverse(g));
    for i in 0..head {
        let (gain, _) = effect[i];
        if lower < gain {
            return true;
        }
        lower -= gain;
    }

    let (next, _) = effect[head];
    for (k, &(removed_gain, i)) in effect.iter().enumerate() {
        let in_head = k < head;
        let (b, l, u) = blu[i];

        let gain = if remain >= b {
            remain * u - b * (u - l)
        } else {
            remain * l
        };
        if in_head {
            if gain + next >= lower + removed_gain {
                assert!(next <= removed_gain);
                return true;
            }
        } else {
            if gain >= lower {
                return true;
            }
        }
    }
    false
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int64_t> L(87);
  L.at(0)=2LL;
  L.at(1)=1LL;
  for(int i=2;i<=N;i++){
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  cout << L.at(N) << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void dfs(int u, vector<int>adj[], vector<bool>&visited, vector<int>&res, int count) {
	res[u] = count;
	visited[u] = true;
	for (auto v: adj[u]) {
		if (!visited[v]) {
			dfs(v, adj, visited, res, count);
		}
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	vector<int>adj[n];
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		adj[a - 1].push_back(b - 1);
		adj[b - 1].push_back(a - 1);
	}
	vector<int>res(n, 0);
	vector<bool>visited(n, false);
	int count = 0;
	for (int i = 0; i < n; ++i) {
		if (!visited[i]) {
			count++;
			dfs(i, adj, visited, res, count);
		}
	}
	int maximum = INT_MIN;
	for (int i = 0; i < n; ++i)
		maximum = max(maximum, res[i]);
	cout << maximum - 1;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// x^y in O(log N)
ll pow_r(ll x, ll y) {
  assert(y>=0);

  ll ret = 1;
  while (y>0) {
    if (y%2) {
      ret = ret*x;
    }
    x *=x;
    y >>= 1;
  }

  return ret;
}
// ========== end of template ==========

vvi sets;
vi ps;

int validate(const vi& switches) {
  for (int i=0; i<int(sets.size()); i++) {
    int x = 0;
    for (auto j : sets[i]) {
      x += switches[j];
    }
//cerr << "i " << i << ", x " << x <<endl;
    if (x%2 != ps[i]) {
      return 0;
    }
  }

  return 1;
}

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;

  sets.resize(M);

  for (int i=0; i<M; i++) {
    int k;
    cin >> k;
    sets[i] = vi(k);
    for (int j=0; j<k; j++) {
      cin >> sets[i][j];
      sets[i][j]--; // 0-indexed
    }
  }

  ps.resize(M);
  for (int i=0; i<M; i++) {
    cin >> ps[i];
  }

  int ret = 0;
  for (uint32_t i=0; i<pow_r(2, N); i++) {
    vi switches(N);
    for (int j=0; j<N; j++) {
      switches[j] = i>>j & 1u;
    }
    ret += validate(switches);

    // for (int j=0; j<N; j++) {
    //   cerr << switches[j];
    // }
    // cerr << "\nret " << ret << endl;
  }

  cout << ret << endl;


  return 0;
}


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

int n,m,a[maxn];

LL sum[maxn];

void init()
{
    scanf("%d%d",&m,&n);
    for (int i=1;i<=n;++i)
        scanf("%d",&a[i]);
}

LL calc(int *a)
{
    LL ans=0;
    for (int i=1;i<=n;++i)  sum[i]=sum[i-1]+a[i];
    // for (int i=1;i<=n;++i)  cout<<a[i]<<" "; cout<<endl;
    for (int i=1;i<=n;++i)
    {
        if (i+(i-1)<=n) // LL
            ans=max(ans,-2LL*(sum[2*i-1]-sum[i])+2LL*sum[i]-a[i]+2LL*(i-1)*m);
        if (i+i<=n) //LR
            ans=max(ans,-2LL*(sum[2*i]-sum[i])+a[i+1]+2LL*sum[i]+(2LL*i-1)*m);
        if (i+i<=n) //RL
            ans=max(ans,-2LL*(sum[2*i]-sum[i])+2LL*sum[i]-a[i]+2LL*i*m);
        if (i+i+1<=n)
            ans=max(ans,-2LL*(sum[2*i+1]-sum[i])+a[i+1]+2LL*sum[i]+(2LL*i+1)*m);
        // cout<<i<<" "<<-2LL*(sum[2*i-1]-sum[i])+2LL*sum[i]-a[i]+2LL*(i-1)*m<<" "
        //                 <<-2LL*(sum[2*i]-sum[i])+a[i+1]+2LL*sum[i]+(2LL*i-1)*m<<" "
        //                 <<-2LL*(sum[2*i]-sum[i])+2LL*sum[i]-a[i]+2LL*i*m<<" "
        //                 <<-2LL*(sum[2*i+1]-sum[i])+a[i+1]+2LL*sum[i]+(2LL*i+1)*m<<endl;
    }
    return ans;
}

void solve()
{
    LL ans=calc(a);
    reverse(a+1,a+n+1);
    for (int i=1;i<=n;++i)
        a[i]=m-a[i];
    ans=max(ans,calc(a));
    printf("%lld\n",ans);
}

int main()
{
    init();
    solve();
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int a, b, c; cin >> a >> b >> c;
  int result;
  if (a==b&&b==c) result = 1;
  else if (a==b||b==c||c==a) result = 2;
  else result = 3;
  cout << result << endl;
  return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  
  int s, c;
  vector<int> digits = {-1, -1, -1};
  for (int i = 0; i < m; i ++)
  {
    cin >> s >> c;

    // 2桁以上で最上位に0を要求してるやつ
    if (n != 1 && s == 1 && c == 0)
    {
      cout << "-1" << endl;
      return 0;
    }

    // 桁の条件指定が矛盾するやつ
    if ((digits.at(s - 1) != -1) && (digits.at(s - 1) != c))
    {
      cout << "-1" << endl;
      return 0;
    }

    digits.at(s - 1) = c;
  }
  
  for (int i = 0; i < n; i ++)
  {
    if (digits.at(i) == -1)
    {
      if (i == 0 && n != 1)
        cout << 1;
      else
        cout << 0;
    }
    else
      cout << digits.at(i);
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>

#define MEMZERO(x) memset(x, 0, sizeof(x))
#define MEMSET(x, y) memset(x, y, sizeof(x))

using namespace std;

const int SIZE = 500200;
bool isPrime[SIZE];
int prime[SIZE/2], pSize;
int table[5100];

void setPrime( void )
{
	pSize = 0;
	for(int i=2; i < SIZE; ++i) isPrime[i] = true;
	isPrime[0] = isPrime[1] = false;
	for(int i=2; i < SIZE; ++i) {
		if(!isPrime[i]) continue;
		prime[pSize++] = i;
		for(int j=i+i; j < SIZE; j+=i) {
			isPrime[j] = false;
		}
	}
}

int search_index( int num )
{
	int l=0, h = pSize;
	while(l < h) {
		int m = (l + h) / 2;
		if(prime[m] < num) l = m + 1;
		else if(prime[m] > num) h = m;
		else return (m+1);
	}
	return l;
}

int main( void )
{
	setPrime();
	int m, p;
	while(cin >> m >> p, m != -1 || p != -1) {
		MEMZERO(table);
		int ii = search_index(m);
		int count = 0;
		for(int i=0; i < 100; ++i)
			for(int j=i; j < 100; ++j) {
				table[count++] = prime[i+ii] + prime[j+ii];
			}
		sort(table, table+count);
		cout << table[p-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>

int main(void)
{
  int n;
  std::vector<int> buttons;

  std::cin >> n;
  buttons.resize(n);

  for (int i = 0; i < n; i++)
    std::cin >> buttons[i];

  int count = 0;
  int light = 1;
  std::vector<bool> touched(n, false);
  while (light != 2) {
    if (touched[light-1] == true) {
      count = -1;
      break;
    }
    else {
      count++;
      touched[light-1] = true;
      light = buttons[light-1];
    }
  }

  std::cout << count << std::endl;

  return 0;
}

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

int main() {
  int X;
  cin >> X;
  
  int ans = (X/500) * 1000;
  X %= 500;
  ans += (X/5) * 5;
  
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 3580
//LRが連続している分だけ繰り返せば十分
//その後は、偶奇で繰り返すだけ
//
//実際は偶奇に分ければ、繰り返さなくても答えは出る
//RRRRL -> Rの端に集まるのは、Rの端から左に見て、2個目と4個目のR

#include <iostream>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  int s_size = s.size();

  vector<int> result(s_size, 0);

  //Rを計算する
  vector<int> r_count(2, 0);
  int count = 0;
  for (int i = 0; i < s_size; i++) {
    if (s[i] == 'R') {
      r_count[i%2]++;
      count++;
    } else {
      if (count > 0) {
        // RからLに切り替わったら
        result[i] += r_count[i%2]; //Lの方には、Lと偶奇が同じR
        result[i-1] += r_count[(i+1)%2];
        r_count[0] = r_count[1] = count = 0;
      }
    }
  }

  //Lを計算する
  count = 0;
  vector<int> l_count(2, 0);
  for (int i = s_size - 1; i >= 0; i--) {
    if (s[i] == 'L') {
      l_count[i%2]++;
      count++;
    } else {
      if (count > 0) {
        result[i] += l_count[i%2]; //Rの方には、Rと偶奇が同じL
        result[i+1] += l_count[(i+1)%2];
        l_count[0] = l_count[1] = count = 0;
      }
    }
  }

  bool is_first = true;
  for (int i = 0; i < s_size; i++) {
    if (is_first) {
      is_first = false;
    } else {
      cout << " ";
    }

    cout << result[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1024
S = input()

MM = ["01","02","03","04","05","06","07","08","09","10","11","12"]

S1 = S[:2]
S2 = S[2:]

if S1 in MM and S2 in MM:
    print("AMBIGUOUS")
elif S1 in MM:
    print("MMYY")
elif S2 in MM:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
n, amount = gets.split.map(&:to_i)

yen_10000 = 0
yen_5000 = 0
yen_1000 = 0

fin = false

k = (amount / 10000).ceil
k.downto(0) do |m|
  if m * 10000 <= amount
    j = ((amount - m* 10000) / 5000).ceil
    j.downto(0) do |l|
      if (m * 10000 + l * 5000) <= amount
        if (m * 10000 + l * 5000 + (n-m-l) * 1000) == amount
          puts "#{m} #{l} #{n-m-l}"
          fin = true
          break
        end
        break if fin
      end
    end
    break if fin
  end
end

puts '-1 -1 -1' unless fin


Measured memory_bytes: 3836
#include <stdio.h>
#define SIZE 200001

int main(void){
  char S[SIZE], T[SIZE];
  int count = 0, i = 0;
  
  scanf("%s %s", S, T);
  
  for(i = 0; S[i] != '\0'; i++){
    if(S[i] != T[i])count++;
  }
  printf("%d", count);
  
  return 0;
}

Measured memory_bytes: 2092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.nextLine();
			int number = Integer.parseInt(s.replaceAll(" ", ""));
			System.out.println((0 == (number % 4)) ? "YES" : "NO");
		}
	}
}


Measured memory_bytes: 23764
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, P[int(2e5 + 5)];

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", P + i);

  int ans = 1, now = P[0];
  for (int i = 1; i < N; i++){
    if (now >= P[i]) ans++;
    now = min(now, P[i]);
  }
  printf("%d\n", ans);

  return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int nums[100001];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  ll ans = 0L;
  for(int i=0;i<n;i++) {
    cin >> a[i];
    nums[a[i]]++;
    ans += a[i];
  }

  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int b,c;
    cin >>b>>c;
    ans += (c-b)*nums[b];
    nums[c] += nums[b];
    nums[b] = 0;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3892
#include <stdio.h>

int main()
{
	int i, K;
	char S[101];
	scanf("%d", &K);
	scanf("%s", S);
	for (i = 0; i < K && S[i] != 0; i++) printf("%c", S[i]);
	if (S[i] == 0) printf("\n");
	else printf("...\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1648
#include<iostream>
#include<algorithm>
// Need start
#include<vector>
#include<limits>
// Need end
using namespace std;

template <class T>
class WarshallFloyd {
    private:
        T inf;
        T node_num;
        vector<vector<T> > dist;
    public:
        WarshallFloyd(T n) {
            inf = numeric_limits<T>::max();
            node_num = n;
            dist.resize(node_num);
            for (T i = 0; i < node_num; i++) {
                dist[i].resize(node_num);
                fill(dist[i].begin(), dist[i].end(), inf);
            }
        }
        void add_edge(T from, T to, T cost) {
            dist[from][to] = cost;
        }
        void calc_shortest_path() {
            for (T k = 0; k < node_num; k++) {
                for (T i = 0; i < node_num; i++) {
                    for (T j = 0; j < node_num; j++) {
                        if (dist[i][k] == inf || dist[k][j] == inf) continue;
                        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                    }
                }
            }
        }
        T get_dist(T from, T to) {
            return dist[from][to];
        }
};

int main() {
    int N, M, R, A, B, C;
    cin >> N >> M >> R;
    vector<int> r(R);
    for (int i = 0; i < R; i++) {
        cin >> r[i];
        r[i]--;
    }
    WarshallFloyd<int> W(N);
    for (int i = 0; i < M; i++) {
        cin >> A >> B >> C;
        A--, B--;
        W.add_edge(A, B, C);
        W.add_edge(B, A, C);
    }
    W.calc_shortest_path();
    vector<int> perm(R);
    for (int i = 0; i < R; i++) {
        perm[i] = i;
    }
    int ans = numeric_limits<int>::max();
    int inf = numeric_limits<int>::max();
    do {
        int now_dist = 0;
        for (int i = 1; i < R; i++) {
            if (W.get_dist(r[perm[i - 1]], r[perm[i]]) == inf) {
                now_dist = inf;
                break;
            }
            now_dist += W.get_dist(r[perm[i - 1]], r[perm[i]]);
        }
        ans = min(ans, now_dist);
    } while (next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool dfs(int st,int par,vector<vector<int> >&adj,vector<int>&p,vector<int>&h,vector<int>&g,vector<int>&b){
    bool ans=true;
    int flag=0;
    int x,y;
    for(int j=0;j<adj[st].size();j++){
        if(adj[st][j]!=par){
        //cout<<adj[st][j]<<" "<<par<<" "<<st<<endl;
            flag=1;
            ans=ans&dfs(adj[st][j],st,adj,p,h,g,b);
            g[st]+=g[adj[st][j]];
            b[st]+=b[adj[st][j]];
            p[st]+=p[adj[st][j]];
        }
    }
    if(flag==0){
        if(abs(h[st])>p[st]){
        	//cout<<st<<endl;
        	return false;
		}
        else {
            g[st]=(p[st]+h[st])/2;
            b[st]=(p[st]-h[st])/2;
            //cout<<st<<" "<<p[st]<<" "<<h[st]<<" "<<g[st]<<" "<<b[st]<<endl;
            if(g[st]+b[st]==p[st])
            return true;
            else return false;
        }
    }
    else{
        int x=(p[st]+h[st])/2;
        int y=(p[st]-h[st])/2;
        //cout<<st<<" "<<p[st]<<" "<<h[st]<<" "<<g[st]<<" "<<b[st]<<" "<<ans<<endl;
        if(x<0||y<0||(x+y)!=p[st]||(x-y)!=h[st]||abs(h[st])>p[st]||x<g[st])return ans&false;
        else {
        	g[st]=x;
        	b[st]=y;
        	return ans&true;
		}
    }
}

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    int ans=0;
    long  long sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        ans=max(ans,arr[i]);
        sum+=(long long)(2*arr[i]-1);
    }
    int l=0,h=ans;
    //cout<<ans<<endl;
    while(l+1<h){
        int m=(l+h)/2;
        if(m==0)m=1;
        int cnt=0;
        for(int i=0;i<n;i++){
            if(arr[i]%m==0)cnt+=(arr[i]/m)-1;
            else cnt+=arr[i]/m;
        }
        if(cnt<=k){
            h=m;
        }
        else {
            l=m;
        }
        //cout<<ans<<" "<<l<<" "<<h<<endl;
    }
    cout<<h<<endl;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    if( s[k-1] == 'A'){
        s[k-1] = 'a';
    }else if( s[k-1] == 'B'){
        s[k-1] = 'b';
    }else {
        s[k-1] = 'c';
    }
    cout << s << endl;

}


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

using namespace std;

int main(){
  int n, l;
  vector<string> s;
  cin >> n >> l;
  for(int i=0;i<n;i++){
    string tmp;
    cin >> tmp;
    s.push_back(tmp);
  }
  sort(s.begin(),s.end());
  for(x:s)cout << x;
  cout << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> P;
const int INF=pow(2,31)-1;
std::vector<P> v(1e6,P(0,-1));
int N=1;
void update(int a,int b,int c,int d,int k,int l,int r){
  if(r<=a||b<=l)return;
  if(a<=l&&r<=b)v[k]=P(c,d);
  else{
    update(a,b,c,d,k*2+1,l,(l+r)/2);
    update(a,b,c,d,k*2+2,(l+r)/2,r);
  }
}
int ma(int a){
  int k=a+N-1;
  P res=v[k];
  while(k){
    k=(k-1)/2;
    if(res.second<v[k].second)res=v[k];
  }
  return res.first;
}

signed main(){
  int n;cin>>n;while(n>=N)N*=2;
  std::vector<int> h(n),a(n);
  for(int i=0;i<n;i++)cin>>h[i];
  for(int i=0;i<n;i++)cin>>a[i];
  update(n+1,n+2,INF,0,0,0,N);
  for(int i=0;i<n;i++){
    int l=h[i],r=N+1;
    int k=ma(h[i]-1)+a[i];
    while(r-l>1){
      int m=(l+r)/2;
      if(ma(m)<k)l=m;
      else r=m;
    }
    update(h[i],r,k,i+1,0,0,N);
  }
  cout<<ma(n)<<endl;
}


Measured memory_bytes: 18944
inputs = input()
answer = ''

for s in inputs:
    if s == '0':
        answer = answer + '0'
    elif s == '1':
        answer = answer + '1'
    elif s == 'B' and answer == '':
        answer = answer + ''
    elif s == 'B' and answer != '':
        answer = answer[:-1]
print(answer)

Measured memory_bytes: 2940
<?php
$n = fgets(STDIN);
if ($n <= 9) {
    echo $n;
} elseif (10 <= $n and $n <= 99) {
    echo 9;
} elseif (100 <= $n and $n <= 999) {
    echo 9+($n-99);
} elseif (1000 <= $n and $n <= 9999) {
    echo 909;
} elseif (10000 <= $n and $n <= 99999) {
    echo 909+($n-9999);
} elseif (100000 <= $n ) {
    echo 90909;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
vector<ll> a(n), b(n);
rep(i, n) cin >> a[i] >> b[i];
ll ans = 0;
a[n - 1] %= b[n-1];
rrep(i,n){
    if(a[i]>0){
        ll diff = b[i] - a[i];
        ans += diff;
        // rep(j,i){
        //     a[j] = (a[j] + diff) % b[j];
        // }        
    }
    if(i>0){
    a[i - 1] = (a[i - 1] + ans) % b[i - 1];
}
}
cout << ans << endl;
//system("pause");
return 0;
}

Measured memory_bytes: 1792
from math import ceil, floor

n = int(input())
a_list = [int(x) for x in input().split()]

temp_list = sorted([a - i for a, i in zip(a_list, range(1, n + 1))])

def calc(num):
    return sum([abs(temp - num) for temp in temp_list])

i = n // 2
if n % 2 == 0:
    med = (temp_list[i - 1] + temp_list[i]) / 2
    print(min(calc(floor(med)), calc(ceil(med))))
else:
    med = temp_list[i]
    print(calc(med))

Measured memory_bytes: 28144
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, m;
vector<vector<int>> adj;

int dfs(int u, int d){
  if(d > 2)
    return false;
  if(d == 2)
    return u == n - 1 ? 1 : 0;
  for(auto el : adj[u]){
    if(dfs(el ,d + 1))
      return 1;
  }
  return 0;
}


int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  cin >> n >> m;
  adj.resize(n);
  for(int i = 0;i < m;i++){
    int a, b ;
    cin >> a >> b;
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  cout << vector<string>({"IMPOSSIBLE", "POSSIBLE"})[dfs(0, 0)];


}


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



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
     ll a,b;
     cin>>a>>b;
     cout<<(ll)a*b<<"\n";

        

}






Measured memory_bytes: 3652
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace AOJALDS12A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var strlist = new List<string>();
            strlist.AddRange(Console.ReadLine().Split(' ').ToList());
            var numlist = strlist.ConvertAll(int.Parse);

            var flag = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = n-1; j > i; j--)
                {
                    if (numlist[j] < numlist[j-1])
                    {
                        var temp = numlist[j];
                        numlist[j] = numlist[j - 1];
                        numlist[j - 1] = temp;
                        ++flag;
                    }
                }
            }

            for (int i = 0; i < n; i++)
            {
                Console.Write("{0}",numlist[i]);
                if (i != n-1)
                {
                    Console.Write(" ");
                }
                else
                {
                    Console.WriteLine();
                }
            }

            Console.WriteLine("{0}",flag);
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 18268
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}

int main() {
	int K;
	cin >> K;
	vector<ll> l;

	repeat(i, 1, 10) {
		l.push_back(i);
	}

	ll idx = 0;
	ll result = 0;
	while(l.size() < K) {
		ll n = l[idx];
		ll n1 = n*10;

		string s = to_string(n);
		string s1 = to_string(n1);

		int last = ctoi(s[s.length()-1]);

		if (last == 0) {
			l.push_back(n1);
			l.push_back(n1+1);
		} else if (last == 9) {
			l.push_back(n1 + last-1);
			l.push_back(n1 + last);
		} else {
			l.push_back(n1 + last-1);
			l.push_back(n1 + last);
			l.push_back(n1 + last+1);
		}
		idx++;
	}

	cout << l[K-1] << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    ll a, b;
    cin >> a >> b;
    if(a * b <= 0) {
        cout << "Zero" << endl;
    } else if(a > 0 && b > 0) {
        cout << "Positive" << endl;
    } else {
        if(abs(a - b) % 2 == 0) {
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 10000

int main(void){
  int i,num,j;
  int hand[5],ans[N][5];
  int rps[3];

  for(i=0;;i++){
    for(j=0;j<3;j++)
      rps[j]=0;
    scanf("%d",&hand[0]);
    rps[hand[0]-1]=1;
    if(hand[0]==0)
      break;
    for(j=1;j<5;j++){
      scanf("%d",&hand[j]);
      rps[hand[j]-1]=1;
    }
    if(
        (hand[0]==hand[1] &&
         hand[1]==hand[2] &&
         hand[2]==hand[3] &&
         hand[3]==hand[4])
        ||
        (rps[0]==1 &&
         rps[1]==1 &&
         rps[2]==1)
      )
      for(j=0;j<5;j++)
        ans[i][j]=3;
    else if(rps[0]==0)
      for(j=0;j<5;j++)
        if(hand[j]==2)
          ans[i][j]=1;
        else
          ans[i][j]=2;
    else if(rps[1]==0)
      for(j=0;j<5;j++)
        if(hand[j]==3)
          ans[i][j]=1;
        else
          ans[i][j]=2;
    else if(rps[2]==0)
      for(j=0;j<5;j++)
        if(hand[j]==1)
          ans[i][j]=1;
        else
          ans[i][j]=2;
  }
  num=i;
  for(i=0;i<num;i++)
    for(j=0;j<5;j++)
      printf("%d\n",ans[i][j]);
  return 0;
}

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

int main(){
	int n;
	cin >> n;
	double a;
	double sum = 0;
	rep(i, n){
		cin >> a;
		a = 1/a;
		sum += a;
	}
	cout << fixed << setprecision(10) << 1/sum << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
c = []
count = 0
for i in range(n):
    if a[i] < 400:
        c.append(1)
    elif a[i] >= 400 and a[i] < 800:
        c.append(2)
    elif a[i] >= 800 and a[i] < 1200:
        c.append(3)
    elif a[i] >= 1200 and a[i] < 1600:
        c.append(4)
    elif a[i] >= 1600 and a[i] < 2000:
        c.append(5)
    elif a[i] >= 2000 and a[i] < 2400:
        c.append(6)
    elif a[i] >= 2400 and a[i] < 2800:
        c.append(7)
    elif a[i] >= 2800 and a[i] < 3200:
        c.append(8)
    else:
        count = count + n - i
        break
cl = set(c)
if len(cl) > 0:
    print(len(cl),len(cl)+count)
else:
    print(1,n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  p=1e9+7; 
double pi=3.141592653589793238;
  

 int main() {
        ff;
        ll vis[200005]={0};
        
         int n;ll k;
         
	scanf("%d%llu",&n,&k);
	int a[n];
	vector<int> v;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int tmp=1;
	int tot=0;
	while(1){
		if(vis[tmp]) break;
		vis[tmp]=1;
		v.push_back(tmp);
		tmp=a[tmp];
	}
	int sz=v.size();
	for(tot=0;tot<sz;tot++) if(v[tot]==tmp) break;
	if(k<=tot){
		printf("%d\n",v[k]);
		return 0;
	}
	int rot=sz-tot;
	int rmd=(k-tot)%rot+tot;
	printf("%d\n",v[rmd]);
        
           
       
    return 0;
}


Measured memory_bytes: 6700
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#define int long long
using namespace std;

void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

signed main() {
	fast();
	int n, k;
	cin >> n >> k;
	if ((n + 1) / 2 >= k) {
		cout << "YES";
	} else {
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())

a = np.array(list(map(int, input().split())) + [float("inf")])

cnt = 0
ans = 0
for v in a[1:] <= a[:-1]:
    if v:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
print(ans)


Measured memory_bytes: 23372