akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e17
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void evaluate()
{
    ;
}
int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    ll n;   cin>>n;
    vii v(n+1,0);
    ll temp;
    forin(0,n-1)
    {
        cin>>temp;
        v[temp]++;
    }
    forin(1,n+1)
        cout<<v[i]<<endl;
}


Measured memory_bytes: 4788
N,x = map(int,input().split())
A = list(map(int,input().split()))
total = sum(A)
con = 0

for i in range(1,N):
  b = A[i - 1] + A[i]
  if b - x > 0:
    c = b - x
    if c > A[i]:
      d = c - A[i]
      A[i] = 0
      A[i - 1] = A[i - 1] - d
    else:
      A[i] = A[i] - c

print(total - sum(A))

Measured memory_bytes: 14068
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
using namespace std;
const int maxn = 100010;
const int mod = 10007;
typedef pair<int,int> Pair;
vector<Pair> a, b;
int color[maxn];
int t, n, i, j, colors, aa, bb, t1, t2, ans, maxedge, edge, cnt;
int main()
{
    //freopen("e.in", "r", stdin);
    while (scanf("%d", &n), n>0)
    {
        a.clear(); b.clear();
        for (i = 0; i < n; i++)
        {
            scanf("%d%d%d%d", &aa, &t1, &bb, &t2);
            a.push_back(make_pair(aa, t1));
            b.push_back(make_pair(bb, t2));
        }
        memset(color,0,sizeof(color));
        colors = 0; ans = 1;
        for (i = 0; i < n; i++)
        if (color[i] == 0)
        {
            colors++;
            j = a[i].first; maxedge = a[i].second; cnt = 1;
            bool first = true;
            do {
                color[j] = colors;
                if (color[a[j].first]==0 && (a[j].first!=i || !first)) {
                    edge = a[j].second;
                    j = a[j].first;
                } else
                if (color[b[j].first]==0 && (b[j].first!=i || !first)) {
                    edge = b[j].second;
                    j = b[j].first;
                } else break;
                first = false;
                if (edge > maxedge)
                {
                    maxedge = edge;
                    cnt = 1;
                } else
                if (edge == maxedge) cnt++;
            } while (j != i);
            ans = (ans*cnt)%mod;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();

		System.out.println(lcm(a,b));

	}

	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}

	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}

}

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

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

  int a, mx, mn;
  cin >> a;
  mx = a;
  mn = a;
  for (int i = 0; i < N-1; i++) {
    cin >> a;
    if (a < mn) {
      mn = a;
    } else if (mx < a) {
      mx = a;
    }
  }
  cout << mx - mn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 100;
long long arr[N];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    long long s = 0;
    for(int i = 1;i <= n;++i)cin >> arr[i];
    long long ans = 0;
    for(int i = 1;i <= n;i++){
        ans += (arr[i] / 2);
        arr[i] %= 2;
        long long t = min(arr[i], arr[i + 1]);
        arr[i] -= t;
        arr[i + 1] -= t;
        ans += t;
    }
    cout << ans;
	return 0;
} 

Measured memory_bytes: 4428
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-6
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pr;

ll binpow(ll x, ll p)
{
	if (p == 0)
		return 1;
	if (p % 2)
		return (binpow(x, p - 1) * x) % MOD;
	else
	{
		ll xx = binpow(x, p / 2);
		return (xx * xx) % MOD;
	}
}

inline void solve()
{
	ll n, cnt = 0, rd, wh = 0;
	string c;
	cin >> n >> c;
	rd = n - 1;
	while (wh < rd)
	{
		while (c[wh] == 'R' && wh < n) wh++;
		while (c[rd] == 'W' && rd > -1) rd--;
		if (wh < rd)
		{
			c[wh] = 'R';
			c[rd] = 'W';
			cnt++;
		}
		else
			break;
	}
	cout << cnt;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	/*int q = 1;
	//cin >> q;
	while (q--)
	{*/
		solve();
		//cout << '\n';
	//}
}

Measured memory_bytes: 3764
NY = input().split()
N = int(NY[0])
Y = int(NY[1])

output = '-1 -1 -1'

for i in range(min(int(Y/10000),N)+1):
    for j in range(min(int((Y-10000*i)/5000),N-i)+1):
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y:
            output = str(i) + ' ' + str(j) + ' ' + str(k)
            break

print(output)


Measured memory_bytes: 3060
//ITNOA
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
const long long INF=1e9+10,MAX=2e5+1e4,MOD=1e9+7;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
void OUT(long double o,int x){
	 cout<<fixed<<setprecision(x)<<o;
	 return;
}
ll a[MAX];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,x=0,y=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%4==0)
			x++;
		else if(a[i]%2==0)
			y++;
	}
	if((x*2)+y>=n||(y==0&&x==(n/2)))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 1024
def main():
    s = input()
    x, y = map(int, input().split())
    d = {}
    d[True] = []
    d[False] = []
    xf = True
    t = 0
    for i in s:
        if i == 'F':
            t += 1
        else:
            d[xf].append(t)
            xf = not xf
            t = 0
    if t > 0:
        d[xf].append(t)
    dpx = set()
    dpx.add(d[True][0])
    for i in d[True][1:]:
        dnew = set()
        for j in dpx:
            dnew.add(-i+j)
            dnew.add(i+j)
        dpx = dnew
    if x not in dpx:
        return False
    dpy = set()
    dpy.add(0)
    for i in d[False]:
        dnew = set()
        for j in dpy:
            dnew.add(-i+j)
            dnew.add(i+j)
        dpy = dnew
    if y not in dpy:
        return False
    return True
if main():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 46940
from sys import stdin
readlines = stdin.readlines


badge = ['AAA', 'AA', 'A', 'B', 'C', 'D', 'E', 'NA']
limit = {500: [
    35.50,
    37.50,
    40.00,
    43.00,
    50.00,
    55.00,
    70.00,
    float('inf')],
    1000: [
    71.00,
    77.00,
    83.00,
    89.00,
    105.00,
    116.00,
    148.00,
    float('inf')]}


def rank(time, limit):
    for i, l in enumerate(limit):
        if time < l:
            return i

for line in readlines():
    t500, t1000 = map(float, line.split())
    print(badge[max(rank(t500, limit[500]), rank(t1000, limit[1000]))])

Measured memory_bytes: 6748
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int r, c, n;
int __where(int x, int y){
    if(x == 0)  return 0;
    if(y == c)  return 1;
    if(x == r)  return 2;
    if(y == 0)  return 3;
    return -1;
}

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

    cin >> r >> c >> n;
    vector<vector<P>> hoge(4);
    for(int i = 0; i < n; ++i){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int foo = __where(x1, y1), bar = __where(x2, y2);
        if(foo == -1 || bar == -1)  continue;

        if(foo % 2 == 0)    hoge[foo].push_back(P(y1, i));
        else    hoge[foo].push_back(P(x1, i));

        if(bar % 2 == 0)    hoge[bar].push_back(P(y2, i));
        else    hoge[bar].push_back(P(x2, i));
    }
    sort(hoge[0].begin(), hoge[0].end());
    sort(hoge[1].begin(), hoge[1].end());
    sort(hoge[2].begin(), hoge[2].end(), greater<P>());
    sort(hoge[3].begin(), hoge[3].end(), greater<P>());

    stack<P> st;
    for(int i = 0; i < 4; ++i){
        for(int j = 0; j < hoge[i].size(); ++j){
            if(st.size() == 0)  st.push(hoge[i][j]);
            else{
                P p = st.top();
                if(hoge[i][j].second == p.second)   st.pop();
                else    st.push(hoge[i][j]);
            }
        }
    }
    if(st.size() == 0)  cout << "YES\n";
    else    cout << "NO\n";
}

Measured memory_bytes: 2644
/**
	Language: C++
	Author  : ebby21
**/

#include <bits/stdc++.h>

using namespace std;

#define FastIO() ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define Debug(v) cerr << '\n' << #v << ":\t" << v << '\n'
#define Loop(i, L, U) for (ll i = (L); i <= (U); ++i)
#define RLoop(i, U, L) for (ll i = (U); i >= (L); --i)
#define All(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;

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

	if (s[2] == s[3] && s[4] == s[5])	cout << "Yes\n";
	else cout << "No\n";


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

string week[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};


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

  string s;
  cin >> s;
  rep(i,7){
    if(s==week[i]){
      cout << 7-i << endl;
      return 0;
    }
  }
  
  return 0;
    

}


Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    A = []
    for i in range(N):
        input_raw = read_func().strip().split()
        A.append(long(input_raw[0]))

    s = 0
    count = 0
    for i in range(N):
        if A[i] != 0:
            s += A[i]
        else:
            count += s/2
            s = 0
    count += s/2

    print count



if __name__ == '__main__':
    main()


Measured memory_bytes: 10284
//use std::cmp::Reverse;

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,
        k: usize,
        h: [usize;n],
    }

    let mut h_tmp: Vec<usize> = Vec::with_capacity(n);
    for value in h {
        h_tmp.push(value);
    }

    h_tmp.sort();
    let mut h_tmp1: Vec<usize> = Vec::with_capacity(n);
    for i in 0..n {
        h_tmp1.push(h_tmp[n-1-i]);
    }   

    let mut ans = 0;
    for i in 0..n {
        if i+1 > k {
            ans += h_tmp1[i];
        }
    }

    println!("{}", ans);

}

Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    vector<vector<ll>> dp(n,vector<ll>(n));
    vector<ll> psum(n+1);
    rep(i,1,n+1) psum[i]=a[i-1]+psum[i-1];
    rep(len,0,n) {
        rep(l,0,n-len) {
            int r = l+len;
            if(len==0) dp[len][l] = 0;
            else {
                ll ans = LLONG_MAX;
                rep(rr,l,r) ans = min(ans, dp[rr-l][l]+dp[r-rr-1][rr+1]);
                ans += psum[r+1]-psum[l];
                dp[len][l] = ans;
            }
        }
    }
    cout << dp[n-1][0] << "\n";
}


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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

constexpr ll mod = 998244353;

ll pow(ll x, ll m)
{

    ll re = 1, y = 1;

    for (int i = 0; i < 60; ++i)
    {
        if (m & y)
            re = re * x % mod;
        x = x * x % mod;
        y *= 2;
    }

    return re;
}

ll inv(ll x)
{

    return pow(x, mod - 2);
}

class mint
{
    ll num = 0;

public:
    mint(ll x = 0) : num(x) {}

    mint operator+(const mint &rhs) const
    {
        return (num + rhs.num) % mod;
    }
    mint operator*(const mint &rhs) const
    {
        return num * rhs.num % mod;
    }
    mint operator-(const mint &rhs) const
    {
        return (num - rhs.num + mod) % mod;
    }
    mint operator/(const mint &rhs) const
    {
        return num * inv(rhs.num) % mod;
    }
    mint operator+=(const mint &rhs)
    {
        return *this = *this + rhs;
    }
    mint operator*=(const mint &rhs)
    {
        return *this = *this * rhs;
    }
    mint operator-=(const mint &rhs)
    {
        return *this - *this / rhs;
    }
    mint operator/=(const mint &rhs)
    {
        return *this = *this / rhs;
    }
    friend std::ostream &operator<<(std::ostream &os, const mint &rhs);
};

std::ostream &operator<<(std::ostream &os, const mint &rhs)
{

    os << rhs.num;

    return os;
}

constexpr int MAX = 2 * 1e5 + 5;

mint dp[MAX];

constexpr int INF = 2 * 1e9 + 1;

int next[MAX];

std::vector<int> xs;
std::vector<P> ps;

int n;

int dfs(int v)
{
    if (next[v] > 0)
        return next[v];

    int m = std::lower_bound(rag(xs), ps[v].first + ps[v].second) - std::begin(xs);

    int res = v + 1;

    for (int i = v + 1; i < m; ++i)
    {
        if (res == n)
            return next[v] = res;
        res = std::max(res, dfs(i));
    }

    return next[v] = res;
}

int main()
{

    std::cin >> n;

    ps.resize(n);
    xs.resize(n + 1);

    rep(i, n)
    {
        std::cin >>
            ps[i].first >> ps[i].second;
        xs[i] = ps[i].first;
    }
    xs[n] = INF;
    std::sort(rag(xs));
    std::sort(rag(ps));

    dp[n] = 1;

    for (int i = n - 1; i >= 0; --i)
    {
        dp[i] = dp[dfs(i)] + dp[i + 1];
        //std::cerr << dp[i] << std::endl;
    }

    std::cout << dp[0] << std::endl;

    return 0;
}

Measured memory_bytes: 8008
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;



ll K, N,uni,ans;
ll B[200001];
map<int, int> mp;
int main() {
	cin >> N >> K;
	FOR(i, 0, N) {
		int A;
		cin >> A;
		if (mp[A] == 0)uni++;
		mp[A]++;
	}
	int cnt = 0;
	FOR(i, 1, N+1) {
		if (mp[i] > 0) {
			B[cnt] = mp[i];
			cnt++;
		}
	}
	sort(B, B + cnt);
	cnt = 0;
	while (uni > K) {
		ans += B[cnt];
		uni--;
		cnt++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
using namespace std;
using ll = long long;
using vll = vector<ll>;

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

int main(){
	ll N;
	cin>>N;
	vll A(N);
	REP(i,N)cin>>A[i];
	VSORT(A);
	
	int T=0;
	REP(i,N-1){
		if(A[i]!=A[i+1]) T++;
	}
	
	if(T==N-1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
ll func(int l,int r,VV&dp, V&a,V&size){
    ll res=INFLL;
    ll sum=0LL;
  //  clog<<l<<" "<<r<<"   ";
    if(dp[l][r]==-1){
        if(l==r){
            dp[l][r]=0;
         
        }else if(l+1==r){
            dp[l][r]=size[r+1]-size[l];
            
        }else{
            for(int med=l;med<r;med++){
                chmin(res,func(l,med,dp,a,size)+func(med+1,r,dp,a,size)+size[r+1]-size[l]);
            }
            dp[l][r]=res;
        }
    }
   // clog<<" -->  "<<dp[l][r]<<endl;
    return dp[l][r];
}
int main(){
    int n;
    int ans=0;
    cin >>n;
    vector<ll>a(n+2,0LL);
    vector<ll> size(n + 2, 0LL);
    rep(i,n){
        cin>>a[i];
        if(i==0){
            size[i+1]=a[i];
        }else{
            size[i+1]=a[i]+size[i];
        }
    }
    VV dp(n+1,V(n+1,-1LL));
    /*
    dp [l][r]=mincost in start:l , stop:r
    init : -1
    transit : l+1== r -> dp[l][r]=a[l]+a[r];
            otherwise -> dp[l][r]=min(all of (mid) (l >=mid >r) (dp[l][at]+dp[at+1][r]) )
    */
   /*
    1 2 3  -> (1 2) 3, 1 (2 3)
    dp[1][3]= dp[1][2]+dp[3][3]=dp[1][1]+dp[2][3];
   */


    cout<<func(0,n-1,dp,a,size)<<endl;

 //   clog<<endl;

 //   rep(i,n){
 //       rep(j,n){
 //           clog<<dp[i][j]<<" ";
  //      }
  //      clog<<endl;
 //   }
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>
#include <stack>

using namespace std;

#define long long long
#define fi first
#define se second
typedef pair<int,int> ii;

int n;
vector<ii> ans;

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	scanf("%d", &n);

	int num = n;
	if(!(n&1)) num++;


	for(int i = 1; i <= n; i++)
	{
		for(int j = i+1; j <= n; j++)
		{
			if(i+j == num) continue;
			ans.push_back({i,j});
		}
	}
	printf("%lu\n", ans.size());
	for(auto i : ans) printf("%d %d\n", i.fi, i.se);
}










Measured memory_bytes: 384
n,m = map(int, input().split())
link = []
for i in range(m):
    tmp = list(map(int,input().split()))
    link.append([tmp[0]-1,tmp[1]-1,-tmp[2]])

def bell(edges, start,num_v):
    cost = [float('inf')] * num_v
    cost[start] = 0
    for _ in range(num_v):
        updated = False
        for a, b, c in edges:
            if cost[b] > cost[a] + c:
                cost[b] = cost[a] + c
                updated = True
        if not updated: break
    else:
        return -1,cost
    return 1,cost

ans1,d = bell(link,0,n)

if ans1 == -1:
    inf_flag = [False]*n
    for i in range(n):
        for f, t, c in link:
            if d[f] == float("inf"): continue
            if inf_flag[f] == True:
                inf_flag[t] = True
            if d[t] > d[f] + c:
                d[t] = d[f] + c
                inf_flag[t] = True
    print("inf" if inf_flag[n-1] else -d[n-1])
else:
    print(-d[-1])

Measured memory_bytes: 46808
#include<bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;

int n, q, siz;
long long ms[N], num[N], ans[N];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    ms[++siz] = n;
    for (int i = 1; i <= q; i++){
        long long x; cin >> x;
        while (siz && ms[siz] >= x) siz--;
        ms[++siz] = x; 
    }
    num[siz] = 1;
    for (int i = siz; i >= 1; i--){
        long long k = ms[i];
        while (k > ms[1]){
            int pos = lower_bound(ms+1, ms+1+siz, k) - ms - 1;
            num[pos] += num[i] * (k / ms[pos]);
            k %= ms[pos];
        }
        ans[k] += num[i];
    }
    for (int i = n; i >= 1; i--) ans[i] += ans[i+1];
    for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
}

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

const int N = 2020, inF = N;

int n, k, u, v, res, ans = inF;
vector<int> nei[N];

void dfs(int v, int par, int now, int maxi) {
	if(now > maxi)
		res++;
	for (int u: nei[v])
		if(u != par)
			dfs(u, v, now + 1, maxi);
}
			
void center(int v) {
	res = 0;
	dfs(v, v, 0, k >> 1);
	ans = min(ans, res);
}

void edge(int u, int v) {
	res = 0;
	dfs(u, v, 0, k >> 1);
	dfs(v, u, 0, k >> 1);
	ans = min(ans, res);
}
int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	
	cin >> n >> k;
	for (int i = 0; i < n - 1; i++) {
		cin >> u >> v;
		nei[--u].push_back(--v);
		nei[v].push_back(u);
	}
	
	if(k & 1)
		for (int v = 0; v < n; v++)
			for (int u: nei[v])
				edge(u, v);
	else
		for (int v = 0; v < n; v++)
			center(v);
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <climits>

#define INF INT_MAX / 2
#define REP(i, m, n) for(int i = m; i < static_cast<int>(n); ++i)
int main()
{
    int line_num, station_num;
    
    while (std::cin >> line_num >> station_num) {
        
        if (line_num == 0 && station_num == 0) break;

        int map[2][101][101];
        
        REP(i, 0, 2) REP(j, 0, 101) REP(k, 0, 101) map[i][j][k] = INF;
        
        REP(i, 0, line_num) {
            int a, b, cost, time;
            std::cin >> a >> b >> cost >> time;
            --a;
            --b;
            map[0][a][b] = map[0][b][a] = cost;
            map[1][a][b] = map[1][b][a] = time;
        }
        
        REP(k, 0, station_num) {
            REP(i, 0, station_num) {
                REP(j, 0, station_num) {
                    REP(l, 0, 2) {
                        map[l][i][j] = std::min(map[l][i][j], map[l][i][k] +
                                                map[l][k][j]);
                    }
                }
            }
        }

        int input_num;

        std::cin >> input_num;

        REP(i, 0, input_num) {
            int p, q, r;

            std::cin >> p >> q >> r;
            --p;
            --q;
            std::cout << map[r][p][q] << std::endl;
        }
    
    }
    return 0;
}

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

if n % 2 == 1:
  print('No')
else:
  m = int(n/2)
  s1 = s[: m]
  s2 = s[m: ]
  
  if s1 == s2:
    print('Yes')
  else:
    print('No')


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

int main(){
    int m,f,r,s;
    while (1){
        cin >> m >> f >> r ;
        s = m + f;
        if ( m == -1 && f == -1 && r == -1){
            break;
        } else if ( m == -1 || f == -1){
            cout << 'F' << endl;
        }else if ( s >= 80 ){
            cout << 'A' << endl;
        } else if ( 65 <= s && s < 80 ){
            cout << 'B' << endl;
        } else if ( 50 <= s && s < 65 ){
            cout << 'C' << endl;
        } else if ( 30 <= s && s < 50 ){
            if ( r >= 50 ){
                cout << 'C' << endl;
            } else {
                cout << 'D' << endl;
            }
        } else if ( s < 30 ){
            cout << 'F' << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let T: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    let M: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (P, X): (Vec<usize>, Vec<i64>) = {
        let (mut P, mut X) = (vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            P.push(iter.next().unwrap().parse().unwrap());
            X.push(iter.next().unwrap().parse().unwrap());
        }
        (P, X)
    };

    let ans = (0..M)
        .map(|i| (0..N).map(|j| if P[i] == j + 1 { X[i] } else { T[j] }).sum::<i64>().to_string())
        .collect::<Vec<_>>()
        .join("\n");

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cstdlib>

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

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while (1) {
        if (cur == nil) break;
        
        if (isf++ > 0) {
            printf(" ");
        }
        printf("%d",cur->key);
        cur = cur->next;
    }
    printf("\n");
}

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

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

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

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

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

int main(){
    
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0;i < n; i++) {
        scanf("%s%d", com,&key);
        if (com[0] == 'i') {
            insert(key);np++;size++;
        }else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6] == 'F')deleteFirst();
                else if(com[6] == 'L')deleteLast();
            }else{
                deleteKey(key);nd++;
            }
            size--;
            
        }
    }

    printList();
    
    return 0;
}

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

#define fi first
#define se second

const int N = 500;

using namespace std;

int n;
long long W;
long long a[N];
long long b[N];
long long d[N][N];

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

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n >> W;
        for(int i = 1; i <= n; i++){
                cin >> a[i] >> b[i];
        }
        long long inf = 1e18;
        for(int i = 0; i < N; i++){
                for(int j = 0; j < N; j++){
                        d[i][j] = -inf;
                }
        }
        d[0][0] = 0;
        for(int i = 1; i <= n; i++){
                long long x = a[i] - a[1];
                for(int j = n; j >= 0; j--){
                        for(int h = 0; h + x < N; h++){
                                d[j + 1][h + x] = max(d[j + 1][h + x], d[j][h] + b[i]);
                        }
                }
        }
        long long res = 0;
        for(int i = 1; i <= n; i++){
                for(int j = 0; j < N; j++){
                        if(j + a[1] * i <= W){
                                res = max(res, d[i][j]);
                        }
                }
        }
        cout << res << "\n";
}


Measured memory_bytes: 2176
N,K = map(int,input().split())
A = list(map(int,input().split()))

def s(n,a):
  b = [0]*n
  for i in range(n):
    l = max(0,i-a[i])
    r = min(n-1,i+a[i])
    b[l] += 1
    if r < n - 1:
      b[r+1] -= 1
  for i in range(n-1):
    b[i+1] += b[i]
  return b

for i in range(min(41,K)):
  A = s(N,A)
  
print(*A)
      


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

int main() {
  ll K,A,B;
  cin >> K >> A >> B;

  for(ll i=A ; i<=B; i++){
    if(i%K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define all(x) x.begin(), x.end()

int binpow(int a, int b)
{
    int ans = 1;
    if (b == 0)
        return 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int d, t, s;
        cin >> d >> t >> s;
        int req = d / s;
        int rem = d % s;
        if (rem == 0)
        {
            if (req <= t)
            {
                cout << "Yes"
                     << "\n";
            }
            else
            {
                cout << "No"
                     << "\n";
            }
        }
        else
        {
            if (req < t)
            {
                cout << "Yes"
                     << "\n";
            }
            else
            {
                cout << "No"
                     << "\n";
            }
        }
    }
}


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

int main() {
  int n;
  while (cin >> n && n) {
    int dp[40];
    for (int i = 0; i < 40; i++) {
      dp[i] = 0;
    }
    dp[0] = 1;
    for (int i = 0; i <= n; i++) {
      dp[i+3] += dp[i];
      dp[i+2] += dp[i];
      dp[i+1] += dp[i];
    }
    cout << (dp[n] + 3649) / 3650 << endl;
  }
}

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

const int maxn = 5009;
bitset<maxn> x;
int a[maxn], n, K;
int l, r, mid;

inline int read(){
	char ch = getchar(); int x = 0;
	while (ch < '0' || '9' < ch) ch = getchar();
	while ('0' <= ch && ch <= '9') { x = x*10+ch-'0'; ch = getchar(); }
	return x;
}

bool check(int k){
	x.reset(); x[0] = 1;
	for (int i=1; i<=n; i++)
		if (i != k) x = x | (x << a[i]);
	for (int i=max(0, K-a[k]); i<=K-1; i++)
		if (x[i]) return false;
	return true;
}

int main(){
	n = read(); K = read();
	for (int i=1; i<=n; i++) a[i] = read();
	sort(a+1, a+n+1);
	l = 0; r = n;
	while (l < r){
		mid = (l + r + 1) >> 1;
		if (check(mid)) l = mid;
		else r = mid-1;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<stdio.h>
//using namespace std;
//scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
//printf("Yes\n");
int main() {
  int a;
  int i = 1;
  while(1){
    
    scanf("%d",&a);
    if (a == 0) break;
     if(a != 0){
      printf("Case %d: %d\n",i,a);
      i = i+1;
     }
  }

  return 0;
}


Measured memory_bytes: 2680
// #pragma GCC optimize "trapv" Uncomment when dealing with huge numbers
/*<----------PBDS---------->

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template <typename T>
using order_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

order_set<datatype>oset;
Kth smallest : *oset.find_by_order(k-1); // 0 based index
No of elements less than k : oset.order_of_key(k);
Erase X : oset.erase(x)
<----------PBDS---------->*/
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int dp[3001][3001];
int32_t main()
{
    fast;
  	int h,w;
	cin >> h >> w;
	dp[0][0] = 0;
	int arr[h][w];
	char x;
	for(int i = 0 ; i < h ; i++ ){
		for(int j = 0 ; j < w ; j++ ){
			cin >> x;
			if(x=='#'){
				arr[i][j] = 1;
			}
			else{
				arr[i][j] = 0;
			}
		}
	}
	bool ok = false;
	for(int i = 0 ; i < w ; i++ ){
		if(arr[0][i]==1){
			dp[0][i] = -1;
			ok = true;
		}
		if(!ok)
		dp[0][i] = 1;
		else
		dp[0][i] = -1;
	}
	ok = false;
	for(int i = 0 ; i < h ; i++ ){
		if(arr[i][0]==1){
			dp[i][0] = -1;
			ok = true;
		}
		if(!ok)
		dp[i][0] = 1;
		else
		dp[i][0] = -1;
	}
	for(int i = 1 ; i < h ; i++ ){
		for(int j = 1 ; j < w ; j++ ){
			if(arr[i][j]==0 && dp[i][j]!=-1){
				if(arr[i-1][j]==0 && arr[i][j-1]==0 && dp[i-1][j]>0 && dp[i][j-1]>0){
					dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
				}
				else if(dp[i][j-1]==-1 && dp[i-1][j]==-1){
					dp[i][j]=-1;
				}
				else{
					dp[i][j] = max(dp[i][j-1],dp[i-1][j])%mod;
				}
			}
			else{
				dp[i][j] = -1;
			}
		}
	}
	cout << max(0LL,dp[h-1][w-1]);
}






Measured memory_bytes: 31616
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (A, B, C) = Read3Longs();
            if (A == B) return C;
            if (B == C) return A;
            if (A == C) return B;
            return null;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int[] x = new int[n];

		for(int i = 0; i < n; i++){
			x[i] = sc.nextInt();
		}

		long result = 0;

		for(int i = 1; i < n; i++){
			if((long)a*(x[i] - x[i - 1]) > b){
				result += b;
			}
			else {
				result += a*(x[i] - x[i - 1]);
			}
		}


		System.out.println(result);
	}

}


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

#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  map<int, int> cnt;
  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    int a;
    cin >> a;
    ans += a;
    cnt[a]++;
  }

  int Q;
  cin >> Q;
  while ( Q-- ) {
    int b, c;
    cin >> b >> c;;
    ans += c * cnt[b];
    ans -= b * cnt[b];
    cout << ans << endl;
    cnt[c] += cnt[b];
    cnt[b] = 0;
  }
  
  return 0;
}


Measured memory_bytes: 9400
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr int INF = 1 << 30;
constexpr int MOD = 1e9 + 7;

vector<pair<char, long>> RLE(string s) {
  vector<pair<char, long>> ret;
  for(int i = 0; i < (int)s.size();) {
    long cnt = 0;
    while(s[i] == s[i+cnt]) ++cnt;
    ret.emplace_back(s[i], cnt);
    i += cnt;
  }
  return ret;
}

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

  long n, k; cin >> n >> k;
  long k2 = k;
  string s; cin >> s;
  auto t = RLE(s);
  for(int i = 1; i < t.size(); ++i) {
    if(t[i].first == 'R') {
      t[i].first = 'L';
      --k;
    }
    if(k == 0) break;
  }
  if(k > 0) t[0].first = 'L';

  long ans = 0;
  // score L
  for(int i = 0; i < t.size(); ++i) {
    if(t[i].first == 'L' ){
      if(i == 0) ans += t[i].second - 1;
      else if(t[i-1].first == t[i].first) ans += t[i].second;
      else ans += t[i].second - 1;
    }
  }

  for(int i = 0; i < t.size(); ++i) {
    if(t[i].first == 'R') {
      if(i == t.size() - 1) ans += t[i].second - 1;
      else if(t[i].first == t[i+1].first) ans += t[i].second;
      else ans += t[i].second - 1;
    }
  }

  t = RLE(s);
  for(int i = 1; i < t.size(); ++i) {
    if(t[i].first == 'L') {
      t[i].first = 'R';
      --k2;
    }
    if(k2 == 0) break;
  }
  if(k2 > 0) t[0].first = 'R';

  long tmp = ans;
  ans = 0;
  // score L
  for(int i = 0; i < t.size(); ++i) {
    if(t[i].first == 'L' ){
      if(i == 0) ans += t[i].second - 1;
      else if(t[i-1].first == t[i].first) ans += t[i].second;
      else ans += t[i].second - 1;
    }
  }

  for(int i = 0; i < t.size(); ++i) {
    if(t[i].first == 'R') {
      if(i == t.size() - 1) ans += t[i].second - 1;
      else if(t[i].first == t[i+1].first) ans += t[i].second;
      else ans += t[i].second - 1;
    }
  }

  ans = max(ans, tmp);

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

Measured memory_bytes: 5056
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;



int main() {

	int n;
	cin >> n;

	string s;
	int cnt[51][26] = {};
	char c;
	int idx;
	for (int i = 0; i < n; i++) {
		cin >> s;
		for (int j = 0; j < s.length(); j++) {
			c = s[j];
			idx = c - 'a';
			cnt[i][idx]++;
		}

	}

	int mincnt;
	for (int i = 0; i < 26; i++) {
		mincnt = 100;
		for (int j = 0; j < n; j++) {
			mincnt = min(mincnt, cnt[j][i]);
		}
		cnt[0][i] = mincnt;
	}


	string ans = "";
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < cnt[0][i]; j++) {
			ans += char(i + 'a');
		}
	}

	cout << ans << endl;



	return 0;
}

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

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

  bool ok = true;
  int curT,curX,curY,nextT,nextX,nextY;
  nextT = nextX = nextY = 0;

  for (int i = 0; i < N; ++i) {
    curT = nextT;
    curX = nextX;
    curY = nextY;
    cin >> nextT >> nextX >> nextY;

    if (abs(nextX-curX) + abs(nextY-curY) > nextT-curT ||
        (curX + curY + nextX + nextY) % 2 != (nextT - curT) % 2) {
      ok = false;
    }
    if (!ok) break;
  }

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

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		if(e-a <= k) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
	}

}

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 19
#define mod 1000000007

int modpow(int x, int y)
{
  int z = 1;
  while (y)
  {
    if (y & 1)
      z = (z * x) % mod;
    x = (x * x) % mod;
    y >>= 1;
  }
  return z;
}
int inverse(int x)
{
  return modpow(x, mod - 2);
}
int divide(int x, int y)
{
  return (x * inverse(y)) % mod;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> v(n);
  int acc = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
    acc = (acc + v[i]) % mod;
  }
  acc = (acc * acc) % mod;
  int ans = 0;
  for (int i = 0; i < n; i++)
    ans = (ans + (v[i] * v[i])) % mod;
  cout << divide((acc - ans + mod) % mod, 2) << endl;
  return 0;
}


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

int gcd(int x,int y){

  if(y > x)
    swap(x,y);

  while(y > 0){
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main(){
  int x,y;
  cin>>x>>y;

  cout<<gcd(x,y)<<endl;

  return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>
 
using namespace std;
  
/********** TEMPLATE STARTS HERE ***********/
    
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) (int)v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define gcd __gcd 
#define mp make_pair
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);
#define digits(n) (int)(log10(n) + 1)
  
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pii> vii;
typedef vector <pll> vll;
    
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
    
template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
   
/*********** TEMPLATE ENDS HERE *************/


main()
{
	IOS
	
	int n, c;
	int cost = INF;
	
	cin >> n >> c;
	
	while(n--)
	{
		int x, y;
		cin >> x >> y;
		if(y <= c)
			amin(cost, x);
	}
	
	if(cost == INF)
		cout << "TLE";
	else
		cout << cost;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] n = sc.next().toCharArray();
        int count = 0;
        int ans = 0;
        for (int i = 0; i < n.length - 1; i++) {
            if(n[i] == n[i + 1]) {
                count++;
                if(ans < count) {
                    ans = count;
                }
            } else {
                count = 0;
            }
        }
        if(ans >= 2) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
ll mod=1e9+7;
using P=pair<int,int>;
struct op{int a,b,c,d;};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;cin>>h>>w;
    vector<vector<int>> a(h,vector<int>(w));
    vector<op> ans;
    int tot=0;
    rep(i,h)rep(j,w)cin>>a[i][j];
    rep(i,h){
        if(i){
            for(int j=w-1;j>=0;j--){
                if(i==h-1 && j==0)break;
                if(j!=0 && a[i][j]%2!=0){
                    a[i][j-1]++;
                    tot++;
                    ans.push_back({i,j,i,j-1});
                }
                else if(j==0 && a[i][j]%2!=0){
                    a[i+1][j]++;
                    tot++;
                    ans.push_back({i,j,i+1,j});
                }
            }
        }
        else {
            for(int j=0;j<w;j++){
                if(i==h-1 && j==w-1)break;
                if(j!=w-1 && a[i][j]%2!=0){
                    a[i][j+1]++;
                    tot++;
                    ans.push_back({i,j,i,j+1});
                }
                else if(j==w-1 && a[i][j]%2!=0){
                    a[i+1][j]++;
                    tot++;
                    ans.push_back({i,j,i+1,j});
                }
            }
        }
    }
    cout<<tot<<endl;
    rep(i,ans.size())cout<<ans[i].a+1<<' '<<ans[i].b+1<<' '<<ans[i].c+1<<' '<<ans[i].d+1<<endl;
    return 0;
}


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


int main()
{
	int D, G, p[11], c[11];
	cin >> D >> G;
	for (int i = 0; i < D; ++i)
		cin >> p[i] >> c[i];
	int ans = 1e9;	
	for (int mask = 0; mask < 1 << D; ++mask)
	{
		int sum = 0, num = 0;
		for (int i = 0; i < D; ++i)
		{
			if (mask & 1 << i)
			{
				sum += (i + 1) * 100 * p[i] + c[i];
				num += p[i];
			}
		}
		if (sum >= G)
		{
			ans = min(ans, num);
		}
		else
		{
			for (int i = D - 1; i >= 0; --i)
			{
				if (mask & 1 << i)
				{
					continue;
				}
				for (int j = 0; j < p[i]; j++)
				{
					if (sum >= G)
					{
						break;
					}
					sum += 100 * (i + 1);
					num++;
				}
			}
			ans = min(ans, num);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
  int W, a, b, rel=0; cin >> W >> a >> b;
  rel = max(a,b) - (min(a,b) + W);
  if(rel < 0) rel = 0;
  cout << rel << endl;
}


Measured memory_bytes: 256
#n,y=tuple(map(int,input().split(' ')))
#N=int(input())
#x=list(map(int,input().split(' ')))

S=input()

be=S[0]

for e in list(S[1:]):
    if e==be:
        print("Bad")
        exit()
    be=e

print("Good")



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int arr[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	scanf("%d",&arr[i]);
	sort(arr,arr+n);
	if (arr[n-1]>arr[0]+1)
	printf("No");
	else if (arr[n-1]==arr[0])
	printf((arr[0]==n-1 || arr[0]<=n/2)? "Yes":"No");
	else
	{
		int tmp=0;
		while (arr[0]==arr[tmp])
		tmp++;
		printf((tmp<=arr[0] && arr[n-1]<=tmp+(n-tmp)/2)? "Yes":"No");
	}
}

Measured memory_bytes: 640
K, T = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
# print('A', A)

for i in range(len(A)):
    for j in range(i + 1, len(A)):
        if A[i] == 0:
            break
        v = min(A[i], A[j])
        A[i] -= v
        A[j] -= v

cnt = 0
for i in range(len(A)):
    if A[i] >= 1:
        cnt += 1
print(max(A) - cnt)


Measured memory_bytes: 3064