akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k;
	cin>>k;
	vector<ll> a(k);
	REP(i,k) cin>>a[i];
	reverse(ALL(a));
	ll l=2, r=2;
	REP(i,k) {
		if(r<a[i]) {
			cout<<-1<<endl;
			return 0;
		}
		ll nl=0, nr=r;
		if(l%a[i]!=0) nl=a[i]*(l/a[i]+1);
		else nl=l;
		if(nl>r) {
			cout<<-1<<endl;
			return 0;
		}
		nr-=r%a[i];
		nr+=a[i]-1;
		l=nl;
		r=nr;
	}
	cout<<l<<" "<<r<<endl;
}


Measured memory_bytes: 1024
def main():
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    total = sum(A)
    cnt = 0
    for i in range(N):
        if A[i] < total*1.0/(4.0*M):
            pass
        else:
            cnt += 1
    if cnt >= M:
        print("Yes")
    else:
        print("No")
main()

Measured memory_bytes: 3060
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Count(R *[][]int, A *[]int, ans *int, N, M, i int) {
  if i <= N {
    for a := (*A)[i - 1]; a <= M; a++ {
      (*A)[i] = a
      Count(R, A, ans, N, M, i + 1)
    }
  } else {
    cnt := 0
    for _, r := range (*R) {
      if (*A)[r[1]] - (*A)[r[0]] == r[2] { cnt += r[3] }
    }
    (*ans) = MaxInt(cnt, (*ans))
  }
}

func Solve() {
  var N, M, Q int
  NextInt(&N, &M, &Q)
  R := make([][]int, Q)
  for i := range R { NextIntVec(&R[i]) }
  A := make([]int, N + 1)
  A[0] = 1
  ans := 0
  Count(&R, &A, &ans, N, M, 1)
  Write(ans)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 1848
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;
 
stack<int> s;

/*
<stack>で使うもの
empty()　→　コンテナが空かどうかチェック
pop()　  →　要素を末尾から削除
push()　 →　要素を末尾に追加
top()　  →　末尾の要素を取得
size()　 →　要素数を取得
*/
 
int calc(string str){
    int x = s.top();
    s.pop();
    int y = s.top();
    s.pop();
     
    switch(str[0]){
        case '+':
            return x+y;
        case '-':
            return y-x;
        case '*':
            return x*y;
    }
    return y/x;
}
 
void judge(){
    string str;
     
    while(cin >> str){
        if(str=="+"||str=="-"||str=="*"||str=="/"){
            s.push(calc(str));
        }
        else{
            s.push(atoi(str.c_str())); //atoiはchar型なので変換する。
        }
    }
    cout << s.top() << endl;
}
 
 
int main(){
    judge();
    return 0;
}


Measured memory_bytes: 3200
from fractions import Fraction
x, y = list(map(int, input().split(' ')))

ls = []
for start in range(1, x + 1):
    if start < y:
        tmp = start
        turns = 0
        while tmp < y:
            tmp *= 2
            turns += 1

        f1 = Fraction(1, pow(2, turns))        
        ls.append(f1)

t = Fraction(0, 1)
for num in ls:
    t += num

t += Fraction(max(x - y + 1, 0), 1)

print(float(t) / x)

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

long long h, n;
vector<long long> a, b;
vector<vector<long long>> dp;

long long solve();

int main() {
  cin >> h >> n;
  a.resize(n);
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i] >> b[i];

  cout << solve() << endl;
  return 0;
}
long long solve() {
  long long res = 1e18;
  dp.assign(n + 1, vector<long long>(h + 10001, 1e17));
  dp[0][0] = 0;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j <= h + 10000; ++j) {
      dp[i + 1][j] = dp[i][j];
      if(j >= a[i])
        dp[i + 1][j] =
            min(dp[i + 1][j], dp[i + 1][j - a[i]] + b[i]);
      if(j >= h) res = min(res, dp[i + 1][j]);
    }
  }
  return res;
}

Measured memory_bytes: 160640
#include<iostream>
#include<string>
using namespace std;
string S;
int n;
int main() {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (n % 2 == 0 && S[i] == 'A') { n++; }
		if (n % 2 == 1 && S[i] == 'Z') { n++; }
	}
	if (n < 2) { cout << "-1" << endl; }
	else {
		for (int i = 0; i < n / 2; i++) {
			cout << "AZ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1180
import collections
mod = 998244353

n = int(input())
d = list(map(int, input().split()))

if d[0]!=0:
    print(0)
else:
    d.sort()
    d_max = d[-1]
    a = 1
    count = 0
    l = collections.Counter(d)
    for i in range(d_max+1):
        if l[i]==0:
            count +=1
            break

    if l[0]!=1:
        print(0)
        exit()

    if count ==1:
        print(0)
    else:
        for i in range(1,d_max+1):
            a = a*(l[i-1]**l[i])
        print(a%mod)

Measured memory_bytes: 62004
#include<stdio.h>
int main(void)
{
char str[4];
scanf("%s",str);

int i,a,b,c;//a,b,cはそれぞれがあることを示す
a=b=c=0;
for(i=0;i<3;++i){//フラグ分岐
	if(str[i]=='a') a=1;
	if(str[i]=='b')	b=1;
	if(str[i]=='c')	c=1;
}

if(a==0||b==0||c==0) printf("No\n");
else printf("Yes\n");

return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

const double pi = 3.141592653589793;
#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long LCM(long long x, long long y) {
	return x * y / GCD(x, y);
}

//give up
//infを低く設定しすぎてたせいで失敗
int Main() {
	ll n, m, x;
	const ll inf = pow(10, 7);
	ll ans = inf;

	scanll(n);
	scanll(m);
	scanll(x);
	vector<ll> yen(n, 0), und(m, 0);
	vector<vector<ll>> hon;
	hon.resize(n);
	for (auto& itr : hon) {
		itr.resize(m);
	}

	for (ll j = 0; j < n; j++) {
		scanll(yen[j]);
		for (ll i = 0; i < m; i++) {
			scanll(hon[j][i]);
		}
	}

	ll flag = 1;
	while (1) {
		ll cost = 0;
		fill(und.begin(), und.end(), 0);

		//calc cost
		for (ll i = 0; i < n; i++) {
			if (flag & (ll)pow(2, i)) {
				cost += yen[i];
				for (ll j = 0; j < m; j++) {
					und[j] += hon[i][j];
				}
			}
		}

		//clear check
		ll ok = true;
		for (auto& itr : und) {
			if (itr < x) {
				ok = false;
			}
		}

		if (ok) {
			ans = min(ans, cost);
		}

		flag++;
		if (flag == pow(2, 14)) break;
	}
	if (inf == ans) {
		printf("-1");
	}
	else {
		printll(ans);
	}

	return 0;
}

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

Measured memory_bytes: 4244
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n, y;
	cin>>n>>y; y /= 1000;
	for(ll i = 0; i <= y/10; i++){
		for(ll j = 0; j <= y/5; j++){
			ll k = y-10*i-5*j;
			if(k<0) continue;
			if(i+j+k==n){
				cout<<i<<" "<<j<<" "<<k<<endl;
				return 0;
			}
		}
	}
	puts("-1 -1 -1");
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000003;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

ll fac[1000005];
ll mul(ll a,ll b){return (a*b)%MOD;}
inline ll inv(int x){return POW(x,MOD-2);}
ll go(int x,int d,int n)
{
	if(d==0)return POW(x,n);
	ll t=POW(d,n);
	ll xx=mul(x,inv(d));
	if(xx+n-1>=1000003)return 0;
	ll res=mul(fac[xx+n-1],inv(fac[xx-1]));
	res=mul(res,t);
	return res;
}
int main(){
	fac[0]=1;
	fup(i,1,1000003,1)fac[i]=(fac[i-1]*i)%MOD;
	int q;
	scanf("%d",&q);
	while(q--)
	{
		int x,d,n;
		scanf("%d%d%d",&x,&d,&n);
		printf("%lld\n",go(x,d,n));
	}
}

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

int main(){
    int N,M;
    cin>>N>>M;
    vector<int>A(N),B(N);
    for(int i=0;i<N;i++)cin>>A[i]>>B[i];

    vector<pair<int,int>>AB(N);
    for(int i = 0; i < N; i++)
    {
        AB[i]=make_pair(A[i],B[i]);

    }
    sort(AB.begin(),AB.end());

    long long ans=0;
    for(int i = 0; i < N; i++)
    {
        int buy=min(M,AB[i].second);
        ans+=(long long)buy*AB[i].first;
        M-=buy;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

int LIS(vi in){//Longest Increasing Subsequence
	int n=in.size();
	vi out(n+1,inf);
	rep(i,n){
		*lower_bound(all(out),in[i])=in[i];
	}
	return lower_bound(all(out),inf)-out.begin();
}
int n;
vi in,out;
vvi G;
vi lis;
void dfs(int a,int p){
	int prei=lower_bound(all(lis),in[a])-lis.begin();
	int pre=lis[prei];
	lis[prei]=in[a];
	int t=lower_bound(all(lis),inf)-lis.begin();
	out[a]=t;
	rep(i,G[a].size()){
		int to=G[a][i];
		if(p==to)continue;
		dfs(to,a);
	}
	lis[prei]=pre;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n;
	in=out=vi(n);
	rep(i,n)cin>>in[i];
	G=vvi(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	lis=vi(n+1,inf);
	dfs(0,-1);
	rep(i,n)cout<<out[i]<<endl;
}


Measured memory_bytes: 33124
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define N 200005
vi par(2*N);
vi unionrank(2*N);
void init(int n)
{
    rep(i, n)
    {
        par[i] = i;
        unionrank[i] = 0;
    }
}
int root(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = root(par[x]);
    }
}
void unite(int x, int y)
{
    x = root(x);
    y = root(y);
    if (x == y)
    {
        return;
    }
    if (unionrank[x] < unionrank[y])
    {
        par[x] = y;
        }
    else
    {
        par[y] = x;
        if (unionrank[x] == unionrank[y])
        {
            unionrank[x]++;
        }
    }
}
bool same(int x, int y)
{
    return root(x) == root(y);
}
int main(){
    int n, k, l;
    cin >> n >> k >> l;
    init(2 * n);
    map<P, int> m;
    rep(i, k)
    {
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        unite(p, q);
    }
    rep(i,l){
        int r, s;
        cin >> r >> s;
        r--;
        s--;
        unite(s + n, r + n);
    }
    int a[n];
    int b[n];
    rep(i, n)
    {
        a[i] = root(i);
        b[i] = root(i + n);
    }
    rep(i,n){
        m[P(a[i], b[i])]++;
    }
    rep(i,n-1){
        cout << m[P(a[i], b[i])] << " ";
    }
    cout << m[P(a[n - 1], b[n - 1])] << endl;

    return 0;
}

Measured memory_bytes: 16768
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();
        char[][] s = new char[n][m];
        for(int i=0; i < s.length; i++){
            String t = sc.next();
            s[i] = t.toCharArray();
        }

        int res = 0;
        for(int i = 0; i < 1 << n; i++){
            for(int j = 0; j < 1 << m; j++){
                int count = 0;
                for(int c = 0; c < n; c++){
                    for(int d = 0; d < m; d++){
                        if(((i >> c & 1) == 1) && ((j >> d & 1) == 1)){
                            if(s[c][d] == '#'){
                                count++;
                            }
                        }
                    }
                }
                if(count == k){
                    res++;
                }
            }
        }
        pw.println(res);
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

  int N;
  cin >> N;

  cout << 800*N-(N/15)*200 << endl;

}


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

int main(){
  map <string, int> mp;
  string s;
  long long ans = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    sort(s.begin(), s.end());
    ans += mp[s];
    ++mp[s];
  }
  cout << ans << endl;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    int sum = 0;
    vector<int> a(n);
    for (int i= 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }

    int flag = 0;
    int t = (sum % (4*m) == 0 ? sum/(4*m) : sum/(4*m) + 1);
    for (int i = 0; i < n; i++){
        if (a[i] >= t){
            flag++;
        }
    }
    cout << (flag >= m ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
inline int read(void){
    char ch = getchar();
    int ans = 0;
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) ans = ans*10 + ch-'0', ch = getchar();
    return ans;
}
const int N = 5e5 + 7;
int n, m, c[N], pre[N], pos[N];
struct node{
    int l, r, id;
    bool operator<(const node& rh)const{
        return r < rh.r;
    }
}q[N];
int T[N], ans[N];
void add(int x, int y){
    for (; x <= n; x += x&(-x)) T[x] += y;
}
int query(int x){
    int ans = 0;
    for (; x >= 1; x -= x&(-x)) ans += T[x];
    return ans;
}
int main(void){
    n = read(), m = read();
    for (int i = 1; i <= n; ++i){
        c[i] = read();
        pre[i] = pos[c[i]];
        pos[c[i]] = i;
    } 
    for (int i = 1; i <= m; ++i){
        q[i].l = read(), q[i].r = read();
        q[i].id = i;
    }
    sort(q+1, q+m+1);
    int R = 0;
    //for (int i = 1; i <= n; ++i) printf("%d ", pre[i]); printf("\n");
    for (int i = 1; i <= m; ++i){
        while (R < q[i].r){
            ++R;
            if (pre[R]) add(pre[R], -1);
            add(R, 1);
        }
        ans[q[i].id] = query(q[i].r)-query(q[i].l-1);
    }
    for (int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 19340
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
 
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}

ll p[100010];
int main(){
	ll N,K;
	cin>>N>>K;
	rep(i,N){
		int a,b;
		cin>>a>>b;
		p[a]+=b;
	}
	ll cnt=0;
	REP(i,1,100001){
		cnt+=p[i];
		if(cnt>=K){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 1024
def trace( nums ):
	output = []
	for num in nums:
		output.append( str( num ) )
		output.append( " " )
	output.pop( )
	print( "".join( output )  )

n = int( raw_input( ) )
nums = [ int( val ) for val in raw_input( ).split( " " ) ]
trace( nums )

for i in range( 1, len( nums ) ):
	key = nums[i]
	j = i - 1
	while 0 <= j and key < nums[j]:
		nums[ j+1 ] = nums[j]
		j -= 1
	nums[ j+1 ] = key
	trace( nums )

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n,k;
    cin >> n >> k;
    long h[n];
    rep(i,0,n) cin >> h[i];
    sort(h, h+n);
    long long ans;
    for(int i=n-k-1; i>=0; --i) ans += h[i];
    cout << ans << "\n";




}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws IOException {
		Main instance = new Main();
		instance.execute();
	}
	
	private void execute() throws IOException {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		
		Map<String, String> encriptMap = getEncriptMap();
		Map<String, String> decriptMap = getDecriptMap();

		StringBuilder sb;
		StringBuilder result;
		String line;
		while((line = sc.readLine()) != null) {
			sb = new StringBuilder();
			for(int i = 0 ; i < line.length() ; i++) {
				sb.append(encriptMap.get(line.substring(i, i + 1)));
			}
			
			while(sb.length() % 5 > 0) {
				sb.append("0");
			}
			
			result = new StringBuilder();
			for(int i = 0 ; i < sb.length(); i = i + 5) {
				result.append(decriptMap.get(sb.substring(i, i + 5)));
			}
			System.out.println(result.toString());
		}
	}
	
	private Map<String, String> getEncriptMap() {
		Map<String, String> map = new HashMap<String, String>();
		map.put(" ", "101");
		map.put("'", "000000");
		map.put(",", "000011");
		map.put("-", "10010001");
		map.put(".", "010001");
		map.put("?", "000001");
		map.put("A", "100101");
		map.put("B", "10011010");
		map.put("C", "0101");
		map.put("D", "0001");
		map.put("E", "110");
		map.put("F", "01001");
		map.put("G", "10011011");
		map.put("H", "010000");
		map.put("I", "0111");
		map.put("J", "10011000");
		map.put("K", "0110");
		map.put("L", "00100");
		map.put("M", "10011001");
		map.put("N", "10011110");
		map.put("O", "00101");
		map.put("P", "111");
		map.put("Q", "10011111");
		map.put("R", "1000");
		map.put("S", "00110");
		map.put("T", "00111");
		map.put("U", "10011100");
		map.put("V", "10011101");
		map.put("W", "000010");
		map.put("X", "10010010");
		map.put("Y", "10010011");
		map.put("Z", "10010000");
		return map;
	}
	private Map<String, String> getDecriptMap() {
		Map<String, String> map = new HashMap<String, String>();
		map.put("00000", "A");
		map.put("00001", "B");
		map.put("00010", "C");
		map.put("00011", "D");
		map.put("00100", "E");
		map.put("00101", "F");
		map.put("00110", "G");
		map.put("00111", "H");
		map.put("01000", "I");
		map.put("01001", "J");
		map.put("01010", "K");
		map.put("01011", "L");
		map.put("01100", "M");
		map.put("01101", "N");
		map.put("01110", "O");
		map.put("01111", "P");
		map.put("10000", "Q");
		map.put("10001", "R");
		map.put("10010", "S");
		map.put("10011", "T");
		map.put("10100", "U");
		map.put("10101", "V");
		map.put("10110", "W");
		map.put("10111", "X");
		map.put("11000", "Y");
		map.put("11001", "Z");
		map.put("11010", " ");
		map.put("11011", ".");
		map.put("11100", ",");
		map.put("11101", "-");
		map.put("11110", "'");
		map.put("11111", "?");
		return map;
	}
}

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

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var deck = Console.ReadLine();
                if (deck == "-")
                {
                    break;
                }

                var m = int.Parse(Console.ReadLine());

                for (var i = 0; i < m; i++)
                {
                    var h = int.Parse(Console.ReadLine());
                    deck = deck.Substring(h) + deck.Substring(0, h);
                }

                Console.WriteLine(deck);
            }
        }
    }
}



Measured memory_bytes: 15924
def rle(t):
    tmp2, count_, ans_ = t[0], 1, []
    for i_ in range(1, len(t)):
        if tmp2 == t[i_]:
            count_ += 1
        else:
            ans_.append([tmp2, count_])
            tmp2 = t[i_]
            count_ = 1
    ans_.append([tmp2, count_])
    return ans_


S = list(input())

l = rle(S)
ans = [0] * (len(S) + 1)
count = 0
for i in range(len(l)):
    if l[i][0] == '<':
        for j in range(l[i][1] + 1):
            ans[count + j] = max(ans[count + j], j)
    elif l[i][0] == '>':
        for k in range(l[i][1] + 1):
            ans[count + k] = max(ans[count + k], l[i][1] - k)
    count += l[i][1]
print(sum(ans))


Measured memory_bytes: 36784
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final PrintStream so = System.out;
    static final Scanner sc = new Scanner(System.in);
    static final char BLACK = '0';
    static final char WHITE = '1';
    
    public static void main(String[] args) {
        char[] tiles = nsToChars();
        so.println(Math.min(count(tiles, BLACK), count(tiles, WHITE)));
    }
    
    static int count(char[] tiles, char start) {
        int count = 0;
        for (int i = 0; i < tiles.length; i++) {
            if (i % 2 == 0) {
                if (tiles[i] == start) {
                    count++;
                }
            } else {
                if (tiles[i] == rev(start)) {
                    count++;
                }
            }
        }
        return count;
    }
    
    static char rev(char c) {
        return c == BLACK ? WHITE : BLACK;
    }

    static int ni() {
        return sc.nextInt();
    }

    static long nl() {
        return sc.nextLong();
    }

    static String ns() {
        return sc.next();
    }

    static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    static int[] nints(int n, int padHead, int padTail) {
        int[] a = new int[padHead + n + padTail];
        for (int i = 0; i < n; i++)
            a[padHead + i] = ni();
        return a;
    }
}


Measured memory_bytes: 27988
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

int main() {
  char a, b;
  cin >> a >> b;
  if (a == b)
    cout << "=";
  else if (a > b)
    cout << ">";
  else
    cout << "<";
  cout << endl;
  return 0;
}

Measured memory_bytes: 3600
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

char A[55][55], B[55][55];
int n, m;
int func() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i + m > n || j + m > n) continue;

			int match = 1;
			for (int i1 = 0; i1 < m; i1++) {
				for (int j1 = 0; j1 < m; j1++) {
					match &= A[i + i1][j + j1] == B[i1][j1];
				}
			}

			if (match) return 1;
		}
	}

	return 0;
}
int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) scanf("%s", A[i]);
	for (int i = 0; i < m; i++) scanf("%s", B[i]);

	if (func()) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]

even_only = 0
odd_only = 0

if n > 1:
    even_only = n * (n - 1) / 2
if m > 1:
    odd_only = m * (m - 1) / 2

result = int(even_only + odd_only)
print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define US unordered_set
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef vector<vvi> vvvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

struct RAQ{
  ll size;
  ll *tree;
  RAQ(ll sz){
    ll logsize; for(logsize=0;(1ll<<logsize)<=sz;logsize++);
    size=(1ll<<logsize);
    tree=new ll[size*2-1]; REP(i,size*2-1) tree[i]=0;
  }
  void add(ll s,ll t,ll x){
    add(s,t,0,size,x,0);
  }
  void add(ll s,ll t,ll l,ll r,ll x,ll k){
    if(r<=s||t<=l||r<=l) return;
    if(l+1==r) {tree[k]+=x; return;}
    if(s<=l&&r<=t) {tree[k]+=x; return;}
    ll mid=(l+r+1)/2;
    add(s,t,l,mid,x,k*2+1);
    add(s,t,mid,r,x,k*2+2);
  }
  ll get(ll i){
    ll k=i+size-1;
    ll ret=tree[k];
    while(k){
      k=(k-1)/2;
      ret+=tree[k];
    }
    return ret;
  }
};


int main() {
  ll N,M; cin>>N>>M;
  RAQ raq(M+1);
  vi l(N),r(N); REP(i,N) cin>>l[i]>>r[i];
  vvpii v(M+1);
  REP(i,N) {
    v[r[i]-l[i]+1].PB({l[i],r[i]});
  }
  ll cnt=N;
  FOR(d,1,M+1) {
    for(pii p:v[d-1]) raq.add(p.first,p.second+1,1);
    cnt-=v[d-1].size();
    ll ans=cnt;
    for(ll i=0;i*d<=M;i++) ans+=raq.get(i*d);
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 17152
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(sc.nextInt());
        }
        if (n == set.size()) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 100692
n, a, b, c = map(int, input().split())
L = [int(input()) for _ in range(n)]

ans = float("inf")
for i in range(4**n):
  T = [0]*4
  C = [0]*4
  for j, l in enumerate(L):
    T[(i>>(2*j))&3] += l
    C[(i>>(2*j))&3] += 1
  ta, tb, tc = T[1:]
  if ta == 0 or tb == 0 or tc == 0:
    continue
  temp = 0
  temp += max(C[1]-1, 0)
  temp += max(C[2]-1, 0)
  temp += max(C[3]-1, 0)
  temp *= 10
  temp += abs(a-ta) + abs(b-tb) + abs(c-tc)
  ans = min(ans, temp)
print(ans)

Measured memory_bytes: 73652
#include <iostream>
#include <vector>
#include <cstring>

#define DAY_MAX 30

using namespace std;
using LL = long long;

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;

        LL maps[n];
        int scds[n];

        memset(maps, 0, sizeof(maps));
        memset(scds, 0, sizeof(maps));

        int c, f;
        for (int i = 0; i < n; i++) {
            maps[i] = 1L << i;
            cin >> c;
            for (int j = 0; j < c; j++) {
                cin >> f;
                scds[i] |= 1 << (f - 1);
            }
        }

        int i = 0;
        bool complete = false;
        for (; i < DAY_MAX; i++) {
            vector<int> meets;
            LL gathers = 0;
            for (int j = 0; j < n; j++) {
                if (scds[j] >> i & 1) {
                    meets.push_back(j);
                    gathers |= maps[j];
                }
            }
            if (gathers == (1L << n) - 1) {
                complete = true;
                break;
            }
            for (int j : meets) {
                maps[j] = gathers;
            }
        }

        if (complete)
            cout << i + 1 << endl;
        else
            cout << -1 << endl;
    }
}


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

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0) : d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    UnionFind uf(12);
    uf.unite(1, 3);
    uf.unite(3, 5);
    uf.unite(5, 7);
    uf.unite(7, 8);
    uf.unite(8, 10);
    uf.unite(10, 12);
    uf.unite(4, 6);
    uf.unite(6, 9);
    uf.unite(9, 11);
    int x, y;
    cin >> x >> y;
    if (uf.same(x, y)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 500006
using namespace std;
int l=200001,r,q,t,f,c;
char p[N];
string s;
bool flag;
int main(){
	cin>>s;
	for(int i=200001;i<=s.size()+200000;i++)p[i]=s[i-200001];
	r=s.size()+200000;
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>t;
		if(t==1)flag^=1;
		else{
			cin>>f;
			if(f==1){
				if(flag)cin>>p[++r];
				else cin>>p[--l];
			}else{
				if(flag)cin>>p[--l];
				else cin>>p[++r];
			}
		}
	}
	if(flag)for(int i=r;i>=l;i--)cout<<p[i];
	else for(int i=l;i<=r;i++)cout<<p[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 4024
import java.util.*;

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

        int varN   = Integer.parseInt(scan.next());
        int kill   = Integer.parseInt(scan.next());
        Integer[] health = new Integer[varN];

        for(int i=0; i<varN; i++){
            health[i] = Integer.parseInt(scan.next());
        }

        if(varN <= kill){
            System.out.println(0);
        }else{
            Arrays.sort(health, Comparator.reverseOrder() );

            long attack = 0;
            for(int i=kill; i<varN; i++){
                attack += health[i];
            }
            System.out.println(attack);
        }

    }
}

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

int main() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        s = s[s.size()-1] + s.substr(0, s.size() - 1);
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

using namespace std;

const int MAX = 1 << 15;
bool is_prime[MAX];

void sieve() {
    fill(is_prime, is_prime + MAX, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= MAX; i++) {
        if (!is_prime[i]) continue;
        for (int j = i * i; j < MAX; j += i)
            is_prime[j] = false;
    }
}

int main(void) {
    sieve();
    
    int n;
    while (cin >> n, n) {
        int ans = 0;
        for (int i = 2; i <= n - i; i++)
            if (is_prime[i] && is_prime[n - i]) ans++;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3032
x,n=map(int,input().split())
P=list(map(int,input().split()))
Q=[-1,0]
for i in range(1,102):
    if i not in P:
        Q.append(i)

ans=10**9
A=[]
for i,q in enumerate(Q):
    A.append([i,abs(q-x)])
A.sort(key=lambda x:(x[1],x[0]))
print(Q[A[0][0]])

Measured memory_bytes: 61956
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            // int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int b = int.Parse(input[0]);
            int c = int.Parse(input[1]);
            // 文字列の入力
            //string s = Console.ReadLine();
            
            if (b<=9 && c<=9) Console.WriteLine(b*c);
            else
            {
                Console.WriteLine(-1);
            }

        }
    }
}


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

int main(){
    int n ; cin >> n ;
    vector<int> a(n) ;
    long long int sum = 0 ;
    for(int i=0;i<n;i++){
        cin >> a.at(i) ;
        sum += a.at(i) ;
    }
    sort(a.begin(),a.end()) ;
    cout << a.at(0) << " " << a.at(n-1) << " " << sum << endl ;
}


Measured memory_bytes: 3208
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <cmath>
    using namespace std;
     
    bool IsOneBit(long long bits, int i) {
    	return (bits & (1ll << i)) > 0;
    }
    int main() {
    	int N;
    	const int M = 1000000007;
    	cin >> N;
    	vector<long long> A(N);
    	long long AMax = 0;
    	for (int i = 0; i < N; i++) {
    		cin >> A[i];
    		AMax = max(A[i], AMax);
    	}
    	int digit = log2(AMax);
    	long long ans = 0;
    	for (int i = 0; i <= digit; i++) {
    		long long zero = 0, one = 0;
    		for (long long a : A) {
    			if (IsOneBit(a, i))one++;
    			else zero++;
    		}
    		long long k = (1ll << i) % M;
    		k = k * one % M;
    		k = k *zero % M;
    		ans = (ans + k) % M;
    	}
    	cout << ans << endl;
    }

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

constexpr long long int mod = 1e9 + 7;

long int solve(long long int x, long long int n) {
	long int num = 1;
	
	for (long int i = 0; i < n; i++) {
		num = num * x % mod;
	}
	return num;
}

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

	long long int ans = solve(10, n) - solve(9, n) - solve(9, n) + solve(8, n);
	ans %= mod;
	ans = (ans + mod) % mod;

	cout << ans << endl;
}


Measured memory_bytes: 3612
def main():
    n = int(input())
    a = [int(s) for s in input().split()]
    print(solve(a))

def solve(a):
    n = len(a)
    b = [a[i] - i for i in range(n)]
    b.sort()

    c = b[n // 2]

    return sum(abs(bi - c) for bi in b)

main()


Measured memory_bytes: 26128
package main

import (
	"bufio"
	"fmt"
	"os"
	"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 getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	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)
	aa := make([]int, n)
	ll := make([]int, n+2)
	rr := make([]int, n+2)

	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}

	for i := 0; i < n; i++ {
		ll[i+1] = aa[i]
		rr[n-i] = aa[n-i-1]
		if ll[i+1] < ll[i] {
			ll[i+1] = ll[i]
		}
		if rr[n-i] < rr[n-i+1] {
			rr[n-i] = rr[n-i+1]
		}
	}

	for i := 1; i <= n; i++ {
		ans := ll[i-1]
		if ll[i-1] < rr[i+1] {
			ans = rr[i+1]
		}
		fmt.Fprintln(writer, ans)
	}

	writer.Flush()
}


Measured memory_bytes: 10624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x = x2 - x1, y = y1 - y2;
  cout << x2 + y << " " << y2 + x << " " << x1 + y << " " << y1 + x << endl;
  return 0;
}


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

int main() {
  int A,B,C; cin >>A>>B>>C;
  bool hantei=false;
  if(A+B+C==17){
    if(A==5||A==7){
      if(B==5||B==7){
        hantei=true;
      }
    }
  }
  if(hantei){
    cout<<"YES"<<endl;
  }else {
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
const M: usize = 1_000_000_007;

fn main() {
    input! {
        s: chars,
    }

    // n, mod
    let mut dp = vec![vec![0; 13]; s.len() + 1];
    dp[0][0] = 1;

    let mut p = vec![0; s.len()];
    p[s.len() - 1] = 1;
    for i in (0..s.len() - 1).rev() {
        p[i] = p[i + 1] * 10 % 13;
    }

    for i in 0..s.len() {
        for j in 0..13 {
            if s[i] == '?' {
                for k in 0..10 {
                    let nmod = (j + k * p[i]) % 13;
                    dp[i + 1][nmod] += dp[i][j];
                    dp[i + 1][nmod] %= M;
                }
            } else {
                let nmod = (j + (s[i] as usize - '0' as usize) * p[i]) % 13;
                dp[i + 1][nmod] += dp[i][j];
                dp[i + 1][nmod] %= M;
            }
        }
    }
    println!("{}", dp[s.len()][5]);
}


Measured memory_bytes: 20732
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
   unsigned short *A,*B;
   
   int C[VMAX+1];
   int n,i,j;
   scanf("%d", &n);
   
   A=malloc(sizeof(short)*n +1);
   B= malloc(sizeof(short)*n+1);

   for(i=0; i<=VMAX; i++) C[i]=0;
      
   for(i=0; i<n; i++){
      scanf("%hu", &A[i+1]);
      C[A[i+1]]++;
   }

   for( i= 1; i<=VMAX; i++) C[i]=C[i]+C[i-1];

   for(j=1;j<=n; j++){
      B[C[A[j]]] = A[j];
      C[A[j]]--;
   }

   for( i = 1; i<=n; i++){
      if(i>1) printf(" ");
      printf("%d",B[i]);
   }
   printf("\n");
 
   return 0;
}


Measured memory_bytes: 9568