akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

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

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

int main(void){
	int k, t;
	cin >> k >> t;

	vector<int> a(t);

	int maxi = 0;
	int maxindex = 0;

	for (int i = 0; i < t; i++){
		cin >> a[i];

		if (maxi < a[i]){
			maxi = a[i];
			maxindex = i;
		}
	}

	int others = 0;

	for (int i = 0; i < t; i++){
		if (i == maxindex){
			continue;
		} else {
			others += a[i];
		}
	}

	cout << max(0, maxi - others - 1) << endl;

} 


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

int main(void) {
    string A,B,C;cin>>A>>B>>C;
    char A_last = A[A.size() - 1];
    char B_first = B[0];
    char B_last = B[B.size() - 1];
    char C_first = C[0];
    if (A_last == B_first && B_last == C_first) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
int dp[100001][2];
bool find(vector<ll>&a,int chance,ll sum){
	// cout<<chance<<" "<<sum<<endl;
	if(sum<a[0]){
		return 0;
		// return 1;
	}
	int &ans=dp[sum][chance];
	if(ans!=-1) return ans;
	ans=1;
	for(int i=0;i<a.size();i++){
		if(a[i]<=sum){
			ans=ans&&find(a,1-chance,sum-a[i]);
		}
	}
	ans=1-ans;
	// cout<<chance<<" "<<sum<<" "<<ans<<endl;
	return ans;
}
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n,k;
		cin>>n>>k;
		vector<ll>a(n);
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		for(int i=0;i<=k;i++){
			dp[i][0]=-1;
			dp[i][1]=-1;
		}
		find(a,0,k);
		if(dp[k][0]){
			cout<<"First"<<endl;
		}
		else{
			cout<<"Second"<<endl;
		}
	}
}

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

void solve()
{
    string s, t;
    cin >> s >> t;
    reverse(t.begin(), t.end());
    if (s == t)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

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

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

int main(){
  int Q,b,rev=0;
  string S;
  char c;
  cin >> S >> Q;
  vector<char>right;
  vector<char>left;
  for(int i=0;i<Q;i++){
    cin >> b;
    if(b==1){
      rev++;
    }else{
      cin >> b >> c;
      if(rev%2!=b-1)
        right.push_back(c);
      else
        left.push_back(c);
    }
  }
  if(rev%2==1){
    reverse(S.begin(),S.end());
    for(int i=right.size()-1;i>=0;i--)
      cout << right.at(i);
    cout << S;
    for(int i=0;i<left.size();i++)
      cout << left.at(i);
    cout << endl;
  }else{
    for(int i=left.size()-1;i>=0;i--)
      cout << left.at(i);
    cout << S;
    for(int i=0;i<right.size();i++)
      cout << right.at(i);
    cout << endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n=s.size();
    string t = s;
    reverse(all(s));
    bool A = (t==s);
    string u = s.substr(0,(n-1)/2);
    t = u;
    reverse(all(t));
    bool B = (t==u);
    u = s.substr((n+3)/2-1);
    t = u;
    reverse(all(t));
    bool C = (t==u);
    if (A && B && C){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = [1]*(N+1)
for k in range(2,N+1):
    t = 1
    while k*t <= N:
        L[k*t] += 1
        t += 1
ans = 0
for k in range(1,N+1):
    ans += k*L[k]
print(ans)


Measured memory_bytes: 151356
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n, m, l := nextInt(), nextInt(), nextInt()

	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			a[i][j] = nextInt()
		}
	}

	b := make([][]int, m)
	for i := 0; i < m; i++ {
		b[i] = make([]int, l)
		for j := 0; j < l; j++ {
			b[i][j] = nextInt()
		}
	}

	c := make([][]int, n)
	for i := 0; i < n; i++ {
		c[i] = make([]int, l)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < l; j++ {
			for k := 0; k < m; k++ {
				c[i][j] += a[i][k] * b[k][j]
			}
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < l; j++ {
			fmt.Fprintf(out, "%d", c[i][j])
			if j != l-1 {
				fmt.Fprintf(out, " ")
			}
		}
		fmt.Fprintf(out, "\n")
	}
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



Measured memory_bytes: 1744
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
using namespace boost::multiprecision;  
using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
//inline int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
//inline int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

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

    int h,n;
    cin >> h >> n;

    vector<int> a(n+1),b(n+1);
    vector<vector<int> > dp(n+1,vector<int>(1e4 * 2 + 1,LINF));

    reps(i,n){
        cin >> a[i] >> b[i];
    }

    dp[0][0] = 0;
    reps(i,n){
        for(int j = 0;j <= 1e4 * 2;++j){
            dp[i][j] = dp[i-1][j];
            if(j - a[i] >= 0) chmin(dp[i][j],min(dp[i-1][j-a[i]] + b[i],dp[i][j-a[i]] + b[i]));
        }
    }

    int minv = LINF;
    for(int i = 1e4 * 2;i >= h;--i){
        chmin(minv,dp[n][i]);
    }

    cout << minv << '\n';

    return 0;
}


Measured memory_bytes: 160640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<vector<Int>> abc(N, vector<Int>(3));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 3; j++) {
			cin >> abc[i][j];
		}
	}

	vector < vector<Int>> dp(N + 10, vector<Int>(3));

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 3; j++) {
			for (Int k = 0; k < 3; k++) {
				if (j != k) {
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abc[i][j]);
				}
			}
		}
	}
	Int ans = max({ dp[N][0],dp[N][1],dp[N][2] });
	cout << ans << "\n";
}

Measured memory_bytes: 11136
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static List<Integer>[] es;
	static int[] dp;

	private static void dfs(int v) {
		if (es[v].size() == 0) return;
		int a = 0;
		for (Integer e : es[v]) {
			if (dp[e] == 0) {
				dfs(e);
			}
			a = Math.max(a, dp[e]);
		}
		dp[v] = a + 1;
	}

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

		dp = new int[n];
		es = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			es[i] = new ArrayList<>();
		}
		boolean[] hasIn = new boolean[n];
		for (int i = 0; i < m; i++) {
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			es[x].add(y);
			hasIn[y] = true;
		}

		for (int i = 0; i < n; i++) {
			if (!hasIn[i]) dfs(i);
		}

		int answer = 0;
		for (int i = 0; i < n; i++) {
			answer = Math.max(answer, dp[i]);
		}

		System.out.println(answer);
	}
}


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

#define int long long 
vector<int> v;

void solve(int n){
	if(n==0) return ;
	if(n%2){
		solve(n/2);
		v.push_back(v.size());
	}
	else{
		solve(n-1);
		vector<int> g;g.push_back(v.size());
		for(int i=0;i<v.size();i++) g.push_back(v[i]);
		v=g;
	}
}
signed main(){
	int n;
	cin>>n;
	solve(n);
	
	cout<<v.size()*2<<"\n";
	for(int i=0;i<v.size();i++) cout<<v[i]+1<<" ";for(int i=0;i<v.size();i++) cout<<i+1<<" ";
		
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll l,r,d;
  cin >> l >> r >> d;

  ll c=0;

  for(int i=l;i<=r;i++){
    if(i%d==0)c++;
  }

  cout << c <<  endl;

}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] p = new int[n + 1];
            for(int i=0;i<n;++i)
            {
                string[] szarr = Console.ReadLine().Split(' ');
                if( i == 0)
                {
                    p[0] = int.Parse(szarr[0]);
                }
                p[i + 1] = int.Parse(szarr[1]);
            }
            int min = MatrixChainMultiplication(n, p);
            Console.WriteLine(min);
        }
        static int MatrixChainMultiplication(int n, int[] p)
        {
            int[,] m = new int[n + 1, n + 1];

            for(int l=2;l<=n;++l)
            {
                for(int i=1;i<=n-l+1;++i)
                {
                    int j = i + l - 1;
                    m[i, j] = int.MaxValue;
                    for(int k=i;k<=j-1;++k)
                    {
                        m[i, j] = Math.Min(m[i, j], m[i, k] + m[k + 1, j] + p[i - 1] * p[k] * p[j]);
                    }
                }
            }
            return m[1, n];
        }
    }

}



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

int main()
{
    long long size;
    cin >> size;
    stack<long long> n[size];
    long long q;
    cin >> q;
    for (long long i = 0; i < q; i++)
    {
        long long a, t, x;
        cin >> a >> t;
        if (a == 0)
        {
            cin >> x;
            n[t].push(x);
        }
        else if (a == 1)
        {
            if(n[t].empty() == 1) continue;
            cout << n[t].top() << endl;
        }
        else
        {
            if(n[t].empty() == 1) continue;
            n[t].pop();
        }
    }

    return 0;
}


Measured memory_bytes: 5092
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                long[] A = new long[N];
                
                for(int i=0; i<N;i++){
                    A[i] = scan.nextLong();
                }
                
                long sum = 0;
                
                if(N==1){
                    System.out.println(0);
                }else{
                    for(int i=1; i<N;i++){
                        if(A[i-1]>=A[i]){
                            sum += A[i-1] -A[i];
                            A[i] = A[i-1];                            
                        }
                    }
                     System.out.println(sum);
                }                          
        }
}

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

long long n;
string s = "";
long long r;

int main()
{
	ios::sync_with_stdio(0);
	cin >> n;
	while(n--)
	{
		r = n % 26;
		n /= 26;
		s += char('a' + r);
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;
using pii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;

const int MOD = 1e9+7;

class CStep {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        ll sum = 0;
        int prev = 0;
        in >> prev;
        for(int i = 1; i < n; ++i)
        {
            int h;
            in >> h;
            if(h <= prev)
                sum += (prev - h);
            else
                prev = h;
        }
        out << sum << endl;
    }
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    CStep solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

string S;

int ctoi(char c){
  return (c - '0');
}

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

int main(){
  cin >> S;

  int mi = 1000;
  for(int i = 0; i < S.size()-2; i++){
    int seisu = 100 * ctoi(S[i]) + 10 * ctoi(S[i+1]) + ctoi(S[i+2]);
    mi = min(abs(seisu-753), mi);
  }

  cout << mi << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],b[n],c[n-1];
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&b[i]);
    }
    for (int i = 0; i < n-1; i++)
    {
        scanf("%d",&c[i]);
    }
    int sum=0;
    for (int i = 0; i < n; i++)
    {
        sum+=b[a[i]-1];
        if (a[i+1]==a[i]+1)
        {
            sum+=c[a[i]-1];
        }
        
    }
    printf("%d",sum);
    return 0;
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
long double PI= 3.141592653589793238463;
const int N = 1e5+5;
const int MOD = 1e9+7;

ll a[100005];
ll dp[100005];
int n,k;

void D(int x)
{
    for(int i=x;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i-j>=0) dp[i]=min(abs(a[i]-a[i-j])+dp[i-j],dp[i]);
        }
    }
}

int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) {
        dp[i]=N*N;
    }
    dp[0]=0;
    dp[1]=(abs(a[0]-a[1]));
    D(2);
//for(int i=0;i<n;i++) {
//        cout<<dp[i]<<' ';
//    }
    cout<<dp[n-1];
    return 0;
}



Measured memory_bytes: 5168
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	int N, x; cin >> N >> x;
	if (x == 1 || x == 2*N-1) {
		cout << "No" << '\n';
	} else {
		cout << "Yes" << '\n';
		if (x >= N) {
			for (int i = x-N+1; i < 2*N; i++) {
				printf("%d\n", i);
			}
			for (int i = 1; i < x-N+1; i++) {
				printf("%d\n", i);
			}
		} else {
			if (x != 2 || N != 3) {
				for (int i = 2 * N - 1; i > (2 * N - 1) - (N - x); i--) {
					printf("%d\n", i);
				}
				for (int i = 1; i <= (2 * N - 1) - (N - x); i++) {
					printf("%d\n", i);
				}
			} else {
				printf("%d\n", 5);
				printf("%d\n", 4);
				printf("%d\n", 1);
				printf("%d\n", 2);
				printf("%d\n", 3);
			}
		}
	}
	return 0;
}


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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

string s, t;
int ans;

int main(){
    cin >> s >> t;
    ans = 0x3f3f3f3f;
    int n = s.size(), m = t.size();
    for (int i = 0; i <= n - m; i++){
        int cnt = 0;
        for (int j = i; j < i + m; j++)
            if (s[j] != t[j-i])
                cnt++;
        ans = min(ans, cnt);
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {    
    /* Input */
    int a;
    cin >> a;
    /* Output */
    cout << floor(a + a*a + a*a*a) << endl;
    return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
class state{
public:
  int p,d;
  bool operator<(const state & a)const{
    if (d != a.d)return d > a.d;
    return p < a.p;
  }
};

main(){
  int n;
  while(cin>>n&&n ){
    rep(i,n){
      int m,e,j;
      cin>>m>>e>>j;
      if (m>=100||e>=100||j>=100||(m+e)>=2*90 ||m+e+j >= 3*80)cout << "A"<<endl;
      else if (m+e+j>= 3*70 || (m+e+j>=3*50 && (m>=80||e>=80)))cout <<"B"<<endl;
      else cout << "C" << endl;
    }
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for(int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 0x3b9aca07;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;


int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	vector<int> d(n); rep(i, 0, n) cin >> d[i];

	sort(d.begin(), d.end());
	
	cout << d[n / 2] - d[n / 2 - 1] << endl;

	return 0;
}


Measured memory_bytes: 3700
#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 req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


  




int n;
string s, t;

int solve() {
    for (int i = 0; i < n; ++i) {
        if (s.substr(i) == t.substr(0, n-i)) return i + n;
    }
    return n*2;
}
int main() {
    cin >> n >> s >> t;
    cout << solve() << endl;
}


Measured memory_bytes: 3548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Print_a_Rectangle
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                string[] strs = line.Split(' ');
                int h = int.Parse(strs[0]);
                int w = int.Parse(strs[1]);
                if (h == 0 && w == 0) break;
                PrintARectangle problem = new PrintARectangle(h, w);
                Console.WriteLine(problem.Show());
            }
        }
    }
}

public class PrintARectangle{

    public int Height { get; private set; }
    public int Width { get; private set; }

    public PrintARectangle(int h, int w)
    {
        Height = h;
        Width = w;
    }

    public string Show()
    {
        StringBuilder str = new StringBuilder();
        for (int j = 0; j < Height; j++)
        {
            for (int i = 0; i < Width; i++)
            {
                str.Append("#");
            }
            str.Append("\n");
        }
        return str.ToString();
    }

}

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

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

    if (s.size() <= k)
        cout << s << endl;
    else
        cout << s.substr(0, k) << "..." << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
void yes(bool c) { if (c)print("Yes"); else print("No"); };

void solve() {
    int N,K; cin >> N >> K;
    vi vec(N,0);
    rep(i,K){
        int d; cin >> d;
        int a;
        rep(i,d){
            cin >> a;
            a--;
            vec[a]++;
        }
    }
    int ans = 0;
    for(auto x:vec){
        if(x==0) ans++;
    }
    print(ans);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);

    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

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

int main() {
    int n;
    int a,b,c,d;
    cin >> n;
    a = n/1000;
    b = n%1000/100;
    c = n%100/10;
    d = n%10;
    if(a+b+c+d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a+b+c-d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a+b-c+d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a+b-c-d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    else if(a-b+c+d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a-b+c-d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a-b-c+d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a-b-c-d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<ve>      vve;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************

int main(void) {

	//vi A(3);
	//cin >> A;

	//sortall(A);

	//cout << A[2] - A[0] << endl;

	string S, T;
	cin >> S >> T;

	rep(i, S.length()) {
		string S1;
		rep(j, S.length()){
			S1.push_back(S[(i + j) % S.length()]);
		}

		if (S1 == T) {
			cout << "Yes" << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 256
from collections import*
import sys
input = sys.stdin.readline


class UnionFind(object):
    def __init__(self, n):
        # 親の番号を格納する。親だった場合は-(その集合のサイズ)
        # 作るときはParentsの値を全て-1にする
        # こうすると全てバラバラになる
        self.parents = [-1 for i in range(n)]

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return


n, k, l = map(int, input().split())

ro_cl = UnionFind(n)
ra_cl = UnionFind(n)
d = defaultdict(int)

# =================================================================

# w = [list(map(int, input().split())) for i in range(k+l)]
# ro = w[:k]
# ra = w[l:]
# for p, q in ro:
#     ro_cl.union(p-1, q-1)
# for p, q in ra:
#     ra_cl.union(p-1, q-1)

# =================================================================

for i in range(k):
    p, q = map(int, input().split())
    ro_cl.union(p-1, q-1)
for i in range(l):
    p, q = map(int, input().split())
    ra_cl.union(p-1, q-1)

# =================================================================

for i in range(n):
    d[(ro_cl.find(i), ra_cl.find(i))] += 1
print(*[d[(ro_cl.find(i), ra_cl.find(i))]for i in range(n)])


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

int main(){
  	int N;
  	cin >> N;
  	map<string,int> m;
      int ma=0;
    for(int i = 0;i < N;i++){
      string s;
      cin >> s;
      m[s]++;
    ma=max(ma,m[s]);    }
    for(auto b : m){
        if(b.second != ma){
            continue;
        }
      cout << b.first << endl;
    }
}

Measured memory_bytes: 25216
H,W = map(int,input().split())

grid = []

for i in range(H):
    line = input()
    if line == '.'*W:
        continue
    grid.append(list(line))

for j in range(W):
    line = ''
    for i in range(len(grid)):
        line += grid[i][j]
    if line == '.'*len(grid):
        for i in range(len(grid)):
            grid[i][j] = '0'

for i in range(len(grid)):
    line = grid[i]
    line = ''.join(line).replace('0','')
    print(line)


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int h,w;
    cin>>h>>w;
    map<int,int> m;
    multiset<int> s;
    for(int i=0;i<w;++i)m[i]=i,s.insert(0);
    for(int i=0;i<h;++i){
        int a,b;
        cin>>a>>b;
        a--;
        auto it = m.lower_bound(a);
        int ma = -1;
        while(it != m.end() and it->first <= b){
            ma = max(ma,it->second);
            s.erase(s.find(it->first - it->second));
            m.erase(it++);
        }
        if(ma != -1 and b < w){s.insert(b-ma);m[b] = ma;}
        
        int ret =-1;
        if(s.size() > 0)ret = *s.begin() + (i+1);
        cout << ret << endl;
    }
    return 0;
    
}


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

template <typename T>
struct BIT {
	int n;
	vector<T> value;
	BIT(int n): n(n), value(n + 1){}
	
	void add(int k, T x){
		while (k <= n){
			value[k] += x;
			k += k & -k;
		}
	}
	
	T sum(int k){
		T s = 0;
		while (k){
			s += value[k];
			k -= k & -k;
		}
		return s;
	}
	
	T sum(int s, int t){
		return sum(t) - sum(s - 1);
	}
};

int main()
{
	int n, q;
	scanf("%d %d", &n, &q);
	BIT<int> bit(n);
	for (int i = 0; i < q; i++){
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0) bit.add(x, y);
		else printf("%d\n", bit.sum(x, y));
	}
}

Measured memory_bytes: 1528
<?php
  function to_i($e) { 
    return (int)$e;
  }

  $w = (int)fgets(STDIN);

  $numbers = array();
  for($i=0; $i<=$w; $i++) {
    array_push($numbers, $i);
  }

  $n = (int)fgets(STDIN);
  for($i=0; $i<$n; $i++) {
    $line = rtrim(fgets(STDIN), "\n");
    list($a, $b) = array_map("to_i", explode(",", $line));
    list($numbers[$a], $numbers[$b]) = array($numbers[$b], $numbers[$a]);
  }

  for($i=1; $i<=$w; $i++) {
    echo $numbers[$i]."\n";
  }

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}


int solve(){
 	int n;cin>>n;
 	int cnt=0;
 	rep(i,1,n+1){
 		int t;cin>>t;
 		if(t%2 && i%2)cnt++;
 	}cout<<cnt<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m;
    cin >> n;
    string ary[n];
    rep(i,n) cin >> ary[i];
    cin >> m;
    string miary[m];
    rep(i,m) cin >> miary[i];

    map<string, int> mp;

    rep(i,n) {
        mp[ary[i]] += 1;
    }
    rep(i,m) {
        mp[miary[i]] -= 1;
    }
    int ans = 0;
    // int cnt = 0;
    for (auto itr = mp.begin();itr != mp.end(); ++itr) {
        ans = max(ans, itr -> second);
        // cnt++;
    }

    cout << ans << endl; 
    // cout << mp["voldemort"] << endl;
    // cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<queue>
using namespace std;
int main()
{
    priority_queue<double,vector<double>,greater<double>> q;
    int n;
    cin>>n;
    for(int i=0;i<n;++i)
    {
        double x;
        cin>>x;
        q.push(x);
    }
    while(q.size()>1)
    {
        double t1 = q.top();
        q.pop();
        double t2 = q.top();
        q.pop();
        q.push((t1+t2)/2);
    }
    printf("%.6f",q.top());
}

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

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(cin >> n && n){
        vector<pair<int,int>> v;
        v.reserve(n/2);
        rep(i,n){
            int g; cin >> g;
            int cnt = 0;
            if(i&1){
                while(v.size() && v.back().first!=g){
                    cnt+=v.back().second;
                    v.pop_back();
                }
                if(v.size()==0) v.push_back(make_pair(g,0));
                v.back().second++;
                v.back().second += cnt;
            } else {
                if(v.size() && v.back().second==g){
                    cnt+=v.back().second;
                    v.pop_back();
                }
                v.push_back(make_pair(g,cnt+1));
            }
        }
        int ans = 0;
        rep(i,v.size())if(v[i].first==0){
                ans+=v[i].second;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1200
from collections import Counter

while True:
    N, M = map(int, input().split())
    if N == 0 and M == 0:
        break
    H = [int(input()) for _ in range(N)]
    W = [int(input()) for _ in range(M)]

    all_H = []
    for i in range(N):
        s = 0
        for j in range(i, N):
            s += H[j]
            all_H.append(s)

    all_W = []
    for i in range(M):
        s = 0
        for j in range(i, M):
            s += W[j]
            all_W.append(s)

    all_H = Counter(all_H)
    all_W = Counter(all_W)
    ans = 0
    for k, v in all_H.items():
        if k in all_H:
            ans += v * all_W[k]
    print(ans)



Measured memory_bytes: 76420
#include<iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;


int main() {
	llint n,p,sum=0,ans=0;
	cin >> n;
    llint a[n];
	rep(i,n){
      cin >> a[i];
      sum = sum+a[i];
    }
    if(sum%n>n/2){
     	p = sum/n + 1;
    }else{
     	p = sum/n;
    }
  	rep(i,n){
     	ans = ans+(a[i]-p)*(a[i]-p);
    }
	cout << ans;   
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void shortestPath(const vector<vector<int> >& edges, int start, vector<int>& dist)
{
    int n = edges.size();
    dist.assign(n, INT_MAX);
    dist[start] = 0;
    queue<int> q;
    q.push(start);

    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(unsigned i=0; i<edges[v].size(); ++i){
            int u = edges[v][i];
            if(dist[u] == INT_MAX){
                dist[u] = dist[v] + 1;
                q.push(u);
            }
        }
    }
}

int main()
{
    int n, u, v;
    cin >> n >> u >> v;
    -- u;
    -- v;

    vector<vector<int> > edges(n);
    for(int i=0; i<n-1; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> dist1, dist2;
    shortestPath(edges, u, dist1);
    shortestPath(edges, v, dist2);

    int ans = 0;
    for(int i=0; i<n; ++i){
        if(edges[i].size() != 1 || dist2[i] <= dist1[i])
            continue;
        ans = max(ans, dist2[i] - 1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int mod=1e4+7;
const double eps=1e-8;
const LL inf=0x3f3f3f3f;
const double pi=acos(-1.0);
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
struct node{
    int v,p;
}a[200010];
bool cmp(node a,node b){
    return a.v<b.v;
}
int main() {
    int w,h;
    cin>>w>>h;
    int mnp=999999,mnq=999999;
    for(int i=0;i<w;i++){
        cin>>a[i].v;
        a[i].p=0;
    }
    for(int i=w;i<h+w;i++){
        cin>>a[i].v;
        a[i].p=1;
    }
    LL ans=0;
    sort(a,a+w+h,cmp);
    int cw=0,ch=0;
    for(int i=0;i<h+w;i++){
        if(a[i].p){
            ans+=(LL)a[i].v*(w+1-ch);
            cw++;
        }
        else {
            ans+=(LL)a[i].v*(h+1-cw);
            ch++;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
   fast
   ll a;
   cin>>a;
   string s;
   cin>>s;
   if(a<3200)
   {
       cout<<"red"<<endl;
   }
   else
   {
       cout<<s<<endl;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main(){
    int c = 0, d = 0;
    string s;
    cin >> s;
    if (s[0] != 'A'){    
        cout << "WA" << endl;
        return 0;
    }
    for (int i = 1; i < s.size(); i++){
        if ('A' <= s[i] && s[i] != 'C' && s[i] <= 'Z'){
            cout << "WA" << endl;
            return 0;
        }
        if (s[i] == 'C'){
            c++;
            if (1 < i && i < s.size() - 1){
                d++;
            }
        }
    }
    if (c == 0 || c > 1){
        cout << "WA" << endl;
        return 0;        
    }else if (d == 1){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}

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

int main(){
    int count[4][3][10]={{{}}}; 
    int num,b,f,r,v;
    cin >> num;
    rep(i,num){
        cin >> b >> f >> r >> v ;
        count[b-1][f-1][r-1]+=v;
    }
    rep(i,4){
        rep(j,3){
            rep(k,10){
                cout << " " << count[i][j][k];
            }
            cout << endl;
        }
        if(i!=3)cout << "####################" << endl;
    }
    return 0;
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N, M;
    std::cin >> N >> M;
    vector<int> table(N);
    REP(i, M) {
        int a, b;
        std::cin >> a >> b;
        table[a - 1]++;
        table[b - 1]++;
    }

    string ans = "YES";
    REP(i, N) {
        if(table[i] % 2 == 1) {
            ans = "NO";
            break;
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#define MAX 2000000
#define INFTY 1000000000
int H,A[MAX+1];
void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if(l<=H && A[l]>A[i])largest=l;
  else largest=i;
  if(r<=H && A[r]>A[largest])largest=r;
  if(largest!=i){
    int tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if(H<1)return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){
  if(key<A[i])return;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    int tmp=A[i];
    A[i]=A[i/2];
    A[i/2]=tmp;
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e' && com[1]=='n')break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else {
      printf("%d\n",extract());
    }
  }
  return 0;
}



Measured memory_bytes: 5604
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    string s1;
    string s2;
    cin >> s1 >> s2;
    int length = s1.length();
    bool ans = true;
    FOR (i, 0, length) {
        if (s1[i] != s2[length - i - 1]) {
            ans = false;
        }
    }
    if (ans == true) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#define ODER 753

int ans = 642;

int main(){
  std::string str;
  std::cin >> str;
  for(int i = 0; i < str.length() - 2;++i){
    int ntmp;
    std::string tmp;
    tmp.push_back(str[i]);tmp.push_back(str[i+1]);tmp.push_back(str[i+2]);
    ntmp = atoi(tmp.c_str());
    ntmp = std::abs(ODER - ntmp);
    ans = std::min(ans,ntmp);
  }
  std::cout << ans << '\n';
  return 0; 
}

Measured memory_bytes: 256