akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;
 
int main(){
    int n;cin>>n;
    vin a(n),b(n);rep(i,n)cin>>a[i]>>b[i];
    sort(all(a));
    sort(all(b),greater<int>());
    int ans;
    if(n%2){
        int k=(n+1)/2;
        ans=b[k-1]-a[k-1]+1;
    }
    else{
        int k=n/2;
        double m=a[k-1]+a[k];
        double M=b[k-1]+b[k];
        double tmp=M-m+1;
        ans=tmp;
    }
    cout<<ans<<endl;
}

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

int main(){
    long long x,k,d;cin>>x>>k>>d;
    x=abs(x);
    if (k<x/d){
        cout<<x-k*d<<endl;
    }
    else{
        long long tmp_x=x;
        x=x-d*(x/d);
        k=k-(tmp_x/d);
        if(k&1){
            cout<<abs(x-d)<<endl;
        }
        else{
            cout<<x<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>

using namespace std;

int p,q,a,n;

int func(int turn,int last,int product,int c,int d){
  if(p*d==c*q)return 1;
  if(!turn)return 0;
  
  int count=0;
  for(int i=last;product*i<=a;i++){
    if(c/d+1/i<=p/q)
      count+=func(turn-1,i,product*i,i*c+d,i*d);
  }  
  return count;
}

int main(void){
  
  while(cin >> p >> q >> a >> n,p|q|a|n){
    cout << func(n,1,1,0,1) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
import math
N,D = map(int,input().split())
X_ = [0] * N
X = [0]*N
for i in range(N):
    X_[i] = input().split()
for i in range(len(X_)):
    X[i] = [int(j) for j in X_[i]]
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        l2 = 0
        for k in range(D):
            l2 += (X[i][k]-X[j][k])**2 #i番目の点とj番目の点の距離の二乗
        if math.sqrt(l2) == int(math.sqrt(l2)):
            cnt += 1
            
print(cnt)

Measured memory_bytes: 38384
dice = list(map(int, input().split()))
q = int(input())

anslist = []

for _ in range(q):
    up, front = map(int, input().split())
    if up == dice[1]:
        slist = "N"
    elif up == dice[2]:
        slist = "W"
    elif up == dice[3]:
        slist = "E"
    elif up == dice[4]:
        slist = "S"
    elif up == dice[5]:
        slist = "NN"
    else:
        slist = ""

    for s in slist:
        if s == "N":
            next = list("263415")
        elif s == "E":
            next = list("421653")
        elif s == "S":
            next = list("513462")
        else:
            next = list("326154")

        tmp = [0] * 6
        for i, n in enumerate(next):
            tmp[i] = dice[int(n)-1]

        dice = tmp

    if front == dice[1]:
        ans = dice[2]
    elif front == dice[2]:
        ans = dice[4]
    elif front == dice[3]:
        ans = dice[1]
    elif front == dice[4]:
        ans = dice[3]

    anslist.append(ans)

for ans in anslist:
    print(ans)



Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
using namespace std;


int main(){
    int n,a; cin >> n >> a;
    vector<int> v(n); for(int i=0;i<n;i++){cin >> v[i]; v[i] -= a;}
    vector<long long int> plus(3000), minus(3000),sub(3000);
    sort(v.begin(),v.end());
    long long int num_zero = upper_bound(v.begin(),v.end(), 0) - lower_bound(v.begin(),v.end(), 0);
    vector<long long int> pv,mv;
    for(int i=0;i<n;i++){
        if(v[i] < 0) mv.push_back(-v[i]);
        else if(v[i] > 0) pv.push_back(v[i]);
    }
    plus[0] = 1; minus[0] = 1;
    for(int i=0;i<mv.size(); i++){
        for(int j=0;j<2600;j++) sub[j] = minus[j];
        for(int j=0;j<2600;j++) minus[j+mv[i]] += sub[j];
    }
    for(int i=0;i<pv.size(); i++){
        for(int j=0;j<2600;j++) sub[j] = plus[j];
        for(int j=0;j<2600;j++) plus[j+pv[i]] += sub[j];
    }
    long long int ans = 0;
    for(int i=0;i<2501;i++) ans = ans + (plus[i] * minus[i]);
    //cout << ans << "," << num_zero << endl;
    long long o = 1;
    ans = (ans - 1) * (o<<num_zero) + (o<<num_zero) - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(r,e){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,l=r[Symbol.iterator]();!(n=(i=l.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==l.return||l.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=r.split("\n"),n=t(e[0].split(" ").map(function(r){return Number(r)}),2),o=n[0],u=n[1],i=new Array(o),l=0;l<o-1;l++){var a=t(e[l+1].split(" ").map(function(r){return Number(r)-1}),2),f=a[0],c=a[1];i[f]||(i[f]=[]),i[c]||(i[c]=[]),i[f].push(c),i[c].push(f)}for(var p=new Array(o).fill(0),y=0;y<u;y++){var s=t(e[y+o].split(" ").map(function(r){return Number(r)}),2),d=s[0],v=s[1];p[d-1]+=v}for(var b=[0],m=new Array(o).fill(0);b.length>0;){var h=b.pop();m[h]=1;var x=!0,g=!1,j=void 0;try{for(var w,S=i[h][Symbol.iterator]();!(x=(w=S.next()).done);x=!0){var O=w.value;1!=m[O]&&(p[O]+=p[h],b.push(O))}}catch(r){g=!0,j=r}finally{try{x||null==S.return||S.return()}finally{if(g)throw j}}}console.log(p.join(" "))}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 126072
#include<iostream>
#include<algorithm>
#include<vector>
#include<iterator>
using namespace std;

long long nibutan(vector<long long>& in, long long comp)
{
    /*if(in[0] >= comp){
        return -1;
    }
    long long ok = 0;
    long long ng = in.size();
    while(ng - ok != 1){
        long long mid = (ok + ng) / 2;
        if(in[mid] < comp){
            ok = mid;
        } else {
            ng = mid;
        }
    }*/
    //cout << comp << " " <<  distance(in.begin(), lower_bound(in.begin(), in.end(), comp)) << endl;
    return distance(in.begin(), lower_bound(in.begin(), in.end(), comp));
}

int main()
{
    int n;
    vector<long long> a;
    vector<long long> b;
    vector<long long> c;
    cin >> n;
    for(int i = 0; i < n;  i++){
        int in;
        cin >> in;
        a.push_back(in);
    }
    for(int i = 0; i < n;  i++){
        int in;
        cin >> in;
        b.push_back(in);
    }
    for(int i = 0; i < n;  i++){
        int in;
        cin >> in;
        c.push_back(in);
    }
    //cout << "start" << endl;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    long long capacityB[100010];
    for(int i = 0; i < n; i++){
        capacityB[i] = nibutan(a, b[i]);
    }
    long long capacitySumB[100010];
    capacitySumB[0] = capacityB[0];
    for(int i = 1; i < n; i++){
        capacitySumB[i] = capacitySumB[i - 1] + capacityB[i];
    }
    long long capacityC[100010];
    for(int i = 0; i < n; i++){
        int l = nibutan(b, c[i]);
        if(l == 0){
            capacityC[i] = 0;
        } else {
            capacityC[i] = capacitySumB[l - 1];
        }
    }
    long long answer = 0;
    for(int i = 0; i < n; i++){
        answer += capacityC[i];
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 5364
N,K = map(int,input().split())
p = list(map(int,input().split()))
l = []
maxe = 0
e = 0
for i in range(N):
    l.append((p[i]+1)/2)

for i in range(K-1):
    e += l[i]

for i in range(K-1,N):
    e += l[i]
    if (maxe < e):
        maxe = e
    e -= l[i-K+1]

print(maxe)

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

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    long long all = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i]; all += a[i];
    }
    long long ans = all;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        ans = min(ans, abs(all-sum*2));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {

    static Scanner sc;
    static final int k = 10001;
    static int n = 0;
    static int[] counter = new int[k+1];
    static int[] input, output;

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

        n = sc.nextInt();
        input = new int[n+1];
        output = new int[n+1];
        for(int i = 0; i < n; i++) {
            input[i+1] = sc.nextInt();
            counter[input[i+1]]++;
        }

        CountingSort();
        StringBuilder builder = new StringBuilder();
		for (int i = 1; i < n; i++) {
			builder.append(output[i] + " ");
        }
		System.out.println(builder.append(output[n]));
    }

    static public void CountingSort() {
        for(int i = 1; i <= k; i++) {
            counter[i] += counter[i-1];
        }

        for(int j = 1; j <= n; j++) {
            output[counter[input[j]]] = input[j];
            counter[input[j]]--;
        }
    }
}



Measured memory_bytes: 587404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

ll pow2(ll a, ll b){
  if(b == 0){
    return 1;
  }
  if(b % 2 == 0){
    ll x = pow2(a, b/2);
    return (x * x) % 2019;
  }
  else{
    ll x = pow2(a, b/2);
    return (x * x * a) % 2019;
  }
}

int main(){
  string S;
  cin >> S;
  vector<ll> r(sz(S)+1, 0);
  rep(i, sz(S)){
    r.at(i+1) = ((S.at(sz(S)-i-1)-'0')*pow2(10, i)+ r.at(i)) % 2019;
  }
  vector<ll> c(2019);
  rep(i, sz(S)+1){
    c.at(r.at(i))++;
  }
  ll ans = 0;
  rep(i, 2019){
    ans += c.at(i)*(c.at(i)-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,s=0,p,c=0;
  cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++)cin>>x.at(i);
  for(int i=0;i<n;i++)s+=x.at(i);
  p=(s+n/2)/n;
  for(int i=0;i<n;i++)c+=(x.at(i)-p)*(x.at(i)-p);
  cout<<c<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

ll H[100001];
ll dp[100001];//i番目まで見たときの右にいける回数
int main(){
    int N;
    cin >> N ;
    rep(i,N)cin >> H[i];
    ll maxt = 0;
    dp[N-1] = 0;
    for(int i=N-1;i>0;i--){
        if(H[i]<=H[i-1]){
            dp[i-1] = dp[i]+1;
        }else dp[i-1] = 0;
        maxt = max(maxt,dp[i-1]);
    }
    //rep(i,N)cout << dp[i] << endl;
    cout << maxt << endl;
    
    return 0;

}

Measured memory_bytes: 1920
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i+j*j+k*k+i*j+j*k+k*i;
            if v<10050:
                ans[v]+=1
for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 9156
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String[] token = br.readLine().split(" ");
			int h = Integer.parseInt(token[0]);
			int w = Integer.parseInt(token[1]);

			if(h == 0 && w == 0){
				break;
			}

			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(i % 2 == 0){
						if(j % 2 == 0){
							sb.append("#");
						}else{
							sb.append(".");
						}
					}else{
						if(j % 2 == 0){
							sb.append(".");
						}else{
							sb.append("#");
						}
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}

		System.out.print(sb);

	}
}

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

int main() {
  int A, B; cin >> A >> B;
  if (A > B) swap(A, B);
  rep(i, B) {
    cout << A;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define pb push_back
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x),ri(y)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define ms2(obj,val,sz) memset(obj,val,sizeof(obj[0])*sz)
#define FOR(i,f,t) for(int i=f;i<(int)t;i++)
#define FORR(i,f,t) for(int i=f;i>(int)t;i--)

typedef long long ll;
typedef vector<int> vi;

const int MAXN=0;

int N,K;
ll ans=0;

int main() {
	rii(N,K);
	FOR(b,K+1,N+1) ans += 1ll*(N/b)*(b-K) + max((N%b)-K+(K!=0),0);
	printf("%lld\n",ans);
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  string s;
  int w;
  cin>>s>>w;
  for(int i(0);i<int(s.size());i++){
    if(i%w==0) cout << s[i];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3540
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        long MOD = (long) 1e9 + 7;
        int n = sc.nextInt();
        long[] arr = new long[n];
        long[] acc = new long[n + 1];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextLong();
            acc[i + 1] = acc[i] + arr[i];
        }

        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans = (ans + ((acc[n] - acc[i + 1]) % MOD) * arr[i] % MOD) % MOD;
        }

        System.out.println(ans);

        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 62128
use std::io::*;
const MOD: usize = 1_000_000_007;

fn pow(mut x: usize, mut e: usize) -> usize {
    let mut res = 1;
    while e > 0 {
        if e & 1 == 1 {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        e >>= 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();

    let mut table: Vec<usize> = vec![0; 100010];
    for i in 1..k + 1 {
        table[i] = pow(k / i, n);
    }

    for i in (1..k).rev() {
        let mut j = i * 2;
        while j <= k {
            table[i] = (table[i] + MOD - table[j]) % MOD;
            j += i;
        }
    }

    let mut ans = 0;
    for i in 1..k + 1 {
        ans = (ans + table[i] * i % MOD) % MOD;
    }
    println!("{}", ans);
}


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

using ll = long long;

ll x;
int main(){
  cin>>x;
  ll ans=0;
  ll a=x/11;
  ll b=x%11;

  if(b>6)ans+=2;
  else if(0<b && b<=6)ans++;

  cout<<ans+a*2<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
int main()
{
    char s[100];
    int i,l;
    scanf("%s",s);
    l=strlen(s);
    for(i=0;i<l;i++){
        if(i%2==0){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D'){
            }
            else{
                break;
            }
        }
        else{
        	if(s[i]=='L'||s[i]=='U'||s[i]=='D'){
            }
            else{
                break;
            }
        }
    }
    if(i==l){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
/**
*    created: 05.07.2020 21:05:49
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int h, w, check;
    cin >> h >> w >> check;
    char mp[h][w];
    rep(i,h) rep(j,w) cin >> mp[i][j];
    int ans = 0;
    // bit1 : h
    // bit2 : w
    for (int bit1 = 0; bit1 < (1 << h); bit1++) {
        for (int bit2 = 0; bit2 < (1 << w); bit2++) {
            int tmp = 0;
            rep(i,h) rep(j,w) {
                if ((bit1 >> i) & 1) continue;
                else if ((bit2 >> j) & 1) continue;
                else if (mp[i][j] == '#') tmp++;
            }
            if (tmp == check) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int r;
  cin>>r;
  cout<<r*r<<endl;
}


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

using namespace std;

const string K{"keyence"};

int main() {
  string S;
  cin >> S;
  bool cond = false;
  for (size_t i = 0; i != K.size(); ++i) {
    if (equal(begin(S), begin(S) + i, begin(K)) &&
        equal(rbegin(S), rbegin(S) + K.size() - i, rbegin(K))) {
      cond = true;
      break;
    }
  }
  cout << (cond ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define FOR(variable,a,b) for(variable=(a);variable<(b);variable++)

int main() {
    int a;
    int b;
    
    while (scanf("%d %d", &a, &b) != EOF) {
        printf("%d\n", (int)log10(a + b) + 1);
    }
    
    return 0;
}

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

int main() {
  char in[120];
  pair<pair<string,int>,int> p[110];
  int a;scanf("%d",&a);
  for(int i=0;i<a;i++){
    int t;scanf("%s%d",in,&t);
    string tmp=in;
    p[i]=make_pair(make_pair(in,-t),i);
  }
  sort(p,p+a);
  for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);
}

Measured memory_bytes: 256
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
	int n=read();
	n=n%10;
	if(n==3) cout<<"bon"<<endl;
	else if(n==0 || n==1 || n==6 || n==8) cout<<"pon"<<endl;
	else cout<<"hon"<<endl;
	return 0;
}


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

int main(){
  int n,a,g;
  cin >> n >> a;
  
  g = n % 500;
  
  if(g <= a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
    
  }
}

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

const int nmax = 2e5;
const int mod = 1e9 + 7;

int main () {
  int n, a[nmax+1], s[nmax+1], ans = 0;
  cin >> n;
  s[0] = 0;
  for (int i=1; i<=n; ++i) {
    cin >> a[i];
    s[i] = (s[i-1] + a[i]) % mod;
  }
  for (int i=1; i<=n; ++i) {
    int sum = s[n] - s[i] < 0 ? s[n] - s[i] + mod : s[n] - s[i];
    int to_add = ((long long)a[i] * (long long)sum) % (long long)mod;
    ans = (ans + to_add) % mod;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 5136
#include<bits/stdc++.h>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

using namespace std;

int main(void){
  char c; cin>>c;
  cout << (c=='A'?'T':c=='T'?'A':c=='G'?'C':c=='C'?'G':'e') << endl;
  return 0;
}



Measured memory_bytes: 256
/*お店で 
N
 円の商品を買います。

1000
 円札のみを使って支払いを行う時、お釣りはいくらになりますか？

ただし、必要最小限の枚数の 
1000
 円札で支払いを行うものとします。*/
#include <bits/stdc++.h>
using namespace std;

int main(){
  int a;
  
  //変数aで入力を受け取る
  cin >> a;
  a=a%1000;
  if (a==0) {
    a=1000;
  }
  a=1000-a;
  cout <<a;
}


Measured memory_bytes: 3536
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();


		int h = S/3600;
		int h2 = S%3600;
		int m = h2/60;
		int s = h2%60;

		System.out.println(h + ":" + m + ":" + s);
 	}
}



Measured memory_bytes: 26252
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <cstdio>

using namespace std;
#define prev prev55

long long n, a[500], ss;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    long long fh = 1e18;
    for (int i = 0; i < n; i++) cin >> a[i], ss += a[i];
    for (long long op = ss; op >= 0 && op >= ss - n * n; op--)
    {
        long long cnt = 0;
        for (int i = 0; i < n; i++)
        {
            // 0 <= a[i] - x * (n + 1) + op < n
            long long x = (a[i] + op) / (n + 1);
            cnt += x;
            //cout << op << " " << x << endl;
            if (a[i] + op - ((a[i] + op) / (n + 1)) * (n + 1) == n)
            {
                cnt = 1e18;
            }
            //cout << a[i] + op - ((a[i] + op) / (n + 1)) * (n + 1) << endl;
        }
        if (cnt == op)
        {
            fh = op;
            //return 0;
        }
    }
    cout << fh;
}


Measured memory_bytes: 256
#include <stdio.h>

void printClass( double weight )
{
        if ( weight <= 48.00 )
                fprintf( stdout, "light fly\n" );
        else if ( weight > 48.00 && weight <= 51.00 )
                fprintf( stdout, "fly\n" );
        else if ( weight > 51.00 && weight <= 54.00 )
                fprintf( stdout, "bantam\n" );
        else if ( weight > 54.00 && weight <= 57.00 )
                fprintf( stdout, "feather\n" );
        else if ( weight > 57.00 && weight <= 60.00 )
                fprintf( stdout, "light\n" );
        else if ( weight > 60.00 && weight <= 64.00 )
                fprintf( stdout, "light welter\n" );
        else if ( weight > 64.00 && weight <= 69.00 )
                fprintf( stdout, "welter\n" );
        else if ( weight > 69.00 && weight <= 75.00 )
                fprintf( stdout, "light middle\n" );
        else if ( weight > 75.00 && weight <= 81.00 )
                fprintf( stdout, "middle\n" );
        else if ( weight > 81.00 && weight <= 91.00 )
                fprintf( stdout, "light heavy\n" );
        else if ( weight > 91.00 )
                fprintf( stdout, "heavy\n" );

        return;
}

int main( void )
{
        double weight;
        int i;

        while( scanf( "%lf", &weight ) != EOF ) {
                if ( weight >= 40 && weight <= 150 ) {
                        printClass( weight );
                } else {
                        break;
                }
        }
        return 0;
}



Measured memory_bytes: 2048
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

char ope(int i) {
  if (i == 0) {
    return '+';
  } else {
    return '-';
  }
}

int main() {
  string str;
  int a, b, c, d;
  cin >> str;
  a = str[0] - '0';
  b = str[1] - '0';
  c = str[2] - '0';
  d = str[3] - '0';

  for (int bit = 0; bit < (1 << 3); bit++) {
    int sum = a;
    for (int i = 0; i < 3; i++) {
      if (bit & 1 << i) {
        sum = sum - (str[i + 1] - '0');
      } else {
        sum = sum + (str[i + 1] - '0');
      }
    }
    if (sum == 7) {
      cout << a << ope(bit & 1 << 0) << b << ope(bit & 1 << 1) << c
           << ope(bit & 1 << 2) << d << "=7" << endl;
      return 0;
    }
  }

  return 0;
}


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

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


int main(int argc, char**argv){
    int n, k;
    cin >> n >> k;
    if (k != 1){
        cout << n - k << endl;
    }else{
        cout << 0 << endl;
    }



    return 0;
}





















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

int main() {
  int n; 
  cin >> n;
  vector<int> a(n);
  multiset<int> m;
  vector<int> c(n);
  
  rep(i,n){
    cin >> a[i];
    a[i]--;
    m.insert(a[i]);
  }
  
  ll kumi = 0;
  rep(i,n){
    ll x = m.count(i);
    c[i] = x;
    kumi += x * (x - 1) / 2;
  }
  
  rep(k,n){
    cout << kumi - c[a[k]] + 1 << endl;
  }
} 



Measured memory_bytes: 13568
#include <iostream>

int main()
{
	int day, testNum;
  	std::cin >> day >> testNum;
  	for(int i = testNum; i > 0; --i)
    {
      int testDay;
      std::cin >> testDay;
      day -= testDay;
    }
  
  	std::cout << (day >= 0? day : -1) << std::endl;
            
	return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
def bubble(a):
    card = a[:]
    size = len(card)
    for i in range(size):
        for j in range(size - 1, i, -1):
            if card[j][1] < card[j - 1][1]:
                card[j], card[j - 1] = card[j - 1], card[j]
    return card


def selection(a):
    card = a[:]
    size = len(card)
    for i in range(size):
        minj = i
        for j in range(i, size):
            if card[j][1] < card[minj][1]:
                minj = j
        if minj != i:
            card[i], card[minj] = card[minj], card[i]
    return card


def is_stable(a, b):
    size = len(a)
    for i in range(size):
        if a[i][0] != b[i][0]:
            return False
    return True


def main():
    n = int(input())
    cards = input().split()
    a = bubble(cards)
    b = selection(cards)

    print(*a)
    print("Stable")
    print(*b)
    print("Stable" if is_stable(a, b) else "Not stable")


if __name__ == '__main__':
    main()



Measured memory_bytes: 5620
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
ll dp[200000];
int main(){
int n;
cin>>n;
vector<ll> b(n+1,inf);
for(int i=1;i<n;i++)cin>>b[i];
ll ans=0;
for(int i=0;i<n;i++)ans+=min(b[i],b[i+1]);
cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	balls := make(Balls, n)

	for i := 0; i < n; i++ {
		balls[i].x = getNextInt(scanner)
		balls[i].y = getNextInt(scanner)
	}
	sort.Sort(balls)
	dd := make(IntMapMap, 0)
	for i := 0; i < n; i++ {
		for ii := i + 1; ii < n; ii++ {
			dx := balls[ii].x - balls[i].x
			dy := balls[ii].y - balls[i].y
			dd.increment(dx, dy)
		}
	}
	max := 0
	for _, mm := range dd {
		for _, m := range mm {
			if max < m {
				max = m
			}
		}
	}
	fmt.Fprintln(writer, n-max)

	writer.Flush()
}

type Ball struct {
	x int
	y int
}

type Balls []Ball

func (a Balls) Len() int      { return len(a) }
func (a Balls) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Balls) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y < a[j].y
	}
	return a[i].x < a[j].x
}
type IntMap map[int]int


func (m IntMap) increment(key int) {
	if _, ok := m[key]; ok == false {
		m[key] = 0
	}
	m[key]++
}

type IntMapMap map[int]IntMap
func (m IntMapMap) increment(key1, key2 int) {
	if _, ok := m[key1]; ok == false {
		m[key1] = make(IntMap, 0)
	}
	m[key1].increment(key2)
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
struct card{
  char suit,num;
  // bool operator<(const card &c){
  //   return num < c.num;
  // }
};
bool operator<(card l, card r){
  return l.num < r.num;
}
ostream& operator<<(ostream &os,const card &cd){
  string s;
  s += cd.suit;
  s += cd.num;
  os << s;
  return os;
}
vector<card> selection_sort(vector<card> a){
  REP(i,a.size()){
    auto itr = min_element(a.begin()+i,a.end());
    if(i!=distance(a.begin(),itr)){
      swap(a[i],*itr);
    }
  }
  return a;
}
void printvec(const vector<card> &v){
  REP(i,v.size()-1) cout << v[i] <<" ";
  cout << v.back() << endl;
}
signed main(){
  int n;
  cin >> n;
  vector<card> a(n);
  REP(i,n){
    string s;
    cin >> s;
    a[i] = (card){s[0],s[1]};
  }
  auto b = a;
  stable_sort(ALL(b));
  printvec(b);
  puts("Stable");
  auto c = selection_sort(a);
  printvec(c);
  bool fl = true;
  REP(i,n){
    if(b[i].suit!=c[i].suit) fl = false;
  }
  cout << (fl?"S":"Not s") << "table" << endl;
}



Measured memory_bytes: 3232
from collections import defaultdict


def main():
    d = defaultdict(int)
    nums = []
    _ = input()
    nums = list(map(int, input().split()))
    for n in nums:
        d[n] += 1
    
    total_combs = 0
    for k in d.keys():
        total_combs += int((d[k]*(d[k]-1))/2)
    
    for n in nums:
        print(total_combs - (d[n] - 1))
        
 
if __name__ == "__main__":
    main()

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
const int mod = 2019;

int main() {
    string s; cin >> s;
    reverse(all(s));
    ll base = 1, ans = 0;
    vl dp(2020,0);
    for (char c : s) {
        int x = c - '0';
        int num = (x * base) % mod;
        vl ndp(2020,0);
        per(i,2020) {
            if (dp[i] == 0) continue;
            ndp[(i+num)%mod] = dp[i];
        }
        ndp[num]++;
        ans += ndp[0];
        dp = ndp;
        (base *= 10) %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  ll A, B, C;
  cin >> A >> B >> C;

  cout << max(C - (A - B), 0LL);
  return 0;
}

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll n;
  cin >> n;
  vl count(n+1,0);
  FOR(i,1,200){
    FOR(j,1,200){
      FOR(k,1,200){
        ll sum = i*i+j*j+k*k+i*j+j*k+k*i;
        if(sum<=n) count[sum]++;
      }
    }
  }
  REP(i,n){
    cout << count[i+1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3568
import copy
from collections import deque
def main():
  H, W = map(int, input().split())
  M = [['#' == x for x in input()] for _ in range(H)]

  black = deque([(i, j) for i in range(H) for j in range(W) if M[i][j]])

  ans = 0
  while True:
    ans += 1
    next_black = deque()
    while black:
      bi, bj = black.popleft()
      if bi > 0 and not M[bi - 1][bj]:
        M[bi - 1][bj] = True
        next_black.append((bi - 1, bj))
      if bj > 0 and not M[bi][bj - 1]:
        M[bi][bj - 1] = True
        next_black.append((bi, bj - 1))
      if bi < H - 1 and not M[bi + 1][bj]:
        M[bi + 1][bj] = True
        next_black.append((bi + 1, bj))
      if bj < W - 1 and not M[bi][bj + 1]:
        M[bi][bj + 1] = True
        next_black.append((bi, bj + 1))
    if next_black:
       black = copy.copy(next_black)
    else:
       break
  print(ans - 1)
  
if __name__ == "__main__":
  main()


Measured memory_bytes: 115564
from fractions import gcd
A, B, C, D = map(int, input().split())
E = C*D//gcd(C, D)
X = B - B//C - B//D + B//E
Y = A-1 - (A-1)//C - (A-1)//D + (A-1)//E
print(X-Y)

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N;
	cin>>N;
    ll n,ans=0;
    rep(i,N){
        n = i+1;
        if(n%3!=0){
            if(n%5!=0){
                ans += n;
            }
        }
    }
    cout<<ans<<"\n";
	return 0;
}

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

int main(){
   int k,s;
   cin >> k >> s;
   int ans = 0;
   rep(i,k+1){//x
      rep(j,k+1){//y
         if((s-i-j) >= 0 && (s-i-j) <= k)ans++;
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
    long long N;
    std::cin >> N;
    if((N/100)%10 == 7){
        printf("Yes\n");
    }else if((N/10)%10 == 7){
        printf("Yes\n");
    }else if(N%10 == 7){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

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

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

  if (R < 1200)
  {
    cout << "ABC" << endl;
  }
  else if (R < 2800)
  {
    cout << "ARC" << endl;
  }
  else
  {
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 3600
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
#define ll long long
ll mod = 1000000007;
ll big(ll b, ll p){
	if (p == 0) return 1;
	ll h = big(b, p / 2);
	ll r = h * h % mod;
	if (p % 2 == 1) r = r * b % mod;
	return r;
}
int main(){
	int n, m;
	string s;
	cin >> m >> s;
	n = s.size();
	ll ans = 0, c[m + 1];
	c[0] = 1;
	for (int i = 1; i <= m; i++) c[i] = (c[i - 1] * (n + i - 1) % mod) * big(i, mod - 2) % mod;
	for (int i = 0; i <= m; i++) (ans += c[i] * big(25, i) % mod * big(26, m - i) % mod) %= mod;
	printf("%lld\n", ans);
}

Measured memory_bytes: 12080
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int D = sc.nextInt();
		int N = sc.nextInt();
		int[] T = new int[D];
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N];
		for (int i = 0; i < D; i++) T[i] = sc.nextInt();
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			C[i] = sc.nextInt();
		}
		int[][] dp = new int[D][N];
		for (int i = 0; i < D; i++) Arrays.fill(dp[i], -1);
		for (int i = 0; i < N; i++) {
			if (A[i] <= T[0] && T[0] <= B[i]) dp[0][i] = 0;
		}
		int max = 0;
		for (int i = 0; i < D - 1; i++) {
			// j -> k????????????????????????
			for (int j = 0; j < N; j++) {
				if (dp[i][j] >= 0) {
					for (int k = 0; k < N; k++) {
						if (A[k] <= T[i + 1] && T[i + 1] <= B[k]) {
							dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j] + Math.abs(C[j] - C[k]));
							max = Math.max(max, dp[i + 1][k]);
						}
					}
				}
			}
		}
		System.out.println(max);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> x(n);
    vector<int> xkp(n);
    for(int in=0;in<n;in++) {
        cin >> x.at(in);
        xkp.at(in) = x.at(in);
    }

    sort(x.begin(), x.end());

    for(int in=0;in<n;in++) {
        if(xkp.at(in)<=x.at(n/2-1)) cout << x.at(n/2) << endl;
        else cout << x.at(n/2-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
/* HEADERS & NAMESPACES */
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;

/* MACROS */
#define fastIO() ios_base:: sync_with_stdio(false); cin.tie(NULL)
#define fill(v, x) memset(v, x, sizeof(v))
#define rep(i, a, b) for(__typeof(b) i = (a)-((a)>(b)); i != (b)-((a)>(b)); i += 1-2*((a)>(b)))
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;
#define CHK(x, y) cerr << "\n" << #x << "=" << (x) << ", " << #y << "=" << (y) << "\n"
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define INF (1ll)<<60
#define MOD 1000000007
#define N 200005

/* TEMPLATES */
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}

/* GLOBAL */
/* FUNCTIONS */

void solve() {
    int n, m;
    cin >> n >> m;
    cout << ((n * (n - 1)) + (m * (m - 1))) / 2 ;
}

signed main() {
    fastIO();
    solve();
}


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

void print_vec(vector<int>& vec, int vec_ind){
  cout <<"vec_value: ";
  for(int i = 0; i < vec_ind; i++){
    cout << vec.at(i) << " "; 
  }
  cout << endl;
}

int find_min(vector<int>& vec, int vec_ind){
  int sum = 0;
  int locl_min = vec.at(0);
  vector<vector<int>> vec_sq;
  //print_vec(vec, vec_ind);
  for(int i = 0; i < vec_ind; i++){
    if(locl_min > vec.at(i)) locl_min = vec.at(i);
  }
  int ind_sq_a = 0, ind_sq_b = 0, flag = 0;
  sum += locl_min;
  vector<int> temp_vec;
  for(int i = 0; i < vec_ind; i++){
    int temp = vec.at(i) - locl_min;
    //cout << temp << ", ";
    if (temp != 0){
      temp_vec.push_back(temp);
      //cout << "push" << endl;
      flag = 1;
    }
    else if(temp == 0 && flag == 1){
      vec_sq.push_back(temp_vec);
      temp_vec.clear();
      ind_sq_a++;
      flag = 0;
    }
  }
  if(temp_vec.size() > 0) vec_sq.push_back(temp_vec);
  //cout << "sum:" << sum << endl;
  for(int j = 0; j < vec_sq.size(); j++){
    //print_vec(vec_sq[j], vec_sq[j].size());
    sum += find_min(vec_sq[j], vec_sq[j].size());
    //cout << "sum_change:" << sum << endl;
  }
  
  return sum; 
}


int main(void){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i); 
  }
  
  int min_sum = find_min(vec, N);
  cout << min_sum << endl;
}

Measured memory_bytes: 256
n = gets.to_i
t,a = gets.chomp.split(" ").map(&:to_f)
h = gets.chomp.split(" ").map(&:to_f)
index = 0
min = 1000000.0
n.times do |i|
  x = t - h[i] * 0.006
  if min > (a - x).abs
    min = (a-x).abs
    index = i
  end
end
puts index+1

Measured memory_bytes: 14340
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a >> b;
    int seki = a * b;
    
    if (seki % 2 == 0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
        
    
}


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

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	unordered_map<int, int> m;
	for (int i = 0; i < n; i++)
	{
		int a;
		scanf("%d", &a);
		m[a]++;
	}

	vector<int> c;
	for (auto p : m)
		c.push_back(p.second);
	sort(c.begin(), c.end(), greater<int>());

	int s = 0;
	for (int i = 0; i < c.size() && i < k; i++)
		s += c[i];
	printf("%d\n", n - s);

	return 0;
}

Measured memory_bytes: 10312
package main

import (
	. "fmt"
    "sort"
)

// func init() { Println("----------------------------------------") }

func main() {
    var a, b, k int
    Scanf("%d %d %d", &a, &b, &k)

    set := make(map[int]struct{})

    for i := 0; i < k; i++ {
        if a + i <= b {
            if _, ok := set[a + i]; !ok {
                set[a + i] = struct{}{}
            }
        }

        if b - i >= a {
            if _, ok := set[b - i]; !ok {
                set[b - i] = struct{}{}
            }
        }
    }

    res := make([]int, 0, 205)
    for num := range set {
        res = append(res, num)
    }
    sort.Sort(sort.IntSlice(res))

    for _, v := range res {
        Println(v)
    }
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,k;
  cin >> n >> k;

  ll now = 1;
  REP(i, n){
    now += min(now, k);
  }
  cout << now << endl;
}


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

const int maxh = 100;
const int maxw = 100;

int h, w;
int cnt[26];
int mod[4];
string matrix[maxh];

bool check() {
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cnt[matrix[i][j]-'a'] ++;
    for (int i = 0; i < 26; ++i) {
       mod[cnt[i] % 4] ++; 
    }
    if (h % 2 == 0 && w % 2 == 0) {
        return mod[1] + mod[2] + mod[3] == 0;
    } else if (h % 2 == 1 && w % 2 == 1) {
        if (mod[1] + mod[3] != 1)
            return false;
        if (mod[3] == 1) {
            mod[2] ++;
        } 
        return mod[2] <= h / 2 + w / 2;
    } else {
        if (mod[1] + mod[3] != 0)
            return false;
        if (h % 2)
            return mod[2] <= w / 2;
        else 
            return mod[2] <= h / 2;
    }
}

int main() {
    cin>>h>>w;
    for (int i = 0; i < h; ++i)
        cin>>matrix[i];
    cout<<(check()?"Yes":"No")<<endl;
    return 0;
}

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

const li mod = 1e9 + 7;

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

    vector<li> av(n), bv(n), cv(n);

    priority_queue<pair<li, li>> q;
    for (int i = 0; i < n; ++i) {
        cin >> av[i] >> bv[i];
        q.push(make_pair(av[i] + bv[i], i));
    }

    li ans = 0;
    bool takahashi = true;
    while (not q.empty()) {
        auto top = q.top();
        q.pop();
        if (takahashi) {
            ans += av[top.second];
        } else {
            ans -= bv[top.second];
        }
        takahashi = not takahashi;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4724