akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 2005000
#define MOD 1000000007
#define N 200005
#define M 1000005
#define LOG 60
#define KOK 4000000
using namespace std;

bool form(int x,int y,int z) {

	return (z>=x+1 && z<=x+y/2);

}

int main() {

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

	map<int,int> mp;
	int n,x;

	scanf("%d",&n);

	for(int i=1;i<=n;i++) {

		scanf("%d",&x);

		mp[x]++;

	}

	if(sz(mp)>2 || (sz(mp)==2 && (mp.begin()->st+1!=next(mp.begin())->st || !form(mp.begin()->nd,next(mp.begin())->nd,next(mp.begin())->st))) || (sz(mp)==1 && (mp.begin()->nd/2<mp.begin()->st && mp.begin()->st!=n-1))) {

		printf("No");

	}
	else printf("Yes");

}



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

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

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

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

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

    if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)||s.at(1)==s.at(2)&&s.at(2)==s.at(3)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	rep(i, 1000) {
		stringstream ss;
	    ss << setw(3) << setfill('0') << i;
	    string str = ss.str();
	    int k = 0;
	    rep(j, N) {
	    	if (S[j] == str[k]) {
	    		++k;
	    		if (k == 3) break;
	    	}
	    }
	    if (k == 3) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())

c=list(input())

minimum=len(c)
W=0
R=c.count('R')

for i in range(0,len(c)):
    if c[i]=='W':
        W += 1
    else :
        R -= 1
    min_i=max(W,R)
    if min_i < minimum:
        minimum=min_i

if c.count('R')==0:
    minimum=0

print(minimum)

Measured memory_bytes: 81700
#include <stdio.h>

int main(void) {
    int a,n,i,min=1000000,max=-1000000;
    long int sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum+=a;
        if(min>a)
            min=a;
        if(max<a)
            max=a;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 998244353

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

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

int N, K, Q;
vector<int> A;

#define INF 1123456789


void init()
{
	cin >> N >> K >> Q;
	rep(i, N) A.PB(GET<int>());
}

void add(int x, int& pos, vector<int>& v)
{
	priority_queue<int, vector<int>, greater<int>> q;
	for (; pos < N && A[pos] >= x; pos++) {
		q.push(A[pos]);
	}
	int l = q.size();
	rep(i, l-K+1) {
		v.PB(q.top());
		q.pop();
	}
}

int calc(int x)
{
	vector<int> v;
	for (int pos = 0; pos < N; pos++) {
		while (pos < N && A[pos] < x) pos++;
		add(x, pos, v);
	}
//	rep(i, v.size()) {
//		cout << v[i] << " ";
//	}
//	cout << endl;
	if ((int) v.size() < Q) {
		return INF;
	}
	sort(all(v));
	return v[Q-1] - x;
}

void solve()
{
	int res = INF;
	rep(i, N) {
		res = min(res, calc(A[i]));
	}
	cout << res << endl;
}





Measured memory_bytes: 256
s = [i for i in input()]
atgc = {"A","T","G","C"}
tmp = 0
lng = 0
for p in s:
  if p in atgc:
    tmp += 1
  else:
    if tmp > lng:
      lng = tmp
    tmp = 0
if tmp > lng:
  lng = tmp
print(lng)

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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;

#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--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

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

#define FIND(a,b) find(all(a),b)!=a.end()

int main(){
	int n;cin>>n;
	vector<int> x(n),y(n);
	rep(i,n)cin>>x[i];
	y=x;
	sort(all(x));
	if(x[n/2-1]==x[n/2])rep(i,n)cout<<x[n/2-1]<<endl;
	else{
		double h;
		h=x[n/2-1]+0.5;
		rep(i,n){
			if(y[i]>h)cout<<x[n/2-1]<<endl;
			else cout<<x[n/2]<<endl;
		}
	}
}



Measured memory_bytes: 3712
n = int(input())
restaurants = []
for i in range(n):
  tmp = input().split()
  tmp[1] = int(tmp[1])
  tmp.append(i+1)
  restaurants.append(tmp)
ans = sorted(restaurants, key=lambda x:(x[0],-x[1]))
for i in ans:
    print(i[2])

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

int main(){
  int n;
  cin >> n;
  vector<int>xx(n);
  vector<int>yy(n);
  vector<int>hh(n);
  for (int i = 0 ; i< n; i++){
    cin >> xx.at(i) >> yy.at(i) >> hh.at(i);
  }
   bool a = false;
  for (int j = 0; j <=100 ; j++){
    if (a)
      break;
    for (int k = 0; k <= 100 ; k++){
      if (a)
        break;     
      bool b = false;
      for (int i = 0; i < n; i++){
        if (a) 
          break;
        if(b)
          break;
        if (hh.at(i) == 0){
          continue;
        }
        else{
          int h = hh.at(i) + abs(xx.at(i) - j) + abs(yy.at(i) - k);
          for (int l = 0; l < n ; l++){
            if (max(h - abs(xx.at(l)-j)-abs(yy.at(l)- k),0) == hh.at(l)){
              if (l == n-1){
                a = true;
                cout << j << ' ' << k << ' ' << h << endl;
              }
              else
                continue;
            }
            else{
              b = true;
              break;
            }
          }
        }
      }
    }
  }
}
  
              
              
         


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  int m = (n-1)/2;
  int flag = 0;
  for(int i;i<m;i++){
    if(s.at(i)!=s.at(i+m+1)){
      flag += 1;
    }
  }
  if(flag==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

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

func main() {
	a, b, x := readFloat64(), readFloat64(), readFloat64()
	if x <= a*a*b/2 {
		z := 2 * x / a / b
		fmt.Println(math.Atan(b/z) * 180 / math.Pi)
	} else {
		z := 2*x/a/a - b
		fmt.Println(math.Atan((b-z)/a) * 180 / math.Pi)
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */

#include <bits/stdc++.h>

using namespace std;

class EGluttony {
    const long long INF = 1ll << 60;

public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        long long k;
        in >> n >> k;
        vector<int> A(n), F(n);
        for (int &x: A) {
            in >> x;
        }
        for (int &x: F) {
            in >> x;
        }
        sort(A.begin(), A.end());
        sort(F.rbegin(), F.rend());
        long long res = search(A, F, k);
        out << res << "\n";
    }

    long long search(const vector<int> &A, const vector<int> &B, long long k) {
        long long from = 0, to = INF;
        while (from < to) {
            long long mid = (from + to) / 2;
            if (f(mid, A, B, k)) {
                to = mid;
            } else {
                from = mid + 1;
            }
        }
        return to;
    }

    bool f(long long maxi, const vector<int> &A, const vector<int> &B, long long k) {
        if (maxi == 1) {
            k = 2 * k / 2;
        }
        for (int i = 0; i < A.size(); i++) {
            long long a = A[i], b = B[i], ab = a * b;
            if (ab > maxi) {
                long long delta = (ab - maxi + b - 1) / b;
                k -= delta;
                if (k < 0) {
                    return false;
                }
            }
        }
        return true;
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    EGluttony solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


Int inf = pow(10, 9)+7;


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

    Int n, k;
    Int c[2001][2001];
    cin >> n >> k;

    c[0][0] = 1;
    for(Int i=1; i<=2000; i++){
        c[i][0] = 1;
        for(Int j=1; j<=2000; j++){
            if(i == j){
                c[i][j] = 1;
                continue;
            }
            if(i < j){
                c[i][j] = 0;
                continue;
            }
            c[i][j] = c[i-1][j]%inf + c[i-1][j-1]%inf;
        }
    }
    for(Int i=1; i<=k; i++){
        Int c1 = c[n-k+1][i] * c[k-1][i-1];
        cout << c1%inf << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 31488
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a, b, h = nin(3)

print((a + b) * h // 2)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b){
		printf("a < b\n");
	}
	if (a > b){
		printf("a > b\n");
	}
	if (a == b){
		printf("a == b\n");
	}
	return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  cout << s;
  if (s[n-1] == 's') {
    cout << "es";
  } else {
    cout << "s";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    ll n;
    cin >> n;
    vector<ll> c(87);
    c.at(0) = 2;
    c.at(1) = 1;
    for(int i = 2; i < 87; i++){
        c.at(i) = c.at(i-1) + c.at(i-2);
    }
    cout << c.at(n);
}  

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

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

using namespace std;

int main(){
	int a,b;
	char s[16];
	scanf("%d%d%s",&a,&b,s);

	puts(count(s,s+a+b+1,'-')==1&&s[a]=='-'?"Yes":"No");

	return 0;
}


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

var d [100000]int

func bs(k, l, r int) int {
	for l <= r {
		m := (l + r) / 2
		if d[m] < k {
			r = m - 1
		} else {
			l = m + 1
		}
	}
	return l
}

func main() {
	n := nextInt()
	for i := 0; i < n; i++ {
		d[i] = -1
		a := nextInt()
		j := bs(a, 0, i-1)
		d[j] = a
	}
	ans := bs(0, 0, n-1)
	fmt.Println(ans)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#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__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
	if (b == 0) {
		x = (a >= 0) ? 1 : -1;
		y = 0;
		return abs(a);
	}
	else {
		ll res = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
		return res;
	}
}

ll mod_inverse(ll a, ll m) {
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

vector<ll> f(100005);

ll P(ll n, ll k) {
	if (n < k) return 0;
	return (f[n] * mod_inverse(f[n - k], MOD)) % MOD;
}


//組合せ
//nCk mod MODを返す
ll C(ll n, ll k) {
	if (n < 0) return 0;
	return (P(n, k) * mod_inverse(f[k], MOD)) % MOD;
}

signed main() {
	ll n, a;

	cin >> n;

	vector<pair<ll, ll>> v(n, make_pair(0, 0));
	ll left = 0;
	ll right = 0;

	REP(i, n + 1) {
		cin >> a;
		if (v[a - 1].first > 0) {
			left = v[a - 1].second;
			right = i;
		}
		else {
			v[a - 1] = make_pair(1, i);
		}
	}

	//cout << left << " " << right << endl;

	f[0] = 1;
	FOR(i, 1, 100005) {
		f[i] = (f[i - 1] * i) % MOD;
	}

	ll x, y;

	REP(i, n + 1) {
		x = left + (n - right);
		if (x < i) {
			cout << C(n + 1, i + 1) << endl;
		}
		else {
			y = C(n + 1, i + 1);
			y -= C(x, i);
			y %= MOD;
			y += MOD;
			y %= MOD;
			cout << y << endl;
		}
	}
}

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

using int64 = long long;

int main() {
  int64 n, k;
  cin >> n >> k;
  vector<int64> A(n);
  for (int64& a : A)
    cin >> a;
  vector<int64> F(n);
  for (int64& f : F)
    cin >> f;
  sort(A.begin(), A.end());
  sort(F.begin(), F.end());
  
  int64 ok = A.back() * F.back();
  int64 ng = -1;
  while (abs(ok - ng) > 1) {
    int64 m = (ok + ng) / 2;
    int64 cost = 0;
    for (int64 i = 0, j = n - 1; i < n; ++i, --j) {
      int64 d = m / F[j] - A[i];
      if (d < 0)
        cost -= d;
    }
    if (cost <= k)
      ok = m;
    else
      ng = m;
  }
  cout << ok << "\n";

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
 
using namespace std;
 
int N,tmp,mincost,ans;
 
int main(){
  mincost = IINF, ans = -IINF;
  cin >> N;
  rep(_,N){
    cin >> tmp;
    if(mincost!=IINF)ans = max(ans,tmp-mincost);
    mincost = min(tmp,mincost);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  vl a(n + 1, 0), b(n + 1, 0);
  rep(i, n) {
    ll x;
    cin >> x;
    a[i + 1] = a[i] + x;
    b[i + 1] = b[i] + max(0LL, x);
  }
  ll ans = -1e18;
  rep(i, n - k + 1) {
    ll now = max(0LL, a[k + i] - a[i]);
    now += b[i] + b[n] - b[k + i];
    ans = max(ans, now);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4808
a,b,c = map(int,input().split())
if a == 5:
    if b == 5:
        if c == 7:
            print("YES")
        else:
            print("NO")
    if b == 7:
        if c == 5:
            print("YES")
        else:
            print("NO")
if a == 7:
    if b == 5:
        if c == 5:
            print("YES")
    else:
        print("NO")


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

bool check(string s1){
    string s2 = s1;
    reverse(s1.begin(), s1.end());
    for(int i = 0; i < s1.size(); i++){
        if(s1[i] != s2[i]) return 1;
    }
    return 0;
}

int main(){
    string s1; cin >> s1;
    string sc = s1;

    int N = s1.size();

    if(check(sc)) {
        cout << "No" << endl;
        return 0;
    }

    string s2 = s1.substr(0, (N-1)/2);
    sc = s2;
    if(check(sc)) {
        cout << "No" << endl;
        return 0;
    }

    string s3 = s1.substr((N+3)/2-1);
    sc = s3;
    if(check(sc)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


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

const int mn=2e5+8,mod=998244353;
LL ans,fac[mn],inv[mn];
LL poww(LL a,LL b) {LL ans=1,t=a;while(b) {if(b&1) ans=ans*t%mod;t=t*t%mod;b>>=1;}return ans;}

LL C(int n,int m)
{
	if(m>n) return 0;
	return (fac[n]*inv[m]%mod)*inv[n-m]%mod;
}

int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	inv[0]=fac[0]=1;
	for(int i=1;i<mn;++i) fac[i]=fac[i-1]*i%mod;
	inv[mn-1]=poww(fac[mn-1],mod-2);
	for(int i=mn-2;i>=1;--i) inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=0;i<=k;++i) {
		ans=(ans+(C(n-1,i)*m%mod)*poww(m-1,n-i-1)%mod)%mod;
	}
	cout<<ans;
}

Measured memory_bytes: 6880
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

 //   Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    int k = cin.nextInt();
    int[] height = new int[n];

    for (int i=0;i<n;i++) {
      height[i] = cin.nextInt();
    }
    Arrays.sort(height);
    int diff = Integer.MAX_VALUE;
    for (int i=k-1;i<n;i++) {
      int min = height[i-(k-1)];
      int max = height[i];
      int diffTemp = max - min;
      if (diffTemp < diff) {
        diff = diffTemp;
      }
    }

    System.out.println(diff);

  }

}

Measured memory_bytes: 50704
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <iomanip>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef pair<int,int> PI;
#ifndef M_PI
const double M_PI=acos(-1);
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second

int tx[]={1,0,-1,-1,0,1},ty[]={1,1,0,-1,-1,0};

bool vis[1<<16];
int cost[20][20];

main(){
  int n;
  while(cin >> n){
    if(n==0) break;
    memset(vis,0,sizeof(vis));
    for(int i=0;i<n;i++){
      for(int j=0;j<=n;j++){
	cin >> cost[i][j];
      }
    }
    priority_queue<pair<int,int> >q;
    q.push(mp(0,0));
    int ans=0;
    while(!q.empty()){
      int c=-q.top().F,cst=q.top().S;
      q.pop();
      if(vis[cst])continue;
      vis[cst]=true;
      if(cst==(1<<n)-1){
	ans=c;
	break;
      }
      rep(i,n){
	if((cst>>i)&1)continue;
	int ntime=cost[i][0];
	rep(j,n){
	  if((cst>>j)&1)ntime=min(ntime,cost[i][j+1]);
	}
	q.push(mp(-c-ntime,cst|(1<<i)));
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int main() {
    int N,ans = INF;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        int a, b = 0;
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            b++;
        }
        ans = min(ans, b);
    }
    cout << ans << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
// 剰余演算
constexpr ll p = 1000000007LL; // 10^9+7
ll powll(ll a, ll n) {
    if (n == 0) {
        return 1LL;
    } else if (n == 1) {
        return a % p;
    } else {
        ll temp = powll(a, n/2);
        temp = temp * temp % p;
        return n % 2 ? temp * a % p : temp;
    }
}

inline ll invll(ll a) { return powll(a, p-2); }

vector<ll> fac_cache = {1}, invfac_cache = {1};
void make_fac_cache(ll a) {
    ll old_max = fac_cache.size() - 1;
    if (a > old_max) {
        fac_cache   .resize(a+1);
        invfac_cache.resize(a+1);
        for (ll i = old_max + 1; i <= a; i++) {
            fac_cache[i] = fac_cache[i-1] * i % p;
        }
        invfac_cache[a] = invll(fac_cache[a]);
        for (ll i = a-1; i > old_max; i--) {
            invfac_cache[i] = invfac_cache[i+1] * (i + 1) % p;
        }
    }
}

inline ll    facll(ll a) { make_fac_cache(a); return a < 0 ? 0 : fac_cache[a]; }
inline ll invfacll(ll a) { make_fac_cache(a); return a < 0 ? 0 : invfac_cache[a]; }
inline bool isoutll(ll n, ll r) { return n < 0 || r < 0 || n < r; }
inline ll nPr(ll n, ll r) { return isoutll(n, r) ? 0 : facll(n) * invfacll(n-r) % p; }
inline ll nCr(ll n, ll r) { return isoutll(n, r) ? 0 : facll(n) * invfacll(n-r) % p * invfacll(r) % p; }

// 処理内容
int main() {
    
    ll n, k; cin >> n >> k;

    make_fac_cache(100000);
    RANGE(i, 1, k) {
        cout << nCr(n-k+1, i) * nCr(k-1, i-1) % p << endl;
    }
    
}

Measured memory_bytes: 1792
n = int(input())
string_list = [input() for i in range(n)]
ac = 0
wa = 0
tle = 0
re = 0
for s in string_list:
    if (s == "AC"):
        ac = ac + 1
    elif (s == "TLE"):
        tle = tle + 1
    elif (s == "WA"):
        wa = wa + 1
    else:
        re = re + 1
print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)


Measured memory_bytes: 82836
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/11/20 19:53:47
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int mpow(int x, int p, int mod) {
  ll u = x;
  ll t = 1;
  while (p) {
    if (p&1)
      (t *= u) %= mod;
    (u *= u) %= mod;
    p >>= 1;
  }
  return t;
}

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

  int n;
  cin>>n;
  string x;
  cin>>x;
  int pc = 0;
  for (auto c:x)
    if (c == '1')
      pc++;

  vector<int> ans(n);
  int a = pc+1;
  int b = pc-1;
  int nma = 0, nmb = 0;
  for (int i = 0; i < n; i++) {
    if (x[n-1-i] == '0') continue;
    (nma += mpow(2, i, a)) %= a;
    if (b > 0)
      (nmb += mpow(2, i, b)) %= b;
  }

  for (int i = 0; i < n; i++) {
    if (x[i] == '0') {
      int cnma = (nma + mpow(2, n-1-i, a)) % a;
      int cnt = 1;
      while (cnma) {
        cnma %= __builtin_popcount(cnma);
        cnt++;
      }
      ans[i] = cnt;
    } else {
      if (b == 0) {
        ans[i] = 0;
        continue;
      }
      int cnmb = (nmb + b - mpow(2, n-1-i, b)) % b;
      int cnt = 1;
      while (cnmb) {
        cnmb %= __builtin_popcount(cnmb);
        cnt++;
      }
      ans[i] = cnt;
    }
  }

  for (auto a:ans)
    cout << a << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double lb; 

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> L(M),R(M);
    rep(i,M){
        cin >> L[i] >> R[i];
    }

    ll maxValue=LLONG_MAX,minValue=0;
    rep(i,M){
        minValue = max(minValue,L[i]);
        maxValue = min(maxValue,R[i]);
    }

    //cout << maxValue << minValue << endl;
    ll ans=0;
    rep(i,N+1){
        if(minValue <= i+1 && i+1 <= maxValue){
            ans++;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 1792
#include <iostream>

int main() {
  
  int a, b, c = 0;
  std::cin >> a >> b >> c;
  
  if (a + b + c == 17) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }


  return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

int solve(){
  int h, n;  cin >> h >> n;
  int sum = 0;
  for(int i=0; i<n; i++){
    int v;  cin >> v;
    sum += v;
  }
  cout << (sum>=h ? "Yes" : "No") << endl;
}

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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <set>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <iomanip>
#include <utility>

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int x, y;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("arithm.in", "r", stdin);
	//freopen("arithm.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> x >> y;
	cout << x + y / 2;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

def grading(m, f, r)
  return 'F' if m * f < 0 || m + f < 30
  return 'A' if m + f >= 80
  return 'B' if m + f >= 65
  return 'C' if m + f >= 50 || r >= 50
  'D'
end

while (m, f, r = gets.chomp.split.map(&:to_i)) != [-1, -1, -1]
  puts grading(m, f, r)
end

Measured memory_bytes: 6884
import math

N,*CSFf = map(int, open(0).read().split())
C = [x for x in CSFf[0::3]]
S = [x for x in CSFf[1::3]]
F = [x for x in CSFf[2::3]]
ans = [0] * N
for i in range(N-1):
    temp = S[i] + C[i]
    for j in range(i+1,N-1):
        if temp <= S[j]:
            temp = S[j] + C[j]
        else:
            temp = math.ceil(temp/F[j]) * F[j] + C[j]
    ans[i] = temp
for x in ans:
    print(x)

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

int main() {
  int N, C=0, m;
  cin >> N;
  for (int i=1; i<=N; i+=2) {
    m=0;
    for (int j=1; j<=i; j+=2) {
      if (i%j==0) {
        m++;
      } 
    }
    if (m==8) {
      C++;
    }
  }
  cout << C << endl;
} 


Measured memory_bytes: 3576
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ABX = Console.ReadLine().Split(' ');
            double a = double.Parse(ABX[0]);double b = double.Parse(ABX[1]);
            double x = double.Parse(ABX[2]);
            double tri,hi,hei,atan,kaku,kaku2;
            double h = x / (a * a);
            if(h<(b/2.0))
            {
                hi = a * h;
                tri = (2.0 * hi) / b;
                atan = Math.Atan(tri / b);
                kaku = (atan * 180) / Math.PI;
                kaku2 = 180 - 90 - kaku;
            }
            else
            {
                hi = b - h;
                hei = a * hi;
                tri = (2.0 * hei) / a;
                atan = Math.Atan(a / tri);
                kaku = (atan * 180) / Math.PI;
                kaku2 = 180 - 90 - kaku;
            }
            Console.WriteLine(kaku2);
        }
    }
}


Measured memory_bytes: 27724
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  string a, b;
  cin >> a >> b;
  string n = a + b;
  int num = stoi(n);
  for(int i=1;i*i<=num;i++){
    if(i * i == num){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

ll gcd(ll a, ll b) {
  ll r;
  while (r = a % b) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll C1 = (A - 1) / C, C2 = B / C, D1 = (A - 1) / D, D2 = B / D,
     CD1 = (A - 1) / (C * D / gcd(C, D)), CD2 = B / (C * D / gcd(C, D));
  print(B - A + 1 - (C2 - C1) - (D2 - D1) + (CD2 - CD1));
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<cmath>
using namespace std;
typedef vector<int> vi;
set<string> cands;
int dy[]={-1,-1,-1,0,0,1,1,1};
int dx[]={-1,0,1,-1,1,-1,0,1};
int maxlength=0,h,w;
string ans="";

int z[105];
int y[1005];
void calc()
{
  for(int i=0;i<=100;i++)
    {
      z[i]=i*i*i;
    }
  for(int j=0;j<=1000;j++)
    {
      y[j]=j*j;
    }
}

int main()
{
  calc();
  while(1) 
    {
      int e;
      cin >> e;
      if(e==0) break;
      int ans=10000000;
      for(int i=0;i<=(int)sqrt(e);i++)
	{
	  int tmpe=e;
	  int tmpans=i;
	  tmpe-=i*i;
	  for(int j=100;j>=2;j--)
	    {
	      if(tmpe-z[j]>=0)
		{
		  tmpe-=z[j];
		  tmpans+=j;
		  break;
		}
	    }
	  tmpans+=tmpe;
	  ans=min(ans,tmpans);
	}
      cout << ans << endl;
    }
}



Measured memory_bytes: 3016
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	ll N;
	vector<char> V;
	cin >> N;
	if(N == 0)V.pb('0');
	while(N != 0){
		if(abs(N) % 2 == 1){
			V.pb('1');
			N -= 1;
			N /= -2;
		}
		else{
			V.pb('0');
			N /= -2;
		}
	}
	for(int i = 0; i < V.size(); i ++){
		cout << V[V.size() - 1 - i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
	double a, b, c, d, e, f, x, y;
	while(cin >>a >>b >>c >>d >>e >>f){
		x = (b*f - c*e) / (b*d - a*e);
		y = (c - (a*x)) / b;
		printf("%.3f %.3f\n", x+0.0, y+0.0);
	}
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int,int>
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

bool cmp(PII p1, PII p2) {
	return (p1.first > p2.first or (p1.first == p2.first and p1.second < p2.second));
}

int main() 
{
    FIO
    vector<PII> v;
    int x,y,a,b,c,temp; cin>>x>>y>>a>>b>>c;
    REP(i,0,a) { cin>>temp; v.PB(make_pair(temp,1)); }
    REP(i,0,b) { cin>>temp; v.PB(make_pair(temp,2)); }
    REP(i,0,c) { cin>>temp; v.PB(make_pair(temp,3)); }

    sort(v.begin(),v.end(), cmp);

    int n = x + y;
    ll delcs=0;
    int idx = 0;
    int i = 0,z=0;

    while (x > 0 or y > 0) {
		if (v[i].second == 1 and x > 0) {delcs += v[i].first; x--;}
		else if (v[i].second == 2 and y > 0) {delcs += v[i].first; y--;}
		else if(v[i].second == 3) {	
			z++;
			delcs += v[i].first;
		}
		i++;
		if(x+y == z or i >= a+b+c) break;	
    }

    cout<<delcs<<endl;


    return 0;
}

Measured memory_bytes: 6384
a,b,c,d,e,f = map(int,input().split())

water = []
suger = []
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        if 100*a*i + 100*b*j <= f and 100*a*i + 100*b*j not in water:
            water.append(100*a*i+100*b*j)

for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j not in suger:
            suger.append(c*i+d*j)
max = 0
maxs = [100*a,0]
for w in water:
    for s in suger:
        if w+s > 0 and w//100*e >= s and w + s <= f and max < s/(w+s):
            max = s/(w+s)
            maxs = [w,s]

print(sum(maxs),maxs[1])



Measured memory_bytes: 40688
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e5+8;
const ll INF=1e18;
int prime[N]={0};
int main(){
  IOS;
 ll n;
 cin>>n;
 if(n>=400&&n<=599)
 cout<<"8"<<endl;
 else 
 if(n>=600&&n<=799)
 cout<<"7"<<endl;
 else 
 if(n>=800&&n<=999)
 cout<<"6"<<endl;
 else 
 if(n>=1000&&n<=1199)
 cout<<"5"<<endl;
 else 
 if(n>=1200&&n<=1399)
 cout<<"4"<<endl;
 else 
 if(n>=1400&&n<=1599)
 cout<<"3"<<endl;
 else 
 if(n>=1600&&n<=1799)
 cout<<"2"<<endl;
 else 
 if(n>=1800&&n<=1999)
 cout<<"1"<<endl;
}

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

typedef vector<int> vi;

const int MOD = (int)1e9 + 7;
int N;
vector<vi> A;
vector<vi> dp;

int my_popcount(int T) {
	T -= (T >> 1) & 0x55555555;
	T = (T & 0x33333333) + ((T >> 2) & 0x33333333);
	T = (T + (T >> 4)) & 0x0F0F0F0F;
	T = (T * 0x01010101) >> 24;
	return T;
}

void solve(void) {
	dp.resize(N + 1, vi(1 << N));
	dp[0][0] = 1;
	for (int S = 1; S < (1 << N); ++S) {
		int i = my_popcount(S);
		for (int j = 0; j < N; ++j) {
			if (((S >> j) & 1) == 1 && A[i - 1][j] == 1)
				dp[i][S] = (dp[i][S] + dp[i - 1][S^(1 << j)]) % MOD;
		}
	}
}

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

	cin >> N;
	A.resize(N, vi(N));
	for (int j = 0; j < N; ++j) {
		for (int i = 0; i < N; ++i)
			cin >> A[j][i];
	}

	solve();

	int ans = dp[N][(1 << N) - 1];
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 188800
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<queue>
#include<vector>
#define INF 1e9
using namespace std;

int main()
{
    int n;
    while(cin>>n)
    {
        if(n<=1199)
            printf("ABC\n");
        else if(n>1199&&n<2800)
            printf("ARC\n");
        else
            printf("AGC\n");
    }
    return 0;
}










Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,c,k,t;

	scanf("%d%d%d%d",&a,&b,&c,&k);

	if(a>=b)
		t=a;
	else
		t=b;
	if(t<c)
		t=c;
	printf("%.0lf",t*pow(2,k)-t+a+b+c);
	return 0;
}

Measured memory_bytes: 128
import math
import itertools

n = int(input())
data = []

for i in range(n):
  x, y = map(int,input().split())
  data.append((x, y))

cnt = 0

for a in itertools.permutations(range(n)):
  for j in range(n-1):
    cnt += ((data[a[j+1]][0]-data[a[j]][0])**2 + (data[a[j+1]][1]-data[a[j]][1])**2)**0.5

print(cnt / math.factorial(n))

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

int main()
{
    int n;
    int a[1001],b[1001];
    int ans=0;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        a[i]=0;
    }
    for (int i = 0; i < n-1; i++)
    {
        cin>>b[i];
    }
    a[0]=b[0];
    for (int i = 1; i < n-1; i++)
    {
        a[i]=min(b[i-1],b[i]);
    }
    a[n-1]=b[n-2];

    for (int i = 0; i < n; i++)
    {
        ans+=a[i];
    }
    
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;



int main(){
    std::ios_base::sync_with_stdio(false);

    int A,B; cin >> A >> B;

    if(B%A==0) cout << A+B << endl;
    else cout << B-A << endl;

    return 0;
}


Measured memory_bytes: 764
#include <iostream>

using namespace std;

int main()
{
    string S;

    cin >> S;

    if(S[0] == 'R')
    {
        if(S[1] == 'R' && S[2] == 'R')
            cout << 3;
        else if(S[1] == 'R')
            cout << 2;
        else
            cout << 1;
    }
    else if(S[1] == 'R')
    {
        if(S[2] == 'R')
            cout << 2;
        else
            cout << 1;
    }
    else if(S[2] == 'R')
        cout << 1;
    else
        cout << 0;
    return 0;
}


Measured memory_bytes: 3568
import collections
import itertools


City = collections.namedtuple("City", ("number", "pref", "year"))

n, m = [int(i) for i in input().split()]
cities = []
for i in range(m):
    pref, year = input().split()
    city = City(i, int(pref), int(year))
    cities.append(city)
id_numbers = []
cities.sort(key=lambda x: x.year)
cities.sort(key=lambda x: x.pref)
ans = []
groups = itertools.groupby(cities, key=lambda x: x.pref)
for g in groups:
    for i, d in enumerate(sorted(g[1], key=lambda x: x.year)):
        ans.append((d.number, d.pref, i+1))
ans.sort(key=lambda x: x[0])
for a in ans:
    print("{:0>6}{:0>6}".format(a[1], a[2]))


Measured memory_bytes: 93656
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] seq = new int[100001];
    long tmp = 0;
    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      tmp += a;
      seq[a]++;
    }
    int q = sc.nextInt();
    // 差だけを計算する

    for (int j = 0; j < q; j++) {
      int b = sc.nextInt();
      int c = sc.nextInt();
      seq[c] += seq[b];
      tmp += (c - b) * seq[b];
      System.out.println(tmp);
      seq[b] = 0;
    }
  }
}

Measured memory_bytes: 61304
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;

vector<int> v[100001];
bool vis[100001];
int cnt;

void dfs(int x)
{
    for(auto i:v[x])
    {
        if(!vis[i])
        {
            vis[i]=true;
            dfs(i);
        }
    }
}

int main()
{
    IOS;
    int n,m;
    cin>>n>>m;
    int x,y,z;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y>>z;
        v[x].pb(y);
        v[y].pb(x);
    }
    memset(vis,false,sizeof vis);
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            vis[i]=true;
            cnt++;
            dfs(i);
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 8960
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  //cout << n << a << b << endl;
  int sum_real = 0;
  for (int i = 1; i < n+1; i++) {
    int ii = i;
    //cout << ii << endl;
    int sum = 0;
    while(ii > 0) {
      sum += (ii % 10);
      ii /= 10;
    }
    if (a <= sum && sum <= b) {
      sum_real += i;
    }
  }
  cout << sum_real << endl;
}
      
      
    


Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n,a,b,c;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			if(a==100||b==100||c==100) cout<<'A'<<endl;
			else{
				double A=(a+b+c)/3;
				if((double)(a+b)/2>=90) cout<<'A'<<endl;
				else if(A>=80) cout<<'A'<<endl;
				else if(A>=70) cout<<'B'<<endl;
				else if(A>=50&&(a>=80||b>=80)) cout<<'B'<<endl;
				else cout<<'C'<<endl;
			}
		}
	}
}

Measured memory_bytes: 1152