akhauriyash/Code-Regression huggingface dataset:
/**
 *   created: 22 May 2019  23:20:25
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		vector< vi > v(n, vi(3,0));
		rep(i,0,n){
			cin>>v[i][0]>>v[i][1]>>v[i][2];
		}
		vector< vi > mem(n, vi(3,0));
		mem[0][0] = v[0][0];
		mem[0][1] = v[0][1];
		mem[0][2] = v[0][2];
		rep(i,1,n){
			mem[i][0] = max(mem[i-1][1],mem[i-1][2]) + v[i][0];
			mem[i][1] = max(mem[i-1][0],mem[i-1][2]) + v[i][1];
			mem[i][2] = max(mem[i-1][0],mem[i-1][1]) + v[i][2];
		}
		cout<<max(mem[n-1][0], max(mem[n-1][1], mem[n-1][2]));
	}
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    ll ans = 0;
    rep(i, n + 1)
    {
        if (i * r > n)
        {
            break;
        }
        rep(j, n + 1)
        {
            if (i * r + j * g > n)
            {
                break;
            }
            if ((n - i * r - j * g) % b == 0)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

string roll(string a){
    char temp;
    temp = a[0];
    for(int i=1;i<a.size();i++){
        a[i-1] = a[i];
    }
    a[a.size()-1] = temp;
    return a;
}

int main(){

    string s,t;
    cin >> s >> t;
    bool flag = false;
    for(int i=0;i<s.size();i++){
        t = roll(t);
        if(s == t){
            flag = true;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(train(n))
}

func train(n int) int {
	w := int(math.Pow10(9.0)) + 7
	p := 1
	for i := 1; i <= n; i++ {
		p = p * i % w
	}
	return p
}


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

int main() {
  int n;
  cin >> n;
  vector<double> x(n); //それぞれの具材の価値
  for(int i = 0; i < n; i++){
    cin >> x.at(i);
  } 
  for(int i = 0; i < n - 1; i++){
    double y = 0;
    sort(x.begin(), x.end());
    y = (x.at(0) + x.at(1)) / 2;
    x.at(0) = 1001;
    x.at(1) = 1001;
    x.push_back(y);
    }
  sort(x.begin(), x.end());
  cout << x.at(0) << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> X;
	ans = 1;
	for (int i = 2; i*i <= X; i++) {
		ll tmp = i;
		while (tmp*i <= X) {
			tmp *= i;
		}
		if (tmp != i)ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int n,w;
    cin>>n>>w;
    vector<pair<long long int,long long int>> v;
    int a,b;
    for(long long int i=0;i<n;i++){
    cin>>a>>b;
    v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    long long int T[n+1][w+1];
    
    for(long long int i=0;i<=n;i++){

        for(long long int j=0;j<=w;j++){
            if(i==0||j==0){
                T[i][j]=0;
                continue;
            }
            if(j<v[i-1].first){
                T[i][j]=T[i-1][j];
            }
            else{
                T[i][j]=max(v[i-1].second + T[i-1][j-v[i-1].first],T[i-1][j]);
            }
          //  cout<<T[i][j]<<" ";
        }
       /* if(i!=0)
        cout<<endl<<v[i-1].first<<" "<<v[i-1].second;
        cout<<endl;*/
    }
    cout<<T[n][w];

}


Measured memory_bytes: 79104
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define repc(i, a, n) for (int i = (a); i <= (int)(n); i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init)                                              \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
#define DBG(str) cerr << (str) << endl;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  rep(i, 0, s.length()) { cnt += s[i] == 'o' ? 1 : 0; }
  cout << 700 + 100 * cnt;

  return 0;
}


Measured memory_bytes: 256
INF = 1 << 29

def reader; gets.split(" ").map(&:to_i); end

def add_edge(tb, from, to, val)
  tb[from][to] = val
  tb[to][from] = val
end

def solve!(tb, n)
  n.times do |k|
    n.times do |i|
      n.times do |j|
        m = tb[i][k] + tb[k][j]
        tb[i][j] = m if tb[i][j] > m
      end
    end
  end
end

loop do
  n, m = reader
  break if n == 0 and m == 0
  $costs = Array.new(m) {Array.new(m, INF)}
  $times = Array.new(m) {Array.new(m, INF)}
  n.times do
    from, to, cost, time = reader
    add_edge($costs, from - 1, to - 1, cost)
    add_edge($times, from - 1, to - 1, time)
  end
  solve!($costs, m)
  solve!($times, m)
  gets.to_i.times do
    from, to, r = reader
    tb = (r == 0) ? $costs : $times
    puts tb[from - 1][to - 1]
  end
end

Measured memory_bytes: 9512
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll x,k,d;
	cin>>x>>k>>d;
	x= abs(x);
	if(k<=x/d){
		cout<<x-d*k<<endl;
	}
	else{
		ll minPosx = x-d*(x/d);
		k = k-(x/d);
		ll minNavX = minPosx - d;
		minNavX = abs(minNavX);
		if(k%2==0){
			cout<<minPosx;
		}
		else{
			cout<<minNavX;
		}
	}
}

Measured memory_bytes: 3628
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

#define int long long

const int MAXN = 2e5 + 10;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n,a[MAXN];
int cnt[MAXN];
int ans;

signed main () {
	cin >> n;
	for(register int i = 1;i <= n; ++i) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for(register int i = 1;i <= n; ++i) 
		ans += cnt[i] * (cnt[i] - 1) / 2;
	for(register int i = 1;i <= n; ++i) {
		ans -= cnt[a[i]] - 1;
		cout << ans << endl;
		ans += cnt[a[i]] - 1;
	}
	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll gcd(ll m,ll n){
  if(m<n) return gcd(n,m);
  if(n==0) return m;
  ll md = m % n;
  return gcd(n,md);
}
int main(){
  ll n;
  ll x,a;
  cin>>n>>x;
  ll d[100001]={};
  for(int i=0;i<n;i++){
    cin>>d[i];
    if(i==0)
      a = abs(x-d[i]);
    else
      a = gcd(abs(x-d[i]),a);
  }
  cout<<a<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define N (100010)
typedef long long LL;
int a[N];
char b[N][2];
int n;
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		scanf("%d%s",a+i,b[i]);
	}
	scanf("%d",a+n);
	LL ans1=a[1];
	for (int i=1;i<n;i++) ans1+=b[i][0]=='+'?a[i+1]:-a[i+1];
	LL temp=ans1;
	LL cur=a[n],tot=0;
	for (int i=n-1;i;i--){
		if (b[i][0]=='-'){
			temp=temp+a[i+1];
			if (temp-cur+tot>ans1) ans1=temp-cur+tot;
			tot+=cur;
			cur=0;
		}
		else {
			temp=temp-a[i+1];
		}
		cur+=a[i];
	}
	printf("%lld\n",ans1);
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    string s;
    cin >> n >> s;

    int firstput = 0;
    int lastput = 0;
    int cnt = 0;

    rep(i, n)
    {
        if (s[i] == '(')
        {
            cnt++;
        }
        else
        {
            cnt--;
            if (cnt == -1)
            {
                cnt = 0;
                firstput++;
            }
        }
    }

    lastput = cnt;
    rep(i, firstput) cout << "(";
    cout << s;
    rep(i, cnt) cout << ")";

    return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);

    int n;
    vector<int> v(n);

    cin >> n;

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

    int res = 1 << 30;
    for (int i = -100; i <= 100; ++i) {
        int cur = 0;
        for (int j = 0; j < n; ++j) {
            cur += (v[j] - i) * (v[j] - i);
        }

        if (res > cur) {
            res = cur;
        }
    }

    cout << res;
    return 0;
}


Measured memory_bytes: 3744
s = input()
# x に下1桁の数を入れる．
if len(s) == 1:
    x = s
elif len(s) == 2:   # 例: s = '48'
    x = s[1]
else:
    x = s[2]         # 例: s = '145'

if x == '2' or x == '4' or x == '5' or x == '7' or x == '9':
    print('hon')
elif x == '0' or x == '1' or x == '6' or x == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9064
#include<iostream>

using namespace std;
int main()
{
    int n;
    cin>>n;

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

    long int sum=0;
    int num=0, p=1000000000, neg=-1000000000;
    for(int i=0;i<n;i++)
    {
        if(a[i]<=0)
        {
            num++;
            sum+= -a[i];

            if(a[i]>neg)
                neg = a[i];
        }
        else
        {
            sum+=a[i];

            if(a[i]<p)
                p = a[i];
        }  
    }

    if(num%2==1)
    {
        if(-neg>p)
        {
            sum -= p*2;
        }
        else
        {
            sum += neg*2;
        }    
    }

    cout<<sum;
}

Measured memory_bytes: 640
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());

		double result = (double) N;
		if (N % 2 == 0) {
			result = 0.5;
		} else {
			result = (double) (N / 2 + 1) / (double) N;
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.ST << ", " << p.ND << ")";
}

template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto &e : x)
        	out << e << (&e == &*--x.end() ? "" : ", ");
	return out << '}';
}

template<class... Args> void dump(Args&&... args) {
	((cerr << args << ";  "), ...);
}
 
#ifdef DEBUG
#  define debug(x...) cerr << "[" #x "]: ", dump(x), cerr << "\n"
#else
#  define debug(...) false
#endif
 
template<class T> int size(T && a) { return (int) a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

mt19937 rng(2137);
int rd(int a, int b) {
	return uniform_int_distribution<int>(a, b)(rng);
}

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

	auto start = chrono::steady_clock::now();

	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	REP(i, n) cin >> c[i];
	vector<vector<int>> s(d, vector<int>(n));
	REP(i, d) REP(j, n) cin >> s[i][j];

	auto get_score = [&](vector<int> &ans) {
		LL score = 0;
		vector<int> last(n, -1);
		REP(i, d) {
			score += s[i][ans[i]];
			last[ans[i]] = i;
			REP(j, n) score -= c[j] * (i - last[j]);
		}
		return score;
	};

	auto get_time = [&]() {
		auto curr = chrono::steady_clock::now();
		return int(chrono::duration_cast<chrono::milliseconds>(curr - start).count());
	};


	LL inf = 1e18;
	auto init = [&]() {
		vector<int> ans(d), last(n, -1);
		REP(i, d) {
			pair<LL, int> opt = {0, -1};
			REP(j, n)
				opt = max(opt, {s[i][j] + c[j] * (i - last[j]), j});
			ans[i] = opt.ND;
			last[ans[i]] = i;
		}
		return ans;
	};

	vector<int> best = init();
	LL best_score = get_score(best);

	auto try_update = [&](vector<int> &cur) {
		LL new_score = get_score(cur);
		if(new_score >= best_score) {
			best = cur;
			best_score = new_score;
		}
	};

	while(get_time() <= 1950) {
		auto cur = best;
		if(get_time() <= 800) {
			int x = rd(0, d - 1);
			cur[x] = rd(0, 25);
		}
		else {
			int x = rd(0, d - 2);
			int len = rd(2, min(d - x, 30));
			REP(i, len)
				cur[x + i] = best[x + (i + 1) % len];
		}
		try_update(cur);
	}

	for(int x : best)
		cout << x + 1 << "\n";
}


Measured memory_bytes: 3720
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
  }

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    // 3
    // 1 2
    // 1 3
    // 1 4
    // のようなタイプ
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
  }

// 最大公約数
fn gcd(a: i64, b: i64) -> i64 {
    let mut aa: i64 = if a > b { a } else { b };
    let mut bb: i64 = if a > b { b } else { a };
    while bb != 0 {
        let tmp = bb;
        bb = aa % tmp;
        aa = tmp;
    }
    return aa;
}

// 最小公倍数
fn lcm(a: i64, b: i64) -> i64 {
    a / gcd(a, b) * b
}

const LARGE_PRIME: usize = 1000000007;

fn main() {
    input! {
        a: i64,
        b: i64,
        k: i64
    }

    let mut tcook = a;
    let mut acook = b;
    let mut nokori = k;
    if (nokori > tcook) {
        tcook = 0;
        nokori = nokori - a;
    } else {
        tcook = a - nokori;
        nokori = 0;
    }

    if (nokori > 0) {
        if (nokori > acook) {
            acook = 0;
        } else {
            acook = b - nokori;
        }
    }

    println!("{} {}", tcook, acook);
}


Measured memory_bytes: 4352
use std::io;

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

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

fn main() {
    let s=input_line_str();
    p(s.replace("2017","2018"));
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int A[100100],B[100100],AA[100100],BB[100100];
int main()
{
  int N,M,K;
  cin>>N>>M>>K;
  for(int i=0;i<N;i++)
  {
    cin>>A[i];
    AA[i]=A[i];
  }
  for(int i=0;i<M;i++)
  {
    cin>>B[i];
    BB[i]=B[i];
  }
  sort(A,A+N);
  sort(B,B+M);
  int Ans=A[0]+B[0];
  while(K--)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    Ans=min(Ans,AA[a]+BB[b]-c);
  }
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    cout << pow(2, floor(log2(n))) << endl;
    return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
def main():
  n=int(input())
  a=[list(map(int,input().split())) for _ in range(n)]
  f=lambda x:((x[0]-1)*(n-1+n-x[0]+1))//2+x[1]-x[0]-1
  m=(n*(n-1))//2
  g=[[] for _ in range(m)]
  for i in range(n):
    for j in range(n-2):
      if i+1>a[i][j]:
        t0=f((a[i][j],i+1))
      else:
        t0=f((i+1,a[i][j]))
      if i+1>a[i][j+1]:
        t1=f((a[i][j+1],i+1))
      else:
        t1=f((i+1,a[i][j+1]))
      g[t0].append(t1)
  def dfs(t):
    if v[t]:
      if c[t]==0:
        return -1
      else:
        return dp[t]
    v[t]=1
    for l in g[t]:
      ret=dfs(l)
      if ret==-1:return -1
      dp[t]=max(dp[t],ret+1)
    c[t]=1
    mi.discard(t)
    return dp[t]
  ans=0
  v=[0]*m
  c=[0]*m
  dp=[0]*m
  #print(g)
  mi=set(list(range(m)))
  while mi:
    i=mi.pop()
    tmp=dfs(i)
    if tmp==-1:
      print(-1)
      exit()
    ans=max(ans,tmp)
    #print(dp)
  print(ans+1)

if __name__=='__main__':
  main()


Measured memory_bytes: 230820
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    string s[h];
    rep(i,h){
        cin>>s[i];
    }
    rep(i,w+2){
        cout<<'#';
    }
    cout<<endl;
    rep(i,h){
        rep(j,3){
            if(j==0||j==2){cout<<'#';}
            else{
                cout<<s[i];
            }
        }
        cout<<endl;
    }
    rep(i,w+2){
        cout<<'#';
    }
    cout<<endl;
    
    
return 0;
}


Measured memory_bytes: 256
N, M, K = input().split()
A = input().split()
B = input().split()
ta = 0
cnta = 0
while cnta < int(N) and ta + int(A[cnta]) <= int(K):
    ta += int(A[cnta])
    cnta+=1

tb = 0
cntb = 0
while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
    tb += int(B[cntb])
    cntb += 1
    
ans = cnta + cntb

while cnta - 1 >= 0:
    ta -= int(A[cnta - 1])
    cnta -= 1
    while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
        tb += int(B[cntb])
        cntb += 1
    ans = max(ans, cnta + cntb)

print(ans)


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;   
typedef pair<P,P> PP;

//-----------------------------------------------------------------------------

int n, m, x;
int a;
bool flg[100];

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

	cin >> n >> m >> x;
	x--;
	for (int i = 0; i < m; i++) {
		cin >> a;
		a--;
		flg[a] = true;
	}
	int l = 0, r = 0;
	for (int i = 0; i < x; i++) {
		l += (int)flg[i];
	}
	for (int i = x + 1; i < n; i++) {
		r += (int)flg[i];
	}
	cout << min(l, r) << endl;

    return 0;
}


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


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;



using namespace std;
int n;
int b[300000];
int c[300000];


int main(){
  cin >> n;
  REP(i,n){
    int k;
    cin >> k;
    b[i]=k;
    c[i]=k;
  }
  sort(c,c+n);
  int p = c[n/2-1];
  int q = c[n/2];
  REP(i,n){
    //dump(b[i]);
    //dump(p);
    if(b[i]<=p) cout << q << endl;
    else cout << p << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n,a,b,i;
	cin>>n>>a>>b;
	ll v[n];
	for(i=0;i<n;i++)
	{
		cin>>v[i];
	}
	ll ans1=0,ans2=0,ans3=0;
	for(i=0;i<n;i++)
	{
		if(v[i]>=b+1)
		ans1++;
	}
	for(i=0;i<n;i++)
	{
		if(v[i]>=a+1 && v[i]<=b)
		ans2++;
	}
	for(i=0;i<n;i++)
	{
		if(v[i]<=a)
		ans3++;
	}
	cout<<min(ans1,min(ans2,ans3));
 	return 0;
}


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

int main(){
    int N,S,resa,resb,resc;
    resa = -1;
    resb = -1;
    resc = -1;
    cin >> N >> S;
    for(int i = 0;i <= N;i++){
        for(int j = 0;j + i <= N;j++){
            if(10000 * i + 5000 * j + 1000 * (N - i - j) == S){
                resa = i;
                resb = j;
                resc = N - i - j;
            }
        }
    }

    cout << resa <<" "<< resb <<" " <<" "<< resc << endl;
}

Measured memory_bytes: 384
n,m,l = gets.split.map(&:to_i)
a = n.times.map { gets.split.map(&:to_i) }
b = m.times.map { gets.split.map(&:to_i) }
c = Array.new(n) { Array.new(l) { 0 } }
n.times do |i|
  l.times do |j|
    m.times do |k|
      c[i][j] += a[i][k] * b[k][j] 
    end
  end
end
c.each { |v| puts v * ' ' }

Measured memory_bytes: 6416
cs = 3.times.map{gets.chomp.split.map(&:to_i)}

a = [[0,0],[1,1],[2,2]].inject(0){|sum,(i,j)| sum += cs[i][j]}
b = [[0,2],[1,1],[2,0]].inject(0){|sum,(i,j)| sum += cs[i][j]}
c = [[0,0],[1,2],[2,1]].inject(0){|sum,(i,j)| sum += cs[i][j]}
d = [[0,1],[1,0],[2,2]].inject(0){|sum,(i,j)| sum += cs[i][j]}

puts [a,b,c,d].uniq.size == 1 ? "Yes" : "No"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int digit_sum(int N){
  string s=to_string(N);
  int sum=0;
  for(int i=0;i<(int)s.size();i++){
    sum+=(s[i]-'0');
  }
  return sum;
}

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  for(int i=1;i<=n;i++){
    int sum=digit_sum(i);
    if(sum>=a&&sum<=b)
      ans+=i;
  }
  cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	int n,m;
	int i,j,k;
	char s[100000];
	cin >> n;
	
	int sum=0;
	
	for(i=1;i<=n;i++){
		int num=0;
		int t=i;
		while(t!=0){
			t=t/10;
			num++;
		}
		if(num%2!=0)sum++;
	}
	cout << sum;
	
}

Measured memory_bytes: 256
import sys

n,t=map(int,input().split())
be=1001
count=0
for _ in range(n):
  c,time=map(int,input().split())
  if time<=t and c<=be:
    count+=1
    be=c
  if _==n-1 and count==0:
    print("TLE")
    sys.exit()
    
print(be)

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

int main() {

	int n, d; cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i >= j) continue;
			int tmp = 0;
			for (int k = 0; k < d; k++) {
				tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			for (int z = 1; z <= 1000; z++) {
				if (tmp == z * z) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3588
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0

for i in range(N):
  A = list(map(int, input().split()))
  sum = C
  for j, k in zip(A, B):
    sum += j*k
  if sum > 0:
    cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
	int K;
	string S;
	cin >> K >> S;
	if (S.size() <= K) {
		cout << S << endl;
		return 0;
	}
	cout << S.substr(0, K) << "..." << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

const llong inf = 1e10 + 1;
int n;
llong s[100000];
int pr[10000];
vector<int> ps;
map<llong, llong> se;
map<llong, llong> cnt;

int isqrt(llong x) {
    int s = 1, e = 100000;
    while (s < e) {
        llong m = (s + e + 1) / 2;
        if (x < m * m) e = m - 1;
        else s = m;
    }
    return s;
}

int main() {
    for (int i = 2; i < 10000; ++i) {
        if (pr[i]) continue;
        ps.push_back(i);
        for (int j = i * i; j < 10000; j += i) {
            pr[j] = 1;
        }
    }
    scanf("%d", &n);
    srand(time(0));
    for (int i = 0; i < n; ++i) {
        scanf("%lld", s + i);
        llong x = s[i];
        llong e = 1;
        for (int j : ps) {
            while (x % ((llong)j * j * j) == 0) {
                s[i] /= j;
                s[i] /= j;
                s[i] /= j;
                
                x /= j;
                x /= j;
                x /= j;
            }
            int cnt = 0;
            while (x % j == 0) {
                x /= j;
                ++cnt;
            }
            cnt = (3 - cnt) % 3;
            while (cnt--) {
                if (e < inf) e *= j;
            }
        }
        if (x > 1) {
            if (x <= 100000) {
                if (e < inf) e *= x;
                if (e < inf) e *= x;
            }
            else {
                int q = isqrt(x);
                if ((llong)q * q != x) e = inf;
                else if (e < inf) e *= q;
            }
        }
        ++cnt[s[i]];
        se[s[i]] = min(e, inf);
    }
    int ans = 0;
    map<llong, llong> tp = cnt;
    for (pll i : tp) {
        if (i.first < se[i.first] && cnt[se[i.first]] > 0) continue;
        if (i.first == se[i.first]) ans += min(1ll, cnt[i.first]);
        else ans += max(i.second, cnt[se[i.first]]);
    }
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 21760
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
using ll = long long int;

int main(void) {
    ll n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    rep(i, q) cin >> a[i];
    vector<int> p(n, k - q);
    rep(i, q) p[a[i] - 1]++;
    rep(i, n) {
        p[i] > 0 ? cout << "Yes" << endl : cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,t=0;
	cin>>n;
	if (n%10==1) t=9;
	else if (n%10==9) t=1;
	else t=n%10;
	n/=10;
	if (n%10==1) t+=90;
	else if (n%10==9) t+=10;
	else t+=n%10*10;
	n/=10;
	if (n%10==1) t+=900;
	else if (n%10==9) t+=100;
	else t+=n%10*100;
	n/=10;
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

cnt = 0
for x in range(10):
    x_ = str(x)
    for i in range(n-2):
        if s[i] == x_:
            break
    else:
        continue
    for y in range(10):
        y_ = str(y)
        for j in range(i+1, n-1):
            if s[j] == y_:
                break
        else:
            continue
        for z in range(10):
            z_ = str(z)
            for k in range(j+1, n):
                if s[k] == z_:
                    cnt += 1
                    break

print(cnt)


Measured memory_bytes: 3064
#include <iostream>

#include <cstdlib>
#include <string>
#include <vector>
#include <list>
using namespace std;

struct Node { int key; Node *next, *prev; };
Node *nil;

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil, nil->prev = nil;
}
Node *searchKey(int key) {
	Node *x = nil->next;
	while (x->key != key && x != nil)x = x->next;
	return x;
}

void printlist() {
	Node *cur = nil->next;
	for (int i = 0; cur != nil;i++) {
		if (i)cout << " ";
		cout << cur->key;
		cur = cur->next;
	}
	cout << endl;
}

void popback(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	nil->prev->next = x;
	x->prev = nil->prev;
	x->next = nil;
	nil->prev = x;
	x->key = key;
}

void popfront(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	nil->next->prev = x;
	x->next = nil->next;
	x->prev = nil;
	nil->next = x;
	//if (nil->prev = nil)nil->prev = x;
	x->key = key;
}

void deleteNode(Node *t) {
	if (t == nil)return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(searchKey(key));
}

void print(list<int> x) {
	list<int>::iterator it = x.begin();
	while (it != x.end()) {
		cout << *(it++);
	}
}

int main() {
	init();
	int n, x;
	string s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'i')cin >> x, popfront(x);
		if (s == "delete")cin >> x, deleteKey(x);
		if (s == "deleteFirst")deleteFirst();
		if (s == "deleteLast")deleteLast();
	}
	printlist();
	return 0;
}

Measured memory_bytes: 34272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    int a,b,c,x,y;
  cin >>a>>b>>c>>x>>y;
  int sum=1000000000;
  
for (int i = 0; i <=max(x,y); ++i){
      int j=max(x-i,0);
      int k=max(y-i,0);
      int ans =a*j+b*k+2*c*i;
     sum=min(sum,ans);
     }
    
  cout << sum <<endl;

}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 200100;
int a[N];

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
    int n;
    ve<ll> b;
    cin >> n;
    ll sum = 0;
    b.pb(sum);
    forn(i, n) {
        cin >> a[i];
        sum += a[i];
        b.pb(sum); 
    }
    sort(all(b));
    ll ans = 0;
    for (int i = 0; i < sz(b);) {
        int j = i;
        for (; j < sz(b) && b[i] == b[j]; ++j);
        ans += (1ll * (j - i) * (j - i - 1) / 2);
        i = j;
    }
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2932
# ABC 57 C
n = int(input())
def divisor(n):
    div_list = []
    for i in range(1, int(1+ n**0.5)):
        if n%i == 0 and i**2 == n:
            div_list.append(i)
        elif n%i == 0:
            div_list.append(i)
            div_list.append(int(n/i))
    return div_list
ln = sorted(divisor(n))
#print(len(str(ln[-1*int(len(ln)/2)])))
a = 12
for i in range(len(ln)):
    if a > max(len(str(ln[i])), len(str(ln[-i-1]))):
        a = max(len(str(ln[i])), len(str(ln[-i-1])))
print(a)

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

int main(){
    int a,b,c;
    int cnt = 0;
    cin >> a >> b >> c;
    for(int i = a; i <= b; i++){
        if(c % i == 0){
          cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define INF (int)1e9+4
#define INFL (ll)1e18+4
#define md (int)1e9+7
#define mx 10000000  //use fixed<<setprecion 
#define mk make_pair
#define pi pair<int,int>
#define ss second
#define ff first
#define pb emplace_back 
#define onell(x) __builtin_popcountll(x)
#define one(x) __builtin_popcount(x)
#define all(s) s.begin(),s.end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, a) for (auto& x: a)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sz(x) ((long long)x.size())
#define mez(s) memset(s,0,sizeof s)
#define mex(s) memset(s,-1,sizeof s)
#define metr(s) memset(s,true, sizeof s)
typedef vector<int> vi; 
typedef vector<ll>vl;
typedef map<int,int> mp;
typedef queue<int> que;
typedef vector<pi> vp;
void solve(){
int n=0,x=0,y=0,z=0,m=0,k=0;
cin>>n>>x>>y;
if(n%x==0){
	cout<<(n/x)*y;
}
else{
	cout<<(n/x+1)*y;
}

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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
#define pb push_back
int mod;
int power(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
bool check(string s)
{
	int n=s.size();
	rep(i,0,n-1)
	{
		if(s[i]!=s[n-1-i])
			return false;
	}
	return true;
}
int32_t main()
{
	IOS;
	string s, a,b;
	cin>>s;
	int n=s.size();
	a=s.substr(0,(n-1)/2);
	b=s.substr((n+1)/2,(n-1)/2);
	if(check(a)&&check(b)&&check(s))
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    ll ans;
    if(a%2==0)
        ans=0;
    else
        ans=b*c;
    if(b%2==0)
        ans=0;
    else
        ans=min(ans,a*c);
    if(c%2==0)
        ans=0;
    else
        ans=min(ans,a*b);
    printf("%lld",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int a[4][13] = { 0 }, n, b, x=0, f, r, v, mas[4][3][10]={0};
	vector<string>s;
	string tr;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		mas[b-1][f-1][r-1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 10; k++) {
				if (j == 3 && i != 3){
					cout << "####################"; 
					break;
				}
				else if (j == 3 && i == 3) {
					x = 1;
					break;
				}
				else cout << " " << mas[i][j][k];
				
			}
			if (x == 1)break;
			cout << endl;
		}
	}
}


Measured memory_bytes: 3120
def main1():
    X,N=map(int,input().split())
    p=list(map(int,input().split()))
    ans=-1
    for i in range(X,1000):
        if not (i in p):
            ans=i
            break
    for i in range(X,-1,-1):
        if not (i in p):
            ans2=i
            break
    if abs(ans-X) >= abs(ans2-X):
        print(ans2)
    else:
        print(ans)

main1()

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t;
    t = 1;
    for(int i=0;i<t;i++)
    {
        ll n;
        cin>>n;
        string s;
        while(n>0)
        {
            s += 'a'+(n-1)%26;
            n = (n-1)/26;
        }
        reverse(s.begin(),s.end());
        cout<<s;
    }
    return 0;
}

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

int main(){
	int n, m;
    ll  k;
  	cin >> n >> m >> k;
  	vector<int> a(n), b(m);
  	rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
	
	ll tot = 0;
  	rep(i, m) tot += b[i];
  
  	int ans = 0;
  	int j = m;
  	rep(i, n+1){
    	while(j > 0 && tot > k){
        	j--;
          	tot -= b[j];
        }
      	if(tot > k) break;
      
      	ans = max(ans, i+j);
      	if(i == n) break;
      	tot += a[i];
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 4740
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x = x2 - x1;
    int y = y2 - y1;

    int x3 = x2 - y;
    int y3 = y2 + x;
    int x4 = x1 - y;
    int y4 = y1 + x;

    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;

    return 0;
}

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


//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
using ll = long long;
using vi = vector<int>;
using ii = pair<int,int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define ar array
// no change 

const ll MOD = 1e9+7;   // it is an prime...

template<typename T,typename L>
T power(T a, L b);				// to find reverse modulo its power(a,MOD-2);
template < typename T ,typename L> 
L coefficient(T n, T k);  // computing nCk

//const int MxN = 1e9+5;

int main() {
	FASTER;
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1;i<=n;i++){
		int a;
		cin >> a;

		if(i&1 && a&1)ans++;
	}
	cout << ans;

}


template<typename T,typename L>
T power(T a, L b){
	
	T result = 1;
	while(b){
		if(b&1) result = (result% MOD * a%MOD) % MOD;
	   	a = (a%MOD * a%MOD) % MOD;
   		b/=2;	   
	}
	return result;
}

template < typename T ,typename L> 
L coefficient(T n, T k){  // computing nCk
	k = min(k,(n-k));
	L res = 1;
	for(T i = 0; i< k;i++){
		res *= (n-i);
		res /= (i+1);

	}
	return res;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long pow_mod(long long a, long long b) {
    if (b == 0) return 1;
    long long k = pow_mod(a, b/2);
    long long res = (k*k) % mod;
    if (b % 2 == 1) {
        return (res * a) % mod;
    }
    else {
        return res;
    }
}
long long nCr(long long n, long long r) {
    long long res = 1;
    for (int i = 0; i < r; i++) {
        res *= n-i;
        res %= mod;
    }
    for (int i = r-1; i > 0; i--) {
        r *= i;
        r %= mod;
    }
    res *= pow_mod(r, mod-2);
    res %= mod;
    return res;
}
int main () {
    int n, a, b;
    cin >> n >> a >> b;
    long long ans = pow_mod(2, n);
    ans--;
    ans += mod - nCr(n, a);
    ans += mod - nCr(n, b);
    ans %= mod;
    cout << ans << endl;
}

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

int main() {
	int N,b;
	vector<vector<int>> A(3, vector<int>(3));
	vector<vector<bool>> c(3, vector<bool>(3,0));
	bool ok = 0;

	rep(i,3)
		rep(j,3)
			cin >> A.at(i).at(j);

	cin >> N;

	rep(i,N) {
		cin >> b;
		rep(j,3)
			rep(k,3)
				if(A.at(j).at(k) == b)
					c.at(j).at(k) = 1;
	}

	rep(i,3)
		if(c.at(i).at(0) && c.at(i).at(1) && c.at(i).at(2))
			ok = 1;

	rep(i,3)
		if(c.at(0).at(i) && c.at(1).at(i) && c.at(2).at(i))
			ok = 1;

	if(c.at(0).at(0) && c.at(1).at(1) && c.at(2).at(2))
		ok = 1;
	if(c.at(2).at(0) && c.at(1).at(1) && c.at(0).at(2))
		ok = 1;

	if(ok)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
}

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    ll a[100010];
    std::cin >> n;
    ll count = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if(a[i]%2==1){
            count++;
        }
    }
    if(count%2==0){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rep(i,j) for(ll i=0;i<j;i++)
#define repf(i,m,j) for(ll i=m;i<j;i++)
#define pb push_back
#define sort(a) sort(all(a))
int main()
{
	vector<int> a(100);
	vector<int> b(100);
	ll N;
	ll num;
	cin>>N;
	rep(i,N)cin>>b.at(i);
	rep(i,N){
		if(i+1>=b.at(i)) a.insert(a.begin()+(b.at(i)-1),b.at(i));
		else{
			cout<<-1<<endl; return EXIT_SUCCESS;	
		}
	}
	rep(i,N) cout<<a.at(i)<<endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
# B = [0] * N
n = max(A)
mid = n / 2

dic = defaultdict(int)
for i in range(N):
    dic[A[i]] = abs(A[i] - mid)
    
dic = sorted(dic.items(), key=lambda x:x[1])
k = dic[0][0]
# print(C(n, k))

# ans = (combinations_count(n, k))
print(n, k)

Measured memory_bytes: 26460
#include<bits/stdc++.h>
#define M 100007
using namespace std;
int n,a[M],sum,res,ans[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),res+=a[i];
	for(int i=1;i<n;i+=2)sum+=a[i]*2;
	ans[n]=res-sum;
	int w=ans[n]/2;
	ans[n-1]=(a[n-1]-w)*2;
	for(int i=n-2;i>=1;i--)ans[i]=(a[i]-ans[i+1]/2)*2;
	for(int i=1;i<=n;i++)printf("%d ",ans[i]);
	return 0;
}

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

int main() {

	int A, B, C;

	cin >>A >>B >>C;
	if (A < B && A < C && C < B)	
		cout << "Yes";

	else if (A > B && A > C && C > B)		
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

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

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

ll gcd(ll x, ll y)
{
	return y==0 ? x:gcd(y,x % y);
}

ll lcm(ll number1,ll number2){
	return number1 * number2 / gcd(number1,number2);	
}

int main()
{
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    
    ll ans = 0;
    ll kouyakusuu = lcm(C,D);
    
    ll waruC = A + A%C;
    ll waruD = A + A%D;
    ll waruCD = A + A%kouyakusuu;
    
    if(A%C == 0) ans += B/C - A/C + 1;
    else ans += B/C - A/C;
    if(A%D == 0) ans += B/D - A/D + 1;
    else ans += B/D - A/D ;
    if(A%kouyakusuu == 0) ans  -= B/kouyakusuu - A/kouyakusuu + 1;
    else ans  -= B/kouyakusuu - A/kouyakusuu;

    cout << B-A+1-ans << endl;
}


Measured memory_bytes: 256