akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 252

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
  int h,i,a[N];

  scanf("%d",&h);
  for(i=1;i<=h;i++) scanf("%d",&a[i]);

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(parent(i)>=1) printf("parent key = %d, ",a[parent(i)]);
    if(left(i)<=h) printf("left key = %d, ",a[left(i)]);
    if(right(i)<=h) printf("right key = %d, ",a[right(i)]);
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
int N, l, r, dist[100009], que[100009];
int main() {
	std::cin >> N;
	que[r++] = 1; dist[1] = 1;
	for(int i = 1; l != r; i++) {
		for (int j = l; j < r; j++) {
			int cur = que[j] * 10 % N;
			while (dist[cur] == 0) {
				dist[cur] = i;
				que[r++] = cur;
				cur = cur * 10 % N;
			}
		}
		int cr = r;
		while (l < cr) {
			int val = (que[l] + 1 == N ? 0 : que[l] + 1);
			if (dist[val] == 0) {
				dist[val] = i + 1;
				que[r++] = val;
			}
			l++;
		}
	}
	std::cout << dist[0] << '\n';
	return 0;
}

Measured memory_bytes: 1024
raw_input = list(map(int, input().split()))
n = raw_input[0]
m = raw_input[1]
h = list(map(int, input().split()))
loads = {i+1: [] for i in range(n)}
for _ in range(m):
    raw_input = list(map(int, input().split()))
    a = raw_input[0]
    b = raw_input[1]
    loads[a].append(h[b-1])
    loads[b].append(h[a-1])
# print(loads)
counter = 0
for k, v in loads.items():
    if len(v) == 0:
        counter += 1
    elif max(v) < h[k-1]:
        counter += 1
print(counter)

Measured memory_bytes: 101964
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = (int) 1e5 + 5;
const int mod = (int) 1e9 + 7;

int n, a[N], x = 0;
ll s;

inline void solve () {
        scanf ("%d", &n);
        for (int i = 1; i <= n; i++) {
                scanf ("%d", &a[i]);
        }
        sort (a + 1, a + n + 1);
        s = a[1];
        for (int i = 2; i <= n; i++) {
                if (s + s < a[i]) {
                        x = i - 1;
                }
                s += a[i];
        }
        printf ("%d\n", n - x);
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        srand (time (NULL));
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[25];
	int b[25];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(int i=0;i<n;i++){
		int c;
		cin>>c;
		if(a[i]-c>0)
			sum+=a[i]-c;
	}
	cout<<sum<<endl;
} 

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

using namespace std;

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

  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> ids(M + 1);
  using P = pair<int, int*>;
  vector<priority_queue<P, vector<P>, greater<P>>> cache(N + 1);
  for (int city = 1; city <= M; ++city) {
    int P, Y;
    cin >> P >> Y;
    ids[city].first = P;
    cache[P].emplace(Y, &ids[city].second);
  }

  for (auto&& years : cache) {
    for (int cnt = 0; !years.empty(); years.pop()) {
      auto&& p = years.top();
      *p.second = ++cnt;
    }
  }

  for (int city = 1; city <= M; ++city) {
    auto&& p = ids[city];
    cout << setw(6) << setfill('0') << p.first
         << setw(6) << setfill('0') << p.second << '\n';
  }
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll n = in();
    ll a = 1;
    while (true)
    {
        if (a * a <= n)
            ++a;
        else
            break;
    }
    --a;
    cout << a * a << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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


using namespace std;

int main()
{
	int K,S,X,Y,Z;
	int count = 0;
	cin >> K >> S;
	//Z=S-(X+Y)
	for (int i = 0; i < K + 1; ++i) {
		for (int j = 0; j < K + 1; ++j) {
			if ((S - (i + j) >= 0) && (S - (i + j) <= K)) {
				count++;
			}
		}
	}


    cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main(){
  int M,N,ans;
  std::cin>>M>>N;
  if(N==1){
    ans=0;
  }
  else if(M==2){
    ans=N-1;
  }else if(N%(M-1)==1||N%(M-1)==0){
    ans=N/(M-1);
  }else{
    ans=N/(M-1)+1;
  }
  std::cout<<ans<<std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		switch (D) {
		case 25:
			System.out.println("Christmas");
			break;
		case 24:
			System.out.println("Christmas Eve");
			break;
		case 23:
			System.out.println("Christmas Eve Eve");
			break;
		case 22:
			System.out.println("Christmas Eve Eve Eve");
			break;
		}

	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
void chmax (int& a, int b) { if (a < b) a = b; }
const int MAX = 1500;

int main() {
    int h, w, ans = 0;
    cin >> h >> w;
    vector<vector<int>> s(h, vector<int>(w));
    vector<vector<int>> dp(MAX, vector<int>(MAX, 0));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == 1) continue;
            dp[i+1][j+1] = min({dp[i+1][j], dp[i][j+1], dp[i][j]}) + 1;
            chmax(ans, dp[i+1][j+1] * dp[i+1][j+1]);
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19400
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
	ll x;
	scanf("%lld",&x);
	ll sum=(x/500)*1000;
	x%=500;
	sum+=(x/5)*5;
	printf("%lld",sum);
}

Measured memory_bytes: 256
use proconio::{fastout, input, marker::Chars};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars
    }
    let mut res = s.iter().zip(t.iter()).filter(|(a, b)| a != b).count();
    println!("{}", res);
}


Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
 
int main(){
   ll N;
   cin >> N;
//--------------------------------------------------------
    ll total = 0;
    for(ll i = 1; i <= N; i++){
      if(i%3 == 0) continue;
      if(i%5 == 0) continue;
      total += i;
    }
//--------------------------------------------------------
  cout << total << endl;
}

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

int main() {
    int N, cnt, l, r;
    cnt = 0;

    cin >> N;

    rep (i, N) {
        cin >> l >> r;
        cnt += r - l + 1;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(long long i = 1; i<=n; i++)
typedef long long ll;
using namespace std;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>=22)cout<<"bust"<<endl;
  else cout<<"win"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long mark[101],d,n,k,res=0,a;

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

    cin>>n>>k;
    for (int i=1;i<=n;i++)
    {
        cin>>d;
        for (int j=1;j<=d;j++) 
        {
            cin>>a;
            mark[a]=1;
        }
    }
    for (int i=1;i<=n;i++) 
    if (!mark[i]) res++;
    cout<<res;

}

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

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long

typedef pair<lint, lint> P;
const lint MOD = 1e9+7;
const lint INF = MOD * MOD;

bool expo[1005];

void check(int n){
    int p = n * n;
    while(p <= 1001){
        expo[p] = true;
        p *= n;
    }
}

int main(){
    expo[1] = true;
    for(int i = 2; i <= 400; i++) check(i);
    int x; cin >> x; int ans;
    for(int i = 1; i <= x; i++){
        if(expo[i]) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#define NIL -1

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum;
  int min = INFTY, u, v;
  int M[MAX][MAX], visit[MAX], c[MAX], p[MAX];

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for(i = 0; i < n; i++) {
    c[i] = INFTY;
    visit[i] = 0;
    p[i] = NIL;
  }
  c[0] = 0;

  while(1) {
    u = NIL;
    min = INFTY;

    for(i = 0; i < n; i++) {
      if(c[i] < min && !visit[i]) {
	u = i;
	min = c[i];
      }
    }

    if(u == NIL) {
      break;
    }
    visit[u] = 1;

    for(v = 0; v < n; v++) {
      if(M[u][v] < c[v] && !visit[v]) {
	c[v] = M[u][v];
	p[v] = u;
      }
    }
  }

  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

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

  return 0;
}

Measured memory_bytes: 808
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int N,x[8],y[8],k,u[100],v[100],gx,gy;
typedef complex<int> P;
typedef vector<P> snake;
map<snake,int> msi;
P dp[6],g;
vector<P> rocks;
int dx[6]={1,0,-1,-1,0,1},dy[6]={-1,-1,0,1,1,0};
namespace std{
	bool operator<(const P& p,const P& q){
		if(p.real()!=q.real()) return p.real()<q.real();
		else return p.imag()<q.imag();
	}
}
bool adj(P p,P q){
	rep(i,6) if(p-q==dp[i]) return true;
	return false;
}
bool check(snake s){
	rep(i,N) rep(j,i-1) if(adj(s[i],s[j])||s[i]==s[j]) return false;
	return true;
}
queue<snake> que;
map<snake,snake> recover;
bool tmpok[8][6];
int t;
//snake nowfirst;
void dfs(int cnt,int a,snake s){
//	show(cnt);
	if(cnt==N){
		if(check(s)&&msi.count(s)==0){
			if((20-t)*2<abs((g-s[0]).imag())+abs((g-s[0]).real())) return;
			que.push(s);
//			recover[s]=nowfirst;
			msi[s]=t+1;
		}
		return;
	}
	if(((a>>cnt)&1)==0){
		dfs(cnt+1,a,s);
	}else{
		rep(i,6){
			if(!tmpok[cnt][i]) continue;
			P np=s[cnt]+dp[i];
			snake ns=s;
			ns[cnt]=np;
			dfs(cnt+1,a,ns);
		}
	}
}
void showsnake(snake s){
	puts("snake");
	rep(i,N) cout<<s[i]<<endl;
	cout<<endl;
}
int bfs(snake be){
	while(!que.empty()) que.pop();
	msi.clear();
	que.push(be);
	msi[be]=0;
	while(!que.empty()){
		snake s=que.front();
		que.pop();
		if(s[0]==g){
/*			showsnake(s);
			snake t=s;
			while(recover.count(t)){
				showsnake(t);
				t=recover[t];
			}*/
			return msi[s];
		}
//		showsnake(s);
		rep(i,N){
			rep(j,6){
				tmpok[i][j]=true;
				P np=s[i]+dp[j];
				if(i!=0&&!adj(s[i-1],np)) tmpok[i][j]=false;
				if(i!=N-1&&!adj(s[i+1],np)) tmpok[i][j]=false;
				if(tmpok[i][j]){
					rep(tt,k) if(np==rocks[tt]){tmpok[i][j]=false;break;}
				}
			}
		}
//		nowfirst=s;
		t=msi[s];
		rep(i,1<<N){
			int a[8];
			rep(j,N) a[j]=(i>>j)&1;
			bool ok=true;
			rep(j,N-1) if(a[j]&&a[j+1]) ok=false;
			if(!ok) continue;
			dfs(0,i,s);
		}
	}
}
int main(){
	rep(i,6) dp[i]=P(dx[i],dy[i]);
	while(true){
		cin>>N;
		if(N==0) break;
		msi.clear();
		rocks.clear();
		rep(i,N) cin>>x[i]>>y[i];
		snake be;
		rep(i,N) be.pb(P(x[i],y[i]));
		cin>>k;
		rep(i,k) cin>>u[i]>>v[i];
		rep(i,k) rocks.pb(P(u[i],v[i]));
		cin>>gx>>gy;
		g=P(gx,gy);
		cout<<bfs(be)<<endl;
	}
}

Measured memory_bytes: 20244
use std::io;
fn get_parms() -> Vec<i32> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("stdin error");
    return buf
        .split_whitespace()
        .map(|x| x.parse().expect("Parse failed"))
        .collect();
}

fn main() {
    let mut parms = get_parms();
    parms.sort();
    println!("{} {} {}", parms[0], parms[1], parms[2]);
}



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

using namespace std;

int main(void) {
	int a, b, i, c;
	cin >> a >> b;

	if (a <= 0 && 0 <= b) {
		cout << "Zero" << endl;
		return 0;
	}

	else if (a > 0) {
		cout << "Positive" << endl;
		return 0;
	}

	c = b - a + 1;

	if (c % 2 == 0) {
		cout << "Positive" << endl;
	}

	else
	{
		cout << "Negative" << endl;
	}

}

Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_macros)]

// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
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
    };

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

fn main() {
    input! {
        n: usize,
    }

    let a = vec![1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    println!("{}", a[n-1]);
}


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

long long a[100000];
int cnt[41];

int main() {
	int n;
	long long k;

	scanf("%d %lld", &n, &k);

	for (int i = 0;i < n;++i)
		scanf("%lld", &a[i]);

	for (int i = 0;i < n;++i)
		for (int j = 40;j >= 0;--j)
			if (((1LL << j) & a[i]) == 0)
				cnt[j]++;

	long long tot = 0;
	for (int i = 40;i >= 0;--i) 
		if ((tot | (1LL << i)) <= k && cnt[i] > n - cnt[i])
			tot |= 1LL << i;

	long long ans = 0;
	for (int i = 0;i < n;++i)
		ans += tot ^ a[i];

	printf("%lld", ans);

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, k; cin >> n >> k;
    int ans = 0;
    while (n > 0) {
        ans++;
        n /= k;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
   char c;
   cin>>c;
   if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
      cout<<"vowel"<<endl;
   }else{
      cout<<"consonant"<<endl;
   }
   return 0;
}



Measured memory_bytes: 256
fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    lateinit var dfs: (i: Int, s: Int, p: Int) -> Unit

    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()

        var ans = 0L
        for (i in 1..N) {
            if (!(i % 3 == 0 || i % 5 == 0)) {
                ans += i
            }
        }

        pw.println(ans)
    }
}


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

using namespace std;

int main()
{
    int a;
    scanf("%d",&a);
    int b=0,c=a;
    while(a/10!=0)
        b+=a%10,a/=10;
        b+=a;
    if(c%b==0)
        printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect
a,b,q=map(int,input().split())
INF=10**11+7
ls=[-INF]+[int(input()) for _ in range(a)]+[INF]
lt=[-INF]+[int(input()) for _ in range(b)]+[INF]
lq=[int(input()) for _ in range(q)]
for i in lq:
    inds=bisect(ls,i)
    indt=bisect(lt,i)
    s1,s2=i-ls[inds-1],ls[inds]-i
    t1,t2=i-lt[indt-1],lt[indt]-i
    print(min(max(s1,t1),max(s2,t2),min(2*s1+t2,s1+2*t2),min(2*t1+s2,t1+2*s2)))

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

int main() {
	long long n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	if ((b - a) & 1) printf("%lld\n", min(a - 1 + (b - a - 1) / 2 + 1, n - b + (b - a - 1) / 2 + 1));
	else printf("%lld\n", (b - a) >> 1);
	return 0;
}


Measured memory_bytes: 256
lst = list(map(str, input()))
n = len(lst) - 1
op_lst = ["+", "-"]
for i in range(2**n):
    op = ["-"] * 3
    for j in range(n):
        if ((i >> j) & 1):
            op[n-j-1] = op_lst[0]
    formula = ""
    for num,opp in zip(lst, op + [""]):
        formula += (num + opp)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int x, a;
	cin >> x >> a;
	cout << (x >= a)*10 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
  public static void main(String[]args) {
      Scanner sc=new Scanner(System.in);
      int a=sc.nextInt();
      int b=sc.nextInt();
      //String s;
      if(a>b){
        System.out.println("a > b");
      }
      if(a<b){
        System.out.println("a < b");
      }
      if(a==b){
        System.out.println("a == b");
      }
  }
}


Measured memory_bytes: 26144
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define v vector<int>
#define mi map<int,int>
#define mc map<char,int>
//ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,i=0,j=0,q=0;
	cin>>n;
	string s,t,m="";
	cin>>s >>t;
	for(i=0;i<2*n;i++){
		if(i%2==0){
			m=m+s[q++];
			}
			else{m=m+t[j++];}
		}
		cout<<m <<"\n";
}



Measured memory_bytes: 3648
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n,m,f[N],sz[N],G=1;
int find(int x){
  return f[x]==x?x:(f[x]=find(f[x]));
}
void merge(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return ;
  f[x]=y;
  sz[y]+=sz[x];
  sz[x]=0;
  G=max(G,sz[y]);
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m;
  for(int i=1;i<=n;i++)f[i]=i,sz[i]=1;
  for(int i=1;i<=m;i++){
    int x,y;
    cin>>x>>y;
    merge(x,y);
  }
  cout<<G<<'\n';
  return 0;
}

Measured memory_bytes: 5200
import java.util.*;
public class Main {

	public static void main(String[] args) {
		int ABCD = (new Scanner(System.in)).nextInt();
		int[] A = {ABCD /1000, ABCD % 1000 / 100, ABCD % 100 /10, ABCD % 10};
		boolean[] plus = new boolean[3];
		for(int i = 0; i < 1 << 3; i++) {
			int sum = A[0];
			for(int j = 0; j < 3; j++)
				plus[j] = false;
			for(int j = 0; j < 3; j++) {
				if((1 & (i >> j)) == 1) {
					sum += A[j+1];
					plus[j] = true;
				}
				else 
					sum -= A[j+1];
			}
			if(sum == 7)
				break;
		}
		System.out.print(A[0]);
		for(int i = 0; i < 3; i++) {
			System.out.print(plus[i] ? "+" : "-");
			System.out.print(A[i+1]);		
		}
		System.out.println("=" + 7);
	}

}

Measured memory_bytes: 22736
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var N = Sarray()[0];
            var di = Slist();
            di.Sort();
            var ans = di[(int)N / 2] - di[(int)N / 2 - 1];
            WriteLine(ans);

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 20576
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

A1T1 = A1 * T1
A2T2 = A2 * T2
B1T1 = B1 * T1
B2T2 = B2 * T2
X = A1T1 - B1T1
Y = A2T2 - B2T2
Z = X + Y

if Z == 0:
    print("infinity")
elif X * Z > 0:
    print(0)
else:
    W = abs(X) // abs(Z)
    if (abs(X) / abs(Z)).is_integer():
        print(W * 2)
    else:
        print(W * 2 + 1)


Measured memory_bytes: 3064
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
s = []

ans = sum(a)
s = Counter(a)
for i in range(q):
    bi,ci = map(int, input().split())
    b.append(bi)
    c.append(ci)
for i in range(q):
    ans += s[b[i]] * (c[i]-b[i])
    s[c[i]] += s[b[i]]
    s[b[i]] = 0
    print(ans)

Measured memory_bytes: 30192
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string gotiusa;
    getline(cin,gotiusa);
    string temp;
    map<string,int>mp;
    string ans1;
    rep(i,gotiusa.size()){
        if(i==gotiusa.size()-1)temp.push_back(gotiusa[i]);
        if(gotiusa[i]==' '||i==gotiusa.size()-1){mp[temp]++;if(ans1.size()<temp.size())ans1=temp;temp.clear();continue;}
        temp.push_back(gotiusa[i]);
    }
    pair<string,int>maxi;
    maxi.second=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++)if(itr->second>maxi.second)maxi=make_pair(itr->first,itr->second);
    cout<<maxi.first<<" "<<ans1<<endl;

}

Measured memory_bytes: 3104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var K int64
	scanner.Scan()
	K, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	fmt.Println(solve(K))
}
func solve(K int64) int {
	sum := 0
	for a := 1; a <= int(K); a++ {
		for b := 1; b <= int(K); b++ {
			for c := 1; c <= int(K); c++ {
				sum += lib_Gcd(a, b, c)
			}
		}
	}
	return sum
}
func lib_Gcd(a, b int, values ...int) int {
	g := lib_gcd(a, b)
	for _, v := range values {
		g = lib_gcd(g, v)
	}
	return g
}
func lib_gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return lib_gcd(b, a%b)
}

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

typedef long long ll;


ll power(ll a,ll b,ll d){
	if(b==0){
		return 1;
	}
	else if(a%2==0){
		return power((a*a)%d,b/2,d);
	}
	else{
		return (a*power((a*a)%d,(b-1)/2,d))%d;
	}
}

ll x,y,z;
void exteneded(ll a,ll b){
    if(b==0){
        z=a;
        x=1;
        y=0;
    }
    else{
        exteneded(b,a%b);
        int tmep=x;
        x=y;
        y=tmep-(a/b)*y;
    }
}

int modInverse(int A,int M)
{
    A=A%M;
    for(int B=1;B<M;B++)
        if((A*B)%M==1)
            return B;
}

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

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for(int i = 0; i < n; ++i)
#define INF (2e9)

int main() {
  int x, y; cin >> x >> y;
  if(y >= x*2 && y <= x*4 && y%2 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int gcd(int a, int b){
	if(a < b){
		int t=a;
		a=b;
		b=t;
	}
  /* ユークリッドの互除法 */
int  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
	return b;
}

int main(){
	int k;
	scanf("%d", &k);
	long int sum=0;
	for(int i=1; i<=k; i++){
		for(int j=1; j<=k; j++){
			for(int m=1; m<=k; m++){
				sum += gcd(gcd(i, j), m);
			}
		}
	}
	printf("%ld", sum);
	return 0;
}

Measured memory_bytes: 1728
import itertools
N = int(input())
P = input().split()
Q = input().split()
N_list = []
ka = 0
kb = 0
k = 1
for i in range(1,N+1):
    N_list.append(i)

for list in itertools.permutations(N_list,N):
    for i in range(N):
        if int(P[i]) == list[i]:
            #print(P[i],list[i])
            ka+=1
        if int(Q[i]) == list[i]:
            kb+=1
        if ka == N:
            a = k
        if kb == N:
            b = k
        #print('++++++++++++')
        #print(a,b)
        #print('++++++++++++')
    k+=1
    ka = 0
    kb = 0
print(abs(a-b))
        

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int a, b;

int main() {
scanf("%d %d", &a, &b);
printf("%d\n", 2*b - a);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;
  vector<int> a(26, 0);
  rep(i, 0, s.size()) {
    if (a[s[i] - 'a'] == 1) {
      cout << "no" << endl;
      return 0;
    }
    a[s[i] - 'a']++;
  }
  cout << "yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
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); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  vector<int>v(3);
  rep(i,3)cin >> v[i];
  sort(all(v));
  if(v[0] == 5 && v[1] == 5 && v[2] == 7)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static int findSumOfDigit(int n) {
        int sum = 0;
        while (n > 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int n = Integer.parseInt(scan.next());
        int sumOfDigit = findSumOfDigit(n);

        System.out.println(n % sumOfDigit == 0 ? "Yes" : "No");

    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX / 2;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    ll N;
    cin >> N;
    vll row1(N), row2(N);
    for(auto &a:row1) cin >> a;
    for(auto &a:row2) cin >> a;
    vll s1(N), s2(N);
    partial_sum(row1.begin(), row1.end(), s1.begin());
    reverse(row2.begin(), row2.end());
    partial_sum(row2.begin(), row2.end(), s2.begin());
    reverse(s2.begin(), s2.end());
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ans = max(ans, s1[i] + s2[i]);
    }
    cout << ans << endl;
}

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

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

using namespace std;

#define N 500000
#define pb push_back
#define INF 0x3f3f3f3f
#define mid ((l + r) >> 1)
#define lson (o << 1)
#define rson (o << 1 | 1)

int n, k, p[N + 5], q[N + 5], r[N + 5], minv[4 * N + 5], in[N + 5], tot;
vector<int> G[N + 5];

void pushup(int o) {
    minv[o] = min(minv[lson], minv[rson]);
}

void insert(int o, int l, int r, int x, int k) {
    if (l == r) {
        minv[o] = k;
        return ;
    }
    if (x <= mid) insert(lson, l, mid, x, k);
    else insert(rson, mid + 1, r, x, k);
    pushup(o);
}

int query(int o, int l, int r, int L, int R) {
    if (L > R) return INF;
    if (L <= l && r <= R)
        return minv[o];
    int ret = INF;
    if (L <= mid) ret = min(ret, query(lson, l, mid, L, R));
    if (R > mid) ret = min(ret, query(rson, mid + 1, r, L, R));
    return ret;
}

void add() {
    for (int i = n, p1, p2; i >= 1; --i) {
        p1 = query(1, 1, n, max(q[i] - k + 1, 1), q[i] - 1);
        p2 = query(1, 1, n, q[i] + 1, min(q[i] + k - 1, n));
        if (p1 != INF) G[i].pb(p1), in[p1]++;
        if (p2 != INF) G[i].pb(p2), in[p2]++;
        insert(1, 1, n, q[i], i);
    }
}

struct Cmp {
    bool operator () (const int &a, const int &b) const {
        return q[a] > q[b];
    }
};

void topo() {
    priority_queue<int, vector<int>, Cmp> pq;
    for (int i = 1; i <= n; ++i)
        if (!in[i])
            pq.push(i);
    while (!pq.empty()) {
        int u = pq.top(); pq.pop();
        r[++tot] = q[u];
        for (auto v : G[u]) {
            in[v]--;
            if (!in[v])
                pq.push(v);
        }
    }
    for (int i = 1; i <= n; ++i)
        p[r[i]] = i;
}

int main() {
    scanf("%d%d", &n, &k);
    memset(minv, 0x3f, sizeof minv);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &p[i]);
        q[p[i]] = i;
    }
    add();
    topo();
    for (int i = 1; i <= n; ++i)
        printf("%d\n", p[i]);
    return 0;
}

Measured memory_bytes: 46464
using System.Linq;
using System;

public class P
{
    public int s { get; set; }
    public int v { get; set; }
}

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var ps = new P[n];
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            ps[i] = new P { s = int.Parse(line[0]), v = int.Parse(line[1]) };
        }
        var c = new int[m];
        for (int i = 0; i < m; i++) c[i] = int.Parse(Console.ReadLine().Trim());
        getAns(n, ps, c);
    }
    static void getAns(int n, P[] ps, int[] c)
    {
        Array.Sort(c);
        Array.Reverse(c);
        var ans = 0;
        var p = 0;
        var ps2 = ps.OrderByDescending(x => x.v).ThenByDescending(x => x.s).ToArray();
        foreach (var x in c)
            while (p < n) if (ps2[p++].s <= x) { ans++; break; }
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 32288
/**
 *  @author: pr4shan7 (प्रशांत)
 */
// #define _DEBUG

#ifndef _DEBUG
#define NDEBUG
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;

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

#ifdef _DEBUG
  ifstream cin("input.txt");
  // ofstream cout("output.txt");
#endif

  long long r;
  cin >> r;
  cout << pow(r, 2) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char a[60000];
typedef struct list ls;
struct node {
  char str[11];
  int lev;
  struct node* next;
} *qs,*qe;
typedef struct node st;
int add(char* buf)
{
  int l = strlen(buf);
  int i = 0,j=0;
  for(i=0;i<l-1;i++){
    switch(buf[i]){
    case 'r':
      j = j*3;
      break;
    case 'g':
      j = j*3+1;
      break;
    case 'b':
      j = j*3+2;
      break;
    }
  }
  if(a[j] == 1) return 0;
  a[j] = 1;
  return 1;
}
void push(char* buf,int l)
{
  if(qe == NULL) {
    qe = (st *)(malloc(sizeof(st)));
    qs = qe;
  } else {
    qe->next = (st *)(malloc(sizeof(st)));
    qe = qe->next;
  }
  strcpy(qe->str,buf);
  qe->lev = l;
  qe->next = NULL;
}
struct node* pop()
{
  st* p = qs;
  if(qs == NULL) return NULL;
  qs = qs->next;
  if(qs == NULL) qe = NULL;
  return p;
}
void flush()
{
  st* q=qs;
  while(q!=NULL){
    qs = qs->next;
    free(q);
    q = qs;
  }
  qe = NULL;
  memset(a,0,sizeof(a));
}
int search()
{
  int i,l;
  st *p;
  char s[11];
  char c;
  while((p = pop()) != NULL){
    l = strlen(p->str);
    c = (p->str)[0];
    for(i=1; i<l; i++){
      if((p->str)[i] != c) break;
    }
    if(i==l) return p->lev;
    for(i=0; i<l-1; i++){
      strcpy(s,p->str);
      if((s[i] == 'r' && s[i+1] == 'g')
	 || (s[i] == 'g' && s[i+1] == 'r')){
	s[i] = s[i+1] = 'b';
	if(add(s)) push(s,p->lev+1);
      } else if((s[i] == 'r' && s[i+1] == 'b')
	 || (s[i] == 'b' && s[i+1] == 'r')){
	s[i] = s[i+1] = 'g';
	if(add(s)) push(s,p->lev+1);
      } else if((s[i] == 'b' && s[i+1] == 'g')
	 || (s[i] == 'g' && s[i+1] == 'b')){
	s[i] = s[i+1] = 'r';
	if(add(s)) push(s,p->lev+1);
      }
    }
    free(p);
  }
  return -1;
}
int main()
{
  char buf[11];
  int n;
  for(;;){
    scanf("%s",buf);
    if(strcmp(buf,"0") == 0) break;
    flush();
    add(buf);
    push(buf,0);
    n = search();
    if(n==-1) printf("NA\n");
    else printf("%d\n",n);
  }
}

Measured memory_bytes: 572
program sub_string
    implicit none
    character(len=1000) s
    character(len=1000) t
    integer a, b, n, i, j, con, ans
    integer,allocatable :: x(:)

    read *,s
    read *,t

    a=len_trim(s)
    b=len_trim(t)
    n=a-b
    i=0
    allocate(x(n+1))

    do while(i<=n)
        con=0
        do j=1,b
            if(s(j+i:j+i)/=t(j:j))then
                con=con+1
            end if
        end do
        i=i+1
        x(i)=con
    end do  
    ans=minval(x)
    print *,ans
end program sub_string

Measured memory_bytes: 2860
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int a, b,ab,bb;
	cin >> a >> b;
	int max;
	ab = a;
	bb = b;
	int sum = 0;
	sum += a--;
	sum += a--;
	max = sum;
	sum = 0;
	a = ab;
	b = bb;
	sum += a--;
	sum += b--;
	max < sum ? max = sum : max;
	sum = 0;
	a = ab;
	b = bb;
	sum += b--;
	sum += b--;
	max < sum ? max = sum : max;
	cout << max << endl;
}

Measured memory_bytes: 256
(let* ((n (read))
       (l (read))
       (ss (make-array n)))
      (loop :for i :from 0 :to (1- n) :do (setf (aref ss i) (read-line)))
      (sort ss #'string-lessp)
      (format t "~A~%" (apply #'concatenate (cons 'string (coerce ss 'list)))))

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  
  for (int i=0; i < H ; i++){ //配列を代入
    cin >> vec.at(i);
  }
  
  for (int i=0; i<W; i++){ //1行目を出力
   cout << '#';
  }
  cout << "##" << endl;
  
  for (int i=0; i<H; i++){ //2~H+1行目を出力
    cout << '#' << vec.at(i) << '#' << endl;
  }
  
  for (int i=0; i<W; i++){ //最終行を出力
   cout << '#';
  }
  cout << "##" << endl;

}


Measured memory_bytes: 256
a = input()
b = input()
c = input()
start = a[0]
ac = 0
bc = -1
cc = -1
while True:
	if start == "a":
		ac += 1
		if ac >= len(a):
			print("A")
			break
		start = a[ac]
	elif start == "b":
		bc += 1
		if bc >= len(b):
			print("B")
			break
		start = b[bc]
	elif start =="c":
		cc += 1
		if cc >= len(c):
			print("C")
			break
		start = c[cc] 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define MOD 1e9+7

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

    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());

    rep(i,s.size()){
        bool flag=true;
        rep(j,t.size()){
            if(s[i+j]==t[j]||s[i+j]=='?') continue;
            flag=false;
        }
        if(flag){
            string ans;
            rep(j,i) ans+=s[j];
            rep(j,t.size()) ans+=t[j];
            for(int j=i+t.size();j<s.size();j++) ans+=s[j];
            reverse(ans.begin(),ans.end());
            rep(i,ans.size()){
                if(ans[i]=='?') cout << 'a';
                else cout << ans[i];
            }
            cout << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 3636
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int res = 0;
        
        for(int a = 1; a <= N; ++a){
            for(int b = 1; b <= N; ++b){
                for(int c = 1; c <= N; ++c){
                    res += greatestCommonFactor(a, b, c);
                }
 
            }
        }
        System.out.println(res);
    }
    
    private static int greatestCommonFactor(int a, int b, int c)
    {
        int limit = Math.min(a, b);
        limit = Math.min(limit, c);
        for(int n = limit; n >= 2; n--)
        {
            if ( (a % n == 0) && (b % n == 0) && (c % n == 0) ) {
                return n;
            }
        }
        return 1;
    }
}

Measured memory_bytes: 27208
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    string s;
    cin >> s;
    n = s.size();
    int l = 0, r = n-1;
    int ans = 0;
    while(l < r){
        if(s[l] != s[r])ans++;
        l++,r--;
    }
    cout << ans << endl;

}


Measured memory_bytes: 760
#include <stdio.h>
#include <string.h>
 
int main(void){
  int n;
  int v[50];
  int c[50];
  int i;
  int sa;
  int ans=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)	scanf("%ld",&v[i]);
  for(i=0;i<n;i++)	scanf("%ld",&c[i]);
  
  for(i=0;i<n;i++){
    sa=v[i]-c[i];
    if(sa>=0){
      ans=ans+sa;
    }
  }
  
  printf("%d",ans);
 
  return 0;
}


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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int x = 0,mx = 0;
	for(int i = 0;i < n;i++)
	{
		if(s.at(i) == 'I')
		{
			x++;
		}
		else if(s.at(i) == 'D')
		{
			x--;
		}
		mx = max(x,mx);
	}
    cout << mx << endl;
}


Measured memory_bytes: 256
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    std::string s;
    std::cin >> s;
    if(s[2] == s[3] and s[4] == s[5]) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

ll dp[102][MAX/10];

ll solve(ll pos,ll rem)
{
	if(pos == n)
		return 0;
	ll &ans = dp[pos][rem];
	if(ans != -1)
		return ans;
	ans = 0;
	if(rem >= a[pos])
		ans = max(solve(pos+1,rem-a[pos]) + b[pos],solve(pos+1,rem));
	else
		ans = solve(pos+1,rem);
	return ans;
}


int main()
{

//cout << setprecision(15) << fixed;
fast

	mem(dp,-1);
	cin >> n >> k;
	fr(i,0,n)
		cin >> a[i] >> b[i];
	
	cout << solve(0,k);



 
  return 0;
 
}


Measured memory_bytes: 82176
#include<stdio.h>
int main(void)
{
	int a1,a2,a3,a4,a5,a6,a7;
	int b1,b2,b3,b4,b5,b6,b7;
	int sum1,sum2,sum3,sum4,sum5,sum6,sum7;
	scanf("%d %d",&a1,&b1);
	scanf("%d %d",&a2,&b2);
	scanf("%d %d",&a3,&b3);
	scanf("%d %d",&a4,&b4);
	scanf("%d %d",&a5,&b5);
	scanf("%d %d",&a6,&b6);
	scanf("%d %d",&a7,&b7);
	sum1=a1-b1;
	sum2=a2-b2;
	sum3=a3-b3;
	sum4=a4-b4;
	sum5=a5-b5;
	sum6=a6-b6;
	sum7=a7-b7;
	printf("%d\n",sum1);
	printf("%d\n",sum2);
	printf("%d\n",sum3);
	printf("%d\n",sum4);
	printf("%d\n",sum5);
	printf("%d\n",sum6);
	printf("%d\n",sum7);
	return 0;
}


Measured memory_bytes: 2136