akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void)
{
	int N, minj, count = 0, temp, A[100];
	int a, i, j;

	scanf("%d",&N);
	for (a = 0; a < N; a++)
	{
		scanf("%d",&A[a]);
	}

	for (i = 0; i < N; i++)
	{
		minj = i;
		for (j = i; j < N; j++)
		{
			if (A[j] < A[minj])
			{
				minj = j;
			}
		}
		if (i != minj)
		{
			count++;
			temp = A[i];
			A[i] = A[minj];
			A[minj] = temp;
		}
	/*for (a = 0; a < N-1; a++)
	{
		printf("%d ",A[a]);
	}
	printf("%d ", A[N-1]);
	printf("%d\n", count);*/
	}

	for (a = 0; a < N-1; a++)
	{
		printf("%d ",A[a]);
	}
	printf("%d\n", A[N-1]);
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int D;
  cin >> D;
  vector<int> c(D);
  int s[D][26];

  REP(i,26) cin >> c[i];
  REP(d,D){
    REP(i,26){
      int x;
      cin >> x;
      s[d][i] = x;
    }
  }
  vector<int> t(D);

  REP(d,D){
    int x;
    cin >> x;
    --x;
    t[d] = x;
  }

  int last[26];  //コンテストが最後に行われた日
  REP(i,26) last[i] = -1;
  int ans = 0;

  REP(d,D){
    int ci = t[d];
    ans += s[d][ci];
    last[ci] = d;

    REP(i,26){
      ans -= c[i] * (d - last[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
import sys

cardslist = []
for i in range(3):
  cardslist.append(list(input()))

turn = 'a'

while 1:
 
  if turn == 'a':
    if len(cardslist[0]) == 0:
      print("A")
      sys.exit()

    if cardslist[0][0] == 'a':
      turn = 'a'
    elif cardslist[0][0] == 'b':
      turn = 'b'
    else:
      turn = 'c'
    
  
    del cardslist[0][0]
    continue

  if turn == 'b':
    if len(cardslist[1]) == 0:
      print("B")
      sys.exit()

    if cardslist[1][0] == 'a':
      turn = 'a'
    elif cardslist[1][0] == 'b':
      turn = 'b'
    else:
      turn = 'c'

    del cardslist[1][0]
    continue

  if turn == 'c':
    if len(cardslist[2]) == 0:
      print("C")
      sys.exit()

    if cardslist[2][0] == 'a':
      turn = 'a'
    elif cardslist[2][0] == 'b':
      turn = 'b'
    else:
      turn = 'c'

    if len(cardslist[2]) == 0:
      print("C")
      sys.exit()

    del cardslist[2][0]
    continue

 


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
ll solve(const string& S) {
    const ll n = S.size();
    string T = "";
    each(c, S) {
        if (c != 'x') T += c;
    }
    const ll m = T.size();
    rep(i, (m+1)/2) {
        if (T[i] != T[m-i-1]) return -1;
    }
    ll l = 0, r = n-1;
    ll ans = 0;
    while (l <= r) {
        if (S[l] == S[r]) {
            ++l;
            --r;
        }
        else if (S[l] == 'x') {
            ++ans;
            ++l;
        }
        else {
            assert(S[r] == 'x');
            ++ans;
            --r;
        }
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    cout << solve(s) << endl;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int n,k;
    cin >> n >> k;
    vector<int>p(n);
    rep(i,n) cin >> p[i];
    rep(i,n) p[i]++;
    int mx = 0;
    int s = 0;
    queue<int>q;
    rep(i,n){
        s += p[i];
        q.push(p[i]);
        if(q.size()>k){
            s -= q.front(); 
            q.pop();
        }
        if(q.size() == k){
            mx = max(mx,s);
        }
    }
    double ans = mx;
    ans /= 2;
    printf("%.10f\n",ans);
    return 0;
}




Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
class Main{
    public static void main(String args[]) throws IOException{

	int a=0;
	int b=0;
	int c=0;
	int i=0;

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String str = br.readLine();
	String delimiter = " ";
        StringTokenizer stringTokenizer = new StringTokenizer( str, delimiter );
	while(stringTokenizer.hasMoreTokens())
	{
            String current = stringTokenizer.nextToken();
	    if(i==0)a=Integer.parseInt(current);
	    if(i==1)b=Integer.parseInt(current);
	    if(i==2)c=Integer.parseInt(current);
	    i++;
	}

	if(a<b && b<c)System.out.println("Yes");
	else System.out.println("No");
    }
}

Measured memory_bytes: 16864
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    temp = input()
    if temp == "AC":
        AC = AC + 1
    if temp == "WA":
        WA = WA + 1
    if temp == "TLE":
        TLE = TLE + 1
    if temp == "RE":
        RE = RE + 1
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  sort(begin(a), end(a));
  sort(begin(b), end(b));
  if (n & 1) {
    cout << b[n / 2] - a[n / 2] + 1 << '\n';
  } else {
    cout << (b[n / 2 - 1] + b[n / 2]) - (a[n / 2 - 1] + a[n / 2]) + 1 << '\n';
  }
}


Measured memory_bytes: 4780
(function Main(input){
	var input  = input.split('\n'),
		X      = input[1].split(' ').map(Number),
		result = 0,
		avg    = function(data){
			var sum = 0,
				len = data.length;

			for(var i=0; i<len; i++){
				sum += data[i];
			}
			return Math.round(sum / len);
		}(X);
	
	for(var i=0; i<X.length; i++){
		result += Math.pow(X[i]-avg, 2);
	}
	console.log(result);
})(require("fs").readFileSync("/dev/stdin","utf8"));

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

using namespace std;

int main()
{
    vector<int> vs(3);
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (abs(c - a) <= d || (abs(a - b) <= d && abs(b - c) <= d))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    map<int,int> mp;
    mp[0]++;
    int now=0;
    rep(i,N){
        int A;
        cin >> A;
        now+=A;
        now%=M;
        mp[now]++;
    }
    ll ans=0;
    for(auto key:mp){
        ans+=(ll)(key.second)*(key.second-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

using ll = long long;

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

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll MOD = 1'000'000'007;
ll powmod(ll v, ll x, ll mod=MOD) {
  if (x == 0) return 1;
  if (x % 2 == 0) {
    ll tmp = powmod(v, x / 2);
    return (tmp * tmp) % mod;
  } else {
    return (powmod(v, x - 1) * v) % mod;
  }
}

vector<ll> fact_table(5 * 100000 + 1, -1);
#define MEMOfact fact_table[x]
ll fact(ll x) {
  if (MEMOfact != -1) return MEMOfact;
  if (x <= 1) return MEMOfact = 1;
  return MEMOfact = (fact(x - 1) * x) % MOD;
}

ll p(ll left, ll right) {
  return (fact(left) * powmod(fact(left - right), MOD - 2)) % MOD;
}

ll c(ll left, ll right) {
  return p(left, right) * powmod(fact(right), MOD - 2) % MOD;
}

int main() {
  ll input(n, m);
  ll sum = 0;
  FOR(k, 0, n) {
    ll value = ((c(n, k) * p(m - k, n - k)) % MOD) * ((k + 1) % 2 * 2 - 1);
    (sum += value) %= MOD;
    while (sum < 0) sum += MOD;
  }

  cout << (sum * p(m, n) % MOD) << endl;
}


Measured memory_bytes: 14620
def count_bits(num, digit)
  div = 2 ** (digit - 1)
  d = num / div
  v = (d / 2) * div
  v += num % div + 1 if d % 2 == 1
  v
end

def xor_world(a, b)
  length = (10 ** 13).to_s(2).size

  a -= 1 if a > 0

  a_bits = {}
  1.upto(length) do |digit|
    a_bits[digit] = count_bits(a, digit)
  end

  b_bits = {}
  1.upto(length) do |digit|
    b_bits[digit] = count_bits(b, digit)
  end

  ans = 0
  1.upto(length) do |digit|
    ans += 2 ** (digit - 1) * ((b_bits[digit] - a_bits[digit]) % 2)
  end
  ans
end

a, b = gets.split.map(&:to_i)
puts xor_world(a, b)

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

struct UnionFind{
  int n;
  vector<int> ran,p,cnt;
  UnionFind(){}
  UnionFind(int sz):n(sz),ran(sz,1),p(sz,0){
    r(i,sz)p[i]=i;
  }
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(ran[x]<ran[y]) swap(x,y);
    ran[x]+=ran[y];
    p[y]=x;
  }
  int sum(int x){
    return ran[find(x)];
  }
};

int n,m,w[100009];
vector<vector<int> >v(100009),G(100009),uni(100009);
vector<P>T;
int dp[100009],ans;
bool used[100009];
UnionFind U(100009);

void add(int a,int b){ U.unite(a,b);}

signed main(){
  cin>>n;
  //r(i,n)dp[i]=1;
  r(i,n)cin>>w[i];
  cin>>m;
  r(i,m){
    int x,y;
    cin>>x>>y;
    x--;y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  r(i,n){
    vector<P>a;
    r(j,v[i].size()){
      a.push_back(P(w[v[i][j]],v[i][j]));
      if(w[i]<=w[v[i][j]]){
        G[i].push_back(v[i][j]);
        if(w[i]==w[v[i][j]])add(i,v[i][j]);
      }
    }
    sort(a.begin(),a.end());
    r(j,(int)a.size()-1){
      G[a[j].second].push_back(a[j+1].second);
      if(a[j].first==a[j+1].first){
        add(a[j].second,a[j+1].second);
      }
    }
  }
  r(i,n){
    T.push_back(P(w[i],i));
    uni[U.find(i)].push_back(i);
  }
  r(i,n){
    sort(G[i].begin(),G[i].end());
    G[i].erase(unique(G[i].begin(),G[i].end()),G[i].end());
  }
  sort(T.begin(),T.end());
  r(i,n)if(U.find(T[i].second)==T[i].second){
    int x=T[i].second;
    int y=T[i].first;
    int cnt=1,MAX=0;
    r(k,uni[x].size()){
      MAX=max(MAX,dp[uni[x][k]]);
    }
    r(k,uni[x].size()){
      int X=uni[x][k];
      r(j,G[X].size()){
        int nxt=G[X][j];
        dp[nxt]=max(dp[nxt],MAX+1);
      }
    }
    ans+=U.sum(x)*(MAX+1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 29428
using DataStructures
MOD = 2019

a = readline() |> s -> split(s,"") |> xs -> parse.(Int,xs) |> reverse
n = length(a)
dp = zeros(Int, n+1)

for i in 1:n
  dp[i+1] = (powermod(10, i-1, MOD) * a[i] + dp[i]) % MOD
end

cnt = counter(Int)
for x in dp
  inc!(cnt, x)
end
ans = [x * (x-1) ÷ 2 for (k,x) in cnt] |> sum

println(ans)


Measured memory_bytes: 238184
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<bitset>
using namespace std;

int main(){

  	int a;
    cin >> a;
  	int b=a;
    int sum;

  while(a>0){
   	sum+=a%10 ;
    a/=10;
  }
  
  
  	if(b%sum==0){
    	cout << "Yes" <<endl;  
    }else{
    	cout << "No" <<endl; 
    }
  
    
}

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

int main()
{
  int N,Y;
  cin >> N >> Y;
  for(int n1 = 0;n1<=N;n1++) {
    for(int n2 = 0;n2<=N;n2++) {
      int n3 = N-n1-n2;
      if(n3>=0 && n3<=N && Y==(n1*10000+n2*5000+n3*1000)) {
        printf("%d %d %d\n",n1, n2, n3);
        return 0;
      }
    }
  }
  printf("%d %d %d\n",-1, -1, -1);
  return 0;
}

Measured memory_bytes: 256
/* ***********************************************
Author        :guanjun
Created Time  :2016/7/16 23:23:01
File Name     :agc1a.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
	int x,y;
};
struct cmp{
    bool operator()(Node a,Node b){
        if(a.x==b.x) return a.y> b.y;
        return a.x>b.x;
	}
};

bool cmp(int a,int b){
    return a>b;
}
int a[300];
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    #endif
    //freopen("out.txt","w",stdout);
    int n;
	while(cin>>n){
		for(int i=1;i<=n*2;i++)cin>>a[i];
		sort(a+1,a+1+2*n);
		int sum=0;
		for(int i=2*n;i>=1;i-=2){
			sum+=a[i-1];
		}
		cout<<sum<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

	public static void main(String[] args) {

		// ストリームを作成する
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		int vertical = readNumber(reader);
		int horizontal = readNumber(reader);

		// 横棒リストを作る
		List<int[]> horizontalList = new ArrayList<int[]>();
		for (int i = 0; i < horizontal; i++) {
			horizontalList.add(readPair(reader));
		}

		// 縦棒を左から順番にシミュレートして結果を配列に保持する
		int[] goal = new int[vertical];
		for (int i = 1; i <= vertical; i++) {
			int result = i;
			for (int[] horizontalBar : horizontalList) {
				if (result == horizontalBar[0]) {
					result = horizontalBar[1];
				} else if (result == horizontalBar[1]) {
					result = horizontalBar[0];
				}
			}
			goal[result - 1] = i;
		}

		// 結果を表示する
		for (int i : goal) {
			System.out.println(i);
		}

	}

	/**
	 * ストリームから1行読み込んで、数値として返す。
	 *
	 * @param reader
	 *            入力ストリーム
	 * @return 数値
	 */
	private static int readNumber(BufferedReader reader) {
		int result = 0;
		try {
			String line = reader.readLine();
			result = Integer.parseInt(line);
		} catch (IOException e) {
			throw new RuntimeException();
		}
		return result;
	}

	/**
	 * ストリームから1行読み込んで、数値のペアとして返す。
	 *
	 * @param reader
	 *            入力ストリーム
	 * @return 数値のペア
	 */
	private static int[] readPair(BufferedReader reader) {
		int[] result = new int[2];
		try {
			String line = reader.readLine();
			String[] array = line.split(",");
			result[0] = Integer.parseInt(array[0]);
			result[1] = Integer.parseInt(array[1]);
		} catch (IOException e) {
			throw new RuntimeException();
		}
		return result;
	}

}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int x,n; cin >> x >> n;
  vector<int> _input(n); REP(i,n) cin >> _input[i];
  
  if (n == 0) {
    cout << x << endl;
    return 0;
  }

  int idx = 0;
  while(true) {
    bool minflag = true,maxflag = true;
    REP(i,n) {
      if (_input[i] == x - idx) {
        minflag=false;
        /* cout << "min " << x - idx << endl; */
      } if (_input[i] == x + idx) {
        maxflag=false;
        /* cout << "max " << x + idx << endl; */
      }
    }
    if (minflag) {
      cout << x - idx << endl;
      return 0;
    } else if (maxflag) {
      cout << x + idx << endl;
      return 0;
    }

    idx++;
  }
  return 0;
}

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

int main(){
   ll n; cin >> n; 
   ll ans=0;
   ll t=n%2;
   if(t==1){
     cout << 0 << endl;
   }
   else if(n==0){
     cout << 0 << endl;
   }
   else{
     ll j=n/2;
       while(j!=0){
           j=j/5;
           ans+=j;
       }
    cout << ans << endl;
   }
return 0;
}


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

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

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int r = 100000;
  r = min(abs(a-b) + abs(b-c), r);
  r = min(abs(a-c) + abs(b-c), r);
  r = min(abs(a-b) + abs(a-c), r);

  cout << r << endl;
}


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


int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i, 0, n)cin >> a[i];
    sort(a.begin(), a.end());
    long ans = 0;
    rep(i, 0, n)rep(j, i + 1, n) {
        int bel = a[j] - a[i] + 1;
        int bot = lower_bound(a.begin(), a.end(), bel) - a.begin();
        int up = a[j] + a[i];
        int top = lower_bound(a.begin(), a.end(), up) - a.begin();

        ans += (top - bot);
        if (a[i] >= bel && a[i] < up)ans--;
        if (a[j] >= bel && a[j] < up)ans--;
    }
    ans /= 3;
    cout << ans << endl;
}


Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    var temp = input[0].split(" ").map(x => parseInt(x));
    var N = temp[0];
    var K = temp[1];
    
    var h = input.slice(1, N+1).map(x => parseInt(x));
    h.sort((n,m)=> n-m);

    var min = Math.pow(10, 10);
    
    for( var  i=0; i<(N-K)+1 ; i++) {
        var tempMin = h[i+(K-1)] - h[i];
        min = Math.min(min, tempMin);
    }
    
    console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28740
n = int(input())
x = list(map(int,input().split()))
x.append(0)
m = int(input())
a = list(map(int,input().split()))
for i in a:
    i -= 1
    if x[i] != 2019 and x[i]+1 != x[i+1]:
        x[i] += 1
for i in range(n):
    print(x[i])



Measured memory_bytes: 5608
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    string s;cin>>s;
    rep(i,s.size()){
        if(i%2!=0)continue;
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;
int main() {
    
    int n,a,x,y;
    cin >> n;

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

    for(int i=0;i<n;i++){
        cin >> a;
        for(int j=0;j<a;j++) {
            cin >> x >> y;
            v[i].push_back(make_pair(x,y));
        }
    }

    /*for(int i=0;i<n;i++){
        cout << i << endl;
        for(int j=0;j<v[i].size();j++) {
            cout << v[i][j].first << " " << v[i][j].second << endl;
    
        }
    }
    */
    int ans = 0;
    bool s[n];
    for(int i=0;i<(1<<n);i++) {
        bool status = true;
        int t=0;
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                t+=1;
                s[j] = true;
            } else {
                s[j] = false;
            }
        }

        for(int j=0;j<n;j++) {
            for(int k=0;k<v[j].size();k++) {

                if(s[j]) {

                    if(v[j][k].second==1) {
                        if(s[v[j][k].first-1] == false) status = false;
                    } else {
                        if(s[v[j][k].first-1] ==  true) status = false;
                    }


                } 
            }
        }
        if(status) ans = max(ans, t);
    }
    cout <<ans <<endl;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    bool poor = false;
    if (((a == b) && a != c) ||
        ((a == c) && a != b) ||
        ((b == c) && a != b))
        poor = true;

    if (poor) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n = I()
G = [[] for _ in range(n)]
for a, b in LIR(n - 1):
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]


C = sorted(LI())
ans = [0] * n
ans[0] = C.pop()
total = sum(C)
dq = deque([0])
while dq:
    u = dq.popleft()
    for v in G[u]:
        if not ans[v]:
            ans[v] = C.pop()
            dq += [v]


print(total)
print(*ans)






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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
    string str;
    cin>>str;
    if(str[2]==str[3]&&str[4]==str[5])
        cout<<"Yes";
    else
        cout<<"No";

	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 a,b,c;
  cin >> a >> b >> c;
  
  rep(i,1000) {
    if(a*i >= b && a*i <= c){
      cout << "OK" << endl;
      break;
    }
    else if(a*i > b) {
      cout << "NG" << endl;
      break;
    }
  }
  
  

}


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

def main():
    N = INT()
    uv = [LIST() for i in range(N - 1)]

    # graphがあればまずグラフを辞書で書く
    graph = defaultdict(list)

    # 辺，edge，key: ，value:色情報
    edge = defaultdict(int)

    for u, v in uv:
        graph[u-1].append(v-1)
        graph[v-1].append(u-1)
    
    K = 0
    for v in graph.values():
        # 最も長いリストの長さになる
        K = max(K, len(v))
    color = list(range(1, K + 1))
    
    # 使う色の数，これだけつかえばいい
    # print("K", K)
    # print("color:", color)
    que = deque()
    que.append((0, None))

    # bfs
    # use_color:その辺で使うカラー
    while que:
        i, color_from = que.popleft()
        tmp = -1
        for node in graph[i]:
            str_ = "{},{}".format(i, node)
            if not edge[str_]:
                # 一番最後のカラー
                use_color = color[tmp]
                if use_color == color_from:
                    # 同じなら，一番最後から前に下がっていく
                    use_color = color[tmp - 1]
                    tmp -= 1
                tmp -= 1

                edge[str_] = use_color
                # 逆も然り
                edge["{},{}".format(node, i)] = use_color
                que.append((node, use_color))
    print(K)
    for u, v in uv:
        print(edge["{},{}".format(u-1, v-1)])


if __name__ == "__main__":
    main()




Measured memory_bytes: 82108
#include <iostream>
using namespace std;
 
int main()
{
    while(true){
        int M, T, P, R;
        cin >> M >> T >> P >> R;
 
        if(M==0 && T==0 && P==0 && R==0)
            break;
 
        int CP[50], TT[50], PT[50][10];
        for(int i=0; i<T; i++){
            CP[i] = TT[i] = 0;
            for(int j=0; j<P; j++)
                PT[i][j] = 0;
        }
 
        for(int i=0; i<R; i++){
            int m, t, p, j;
            cin >> m >> t >> p >> j;
 
            if(j==0){
                CP[t-1]++;
                TT[t-1] += (m+PT[t-1][p-1]);
            }
            else{
                PT[t-1][p-1] += 20;
            }
        }
 
        int tnow, tpre = -1;
        bool flg[50];
        for(int i=0; i<T; i++)
            flg[i] = false;
 
        for(int i=0; i<T; i++){
            tnow = -1;
            for(int j=0; j<T; j++){
                if(flg[j])
                    continue;
 
                if(tnow==-1){
                    tnow = j;
                }
                else{
                    if(CP[j]>CP[tnow] || (CP[j]==CP[tnow] && TT[j]<=TT[tnow])){
                        tnow = j;
                    }
                }
            }
 
            if(tpre!=-1){
                if(CP[tnow]==CP[tpre] && TT[tnow]==TT[tpre])
                    cout << '=';
                else
                    cout << ',';
            }
            cout << tnow+1;
 
            flg[tnow] = true;
            tpre = tnow;
        }
        cout << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3088
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main {
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) throws java.lang.Exception {
        // your code goes here
        FastReader scn = new FastReader();
        long i, j, t, a,b,c,d;
        a=scn.nextInt();
        b=scn.nextInt();
        c=scn.nextInt();
        d=scn.nextInt();
        long ans[]=new long[4];
        ans[0]=a*c;
        ans[1]=a*d;
        ans[2]=b*c;
        ans[3]=b*d;
        Arrays.sort(ans);
        System.out.println(ans[3]);
    }
}


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


int main()
{
    int n,k;
    cin >> n >> k;
    int arr[n];
    int dp[k+1] = {0};
    int i,j;
    int b;
    for(i=0;i<n;i++)
    {
        cin >> arr[i];
        dp[k-arr[i]+1] = 1;
    }
    for(i=k;i>=1;i--)
    {
        if(!dp[i])
        {
            dp[i] =  -1;
            for(j=0;j<n;j++)
            {
                b = i+arr[j];
                if(b<=k)
                {
                    if(dp[b] == -1)
                    {
                        dp[i] = 1;
                    }
                }
            }
        }
    }
    if(dp[1]==1) cout << "First";
    else cout << "Second";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w;
    cin >> h >> w;
    char s[h + 2][w + 2];
    rep(i, 0, h + 2) {
        rep(j, 0, w + 2) {
            s[i][j] = '.';
        }
    }
    rep(i, 1, h + 1) {
        rep(j, 1, w + 1) {
            cin >> s[i][j];
        }
    }

    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    rep(i, 1, h + 1) {
        rep(j, 1, w + 1) {
            if (s[i][j] == '#') {
                bool flag = false;
                rep(k, 0, 4) {
                    if (s[i + dx[k]][j + dy[k]] == '#') flag = true;
                }
                if (!flag) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    
    ini(n);
    ini(n1);
    FOR(i,0,n1){
        ini(x);
        n-=x;
    }
    if(n>=0){out(n);}
    else out(-1);
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
#include <random>


using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    vector c(27, 0);
    for (int i=1; i<27; i++) cin >> c[i];
    int csum = accumulate(c.begin(), c.end(), 0);


    vector<vector<int>> s(d, vector<int>(27, 0));
    for (int i=0; i<d; i++) {
        for (int j=1; j<27; j++)
            cin >> s[i][j];
    }

    for (int i=0; i<d; i++) {
        auto it = max_element(s[i].begin(), s[i].end());
        cout << it - s[i].begin() << endl;
    }
}

Measured memory_bytes: 3244
# https://atcoder.jp/contests/abc072/tasks/arc082_a
# C - Together
import itertools
import collections

n = int(input().split()[0])
a_list = list(map(int, input().split()))

a_op_list = [[a-1, a, a+1] for a in a_list]
a_op_list = itertools.chain.from_iterable(a_op_list)
c = collections.Counter(a_op_list)
max_count = max(c.values())

print(max_count)


Measured memory_bytes: 34528
s=gets.chomp
t=gets.chomp
h1 = {}
h2 = {}
0.upto(s.size-1) do |i|
    if h1.has_key?(s[i])
        if h1[s[i]] != t[i]
            puts "No"
            exit
        end
    else
        h1[s[i]] = t[i]
    end

    if h2.has_key?(t[i]) 
        if h2[t[i]] != s[i]
            puts "No"
            exit
        end
    else
        h2[t[i]] = s[i]
    end
end
puts "Yes"

Measured memory_bytes: 2632
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int a[9], b[9];

int main(){
    int T;
    std::cin >> T;

    REP(_, T){
        REP(i, 9){
            std::cin >> a[i];
        }
        std::sort(a, a+9);

        REP(i, 9){
            std::cin >> b[i];
        }

        int a_win = 0, b_win = 0;
        REP(i, 362880){// 9! = 362880
            int a_score = 0, b_score = 0;
            REP(j, 9){
                if(a[j] > b[j]){ // a win
                    a_score += a[j] + b[j];
                }else{ // b win
                    b_score += a[j] + b[j];
                }
            }

            if(a_score > b_score){a_win++;}
            else{b_win++;}

            std::next_permutation(a, a+9);
        }

        printf("%.5f %.5f\n", 1.0 * a_win / 362880, 1.0 * b_win / 362880);
    }
}

Measured memory_bytes: 1200
let g=List.fold_left(fun a s->a+.s)0.;;let rec f()=let n=read_float()in if n>0.then let l=List.map float_of_string(Str.split(Str.regexp" ")(read_line()))in f(Printf.printf"%f
"(sqrt(g(List.map(fun s->(s-.(g l/.n))**2.)l)/.n)));;f()

Measured memory_bytes: 4612
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
//#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
const ll INF=(1ll<<60)-1;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
void bfs(ll node, vector<ll> adj[],vector<bool> &visit,vector<ll> &dis)
{
    queue<ll> q;
    // ve<bool> visit(n+1);
    // ve<ll> dis(n+1);
    visit[node] = true;
    dis[node] = 0;
    q.push(node);
    while (!q.empty())
    {
        ll s = q.front();
        q.pop();
        // process node s
        for (auto u : adj[s])
        {
            if (visit[u])
                continue;
            visit[u] = true;
            dis[u] = dis[s] + 1;
            q.push(u);
        }
    }
}
void NumNodesInSubTree(int s, int e, vector <ll> adj[] , vector<ll> &count1 )
{
    count1[s] = 1;
    for (auto u : adj[s])
    {
        if (u == e)
        cont;
        NumNodesInSubTree(u, s,adj,count1);
        count1[s] += count1[u];
    }
}
class abc
{
    public:
    ll ind;
    ll val;
};
bool fun1(abc x,abc y)
{
    return x.val < y.val;
}
// bool fun2( abc x , abc y )
// {
//     return x.y < y.y ;
// }
void dfs( ll ind , vector<bool> &visit  , vector<ll> adj[] )
{
    visit[ind]=true;
    for(int i=0;i<adj[ind].size();i++)
    {
        if( !visit[ adj[ind][i]] )
        dfs(adj[ind][i],visit,adj);
    }
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    ll n,m;
    cin>>n>>m;
    //ll a[m];
    ll ans=0;
    rep(i,0,m)
    {
        ll x;
        cin>>x;
        ans+=x;
    }
    cout<<max((ll)-1 , n-ans);
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
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; }
using namespace std;

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int l,r; cin>>l>>r;
    if(r-l>=2019){
        cout<<0<<endl; return 0;
    }
    
    int ans = 2019;
    for(int i=l; i<=r; i++){
        for(int j=i+1; j<=r; j++){
            chmin(ans,(i*j)%2019);
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.io.*;
import java.util.Stack;
 
class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
        String[] exp = br.readLine().split(" ");
        Stack<Integer> stack = new Stack<Integer>();
 
        for (int i = 0; i < exp.length; i++) {
            if (exp[i].equals("+")) {
                stack.push(stack.pop() + stack.pop());
            } else if (exp[i].equals("-")) {
                stack.push(-stack.pop() + stack.pop());
            } else if (exp[i].equals("*")) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(exp[i]));
            }
        }
 
        System.out.println(stack.pop());
    }
}


Measured memory_bytes: 24484
mod = 10 ** 9 + 7


def mod_mul(a, b):
    return a * b % mod


N, M = map(int, input().split())
*x, = map(int, input().split())
*y, = map(int, input().split())

sx = sum(mod_mul(_x, i - (N - 1 - i)) for i, _x in enumerate(x))  # _x * i - _x * (N - 1 - i)
sy = sum(mod_mul(_y, i - (M - 1 - i)) for i, _y in enumerate(y))  # _y * i - _y * (M - 1 - i)
print(sx * sy % mod)


Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007LL

int main(){
  ll N;
  cin >> N;
  vector<vector<vvll>> dp(101, vector<vvll>(4, vvll(4, vll(4, 0LL))));
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 4; j++){
      for(int k = 0; k < 4; k++){
        dp.at(3).at(i).at(j).at(k) = 1LL;
      }
    }
  }
  //0...A, 1...T, 2...G, 3...C
  dp.at(3).at(0).at(2).at(3) = 0LL;
  dp.at(3).at(0).at(3).at(2) = 0LL;
  dp.at(3).at(2).at(0).at(3) = 0LL;
  for(int n = 3; n < 100; n++){
    for(int i = 0; i < 4; i++){
      for(int j = 0; j < 4; j++){
        for(int k = 0; k < 4; k++){
          if(j == 0 && k == 2){
            for(int l = 0; l < 4; l++){
              if(l == 3) continue;
              dp.at(n+1).at(j).at(k).at(l) += dp.at(n).at(i).at(j).at(k)%MOD;
              dp.at(n+1).at(j).at(k).at(l) %= MOD;
            }
          }
          else if(j == 0 && k == 3){
            for(int l = 0; l < 4; l++){
              if(l == 2) continue;
              dp.at(n+1).at(j).at(k).at(l) += dp.at(n).at(i).at(j).at(k)%MOD;
              dp.at(n+1).at(j).at(k).at(l) %= MOD;
            }
          }
          else if(j == 2 && k == 0){
            for(int l = 0; l < 4; l++){
              if(l == 3) continue;
              dp.at(n+1).at(j).at(k).at(l) += dp.at(n).at(i).at(j).at(k)%MOD;
              dp.at(n+1).at(j).at(k).at(l) %= MOD;
            }
          }
          else if((i == 0 && j == 1 && k == 2) || (i == 0 && j == 2 && k == 2) || (i == 0 && j == 2 && k == 1)){
            for(int l = 0; l < 4; l++){
              if(l == 3) continue;
              dp.at(n+1).at(j).at(k).at(l) += dp.at(n).at(i).at(j).at(k)%MOD;
              dp.at(n+1).at(j).at(k).at(l) %= MOD;
            }
          }
          else{
            for(int l = 0; l < 4; l++){
              dp.at(n+1).at(j).at(k).at(l) += dp.at(n).at(i).at(j).at(k)%MOD;
              dp.at(n+1).at(j).at(k).at(l) %= MOD;
            }
          }
        }
      }
    }
  }
  ll ans = 0;
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 4; j++){
      for(int k = 0; k < 4; k++){
        ans += dp.at(N).at(i).at(j).at(k)%MOD;
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
}

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

vector<double> input(int N){
    int i;
    vector<double> output(N);
    for(i=0;i<N;i++)cin>>output[i];
    return output;
}

int main(){
    int N,i;
    double result;
    vector<double> V;
    cin>>N;
    V=input(N);
    sort(V.begin(),V.end());
    result=(V[0]+V[1])/2;

    for(i=2;i<N;i++){
        result=(result+V[i])/2;
    }

    cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = 10**20
from heapq import heapify, heappop, heappush


def main():
    n = int(input())
    A = list(map(int, input().split()))

    L = A[:n]
    R = A[2*n:]
    R = list(map(lambda x:x*(-1), R))
    sum_l = [sum(L)]
    sum_r = [sum(R)]
    heapify(L)
    heapify(R)
    for i in range(n):
        elem = A[n+i]
        heappush(L, elem)
        sum_l.append(sum_l[-1] + elem - heappop(L))
    for i in range(n):
        elem = -A[2*n-1-i]
        heappush(R,elem)
        sum_r.append(sum_r[-1] + elem - heappop(R))
    ans = -INF
    sum_r = sum_r[::-1]
    for i in range(len(sum_l)):
        ans = max(ans, sum_l[i]+sum_r[i])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 116836
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    cin >> n;
    vector<long long> h(n);
    for(int i=0; i<n; i++) cin >> h[i];
    
    bool isYes = true;

    if(n == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    else if(n == 2) {
        if(h[0]>h[1]) {
            h[0]--;
            if(h[0]>h[1]) {
                isYes = false;
            }
        }
    }
    else {
        for(int i=n-1; i>=1; i--) {
            if(h[i]<h[i-1]) {
                h[i-1]--;
            }
        }
        
        for(int i=0; i<n-1; i++) {
            if(h[i]>h[i+1]) {
                isYes = false;
            }
        }
        
    }

    if(isYes) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}


Measured memory_bytes: 1152
#include <iostream>

int main() {
  int  number_of__contests, displayed_rating;
  int inner_rating = 0;
  std::cin >> number_of__contests >> displayed_rating;

  if(number_of__contests >= 10){
    inner_rating = displayed_rating;
  }
  else {
    inner_rating = displayed_rating + (100*(10-number_of__contests));
  }

  std::cout << inner_rating ;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    //          int[] split = Console.ReadLine().Split().Select(int.Parse).ToArray();

    public static void Main()
    {
        int[] split = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int W = split[0];
        int H = split[1];
        int X = split[2];
        int Y = split[3];
        int zero_or_one = 0;

        double juushin_x = 1.0 * W / 2;
        double juushin_y = 1.0 * H / 2;


        if (X * 2 == W && Y * 2 == H)
        {
            zero_or_one = 1;
        }

        double area = 1.0 * W * H / 2;

        Console.WriteLine(area + " " + zero_or_one);


    }



}

Measured memory_bytes: 13268