akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int N;
unordered_map<int, int> mp;

int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    int a;
    cin >> a;
    mp[a]++;
  }

  priority_queue<int> v;
  for (auto e : mp) {
    if (e.second >= 2) {
      v.push(e.first);
    }
  }
  if (v.empty()) {
    cout << 0 << endl;
    return 0;
  }
  long first = v.top();
  v.pop();
  long ans = 0;
  if (mp[first] >= 4) {
    ans = first*first;
  } else {
    if (v.empty()) {
      cout << 0 << endl;
      return 0;
    }
    long second = v.top();
    ans = first*second;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4388
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

int max(int a,int b){
    return (a<b) ? b : a ;
}

int main() {

    string s ;
    cin >> s  ;

    if(s=="ARC"){
    cout << "ABC" << endl  ;
    }else{
    cout << "ARC" << endl  ;
    }


 return 0 ;
}  


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N;
	ll A[100010];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		if (A[i] % 2 == 1) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
}

Measured memory_bytes: 1024
from functools import cmp_to_key

MOD = 10 ** 9 + 7


def func(a, b):
    if a[0] * b[1] == a[1] * b[0]:
        return 0
    elif a[0] * b[1] < a[1] * b[0]:
        return - 1
    else:
        return 1


n = int(input())
a = [0] * n
b = [0] * n
i = 0
f = 0
while i < n:
    a[i], b[i] = map(int, input().split())
    if a[i] == 0 and b[i] == 0:
        f += 1
        n -= 1
        continue
    if a[i] < 0:
        a[i] = -a[i]
        b[i] = -b[i]
    if a[i] == 0 and b[i] < 0:
        b[i] = -b[i]
    i += 1
l = sorted(zip(a, b), key=cmp_to_key(func))
if l[0][1] > 0:
    li = [[1, 0, l[0][0], l[0][1]]]
else:
    li = []
for i in range(1, n):
    a, b = l[i - 1]
    c, d = l[i]
    if d <= 0:
        break
    if li and a * d == b * c:
        li[-1][0] += 1
    else:
        li.append([1, 0, c, d])
idx = 0
cnt = 0
for j in range(n):
    a, b = l[j]
    if b > 0:
        continue
    a, b = -b, a
    while idx < len(li) and li[idx][2] * b < li[idx][3] * a:
        idx += 1
    if idx < len(li) and li[idx][2] * b == li[idx][3] * a:
        li[idx][1] += 1
    else:
        cnt += 1
ans = 1
for a, b, c, d in li:
    ans *= (pow(2, a, MOD) + pow(2, b, MOD) - 1)
    ans %= MOD
print((ans * (pow(2, cnt, MOD)) - 1 + f) % MOD)


Measured memory_bytes: 117940
#include <iostream>

template <class T>
struct vec {
  T x, y;
  vec(const T& _x, const T& _y) : x(_x), y(_y) {}
  vec<T> operator+(const vec<T>& rhs) const {
    return vec<T>(x + rhs.x, y + rhs.y);
  }
  vec<T> operator-(const vec<T>& rhs) const {
    return vec<T>(x - rhs.x, y - rhs.y);
  }
};

using namespace std;

int main(int ac, char **av) {
  float x1, x2, x3, y1, y2, y3, xp, yp;
  while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
    vec<float> T1 {x1, y1};
    vec<float> T2 {x2, y2};
    vec<float> T3 {x3, y3};
    vec<float> Tp {xp, yp};

    auto ab = T2 - T1;
    auto bp = Tp - T2;
    auto bc = T3 - T2;
    auto cp = Tp - T3;
    auto ca = T1 - T3;
    auto ap = Tp - T1;

    auto c1 = ab.x * bp.y - ab.y * bp.x;
    auto c2 = bc.x * cp.y - bc.y * cp.x;
    auto c3 = ca.x * ap.y - ca.y * ap.x;

    if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int val;
		while ((val = Integer.parseInt(br.readLine())) != 0) {
			int month = 0;
			for (int i = 1; i <= 12; i++) {
				String s = br.readLine();
				if (month == 0) {
					val -= Integer.parseInt(s.substring(0, s.indexOf(' ')));
					val += Integer.parseInt(s.substring(s.indexOf(' ') + 1));
					if (val <= 0) {
						month = i;
					}
				}
			}
			System.out.println(month > 0 ? (month) : "NA");
		}
	}
}

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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  char s;
  s=b.at(0);

  cout << 'A' << s << 'C' << endl;  
  
  return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
    set<int> st;
    rep(i, 4){
        int x;
        cin >> x;
        st.insert(x);
    }

    set<int> ans = {1, 9, 7, 4};
    for(auto x : ans){
        if(st.count(x) == 0){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
typedef unsigned u;
typedef double d;
int main()
{
	u n,h,i,m;
	d t,a,M=1e9,x;
	scanf("%u%lf%lf",&n,&t,&a);
	for(i=-1;++i<n;)
	{
		scanf("%u",&h);
		x=t-a-h*0.006;
		if(x<0.0)x*=-1.0;
		if(M>x){M=x;m=i+1;}
	}
	printf("%u\n",m);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,q,w,s=0;
	cin>>n>>k;
	int a,b,c[n+1]={0};
	for(q=1;q<=k;q++)
	{
		cin>>a;
		for(w=1;w<=a;w++){
			cin>>b;
			c[b]=1;
		}	
	}
	for(q=1;q<=n;q++)
	{
		if(c[q]==0)  s++;
	}
	cout<<s;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> V(N);
	vector<int> C(N);
	rep(i,N){
		cin >> V[i];
	}
	
	rep(i,N){
		cin >> C[i];
	}
	
	int ans = 0;
	
	rep(i,N){
		if(V[i] > C[i]){
			ans += V[i] - C[i];
		}
	}
	
	cout << ans << endl;
	
    return 0;
}



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

struct point {
	double x, y;
	point(double x_ = 0, double y_ = 0):x(x_), y(y_) {}

	point operator+(const point &p) const {
		return point(x + p.x, y + p.y);
	}

	point operator*(const double d) const {
		return point(x * d, y * d);
	}
};

inline point rotate(const point &p, double theta) {
	const double s = sin(theta);
	const double c = cos(theta);
	return point(c * p.x - s * p.y, s * p.x + c * p.y);
}

inline double degree_to_radian(double degree) {
	return degree / 180.0 * M_PI;
}

int main() {
	point current(0, 0);
	point direction(0, 1);

	for(int d, t; scanf("%d,%d", &d, &t) == 2 && (d | t);) {
		current = current + direction * d;
		direction = rotate(direction, -degree_to_radian(t));
	}

	cout << (int)current.x << endl;
	cout << (int)current.y << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e18
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b,ll m){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % m;  a = (a * a) % m;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e4 + 2;
ll i,j,n,ans;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    for(i = 1;i <= sqrt(n);i += 1) if(n % i == 0){
        if(i > 1 && n / i == n % (i - 1)) ans += i - 1;
        j = n / i;
        if(j > 1 && i != j && n / j == n % (j - 1)) ans += j - 1;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

string S;
int N;

int main(){
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++){
		S[i] += N;
		if (S[i] > 90){
			S[i] -= 26;
		}
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
def main():

    N, M = input_ints()

    A = input_int_list_in_line()

    day = N - sum(A)

    if day < 0:
        print('-1')
    else:
        print(day)


def input_int():
    return int(input())


def input_ints():
    return map(int, input().split())


def input_int_list_in_line():
    return list(map(int, input().split()))


def input_int_tuple_list(n: int, q: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()


Measured memory_bytes: 68192
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int gcd(int a,int b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int a[1005];
int main()
{
    string d;
    cin>>d;
    int i=d.size();
    if(d[i-1]=='s')
    {
        d+='e';
    }
        d+='s';
        cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>                                                                       
using namespace std;                                                                           
                                                                                               
int main(){                                                                                    
                                                                                               
        int n,r,o;                                                                             
        scanf("%d %d", &n,&r);                                                                 
        if(n<=10){                                                                             
                o=100*(10-n);                                                                  
                printf("%d", r+o);                                                             
        } else if(n>=10){                                                                      
                printf("%d", r);                                                               
        }                                                                                      
        return 0;                                                                              
}  

Measured memory_bytes: 256
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const lli N = 305;
lli n;
double dp[N][N][N];
lli one, two, three;
lli x;
void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
double help(lli x, lli y, lli z) {
	if (x < 0 || y < 0 || z < 0) return 0;
	if (x == 0 && y == 0 && z == 0) return 0;
	if (dp[x][y][z] > -0.9) return dp[x][y][z];
	double ret = n + x * help(x - 1, y , z) + y * help(x + 1, y - 1, z) + z * help(x, y + 1, z - 1);
	return dp[x][y][z] = (ret) / (double)(x + y + z);
}
void solve() {
	memset(dp, -1, sizeof dp);
	cin >> n;
	for (lli i = 0; i < n; i++) {
		cin >> x;
		if (x == 1) {
			one++;
		} else if (x == 2) {
			two++;
		} else three++;
	}
	cout << ps(help(one, two, three), 10) << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

Measured memory_bytes: 221952
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll a,b,c,d; cin>>a>>b>>c>>d;
    vector<ll>x(4);
    x[0]=a*c;
    x[1]=a*d;
    x[2]=b*c;
    x[3]=b*d;
    sort(all(x));
    reverse(all(x));
    ll ans=x[0];
    ll mx=0;
    if(a<=0&&0<=b||c<=0&&0<=d){
        ans=max(ans,mx);
    }
    cout<<ans<<endl;
}











Measured memory_bytes: 3628
#pragma GCC optimize(2)
#include<iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <cstring>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <map>
#include <unordered_map>
#include <vector> 
#include <bitset>
#include <cctype>
#include <set>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN = 205;
const int MAXM = 50005;
const int MOD = 1e9+7;

#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mst(X,Y) memset(X,Y,sizeof(X)) 
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define per(i, a, n) for (int i=(a); i>=(n); i--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}
template <typename T> inline T max(T a, T b, T c) { return max(max(a, b),c); }


int l[MAXN];
bool check(int x,int y,int z)
{
	//debug(x,y,z);
	if (x==y || y==z || x==z)
		return false;
	if (x+y>z && x+z>y && y+z>x)
		return true;
	return false;
}
int main()
{closeSync;
#ifdef DEBUG
	// freopen("C:/Users/86159/Desktop/a2.in.txt", "r", stdin);
	// freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif  
	int n;
	cin>>n;
	rep (i,1,n)	cin>>l[i];
	if (n<3)
		cout<<"0\n";
	else 
	{
		int cnt = 0;
		rep (i,1,n-2)
			rep (j,i+1,n-1)
				rep (k,j+1,n)
				{
					if  (check(l[i],l[j],l[k]))
						cnt++;
				}
	
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(1000000)
readline = sys.stdin.readline
from collections import deque


def solve_beam():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    W, DEPTH = 2, 8

    def rec(day, rem):
        if rem == 0 or day > D:
            return 0, 0
        gains = [(S[day - 1][t] + (day - lasts[t]) * C[t], t) for t in range(N)]
        gains.sort(reverse=True)
        max_gain = -1e10
        max_gain_t = 0
        for i in range(W):
            gain, t = gains[i]
            _t = lasts[t]
            lasts[t] = day
            f_gain, _ = rec(day + 1, rem - 1)
            lasts[t] = _t
            gain += f_gain
            if gain > max_gain:
                max_gain = gain
                max_gain_t = t

        return max_gain, max_gain_t

    for day in range(D):
        _, t = rec(day, DEPTH)
        lasts[t] = day
        ans[day - 1] = t
    
    for a in ans:
        print(a + 1)


solve_beam()

Measured memory_bytes: 9848
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void N(int a[], int t) {
	t = a[1];
	a[1] = a[2];
	a[2] = a[6];
	a[6] = a[5];
	a[5] = t;
}

void S(int a[], int t) {
	t = a[1];
	a[1] = a[5];
	a[5] = a[6];
	a[6] = a[2];
	a[2] = t;
}

void E(int a[], int t) {
	t = a[1];
	a[1] = a[4];
	a[4] = a[6];
	a[6] = a[3];
	a[3] = t;
}

void W(int a[], int t) {
	t = a[1];
	a[1] = a[3];
	a[3] = a[6];
	a[6] = a[4];
	a[4] = t;
}

int main(void) {
	int a[10],t=0,p=0,c=0;
	char NEWS[100];
	a[0] = 0;
	for (int i = 1; i <= 6; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < 99; i++) {
		NEWS[i] = 0;
	}

	scanf("%d", &c);
	for (int i = 0; i < c; i++) {
		scanf("%hhd %hhd", &NEWS[0], &NEWS[1]);
		while (a[1] != NEWS[0] || a[2] != NEWS[1]) {
			p = rand() % 4 + 1;
			if (p == 1) {
				N(a, t);
			}
			else if (p == 2) {
				E(a, t);
			}
			else if (p == 3) {
				W(a, t);
			}
			else if (p == 4) {
				S(a, t);
			}
		}
		printf("%d\n", a[3]);
	}
}




Measured memory_bytes: 2692
cnt = 0
def InsertionSort(A, n, g):
    global cnt
    outA = A.copy()
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and outA[j] > v:
            outA[j + g] = outA[j]
            j -= g
            cnt += 1
        outA[j + g] = v
    return outA

def ShellSort(A, n):
    global cnt
    outA = A.copy()
    G = []
    h = n - 1
    while h >= 2:
        G.append(h)
        h = int((h - 1)//3)
    G.append(1)
    m = len(G)
    for i in range(0, m):
        outA = InsertionSort(outA, n, G[i])
    return outA, m, G, cnt
def printlist(L):
    for t in L[:-1]:
        print(t, end = ' ')
    print(L[-1])

n = int(input())
A = [0 for i in range(n)]
for i in range(n):
    A[i] = int(input())

A, m, G, cnt = ShellSort(A, n)
print(m)
printlist(G)
print(cnt)
for itm in A:
    print(itm)



Measured memory_bytes: 60840
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const int A=18;
lint p10[A];


lint dp[A+1][2][6];
int dig[A];

int nxt[6][10];

int main(){
  rep(i,A){
    if(i==0)p10[i]=1;
    else p10[i]=10*p10[i-1];
  }
  lint n;
  cin>>n;
  rep(i,A){
    dig[i]=n%10;
    n/=10;
  }
  dp[A][1][0]=1;
  //states
  nxt[0][5]=1;
  nxt[1][1]=2;
  nxt[1][5]=1;
  rep(i,10)nxt[2][i]=3;
  nxt[2][5]=4;
  nxt[3][3]=5;
  nxt[3][5]=1;
  nxt[4][1]=2;
  nxt[4][3]=5;
  nxt[4][5]=1;
  rep(i,10)nxt[5][i]=5;
  for (int i=A-1;i>=0;--i){
    rep(j,10){
      rep(k,6){
	dp[i][0][nxt[k][j]]+=dp[i+1][0][k];
      }
    }
    rep(j,dig[i]){
      rep(k,6){
	dp[i][0][nxt[k][j]]+=dp[i+1][1][k];
      }
    }
    rep(k,6)
      dp[i][1][nxt[k][dig[i]]]+=dp[i+1][1][k];
    if(0){
      rep(j,2){
	rep(k,6)cerr<<" "<<dp[i][j][k];
	cerr<<"|";
      }
      cerr<<endl;
    }
  }
  cout<< dp[0][0][5]+dp[0][1][5]<<endl;
}



Measured memory_bytes: 3100
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if ((a+b>=c)and(a<=c)) puts("YES");
	else puts("NO");
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int main() {
  LL N, A, B, C, D;
  scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
  --N;

  REP(i,N+1) {
    LL mini = A - i * D + (N-i) * C;
    LL maxi = A - i * C + (N-i) * D;
    if (mini <= B && B <= maxi) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static Scanner scan;

    public static void main(String[] args) {
        scan = new Scanner(System.in);
        while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 31932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll H,W,A,B;
ll jiec[2000010];
ll answ;
void jc()
{
	jiec[1]=1;
	for(ll k=2;k<=2000005;k++)
		jiec[k]=jiec[k-1]*k,jiec[k]%=MOD;
}
ll kzojld(ll a,ll b,ll &x,ll &y)
{
    if(b==0)
    {
        x=1,y=0;
        return a;
    }
    ll answ=kzojld(b,a%b,x,y);
    ll k=y;
    y=x-a/b*y,x=k;
    return answ;
}
ll C(ll x1,ll y1,ll x2,ll y2)
{
	ll all=abs(y2-y1)+abs(x2-x1);
	ll up=abs(y2-y1);
	if(up==0 || all==up)
		return 1;
	ll a1=jiec[all];
	ll a2=jiec[up];
	ll a3=jiec[all-up];
	ll a4=a2*a3+MOD%MOD;
	if(a4<0)
		a4+=MOD;
	ll x=0,y=0;
	kzojld(a4,MOD,x,y);
	ll end0=a1*x%MOD;
	if(end0<0)
		end0+=MOD;
	return end0;
}
int main()
{
	jc();
	scanf("%lld %lld %lld %lld",&H,&W,&A,&B);
	ll hang=A+1;
	for(ll k=B+1;k<=W;k++)
		answ+=C(hang-1,k,1,W)*C(H,1,hang,k),answ%=MOD;
	if(answ<0)
		answ+=MOD;
	printf("%lld",answ);
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <functional>

using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> v(n);
  vector<int> c(n);

  for (int i=0;i<n;i++){
    cin >> v[i];
  }
  for (int i=0;i<n;i++){
    cin >> c[i];
  }
  
  int ans=0;
  for (int i=0;i<n;i++){
    if(v[i]>c[i]){
      ans += v[i]-c[i];
    }
  }
  cout << ans << endl;
  return 0;
}

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

namespace AtCoder.A
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static string S { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            S = CR.GetText();

            var pmInfos = new List<X>();
            var pre = '\0';
            foreach (var s in S)
            {
                if (s != pre)
                {
                    pmInfos.Add(new X
                    {
                        IsRight = s == '<',
                        Count = 0,
                    });
                }
                pre = s;
                pmInfos.Last().Count++;
            }

            var line = new long[S.Length + 1];
            for (int i = 0; i < line.Length; i++)
            {
                line[i] = -1;
            }

            var startIndex = 0L;
            foreach (var info in pmInfos)
            {
                var value = info.IsRight ? 0 : info.Count;
                for (var i = startIndex; i < startIndex + info.Count + 1; i++)
                {
                    line[i] = Math.Max(line[i], value);

                    if (info.IsRight)
                    {
                        value++;
                    }
                    else
                    {
                        value--;
                    }
                }

                startIndex += info.Count;
            }

            return line.Sum();
        }

        internal class X
        {
            public bool IsRight { get; set; }
            public long Count { get; set; }
        }
    }
}


Measured memory_bytes: 31196
#include <iostream>

using namespace std;

const long MOD = 1000000007;

int cnt[6];
int rem[6] = {1, 10, 9, 12, 3, 4};

long dp[13];
long dp_[13];

void copy(){
    for(int i = 0; i < 13; i++) {
        dp[i] = dp_[i];
        dp_[i] = 0;
    }
}

int main(){
    string S;
    cin >> S;
    dp[0] = 1;
    int N = S.size();
    for(int i = 0; i < N; i++){
        if(S[N-i-1] == '?'){
            for(int j = 0; j < 13; j++){
                for(int k = 0; k <= 9; k++){
                    //cout << k << endl;
                    dp_[(j+(k*rem[i%6]))%13] += dp[j];
                    dp_[(j+(k*rem[i%6]))%13] %= MOD;                    
                }
            }
        }else{
            for(int j = 0; j < 13; j++){
                dp_[(j+rem[i%6]*(S[N-i-1]-'0'))%13] = dp[j];
            }
        }
        copy();
    }
    cout << dp[5] << endl;
}

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

int main() {
  char b;
  cin >> b;
  
  if (b=='A') b = 'T';
  else if (b=='T') b = 'A';
  else if (b=='G') b = 'C';
  else if (b=='C') b = 'G';
  
  cout << b << endl;
 }


Measured memory_bytes: 256
import java.util.*;

public class Main {

    int[] stones;

    private int getDist(int i, int j) {
        return Math.abs(stones[i] - stones[j]);
    }

    private void run() {
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        stones = new int[N];
        int[] dp = new int[N];

        for (int i = 0; i < N; i++) stones[i] = sc.nextInt();
        
        dp[N-1] = 0;
        dp[N-2] = getDist(N-1, N-2);

        for (int i = N-3; i >= 0; i--) {
            int min = dp[i+1] + getDist(i,i+1);
            for (int j = 2; j <= K; j++) {
                if (i + j >= N) break;
                int dist = dp[i+j] + getDist(i,i+j);
                if (dist < min) min = dist;
            }
            dp[i] = min;
        }
        System.out.println(dp[0]);
    }
    public static void main(String[] args) {
        Main solver = new Main();
        solver.run();
    }
}


Measured memory_bytes: 61164
#include <cstdio>
#include <algorithm>
#include <vector>

std::vector<long long> ln;

void dfs(long long value, int digit)
{
	if (value > 3234566667)
	{
		return;
	}
	ln.emplace_back(value);

	if (digit > 0) dfs(value * 10 + (long long)(digit - 1), digit - 1);
	dfs(value * 10 + digit, digit);
	if (digit < 9) dfs(value * 10 + (long long)(digit + 1), digit + 1);
}

int main()
{
	for (int i = 1; i < 10; ++i)
	{
		dfs(i, i);
	}
	std::sort(ln.begin(), ln.end());
	int k;
	scanf("%d", &k);
	printf("%lld\n", ln[k - 1]);
	return 0;
}


Measured memory_bytes: 1400
// finish date: 2019/2/9

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
//#define input(name)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N, K;
    cin >> N >> K;
    vi p(N);
    rep(i, N) {
        cin >> p[i];
        p[i]++;
    }
    vi acc(N, 0);
    rep(i, N) {
        acc[i] = p[i];
        if (i > 0) acc[i] += acc[i - 1];
    }
    int ma = acc[K - 1];
    FOR(i, K, N) {
        ma = max(ma, acc[i] - acc[i - K]);
    }
    printf("%.1f\n", (double) ma / 2);


    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2100000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;

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

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

void mod(ll &val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    string S;
    cin >> S;
    if(S.at(S.size() - 1) == 's') {
        S += "es";
    }
    else {
        S += "s";
    }
    cout << S << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
	int a[5]; //A,B,C,D,E
	int sum=0;
	int maxLestTime=0;
	int M;
	for(int i=0; i<5; i++){
		scanf("%d",&a[i]);
	}

	for(int i=0; i<5; i++){
		if(a[i]%10==0){continue;}
		if(a[i]%10<=(10-maxLestTime)){
			maxLestTime = 10-(a[i]%10);
			M = i;
		}
	}

	for(int i=0; i<5; i++){
		int x = a[i] % 10;

		if(x!=0 && i!=M){
			a[i] = a[i]-x+10;
		}
		sum = sum+a[i];
	}

	printf("%d\n",sum );
}

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

using namespace std;

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const long long  INF = 5e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int a, b;

int main() {
	for (int i = 0;i < 7;i++) {
		cin >> a >> b;
		cout << a - b << endl;
	}
	return 0;
}




Measured memory_bytes: 3104
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

LL dp[51][51][2602] = {};
int main() {
  int N, A; cin >> N >> A;

  dp[0][0][0] = 1;
  for (int i = 1; i <= N; ++i) {
    int x; cin >> x;
    for (int k = 0; k <= 50; ++k) {
      for (int j = 0; j < 2602; ++j) {
        dp[i][k][j] = dp[i-1][k][j];
      }
    }

    for (int k = 0; k < 50; ++k) {
      for (int j = x; j < 2602; ++j) {
        dp[i][k+1][j] += dp[i-1][k][j-x];
      }
    }
  }

  LL sum = 0;
  for (int j = 1; j <= N; ++j) {
    sum += dp[N][j][A * j];
  }
  cout << sum << endl;
}


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

using namespace std;

int main() {
  string s, t; cin >> s >> t;
  if(s[2] == t[0] && s[1] == t[1] && s[0] == t[2]) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}


Measured memory_bytes: 256
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if A<=B:
    if A+T*V<B+T*W:
        print('NO')
    else:
        print('YES')
else:
    if B-T*W<A-T*V:
        print('NO')
    else:
        print('YES')

Measured memory_bytes: 9188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
//nomura
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    V<int> h(2),m(2);
    int k;
    rep(i,2) cin>>h[i]>>m[i];
    cin>>k;
    cout<<60*h[1]+m[1]-(h[0]*60+m[0])-k<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3612
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    a,b=parseMap(split(readline()))
    now=1
    for i in 0:100
        if now>=b
            println(i)
            break
        end
        now=now-1+a
    end
end
main()

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i, 0, n) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum % 10 != 0) {
        cout << sum << endl;
    } else {
        sort(a.begin(), a.end());
        rep(i, 0, n) {
            if ((sum - a[i]) % 10 != 0) {
                cout << sum - a[i] << endl;
                return 0;
            }
            if (i == n - 1) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
import math
#----エラトステネスの篩--------
def get_primenumber(number):
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    prime_2007=[]
    j=0
    lr=[0]
    cnt=0

    search_list = list(range(2,number+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
      if search_list[0] > math.sqrt(number):
        #prime_listにsearch_listを結合
        prime_list.extend(search_list)
        break
      else:
        #search_listの先頭をprime_listに入れる
        head_num = search_list[0]
        prime_list.append(head_num)

        #search_listの先頭をpopする
        search_list.pop(0)
        #head_numの倍数を取り除く
        search_list = [num for num in search_list if num % head_num != 0]
    
    for item in prime_list:
        if (item+1)//2 in prime_list:
            prime_2007.append(item)

    for item in prime_2007:
        lr+=[cnt]*(item - j-1)
        cnt+=1
        j=item
        lr.append(cnt)
    lr+=[cnt]*(10**5-j)
    #print(prime_2007)
    #print(lr)
    #return prime_list
    return(lr)


lrlr=get_primenumber(10**5+10)

result=[]
n=int(input())
for i in range(n):
    l,r=map(int,input().split())
    #l=min(l,len(lrlr)-1)
    #r=min(r,len(lrlr)-1)
    #print(l,r)
    #print(len(lrlr))

    result.append(lrlr[r]-lrlr[l-1])

for item in result:
    print(item)


Measured memory_bytes: 59612
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)1e9+1
#define MOD (long long)1e9+7
#define INF64 (long long)1e18+1

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
	//INPUT
	llint N,M;
	cin >> N >> M;
	vector<pair<llint,llint> > w(N);
	rep(i,0,N) {
		pair<llint,llint> buf;
		cin >> buf.F >> buf.S;
		w[i] = buf;
	}
	sort(w.begin(),w.end());

	//SOLVE
	llint ans=0;
	llint wi=0;
	priority_queue<llint> pq;
	for(llint day=M-1;day>=0;day--) {
		for(;wi<N;wi++) {
			if (day + w[wi].F <= M) {
				pq.push(w[wi].S);
			} else {
				break;
			}
		}

		if(!pq.empty()) {
			ans+=pq.top();
			pq.pop();
		}

	}

	//OUTPUT

	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N, M; cin >> N >> M;
VS A(N), B(M);
rep(i, 0, N) cin >> A[i];
rep(i, 0, M) cin >> B[i];

// hash 有り O(N^2M)
hash<string> h;
VI Bh(M); 
rep(i, 0, M) Bh[i] = h(B[i]);
VVI Ah(N, VI(N- M + 1));
rep(i, 0, N)
    rep(j, 0, N - M + 1)
        Ah[i][j] = h(A[i].substr(j, M));

rep(i, 0, N - M + 1){
    rep(j, 0, N - M + 1){
        if (Ah[i][j] == Bh[0]){
            bool match = true;
            rep(k, 1, M){
                if (Ah[i+k][j] != Bh[k]) 
                    match = false;
            }
            if (match){
                cout << "Yes\n";
                return 0;
            }
        }
    }
}

// O(N^2M^2)解法 hash無し
// rep(i, 0, N - M + 1){
//     rep(j, 0, N - M + 1){
//         if (A[i].substr(j, M) == B[0]){
//             bool match = true;
//             rep(k, 0, M){
//                 if (A[i+k].substr(j, M) != B[k]) 
//                     match = false;
//             }
//             if (match){
//                 cout << "Yes\n";
//                 return 0;
//             }
//         }
//     }
// }
cout << "No\n";

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int>X1;
    vector<int>X2;
    rep(i, 0, N){
        int tmp;
        cin >> tmp;
        X1.push_back(tmp);
        X2.push_back(tmp);
    }
    
    sort(X2.begin(), X2.end());
    int numL = X2[N/2-1];
    int numR = X2[N/2];
    rep(i, 0, N){
        
        if(X1[i] <= numL){
            cout << numR << endl;
        } else {
             cout << numL << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3948
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll i,n;
  cin >> n;
  ll a[200010];
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>() );
  ll ans=a[0];
  ll j=1;
  for(i=2;i<n;i++){
    if(i%2==0){
      ans+=a[j];
    }
    else{
      ans+=a[j];
      j++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5200
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

n,m,d = II()

if d!=0:
    print(2*(m-1)*(n-d)/n**2)
if d==0:
    print((m-1)/n)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n,ans=INF; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll sum=accumulate(all(a),0LL);
    ll tmp=0;
    rep(i,n){
        sum -= a[i];
        tmp += a[i];
        ans = min(ans,abs(sum-tmp));
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

int main()
{
    string s;
    cin>>s;
    ll i,j;
    ll n = s.length();
    if(s[n-1]=='s') cout<<s+"es";
    else cout<<s+"s";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std ;
int n ;
char s[55] ;
int main()
{
	scanf("%d" , &n) ;
	scanf("%s" , s) ;
	int cnt = 0 ;
	for(int i = 0 ; i < n - 2 ; i ++)
	  if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')  cnt ++ ;
	printf("%d\n" , cnt) ;
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if((i<b)^(j<a))
				cout<<1;
			else
				cout<<0;
		}
		cout<<"\n";
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    cout << (n/(a+b))*a + min(n%(a+b),a);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main() {
	cout << fixed << setprecision(10);
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<int> > a(h, vector<int>(w, 0));
	vector<vector<int> > s(h + 1, vector<int>(w + 1, 0));

	REP(y, h) {
		string str;
		cin >> str;
		REP(x, w) {
			a[y][x] = str[x] == '1';
		}
	}

	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			s[i + 1][j + 1] = s[i][j + 1] + s[i + 1][j] - s[i][j] + a[i][j];

	int ans = INF;

	REP(i, 1 << (h-1)) {
		vector<int> split;
		split.push_back(0);
		REP(j, h - 1) {
			if (i & (1 << j))split.push_back(j + 1);
		}
		split.push_back(h);

		int cnt = 0;
		int pre = 0;
		int idx = 1;
		while (idx <= w) {
			REP(j, split.size() - 1) {
				int all = s[split[j + 1]][idx]
					- s[split[j + 1]][pre]
					- s[split[j]][idx]
					+ s[split[j]][pre];

				if (k < all) {
					cnt++;
					if (pre == idx - 1) {
						cnt = INF;
                        idx=INF;
						break;
					}
					pre = idx - 1;
					break;
				}
			}
			idx++;
		}
		chmin(ans, cnt + split.size() - 2);
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 384
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};


int main(){
    IOS;
    make(ll,n);
    unordered_map <ll,ll> um1;
    fr(i,n){
        make(ll,x); um1[x]++;
    }
    make(ll,m);
    unordered_map <ll,ll> um2;
    fr(i,m){
        make(ll,x); um2[x]++;
    }
    bool f=1;
    for(auto x : um2){
        if(um1[x.first]<x.second) f=0;
    }
    if(f) cout<<"YES \n";
    else cout<<"NO \n";


    return 0;
}


Measured memory_bytes: 19852