akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll s1=0,s2=0;
  ll ans1=0,ans2=0;
  rep(i,n){
    s1 += a[i];
    if(i%2){
      if(s1>=0) ans1+=s1+1, s1=-1;
    }else{
      if(s1<=0) ans1+=1-s1, s1=1;
    }
  }
  rep(i,n){
    s2 += a[i];
    if(i%2){
      if(s2<=0) ans2+=1-s2, s2=1;
    }else{
      if(s2>=0) ans2+=s2+1, s2=-1;
    }
  }
  cout << min(ans1,ans2) << endl;
}


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

using namespace std;


typedef long long ll;

const int N=300000;

int n;
ll v[N+5];
ll sum=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=3*n;i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+3*n+1);
    for(int i=3*n-1;i>n;i-=2)
        sum+=v[i];
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(void){
	
	int a,b,c,n,vol,ss;
	
	scanf("%d %d",&a,&b);
	
	vol=a*b;
	ss=2*(a+b);
	
	printf("%d %d\n",vol,ss);
	
	
	
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <map>

using namespace std;


void solve()
{
	int p, q;
	while(cin >> p >> q)
	{
		map<int, int> isCalc;
		int count = 0;
		bool flag = true;
		bool first = true;
		while(flag)
		{
			++count;
			if(!first)
			{
				cout << p / q;
			}
			else
			{
				first = false;
			}
			p = p % q;
			if(isCalc[p] >= 1)
			{
				cout << endl;
				break;
			}
			else
			{
				isCalc[p] = count;
			}
			p *= 10;
			if(p == 0)
			{
				flag = false;
			}
		}
		if(flag)
		{
			--isCalc[p];
			--count;
			for(int i = 0; i < isCalc[p]; ++i)
			{
				cout << ' ';
			}
			for(int i = isCalc[p]; i < count; ++i)
			{
				cout << '^';
			}
		}
		cout << endl;
	}
}

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

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;cin>>s;
  stack<char >st;
  for(int i=0;i<(int)s.size();i++){
  	if(s[i]!='B')st.push(s[i]);
    else{
    	if(!st.empty())st.pop();
    }
  }
  vector<char >final;
  while(!st.empty()){
  	final.push_back(st.top());
    st.pop();
  }
  for(int i=final.size()-1;i>=0;i--)cout<<final[i];
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u;
  int a,b;
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(u==s)cout<<a-1<<" "<<b;
  else if(u==t)cout<<a<<" "<<b-1;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

cnt = 0
for i in range(n-1):
    for j in range(i+1, n):
        if a[i] > a[j]: cnt += 1
y = 0
for a1 in a:
    for a2 in a:
        if a1 > a2: y += 1

ans = (cnt*k + y*k*(k-1)//2)%MOD
print(ans)

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

int main(){
  string s;
  int count=0;
  cin >> s;
  for(int i=0;i<3;i++){
  	if(s.at(i)==s.at(i+1))
      count++;
  }
  if(count==0)
    cout << "Good";
  else
    cout << "Bad";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 5050, mo = 1e9+7, inv2 =(mo+1)/2;
const ll MOD=7LL*mo*mo;
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline void sub(int &x, int y){x=x-y>=0?x-y:x-y+mo;}
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}
int n,m,f[N][N],mi[N],ni[N];
int main() {
	n=5000;mi[0]=ni[0]=1;rep(i,1,n)mi[i]=2*mi[i-1]%mo,ni[i]=power(mi[i],mo-2);
	read(n);read(m);
	rep(i,1,m)f[0][i]=1;
	rep(i,1,n){
		int cur=0;
		rep(j,1,m){
			f[i][j]=1ll*f[i-1][j]*(j+1)%mo;
			add(f[i][j],1ll*cur*mi[j-1]%mo);
			cur=(cur+1ll*f[i-1][j]*j%mo*ni[j])%mo;
		}
	}
	cout<<f[n][m];
	return 0;
}


Measured memory_bytes: 102288
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

void preParse(int u) {
  if (u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if (u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u) {
  if (u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main() {
    int i, v, l, r, root;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        T[i].p = NIL;
    }

    for (i = 0; i < n; i++) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if (l != NIL) T[l].p = v;
        if (r != NIL) T[r].p = v;
    }

    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) root = i;
    }

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;
}



Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct in {
    int n;
    in() {}
    in(int n_) : n(n_){};
    template <class T> operator T() {
        T ret;
        cin >> ret;
        return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for (int i = 0; i < n; i++) cin >> ret[i];
        return ret;
    }
};
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

#ifdef _MY_DEBUG
#include "/Users/knshnb/.competitive_local.hpp"
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: Sat Dec 28 21:00:13 JST 2019
 **/

signed main() {
    Int n = in(), M = in(), V = in(), P = in();
    vector<Int> a = in(n);
    sort(a.rbegin(), a.rend());
    auto check = [&](Int idx) -> bool {
        if (a[idx] + M < a[P - 1]) return false;
        Int rem = M * (V - (n - idx));
        REP(i, idx) {
            if (i < P - 1) {
                rem -= M;
            } else {
                rem -= min(M, max(0LL, (a[idx] + M) - a[i]));
            }
        }
        return rem <= 0;
    };
    Int ok = P - 1, ng = n;
    while (abs(ok - ng) > 1) {
        Int mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << ok + 1 << endl;
}


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

int main() {
	
	int N;
	cin >>N;
	
	vector<int> seq_ori(N);
	
	for(int i=0; i<N; i++){
		
		cin >>seq_ori.at(i);
		
	}
	
	int count = 0;
	
	for(int i=0; i<N; i++){
		
		if(seq_ori.at(i)!=i+1){
			
			count++;
			
		}
		
	}
	
	if(count>2){
		
		cout << "NO" <<endl;
		
	}
	else{
		
		cout << "YES" <<endl;
		
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(n,m);
    vector<ll> card(n);
    in(card);
    vector<pair<ll,ll>> query(m);
    rep(i,m){
        in(query[i].second,query[i].first);
    }
    sort(all(card));
    sort(rall(query));
    vector<ll> card2;
    ll sum=0;
    int j=0,counter=0;
    for(int i=0;i<n;i++){
        if(j<query.size()&&card[i]<query[j].first){
            card[i]=query[j].first;
            counter++;
            if(counter==query[j].second){
                j++;
                counter=0;
            }
        }
        sum+=(ll)card[i];
    }
    out(sum);
}


Measured memory_bytes: 5664
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	x := make([]int, n)
	for i := range x {
		x[i] = readInt()
	}

	ans := math.MaxInt64
	for i := 1; i <= 100; i++ {
		sum := 0
		for _, v := range x {
			sum += (v - i) * (v - i)
		}
		ans = min(ans, sum)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    map<int, int> mp;
    rep(i, N) {
        int a;
        cin >> a;
        mp[a]++; mp[a-1]++; mp[a+1]++;
    }

    int res = 0;
    for(auto &p: mp) {
        res = max(res, p.se);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999
#define eps 1e-9


int main(){
    int n,y;
    while(cin>>n&&n){
        cin>>y;
        double maxi=-1;
        int num=-1;
        double x=0;
        rep(i,n){
            int b,r,t;
            cin>>b>>r>>t;
            if(t==1){
                x=(1+y*r/100.0);
                if(x>maxi){
                    num=b;
                    maxi=x;
                }
            }else{
                x=pow((1+r/100.0),y);
                if(x>maxi){
                    num=b;
                    maxi=x;
                }
            }
        }
        cout<<num<<endl;
    }
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int main(){
  while(true){
    int N,M,mex;
    mex = -1;
    cin >> N >> M ;
    if(N+M == 0)break;
    vector<int> val,dp;
    for(int i=0;i<N;i++){
      int a; cin >> a; 
      val.push_back(a);     
      dp.push_back(a);
    }
    dp.push_back(0);
    map<int,bool> exist;
    for(int i=0;i<val.size();i++){
      for(int j=0;j<val.size();j++){
	//if(M > val[i]+val[j])continue;
	dp.push_back(val[i]+val[j]);
      }
    }
    sort(dp.begin(),dp.end());
    int mmex = -1; 
    for(int i=0;i<dp.size();i++){
      if(M >= dp[i])mmex = max(mmex,dp[i]+upper_bound(dp.begin(),dp.end(),M-dp[i])[-1]);
      
    }

    cout << mmex << endl;
    mex = -1;
  }
  return 0;
}

Measured memory_bytes: 9196
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut cnt = 0;
    if s[0] == s[1] { cnt += 1; }
    if s[1] == s[2] { cnt += 1; }
    if s[2] == s[3] { cnt += 1; }
    let ans = if cnt > 0 { "Bad" } else { "Good" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, s, t, u, c, d;
  in(n);
  vector<ll> a(n), b(n), h(n);
  rep(i, n){
    in3(a[i], b[i], h[i]);
    if(h[i] != 0){
      s = a[i];
      t = b[i];
      u = h[i];
    }
  }
  rep(i, 101){
    rep(j, 101){
      k = abs(i - s) + abs(j - t) + u;
      c = 0;
      rep(m, n){
        d = max(k - abs(i - a[m]) - abs(j - b[m]), 0ll);
        if(d != h[m])
          c++;
      }
      if(c == 0){
        out(i);
        hina;
        out(j);
        hina;
        out(k);
        memi;
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream> // cin,cout
#include <stdio.h> // printf,scanf (standard input/output)
#include <cstdlib>
#include <cmath>    // abs() for float, and fabs()
#include <string>
#include <algorithm> // min,max
#include <vector>
using namespace std;

struct PY {
    int pref;
    int year;
    int index;
    
    bool operator<( const PY& right ) const {
        return pref == right.pref ? year < right.year : pref < right.pref;
    }
};

void Print(int x, int y) {
    int temp_x = 6 - to_string(x).length();
    int temp_y = 6 - to_string(y).length();
    for (int i=0;i<temp_x;i++) cout << 0;
    cout << x;
    for (int i=0;i<temp_y;i++) cout << 0;
    cout << y;
    cout << endl;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<PY> data(M);
    
    for (int i=0;i<M;i++) {
        cin >> data[i].pref;
        cin >> data[i].year;
        data[i].index = i;
    }
    
    sort(data.begin(), data.end());
    
    int flag = data[0].pref;
    int j = 1;
    for (int i=0;i<data.size();i++) {
        if (data[i].pref==flag) {
            data[i].year = j;
            j++;
        }
        else {
            flag = data[i].pref;
            j = 1;
            data[i].year = j;
            j++;
        }
    }
    
    vector<PY> data2(M);
    for (int i=0;i<data2.size();i++) {
        data2[i].pref = data[i].index;
        data2[i].year = data[i].year;
        data2[i].index = data[i].pref;
    }
    
    sort(data2.begin(), data2.end());
    
    for (int i=0;i<data2.size();i++) {
        Print(data2[i].index, data2[i].year);
    }
    
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    cout<<max(0LL,a[n/2]-a[n/2-1])<<endl;
}

Measured memory_bytes: 3996
n, k =map(int, input().split())
T = []
D = []

for i in range(n):
    tree = int(input())
    T.append(tree)

T.sort(reverse=True)
                 
for i in range(n - k + 1):
    diff = T[i] - T[i + k -1]
    D.append(diff)
    
print(min(D))

Measured memory_bytes: 11288
#include <stdio.h>

#define DICE 6

typedef struct {
  int side[DICE];
  int tmp;
} dice_t;

int main(void){
  int q, top, front, i;
  dice_t d;

  for (i = 0; i < DICE; i++)
    scanf("%d", &d.side[i]);
  scanf("%d", &q);

  for (i = 0; i < q; i++) {
    scanf("%d %d", &top, &front);
    
    if (top == d.side[0]) {
      if (front == d.side[1])
	printf("%d\n", d.side[2]);
      else if (front == d.side[2])
	printf("%d\n", d.side[4]);
      else if (front == d.side[4])
	printf("%d\n", d.side[3]);
      else // (front == d.side[3])
	printf("%d\n", d.side[1]);
    }
    else if (top == d.side[1]) {
      if (front == d.side[0])
	printf("%d\n", d.side[3]);
      else if (front == d.side[3])
	printf("%d\n", d.side[5]);
      else if (front == d.side[5])
	printf("%d\n", d.side[2]);
      else // (front == d.side[2])
	printf("%d\n", d.side[0]);
      }
    else if (top == d.side[2]) {
      if (front == d.side[0])
	printf("%d\n", d.side[1]);
      else if (front == d.side[1])
	printf("%d\n", d.side[5]);
      else if (front == d.side[5])
	printf("%d\n", d.side[4]);
      else // (front == d.side[4])
	printf("%d\n", d.side[0]);
    }
    else if (top == d.side[3]) {
      if (front == d.side[0])
	printf("%d\n", d.side[4]);
      else if (front == d.side[4])
	printf("%d\n", d.side[5]);
      else if (front == d.side[5])
	printf("%d\n", d.side[1]);
      else // (front == d.side[1])
	printf("%d\n", d.side[0]);
    }
    else if (top == d.side[4]) {
      if (front == d.side[0])
	printf("%d\n", d.side[2]);
      else if (front == d.side[2])
	printf("%d\n", d.side[5]);
      else if (front == d.side[5])
	printf("%d\n", d.side[3]);
      else // (front == d.side[3])
	printf("%d\n", d.side[0]);
    }
    else { // else if (top == d.side[5])
      if (front == d.side[1])
	printf("%d\n", d.side[3]);
      else if (front == d.side[3])
	printf("%d\n", d.side[4]);
      else if (front == d.side[4])
	printf("%d\n", d.side[2]);
      else // else if (front == d.side[2])
	printf("%d\n", d.side[1]);
    }
  }
  return 0;
}

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

using namespace std;
using ll = long long;

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

    int xl = x2 - x1;
    int yl = y1 - y2;

    cout << x2 + yl << " " << y2 + xl << " " << x1 + yl << " " << y1 + xl << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 0;
  cin >> N;
  int a = 0, b = 0, c = 0, d = 0;
  a = N / 1000;
  N = N % 1000;

  b = N / 100;
  N = N % 100;

  c = N / 10;
  N = N % 10;
 
  d = N;

  if(a == b && a == c) {
    cout << "Yes" << endl;
    return 0;
  }
  if(b == c && b == d) {
    cout << "Yes" << endl; 
    return 0;
  }
  cout << "No" << endl; 

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);
const int iINF = (1 << 31)-1;
const double dINF = 1000000000000000000.0;
const int MAX_N = 1 << 17;

int main(){
	int ans = 0;
	int tmp = 0;
	int n; cin >> n;
	string str; cin >> str;
	for (auto &&c : str) {
		if (c == 'I')tmp++;
		else tmp--;
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n);
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> a[i];
    ans += mp[i-a[i]];
    mp[i+a[i]]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 27416
#include <iostream>
using namespace std;
int main(void)
{
  int time;
  int h, m, s;
  cin >> time;

  h = time / 3600;
  int tmp = time % 3600;
  m = tmp / 60;
  s = tmp % 60;

  cout << h << ":" << m << ":" << s << endl;

  return 0;
}


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

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

	int l;
	cin>>l;

	int flav[n+1];
	int sum = 0;
	for(int i =1;i<=n;i++)
		{
			flav[i] = l + i -1;
			sum+=flav[i];
		}

	int ans = abs(flav[1]);
	int a = 1;

	for(int i =2;i<=n;i++){
		if(abs(flav[i]) < ans){
			a = i;
			ans = abs(flav[i]);
		}
	}
	cout<<sum - flav[a];
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
	int n;
	ll a, b, x[100000];
	scanf("%d %lld %lld", &n, &a, &b);
	for(int i = 0; i < n; i++) scanf("%lld", &x[i]);
	ll res = 0;
	for(int i = 0; i < n - 1; i++) res += min(a * (x[i + 1] - x[i]), b);
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>

using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b > c+d){
    cout << "Left" << endl;
  }else if(a+b < c+d){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3552
// Vicfred
// https://atcoder.jp/contests/abc164/tasks/abc164_c
// set
use std::io;
use std::collections::HashSet;

fn main() {
    let mut n = String::new();

    io::stdin()
        .read_line(&mut n)
        .unwrap();

    let n: i64 = n.trim().parse().unwrap();

    let mut kinds = HashSet::new();
    for _ in 0..n {
        let mut s = String::new();

        io::stdin()
            .read_line(&mut s)
            .unwrap();

        kinds.insert(s);
    }
    
    println!("{}", kinds.len());
}



Measured memory_bytes: 15300
#include<cstdio>
using namespace std;
int n,m;
int main()
{
	scanf("%d %d",&n,&m);
	if(m>(n-1)*(n-2)/2)
	{
		puts("-1");
		return 0;
	}
	printf("%d\n",n*(n-1)/2-m);
	for(int i=2;i<=n;i++) printf("%d %d\n",1,i);
	m=(n-1)*(n-2)/2-m;
	for(int i=2;i<=n&&m;i++)
	{
		for(int j=i+1;j<=n&&m;j++)
		{
			printf("%d %d\n",i,j);
			m--;
		}
	}
}

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

const double PI=acos(-1.0);

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

    int cnt = 0;
    rep(i, s.size()) {
        if(s.at(i) == '1') cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
# 完成
class UnionFind:
    __slots__ = ["N", "root"]

    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        rank:ランク
        """
        self.N = N
        self.root = [-1] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        while self.root[x] >= 0:
            x = self.root[x]
        return x

    def union(self, x, y):
        """x, yが属する木をunion"""
        # 根を比較する
        # すでに同じ木に属していた場合は何もしない.
        # 違う木に属していた場合はrankを見てくっつける方を決める.
        # rankが同じ時はrankを1増やす
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.root[y] < self.root[x]:
            x, y = y, x
        self.root[x] += self.root[y]
        self.root[y] = x

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = UnionFind(n)
res = []
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        res.append(int(uf.same(u, v)))
    else:
        uf.union(u, v)
print("\n".join(map(str, res)))


Measured memory_bytes: 85552
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 1; i < n - 1; i++){
        if((p[i - 1] > p[i] && p[i] > p[i + 1]) || (p[i - 1] < p[i] && p[i] < p[i + 1])){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    sum_A = sum(A)
    B = [0] + list(accumulate(A))
    cand = []
    for i in range(N+1):
        for j in range(i+1,N+1):
            cand.append(B[j] - B[i])
    ans = 0
    for i in range(40):
        bit = 1 << (39 - i)
        cnt = 0
        new_cand = []
        for c in cand:
            if c & bit:
                cnt += 1
                new_cand.append(c)

        if cnt >= K:
            ans += 2 ** (39 - i)
            cand = new_cand


    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 116820
#include <cstdio>

using namespace std;

int main() {
    int h1, m1, h2, m2, k;
    
    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
    
    printf("%d\n", h2 * 60 + m2 - h1 * 60 - m1 - k);
    
    return 0;
}


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

int main() {
  long X, A, B;
  cin >> X >> A >> B;

  if (B <= A) {
    cout << "delicious" << endl;
  } else if (B <= A + X) {
    cout << "safe" << endl;
  } else if (A + X < B) {
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
#from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

def trans(s):
    if s=="A":
        return 10
    elif s=="B":
        return 11
    elif s=="C":
        return 12
    elif s=="D":
        return 13
    elif s=="E":
        return 14
    elif s=="F":
        return 15
xy=input().rstrip().split(" ")
x,y=xy[0],xy[1]
if trans(x)>trans(y):
    print(">")
if trans(x)==trans(y):
    print("=")
if trans(x)<trans(y):
    print("<")


Measured memory_bytes: 38384
import java.util.*;
 
class Main {
 
    public static void main(String[] args) {
 
      //入力値取得
      Scanner in = new Scanner(System.in);
      String s = in.next();
      
      //入力値によって出力する天気を変更する
      switch(s){
        case"SUN":
          System.out.println(7);
          break;
       	case"MON":
          System.out.println(6);
          break;
        case"TUE":
          System.out.println(5);
          break;
        case"WED":
          System.out.println(4);
          break;
       	case"THU":
          System.out.println(3);
          break;
        case"FRI":
          System.out.println(2);
          break;
        case"SAT":
          System.out.println(1);
          break;
        default:
          System.out.println(0);
        }
    }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

using PDI = pair<double, int32>;

const int64 mod = 1e9+7;

int main(void){
	int32 a, b;
	cin >> a >> b;
	if(b >= a) cout << a << endl;
	else cout << a-1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int g[10]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
        int mono = 0;
        int ans[10]={0,0,0,0,0,0,0,0,0,0};
        int i = 0, j = 0, k = 0;

        while(scanf("%d",&mono) != EOF)
        {
                while(1)
                {
                        if(g[i] > mono)
                        {
                                ans[j] = g[i-1];
                                mono = mono - g[i-1];
                                i = 0;
                                j++;
                        }
                        if(g[i] == mono)
                        {
                                ans[j] = g[i];
                                break;
                        }
                        i++;
                }
                for(k = j; k >= 0; k--)
                {
                        printf("%d", ans[k]);
                        if(k != 0)
                        {
                                printf(" ");
                        }
                }
                j=0;
                i=0;
                k=0;
                printf("\n");
        }

        return 0;
}

Measured memory_bytes: 600
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    val List(a, b, t): List[Int] = sc.nextLine().split(" ").map(_.toInt).toList
    val realTime: Double = t + 0.5

    println((realTime / a).toInt * b)

  }
}

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

int main(){
	string s;
	int n;
	cin >> n;
	getchar();
	for (int i = 0; i < n; i++){
		getline(cin,s);
		while (1){
			int index = s.find("Hoshino");
			if (index == -1) break;
			s.replace(index,7,"Hoshina");
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <stdbool.h>

int main()
{
  int n;
  int  t, x, y;
  bool flag = true;

  scanf("%d", &n);


  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &t, &x, &y);
    if ( t >= x+y && flag == true) {
      if (t%2 == (x+y)%2) {
        flag = true;
        continue;
     }
    }
    
     flag = false;
    }

  if (flag == true) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }


  return 0;
}


Measured memory_bytes: 128
from collections import deque

class Data:
    def __init__(self, name, value):
        self.name = name
        self.value = value

Q = deque()

n, q = map(int, input().split())
for _ in range(n):
    name, value = input().split()
    tmp = Data(name, int(value))
    Q.append(tmp)

current_time = 0
done = 0

while True:
    datum = Q.popleft()
    if datum.value > q:
        current_time += q
        datum.value -= q
        Q.append(datum)
        
    else:
        current_time += datum.value
        print("%s %d"%(datum.name, current_time))
        done += 1
    if done == n:
        break
    


Measured memory_bytes: 17548
N,M=map(int,input().split())
AB=[[] for i in range(N)]
for j in range(M):
    a,b=map(int,input().split())
    AB[a-1].append(b)
    AB[b-1].append(a)
for ab in AB:
    if 1 in ab and N in ab:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 38368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll MINF = LLONG_MIN;
const int INT_INF = INT_MAX;

int main()
{
    ll n;
    cin >> n;
    cout << (n - 1) * n / 2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(){
    int row, col, i, j;
    int arr[101][101], sum = 0;
    
    scanf("%d %d", &row, &col);
    for(i = 0; i <= row; i++){
        for(j = 0; j <= col; j++){
            arr[i][j] = 0;
        }
    }

    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            getchar();
            scanf("%d", &arr[i][j]);

            arr[i][col] += arr[i][j];
            arr[row][j] += arr[i][j];
            arr[row][col] += arr[i][j];
            sum += arr[i][j];
        }
    }

    for(i = 0; i <= row; i++){
        for(j = 0; j <= col; j++){
            printf("%d%s", arr[i][j], (j == col) ? "\n" : " ");
        }
    }
}


Measured memory_bytes: 2120
while True:
    n=int(input())
    x=[]
    if n==0:
        break
    else:
        for i in range(n):
            s=int(input())
            x.append(s)
        for i in range(0,10):
            a=x.count(i)
            if a==0:
                print("-")
            else:
                print("*"*a)


Measured memory_bytes: 5708
/*
                                        //     //     //\\\\\\\\\
                                        \\    //      \\        \\
                                        //   //       //         \\
                                        \\  //        \\          \\
                                        // //         //           \\
                                        \\//          \\            \\       
                                        //\\          //            //
                                        \\ \\         \\           //
                                        //  \\        //          //
                                        \\   \\       \\         //
                                        //    \\      //        //
                                        \\     \\     \\/////////
*/

#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vint vector <int>
#define vll vector <long long int>
#define endl cout<<'\n'
#define fre(i,l,n) for(long long int i=l;i<n;++i)
#define fr(i,l,n) for(long long int i=l;i<=n;i++)
#define rfre(i,n,l) for(long long int i=n-1;i>=l;i--)
#define rfr(i,n,l) for(long long int i=n;i>=l;--i)
#define tab '\t'
#define debug cout<<'*';
#define s(a) cin>>a
#define p(a) cout<<a
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef pair<int,pair<int,int> > tii;
typedef vector<int> vec;
typedef vector<long long> vecll;
typedef vector<pair<int,int> > vec_pii;
typedef vector<pair<long long int,long long int> > vec_pll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<pair<int,int> > > vvpii;
typedef vector<vector<pair<ll,ll> > > vvpll;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define Pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define sf(n) scanf("%lld",&(n))
#define pf(n) printf("%lld\n",(n))
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define w(t) while(t--)
#define flt(a) cout<<fixed<<setprecision(a)
#define cntSetBits(n) __builtin_popcountll(n)
/*****************************
*****************************/



void solve()
{
    ll n,m;
    s(n);s(m);
    ll hash[101] = {0};
    fre(i,0,m)
    {
        ll val;
        s(val);
        hash[val] = 1;
    }
    ll diff = abs(n+1);
    ll ans = -1;
    fr(i,0,100)
    {
        if(!hash[i])
        {
            if(diff > abs(n-i))
            {
                diff = abs(n-i);
                ans = i;
            }
        }
    }
    if(diff > abs(n-101))
    {
        diff = abs(n-101);
        ans = 101;
    }
    p(ans);endl;
}



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll t=1;
    // s(t);
    w(t)
    {
        solve();
    }
    return 0;
}









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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll k;
	cin >>n >>k;
	VL a(n);
	rep(i, n) cin >>a[i];
	ll ans =1;
	ll sm = accumulate(all(a), 0LL);
	VL ys;
	for(ll i=1; i*i <=sm; i++){
		if(sm%i ==0){
			ys.push_back(i);
			if(i*i != sm) ys.push_back(sm /i); 
		}
	}
	sort(all(ys));
	
	repr(g, sz(ys)-1, 0){
		ll cr = ys[g];
		VL b(n);
		rep(i, n) b[i] = a[i] % cr;
		sort(all(b));
		
		ll sma=0, smb=0, cnd =1LL<<60;
		rep(i, n) smb  += cr - b[i];
		rep(i, n){
			sma += b[i];
			smb -= cr-b[i];
			cnd = min(cnd, max(sma, smb));
		}
		if(cnd <= k){
			cout << cr <<"\n";
			return 0;
		}
	}
	
	return 0;
}


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

int main()
{
  string s;
  bool flag;
  int ans = 0;

  cin >> s;
  for (int i = 1; i < s.size(); i++)
  {
    if ((s.size() - i) % 2 == 1)
      continue;
    flag = true;
    for (int j = 0; j < (s.size() - i) / 2; j++)
    {
      if (s[j] != s[(s.size() - i) / 2 + j])
      {
        flag = false;
        break;
      }
    }
    if (flag)
    {
      ans = s.size() - i;
      break;
    }
  }
  cout << ans << endl;
}

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

int main() {

  int xa,yb,c,d,p;
  cin >> xa >> yb >> c  >> d >> p;

  int x,y;

  x = xa * p;

  y = yb;
  if(c - p < 0) y += (p-c) * d;

  if(x > y) cout << y << endl;
  else cout << x << endl;;

  return 0;

}

Measured memory_bytes: 1160
#include<iostream>

int main(){
    int a,b;
    int c[200][200];
    c[200][202]={};
    
    std::cin>>a>>b;
    for(int i=0;i<a;i++)
    {    
         for(int j=0;j<b;j++){
        int temp;
        std::cin>>c[i][j];
        c[i][b]+=c[i][j];
        c[a][j]+=c[i][j];
        
    }
        c[a][b]+=c[i][b];
    }
      for(int i=0;i<a+1;i++)
    {    
         for(int j=0;j<b+1;j++){
        if(j==b){
        std::cout<<c[i][j]<<"\n";
        }else{
          std::cout<<c[i][j]<<" ";  
        }
        
    }
        
    }


}



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

int q;

int main() {
  cin >> q;
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    for (int yi = a; yi <= c; yi++) {
      for (int xi = b; xi <=d; xi++) {
        if (yi % 2 == 1 and xi % 2 == 0) {
        } else {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}


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

int main() {
    string s;
    int l,kaisu;
    int ans = 0;
    int ans1 = 0;
    cin >> s;
    l = s.size();
    kaisu = l/2;

    for(int i = 0; i < kaisu; i++){
        if(s.at(i) == s.at(l-1-i)){
        }
        else{
            ans += 1;
        }
    }
    cout << ans;
}





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

typedef long long ll;
const ll mod=1e9+7;
const ll N=1001;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({a*c,b*c,a*d,b*d});
}	  


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++){cin >> h[i];}
  sort(h.begin(),h.end());
  int H=INT32_MAX;
  for(int i=0;i<N-K+1;i++){
    H=min(H,abs(h[i]-h[i+K-1]));
  }
  cout << H << endl;
}

Measured memory_bytes: 640
mod = 1000000007
n, k = gets.chomp.split(' ').map(&:to_i)

$memo = {}
def combination(n, k)
  $memo[n] = {} if $memo[n] == nil
  $memo[n][k] = 1 if k == 0
  return $memo[n][k] if $memo[n][k] != nil
  $memo[n][k] = combination(n, k - 1) * (n - k + 1) / k
end

1.upto(k) do |i|
  puts (combination(n - k + 1, i) % mod) * (combination(k - 1, i - 1) % mod) % mod
end


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

int main(){
  string mes;
  char code[6][5] = { {'a','b','c','d','e'},
		      {'f','g','h','i','j'},
		      {'k','l','m','n','o'},
		      {'p','q','r','s','t'},
		      {'u','v','w','x','y'},
		      {'z','.','?','!',' '} };

  while(cin>>mes){
    string ans;
    bool f = true;
    if(mes.size()&1)f = false;
    for(int i=0;i<(int)mes.size();i+=2){
      int c = mes[i]-'0'-1, r = mes[i+1]-'0'-1;
      if(c<0 || r<0 || c>=6 || r>=5)f = false;
      else ans += code[c][r];
    }
    if(f)cout << ans << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int Maxn=105;
struct res
{
	string str;
	int val,id;
	bool operator < (const res &tmp) const
	{
		if(str!=tmp.str) return str<tmp.str;
		return val>tmp.val;
	}
}R[Maxn];
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>R[i].str>>R[i].val;
		R[i].id=i;
	}
	sort(R+1,R+1+n);
	for(int i=1;i<=n;i++)
		printf("%d\n",R[i].id);
	return 0;
}

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

	
	int main(){
		long long a,b,i;
		scanf("%ld %ld",&a,&b);		int t=0,c;
		for(int i=0;i<1000000000;i++){
			if(abs(a-i)==abs(b-i)){
				t=1;
				c=i;
				break;	
			}
		}
		if(t==1){
			printf("%d",c);
		}else{
			printf("IMPOSSIBLE");
		}
	}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
// typedef vector<int> v;

#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //




int main() {
  int n,m;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No") << endl;
  
}


Measured memory_bytes: 256
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


s = input()
print('YES' if s.count('o') + 15 - len(s) >= 8 else 'NO')


Measured memory_bytes: 67052
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	for (int i = 0; i < 5; i++) {
		if (a[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3616