akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    #define out(a) cout<<a<<" "
    #define all(a) (a).begin(), (a).end()
    #define upper_index(v, a) (int)distance(v.begin(), upper_bound((v).begin(), (v).end(), a))
    #define lower_index(v, a) (int)distance(v.begin(), lower_bound((v).begin(), (v).end(), a))
    typedef long long ll;
    const long long INF = 1e17;
     
    int main() {
        int l,r;
        cin>>l>>r;
        if ((r-l)>=2019) {
            cout<<0<<endl;
            return 0;
        }
        int ans=1000000;
        if (l%2019<=r%2019){
            for(int i=l%2019;i<=r%2019-1;++i){
                for(int j=i+1;j<=r%2019;++j){
                    if ((i*j)%2019 < ans) ans=(i*j)%2019;
                }
            }
        }else{
            for(int i=l%2019;i<=r%2019+2018;++i){
                for(int j=i+1;j<=r%2019+2019;++j){
                    if ((i*j)%2019 < ans) ans=(i*j)%2019;
                }
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    
    
    
    

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

using namespace std;

const int Maxn = 210;
int l[Maxn];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < 2 * n; ++i) {
        cin >> l[i];
    }
    sort(l, l + 2 * n);

    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        ans += l[i];


    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll n;
	cin >> n;
	vector<ll> v(n);
	for(int i = 0; i < n;i++)
	{
		cin >> v[i];
	}
	ll ans = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j = i+1; j < n; j++)
		{
			for(int k = j+1; k < n; k++)
			{
				if(v[i] != v[j] && v[j] != v[k] && v[i] != v[k])
				{
					vector<ll> vv = {v[i], v[j], v[k]};
					sort(vv.begin(), vv.end());
					if(vv[0] + vv[1] > vv[2])
						ans++;
				}
			}
		}
	}
	cout << ans << "\n";
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long N, long long K, string S)
{
    vector<ll> map;

    bool isZero;
    bool firstZero;
    if (S[0] == '0')
    {
        isZero = true;
        firstZero = true;
        map.push_back(0);
    }
    else
    {
        isZero = false;
        firstZero = false;
    }
    int cnt = 0;

    for (int i = 0; i < N; i++)
    {
        if (isZero)
        {
            if (S[i] == '1')
            {
                map.push_back(cnt);
                cnt = 0;
                isZero = false;
            }
        }
        else
        {
            if (S[i] == '0')
            {
                map.push_back(cnt);
                cnt = 0;
                isZero = true;
            }
        }
        cnt++;
    }
    if (cnt != 0)
        map.push_back(cnt);

    if (map.size() % 2 == 0)
        map.push_back(0);

    int limit = 2 * K + 1;
    int ans = 0;
    for (int i = 0; i < map.size(); i += 2)
    {
        int tmp = 0;
        int left = i;
        int right = min(i + limit, (int)map.size());
        for (int j = i; j < right; j++)
        {
            tmp += map[j];
        }
        ans = max(tmp, ans);
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    string S;
    cin >> S;
    solve(N, K, S);
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> ans(N);
  bool L = false;
  bool LL = false;
  int numL;
  bool R = false;
  bool RR = false;
  int numR;
  for(int i = 0; i < N; i++){
    if(S.at(i) == 'L'){
      if(L){
        if(LL){
          ans.at(i) = numL;
          LL = false;
        } else {
          ans.at(i) = numL - 1;
          LL = true;
        }
      } else {
        ans.at(i) = i;
        L = true;
        LL = false;
        numL = i;
      }
    } else {
      L = false;
    }
    if(S.at(N-i-1) == 'R'){
      if(R){
        if(RR){
          ans.at(N-i-1) = numR;
          RR = false;
        } else {
          ans.at(N-i-1) = numR + 1;
          RR = true;
        }
      } else {
        ans.at(N-i-1) = N-i-1;
        R = true;
        RR = false;
        numR = N-i-1;
      }
    } else {
      R = false;
    }
  }
  vector<int> num(N);
  for (int i = 0; i < N; i++){
    num.at(ans.at(i))++;
  }
  for (int i = 0; i < N-1; i++){
    cout << num.at(i) << " ";
  }
  cout << num.at(N-1) << endl;
  return 0;
}

Measured memory_bytes: 1408
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n, k = map(int, input().split())

    ans = 0

    min_num = 0
    desk_list = list(reversed(range(n + 1)))

    max_num = 0
    ack_list = list(range(n + 1))

    for i in range(1, n + 1):
        min_num = (min_num + desk_list.pop()) % (pow(10, 9) + 7)
        max_num = (max_num + ack_list.pop()) % (pow(10, 9) + 7)
        if k <= i:
            ans = (ans + max_num - min_num + 1) % (pow(10, 9) + 7)

    print(ans+1)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 2"""
        output = """10"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """200000 200001"""
        output = """1"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """141421 35623"""
        output = """220280457"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 77188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int left = max(a,c);
    int right = min(b,d);
    cout << max(right - left, 0) << endl;
    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int ans = 0;
    if(n%2==0) ans = n/2;
    else ans = n/2 + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]

AC = s.count("AC")
WA = s.count("WA")
TLE = s.count("TLE")
RE = s.count("RE")

AC2 = "AC x " + str(AC)
WA2 = "WA x " + str(WA)
TLE2 = "TLE x " + str(TLE)
RE2 = "RE x " + str(RE)

list = [AC2,WA2,TLE2,RE2]
list_n = "\n".join(list)
print(list_n)

Measured memory_bytes: 16052
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
      	boolean flg = true;
      	int year = 0;
      	long money = 100;
      	long counter = 0;
      
      	while (flg) {
          	money *= 1.01; 
          	counter += 1;
          	if (num<=money) {
              flg = false;
              System.out.println(counter);
            }	
        }

        
    }

}

Measured memory_bytes: 35608
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,k = LI()
    r = []
    for _ in range(n):
        r.append(LI())

    r = sorted(r)
    c = 0
    for a,b in r:
        c += b
        if k <= c:
            return a

print(main())


Measured memory_bytes: 24972
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int m[101],d[101],s[101],v[101];
int out[1000][101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d%d%d",&m[i],&d[i],&v[i],&s[i]);
		int id=(m[i]-1)*30+d[i]-1;
		for(int j=id;j<id+v[i];j++){
			out[j][i]+=s[i];
		}
		if(id+v[i]>=360){
			for(int j=0;j<id+v[i]-360;j++){
				out[j][i]=max(s[i],out[j][i]);
			}
		}
		int now=(id-1+360)%360;
		int cnt=s[i]-1;
		while(cnt>0){
			out[now][i]=max(out[now][i],cnt);
			cnt--;
			now=(now-1+360)%360;
		}
		now=(id+v[i]+360)%360;
		cnt=s[i]-1;
		while(cnt>0){
			out[now][i]=max(out[now][i],cnt);
			cnt--;
			now=(now+1+360)%360;
		}
	}
	int res=11451419;
	for(int i=0;i<360;i++){
		int now=0;
		for(int j=0;j<n;j++){
			now=max(out[i][j],now);
		}
		res=min(now,res);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 3472
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define N               100005
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#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)            ll x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fio(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

ll f(ll *a, ll i, ll j){

    ll dp[i+5][j+5];

    for(ll x=0;x<=j;x++) {
        if(x <= a[1]) dp[1][x] = 1;
        else dp[1][x] = 0;
    }

    for(ll x=2;x<=i;x++){
        for(ll y=0;y<=j;y++){
            if(y == 0) dp[x][y] = dp[x-1][y];
            else{
                dp[x][y] = (mod + dp[x-1][y] + dp[x][y-1] - ((y - a[x] - 1 >= 0) ? dp[x-1][y - a[x] - 1] : 0)) % mod;
            }
        }
    }

    return dp[i][j];
}

int main(){
    fio();

    ll n, k;
    cin>>n>>k;

    ll a[n+1];
    for(ll z=1;z<=n;z++) cin>>a[z];

    cout<<f(a, n, k);

    return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

struct Expr {
    int id;
    vector<Expr> childs;
    void out() {
        cerr << id;
        if (childs.size()) cerr << " (";
        for (auto& e : childs) e.out();
        if (childs.size()) cerr << ") ";
    }
};

vector<string> lst;

int cd(string s) { 
    for (int i = 0;; i++) if (s[i] != '.') return i;
}

Expr gen(int &pos, int depth = 1) {
    Expr e = {pos++, {}};
    while (pos < lst.size() && cd(lst[pos]) >= depth) {
        e.childs.push_back(gen(pos, depth + 1));
    }
    return e;
}

void dofix(const Expr e, int depth = 0) {
    if (e.childs.size() == 0) return;
    for (int i = e.childs.front().id; i <= e.childs.back().id; i++) {
        if (lst[i][depth] == '.') lst[i][depth] = '|';
    }
    for (auto &h : e.childs) dofix(h, depth + 1);
}

int main() {
    for (;;) {
        int n; cin >> n; if (!n) break;
        lst.clear();
        rep(i, 0, n) {
            string s; cin >> s;
            lst.push_back(s);
        }
        int pos = 0;
        Expr e = gen(pos);
        // e.out(); cerr << endl;
        rep(i, 0, n) {
            for (int j = 0;; j++) if (lst[i][j] != '.') {
                if (j) lst[i][j - 1] = '+';
                break;
            }
        }
        dofix(e);
        rep(i, 0, n) for (char &c : lst[i]) if (c == '.') c = ' ';
        rep(i, 0, n) {
            cout << lst[i] << endl;
        }
    }
}


Measured memory_bytes: 27208
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
using A2 = array<int, 2>;
#define printa(A) for (auto a : A) cout << a << ' '; cout << endl;
template<class T> using priority_queue_min = priority_queue<T, vector<T>, greater<T>>;
void dijkstra(vector<vector<pair<int, A2>>>& G, int s, int idx, vector<Int>& out)
{
    priority_queue_min<pair<Int, int>> Q;
    Q.emplace(0, s);
    vector<bool> visited(G.size());
    while (!Q.empty()) {
        Int d; int i; tie(d, i) = Q.top(); Q.pop();
        if (visited[i]) continue;
        visited[i] = true;
        out[i] = d;
        for (auto &p : G[i]) {
            if (!visited[p.first]) {
                Q.emplace(d + p.second[idx], p.first);
            }
        }
    }
}
int main()
{
    int N, M, S, T; cin >> N >> M >> S >> T; S--, T--;
    vector<vector<pair<int, A2>>> G(N);
    while (M--) {
        int u, v, a, b; cin >> u >> v >> a >> b; u--, v--;
        G[u].emplace_back(v, A2{a, b});
        G[v].emplace_back(u, A2{a, b});
    }
    vector<Int> B(N), C(N);
    dijkstra(G, S, 0, B);
    dijkstra(G, T, 1, C);
    vector<Int> cost(N);
    cost[N-1] = B[N-1] + C[N-1];
    for (int i = N-2; i >= 0; i--) {
        cost[i] = min(cost[i+1], B[i] + C[i]);
    }
    for (int i = 0; i < N; i++) {
        cout << (Int)1e15 - cost[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 10672
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,w;
    cin>>n>>w;
    vector<pair<ll,ll>>v(n);
    for(ll i=0;i<n;i++)
        cin>>v[i].first>>v[i].second;
    ll dp[n+1][101000];
    dp[0][0]=0;
    for(ll i=1;i<101000;i++)
        dp[0][i]=1e13;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<101000;j++)
            dp[i][j]=1e13;
        for(ll j=0;j<101000;j++)
        {
            dp[i][j]=min(dp[i-1][j],dp[i][j]);
            if((j-v[i-1].second)>=0)
            {
                dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1].second]+v[i-1].first);
            }
        }
    }
    ll ans=0;
    for(ll i=1;i<101000;i++)
    {
        if(dp[n][i]<=w)
            ans=i;
    }
    cout<<ans;
}

Measured memory_bytes: 80128
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as IS
main=print.f.map(fst.fromJust.B.readInt).B.words=<<B.getContents
f(n:k:p)=n-k+1-g 0 0 0 0 n p IS.empty p where
  g x i a c v(w:p) s (u:q)=g(x+1)j b d w p t r where
    j=if v<w then i+1 else 1
    b=if j>=k then a+1 else a
    d=if x>=k && j<k && IS.findMin s==u && IS.findMax s<w then c+1 else c
    t=IS.insert w$if x<k then s else IS.delete u s
    r=if x<k then (u:q) else q
  g _ _ a c _ _ _ _= max 1 a-1+c

Measured memory_bytes: 46716
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
long long N;

void func(long long num, int &count){
  if(num>N) return;
  func((num*10)+7,count);
  func((num*10)+5,count);
  func((num*10)+3,count);
  string str=to_string(num);
  int s=0,f=0,t=0;
  for(int i=0; i<str.size(); i++){
    if(str[i]=='7') s=1;
    if(str[i]=='5') f=1;
    if(str[i]=='3') t=1;
  }
  if(s==1&&f==1&&t==1) count++;
}


int main(int argc, char *argv[]){
  cin>>N;
  int res=0;
  func(0,res);
  cout<<res<<endl;
}
    


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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


long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}

class Point{
public:
	long long x;
	long long y;
};
long long N,M;
vector<long long>X(100006,0);
bool isOK(long long N){
	string s=to_string(N);
	set<char>set;
	for(int i=0;i<s.length();i++){
		set.insert(s[i]);
	}
	return set.size()==1;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N,M;
	cin>>N>>M;
	vector<long long>dp(M+1,0);
	for(int i=0;i<N;i++){
		long long K;
		cin>>K;
		for(int k=0;k<K;k++){
			long long a;
			cin>>a;
			dp[a]++;
		}
	}
	long long ans=0;
	for(int i=0;i<=M;i++){
		if(dp[i]==N)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define isz(x) (int)(x).size()
using ll = long long;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
const ll INF = (ll)1e18L;
struct SegTree {
    std::vector<ll> data;
    SegTree(int n) : data(4 * n, -INF) { }
    void set(int v, int l, int r, int p, ll x) {
        if (p < l || p >= r) return;
        if (l + 1 == r) { data[v] = x; }
        else { 
            int m = (l + r) / 2;
            set(2*v+1,l,m,p,x);
            set(2*v+2,m,r,p,x);
            data[v] = std::max(data[2*v+1],data[2*v+2]);
        }
    }
    ll get(int v, int l, int r, int ql, int qr) {
        if (qr <= l || r <= ql) { return -INF; }
        if (ql <= l && r <= qr) { return data[v]; }
        int m = (l + r) / 2;
        return std::max(get(2*v+1,l,m,ql,qr),get(2*v+2,m,r,ql,qr));
    }
    void set(int p, ll x) { set(0,0,isz(data)/4,p,x); }
    ll get(int ql, int qr) { return get(0,0,isz(data)/4,ql,qr); }
};
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    int n; std::cin >> n;
    vi h(n), a(n);
    for (auto &it : h) { std::cin >> it; it--; }
    for (auto &it : a) std::cin >> it;
    SegTree segtree(n);
    for (int i = n-1; i >= 0; i--) {
        ll best = std::max(ll(0), segtree.get(h[i],n));
        segtree.set(h[i], best + a[i]);
    }
    std::cout << segtree.get(0,n);
    return 0;
}

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

using namespace std;

int main() {
    int n, w_max; 
    cin >> n;
    cin >> w_max;

    vector<int> w(n);
    vector<int> v(n);

    for (int i = 0; i < n; ++i) {
        cin >> w[i];
        cin >> v[i];
    }

    vector<vector<long>> F(n + 1, vector<long>(w_max + 1, 0));

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= w_max; ++j) {
            int ii = i - 1;
            F[i][j] = max(
                (j - w[ii] >= 0) ? F[i - 1][j - w[ii]] + (long)v[ii] : 0,
                F[i - 1][j]
            );
        }
    }

    cout << F[n][w_max];
    
    return 0;
}

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

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

ll power(ll base, ll exp, ll mod) // O(logn) time
{
    ll ans=1LL; 
    while(exp){
        if(exp&1LL) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exp>>=1LL;
    }
    return ans%mod;
}

int main() { 
    ll tt = 1, n, q, m, l, r, c, i, j, k, w;
    boost;
    
    // cin >> tt;
    ll ans = 1;

    for(int _ = 1; _ <= tt; _++){
        cin >> n;

        vi sum(n), diff(n);
        for(i = 0; i < n; i++){
            cin >> l >> r;
            sum[i] = l + r;
            diff[i] = l - r;
        }
        sort(sum.B, sum.E);
        sort(diff.B, diff.E);

        ans = max(sum.back() - sum.front(), diff.back() - diff.front());
        cout << ans << nl;
    }
}


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

int main() {
    int N, ma = 0, ans = 0;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        ma = max(ma, p);
        ans += p;
    }
    cout << ans - ma / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int a = scan.nextInt();
	int b = scan.nextInt();
	String s = scan.next();
	if(s.length() != a+b+1){
	    System.out.println("No");
	    return;
	}
	for(int i = 0; i < a; i++){
	    if('0' <= s.charAt(i) && s.charAt(i) <= '9'){
	    }else{
		    System.out.println("No");
		    return;
	    }
	}
	if(s.charAt(a) != '-'){
	    System.out.println("No");
	    return;
	}
	for(int i = a+1; i < s.length(); i++){
	    if('0' <= s.charAt(i) && s.charAt(i) <= '9'){
	    }else{
		    System.out.println("No");
		    return;
	    }
	}
	    System.out.println("Yes");
    }
}

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

const int N = 1e5 + 9, P = 1e9 + 7;

int n, m, x[N];
	
struct Matrix {
	int x[3][3];
	Matrix () { memset(x, 0, sizeof x); }
}B, T1, T2[30];

void Mul (Matrix &CC, const Matrix &A, const Matrix &B) {
	static Matrix C;
	for (int i = 0; i < 3; ++i)
		for (int j = 0; j < 3; ++j)
			C.x[i][j] = (1ll * A.x[i][0] * B.x[0][j] + 1ll * A.x[i][1] * B.x[1][j] + 1ll * A.x[i][2] * B.x[2][j]) % P;
	CC = C;
}

int main () {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) scanf("%d", &x[i]); x[++m] = n;
	B.x[0][1] = T1.x[0][1] = T2->x[2][1] = T2->x[2][2] = T2->x[0][1] = 2;
	B.x[0][0] = B.x[0][2] = T1.x[1][1] = T1.x[1][2] = T1.x[2][2] = T1.x[0][2] = T1.x[0][0] = T2->x[2][0] = T2->x[0][0] = T2->x[0][2] = T2->x[1][1] = T2->x[1][2] = 1;
	for (int i = 1; (1 << i) <= n; ++i) Mul(T2[i], T2[i - 1], T2[i - 1]);
	for (int i = 1, d; i <= m; ++i) {
		d = x[i] - x[i - 1] - 1;
		for (int i = 0; d; ++i) if (d >> i & 1) d ^= 1 << i, Mul(B, B, T2[i]);
		if (i < m) Mul(B, B, T1);
	}
	printf("%d\n", B.x[0][2]);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[101];
  
  for(int i=0;i<n;i++){
    cin>>a[i];
  }


  sort(a,a+n,greater<int>());
  int ans1=0,ans2=0;
  
  for(int i=0;i<=n-1;i+=2){
    ans1+=a[i];
  }
  for(int i=1;i<=n-1;i+=2){
    ans2+=a[i];
  }

  cout<<ans1-ans2<<endl;
  
  return (0);
}

  


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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n; cin >> n;
    n %= 10;
    if(n == 3) cout << "bon";
    else {
        if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon";
        else cout << "hon";
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int A[N], B[N+1], C[N];
   for(int i=0; i<N; ++i) std::cin >> A[i];
   for(int i=1; i<N+1; ++i) std::cin >> B[i];
   for(int i=1; i<N; ++i) std::cin >> C[i];

   int ans = 0;
   for(int i=0; i<N; ++i){
      ans += B[A[i]];
      if(i<N-1 && A[i]==A[i+1]-1) ans += C[A[i]];
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        String S = sc.next();
        int l = S.length();
        String a = "AC";
        int b = 0;
        int sum = 0;
        int[] x = new int[l+1];

        if(S.charAt(0)!=a.charAt(0)){
            System.out.println("WA");
        }
        else{
            for(int i=2; i<=l-2; i++){
                if(S.charAt(i)==a.charAt(1)){
                    break;
                }
                if(i==l-2){
                    System.out.println("WA");
                    b = l-2;
                }
            }
            if(b!=l-2){
                String US = S.toUpperCase();
                for(int i=0; i<l; i++){
                    if(S.charAt(i)==US.charAt(i)){
                        sum += 1;
                        x[sum] = i;
                    }
                }
                
                if(sum==2 && S.charAt(x[1])==a.charAt(0) && S.charAt(x[2])==a.charAt(1)){
                    System.out.println("AC");
                }
                else if(sum>2){
                    System.out.println("WA");
                }
            }
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define pi 3.1415  
#define ll long long
#define pii pair<int,int>
#define debug(a) cout<<a<<'\n'
#define maxn 59
#define MOD 1000000007
#define INF (int)3000009
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=1;
    for(int i=0;i<s.size()-1;i++){
        if(s[i+1]!=s[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}   

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

const int M=10000;

int main(int argc,char* argv[])
{
    int n,a[]={4,7,8,11,12,14,15,16};
    cin>>n;
    bool q=0;
    for(int x:a) if(x==n) q=1;
    yn(q||n>=18);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int main(){
    int A,B; cin >> A >> B;
    string S; cin >> S;
    int x=1;
    for(int i=0;i<A+B+1; i++){
        char s = S[i];
        if(i==A){
            if(s == '-')x*=1; else x*=0;
        }else{
            if(isdigit(s)) x*=1; else x*=0;
        }
    }
    if(x) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int64 gcd(int64 a, int64 b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int h, n; cin >> h >> n;
		vector<int> dp(h + 1, INF);
		dp[0] = 0;
		rep (i, n) {
			int a, b; cin >> a >> b;
			for (int j = 0; j < h; ++j) {
				int nj = j + a;
				if (nj >= h) nj = h;
				dp[nj] = min(dp[nj], dp[j] + b);
			}
		}
		cout << dp[h] << endl;
    return;
}

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



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

int main() {
  int N, A;
  cin >> N >> A;
  
  bool tf = false;
  int num = N % 500;
  if (num <= A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>

int G[101][101];
int queue[100];
int queS=0;
int queE=0;
int breadth[101]; //0

int dequeue();
void enqueue();
void bfs(int);
void visit(int); 

main(){
  int i, j, k, l, n, adj;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d%d", &l, &k);
    for(j=0; j<k; j++){
      scanf("%d", &adj);
      G[l][adj] = 1;
    }
  }

  bfs(n);

  for(i=1; i<=n; i++){
    printf("%d %d\n", i, breadth[i]);
  }

  return 0;
}

void enqueue(int data){
  queue[queE] = data;
  queE = (queE + 1)%100;
  //printf("** enqueue(%d), queS:%d, queE:%d **\n", data, queS, queE);
}

int dequeue(){
  int tmp = queue[queS];
  queS = (queS+1)%100;

  //printf("** dequeue()=%d, queS:%d, queE:%d **\n", tmp, queS, queE);
  return tmp;
}

void bfs(int n){
  int i;
  //init
  for(i=1; i<=n; i++) breadth[i]=-1;

  enqueue(1);
  breadth[1]=0;
  while(queS != queE) visit(n);
}

void visit(int n){
  static int qued[101];
  static int depth=0;
  int i, j, p;
  p = dequeue();
  //printf("**visit %d**\n", p);

  
  qued[p] = 1;
  for(i=1; i<=n; i++){
    if(G[p][i]==1 && qued[i]==0){
      qued[i] = 1;
      // printf("** breadth[%d] = breadth[%d]+1 = %d **\n",i, p, breadth[p]+1);
      breadth[i] = breadth[p]+1;
      enqueue(i);
    }
  }
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;
const double PI = 3.14159265358979323846;
//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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


  
  string S,T;
  cin>>S>>T;
  
  int counter=0;
  int a=S.size();
  for(int i=0;i<a;i++){
    if(S[i]!=T[i]){
      counter++;
    }
  }
    cout<<counter<<endl;
  
  
}



Measured memory_bytes: 3916
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	int solve(int[] a, int[] p, int c) {
		int n = a.length;
		int[][] dp = new int[1 << (n - 1)][c * n + 1];
		dp[0][n * a[n - 1]] = 1;

		for (int i = 0; i < c * n; i++) {
			
//			System.err.println(Arrays.deepToString(dp));

			for (int mask = (1 << (n - 1)) - 1; mask >= 0; mask--) {
				for (int ok = i; ok <= c * n; ok++) {
					if (dp[mask][ok] == 0) {
						continue;
					}

					if (i % n != 0) {
						int who = p[i % n - 1];
						if (!test(mask, who)) {
							dp[mask | (1 << who)][Math.min(
									Math.max(ok, i + n * a[who]), c * n)] += dp[mask][ok];
						}
					}

				}
			}
		}

		return dp[(1 << (n - 1)) - 1][c * n];
	}

	static boolean test(int mask, int i) {
		return ((mask >> i) & 1) == 1;
	}

	void submit() {
		int n = nextInt();
		int c = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		Arrays.sort(a);

		int[] p = new int[n - 1];
		for (int i = 0; i < p.length; i++) {
			p[i] = i;
		}

		long good = 0;
		long total = 0;
		long one = BigInteger.valueOf(c).pow(n - 1).intValueExact();

		do {
			good += solve(a, p, c);
			total += one;
		} while (nextPermutation(p));

		out.println(1.0 * good / total);
	}

	static boolean nextPermutation(int[] a) {
		int n = a.length;
		int ptr = n - 1;
		while (ptr > 0 && a[ptr - 1] >= a[ptr]) {
			ptr--;
		}

		for (int i = ptr, j = n - 1; i < j; i++, j--) {
			int tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}

		if (ptr == 0) {
			return false;
		}

		for (int i = ptr;; i++) {
			if (a[ptr - 1] < a[i]) {
				int tmp = a[ptr - 1];
				a[ptr - 1] = a[i];
				a[i] = tmp;
				return true;
			}
		}
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

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

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

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


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define INF 100000000000LL

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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef long double ld;
long long n2(int i){
  long long a = 1;
  while(i--) a *= 2;
  return a;
}
int main(void){
  int n, p, m[2] = {}, a;
  cin >> n >> p;
  rep(i, n){
    cin >> a;
    m[a % 2]++;
  }
  ull ans = 0;
  if(p == 1 && m[1] == 0) ans = 0;
  else ans = n2(m[0]) * n2(max(m[1] - 1, 0));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
N=int(input())
hako=[]
for i in range(N):
    A,B=input().split()
    hako.append([A,int(B)*-1])
kari=hako.copy()
#print(kari)
hako.sort()
hako=sorted(hako,key=itemgetter(0,1))
#print(hako)
for i in range(N):
    print(kari.index(hako[i])+1)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <float.h>
using namespace std;

#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>


const int mod = 1e9 + 7;
typedef long long ll;
typedef pair<int, int> ii;


// Custom comparator
struct cmp {
    bool operator()(int a, int b) {
        return b < a;
    }
};


// Solution class
//class Solution {
//public:
//    char sol(char c) {
//        return c >= 'a' && c <= 'z' ? 'a' : 'A';
//    }
//};



// Run code
int main(int argc, char const *argv[])
{

    int N;
    scanf("%d", &N);

    cout<<ceil((double)N / 1000) * 1000 - N;

    return 0;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#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 pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    ll n;
    cin >> n;
    ll ret = (n-1)*n/2; 
    cout << ret << endl; 
    return 0;
}

Measured memory_bytes: 256
function main (input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const map = {
    M: 0,
    A: 0,
    R: 0,
    C: 0,
    H: 0
  };
  for (let i = 1; i <= n; i++) {
    const str = input[i];
    let target;
    if (str[0] === "M") {
      target = "M";
    } else if (str[0] === "A") {
      target = "A";
    } else if (str[0] === "R") {
      target = "R";
    } else if (str[0] === "C") {
      target = "C";
    } else if (str[0] === "H") {
      target = "H";
    }
    if (!map[target] {
      map[target] = 1;
    } else {
      map[target] = map[target] + 1;
    }
  }
  	const combinations = [
        ["M", "A", "R"],
        ["M", "A", "C"],
        ["M", "A", "H"],
        ["M", "R", "C"],
        ["M", "R", "H"],
        ["M", "C", "H"],
        ["A", "R", "C"],
        ["A", "R", "H"],
        ["A", "C", "H"],
        ["R", "C", "H"]
  	];
	let result = 0;
	for(const combination of combinations) {
		result += combination.map(c => map[c]).reduce((a, b) => a*b);
    }
    console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17100
# 整数の入力
A, B, C = map(int, input().split())

tmp_max = 10*A + B + C 

if tmp_max < 10*B + C +A:
    tmp_max = 10*B + C +A

if tmp_max < 10*C + A +B:
    tmp_max = 10*C + A +B

# 出力
print("{}".format(tmp_max))

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

int main(void){
    int n, d[200020], m, t[200020];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> d[i];
    cin >> m;
    for (int i = 0; i < m; i++) cin >> t[i];
    
    sort(d, d + n);
    sort(t, t + m);
    
    int i = 0, j = 0;
    while (i < n && j < m) {
        if (d[i] == t[j]) {
            i++;  j++;
        }
        else if (d[i] < t[j]) i++;
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    if (j == m) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////
#include <set>


int main()
{
    int N;
    io >> N;
    vi A(N);
    for (int i = 0; i < N; i++)
        io >> A[i];
    
    sort(begin(A), end(A), greater<int>());

    multiset<int, greater<int>> ring;
    ring.insert(A[0]);
    ll ans = 0;
    for (int i = 1; i < N; i++)
    {
        auto max_it = ring.begin();
        ans += *max_it;

        ring.erase(max_it);
        ring.insert(A[i]);
        ring.insert(A[i]);
    }
    io << ans << BR;    
}

Measured memory_bytes: 13576
def slove():
    import sys
    input = sys.stdin.readline
    x = str(input().rstrip('\n'))
    s = 0
    cnt = 0
    for i in range(len(x)):
        if x[i] == "S":
            s += 1
        else:
            if s > 0:
                s -= 1
                cnt += 1
    print(len(x) - cnt * 2)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 40048
import java.util.Scanner;

public class Main{

 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int w = sc.nextInt();
  int n = sc.nextInt();
  int[] values = new int[w];
  for(int i=0;i<values.length;i++){
   values[i]=i+1;
  }
  
  for(int i=0;i<n;i++){
   String str = sc.next();
   String[] ab = str.split(",");

   int a = Integer.parseInt(ab[0])-1;
   int b = Integer.parseInt(ab[1])-1;
   int c = values[a];
   values[a] = values[b];
   values[b] = c;
  }
  for(int i=0;i<w;i++){
   System.out.println(values[i]);
  }
 }
}

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


int main(){

    vector<int> i(3);
    cin >> i[0] >> i[1] >> i[2];
    sort(i.begin(),i.end());
    int ans = 0;  
    if(i[0] % 2 == i[1] % 2){
        ans += (i[1] - i[0]) / 2;
        ans += i[2] - i[1];
    }
    
    else{
        if(i[2] % 2 == i[0] % 2){
            ans += (i[2] - i[0]) / 2;
            ans += 1;
            ans += (i[2] + 1 - i[1]) / 2;
        }
        else if(i[2] % 2 == i[1] % 2){
            ans += (i[2] - i[1]) / 2;
            ans += 1;
            ans += (i[2] + 1 - i[0]) / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::cmp;
use std::io;

fn main() {
	let n: i32 = read_line().parse().unwrap();
	let mut ans = false;
	for i in 0 .. 101 {
		for j in 0 .. 101 {
			if i * 4 + j * 7 == n {
				ans = true;
			}
		}
	}
	println!("{}", if ans { "Yes" } else { "No" });
}

fn read_line() -> String {
	let mut ln = String::new();
	io::stdin().read_line(&mut ln).ok();
	ln.pop();
	return ln;
}


Measured memory_bytes: 4352