akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int a,int b){return b?GCD(b,a%b):a;}
int64_t GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int a, int b){return a * b / GCD(a, b);}
int64_t LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/


constexpr int32_t MAX = 1e5+1;
vector<int64_t> fac(MAX, 0), finv(MAX, 0), inv(MAX, 0);
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;
    }
}

//#define int int64_t
signed main()
{
	COMinit();
	int n, m; cin >> n >> m;
    if(abs(n-m)>=2){
        cout << 0 << endl;
    }
    else{
        if(n>m || m > n){
            cout << fac[n]*fac[m]%MOD << endl;
        }
        else
        {
            cout << (fac[n]*fac[m]%MOD)*2%MOD << endl;
        }
        
    }
}

Measured memory_bytes: 2560
// 2020-08-24 19:55:51
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int inf = 1e9, MX = 410*410;
int dp[MX+10], p[MX+10];
int encode(int a, int b) {
  return a * 410 + b;
}
P decode(int x) {
  return P(x / 410, x % 410);
}
void answer() {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i] >> b[i] >> c[i];
  rep(i, MX) dp[i] = inf;
  dp[0] = 0;
  rep(i, n) {
    swap(dp, p);
    rep(j, MX) {
      dp[j] = p[j];
      auto [ca, cb] = decode(j);
      if(ca < 1 || 400 < ca || cb < 1 || 400 < cb) continue;
      if(ca - a[i] >= 0 && cb - b[i] >= 0) {
        int k = encode(ca - a[i], cb - b[i]);
        chmin(dp[j], p[k] + c[i]);
      }
    }
  }
  int ans = inf;
  rep(j, MX) {
    auto [ca, cb] = decode(j);
    if(ca < 1 || 400 < ca || cb < 1 || 400 < cb) continue;
    int g = __gcd(ca, cb);
    if(ca / g == ma && cb / g == mb) chmin(ans, dp[j]);
  }
  if(ans == inf) ans = -1;
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4916
n, m, q = map(int, input().split())

dia = [[0]*(n+1) for i in range(n+1)]
for i in range(m):
  l, r = map(int, input().split())
  dia[l][r] += 1
  
lst = [[0]*(n+1) for i in range(n+1)]
for i in range(1, n+1):
  for j in range(i, n+1):
    lst[i][j] = lst[i][j-1] + dia[i][j]
    
for i in range(q):
  l, r = map(int, input().split())
  count = 0
  for j in range(l, r+1):
    count += lst[j][r]
  print(count)

Measured memory_bytes: 55256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    string s;
    cin >> s;
    int c=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+'){
            c++;
        }else{
            c--;
        }
    }
    cout<<c<<endl;
}
   

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn prime_factorize(n: u64) -> Vec<(u64, usize)> {
    let mut m = n;
    let mut r = vec![];
    for x in 2..n + 1 {
        if m == 1 { break }
        if x * x > n { r.push((m, 1)); break }
        if n % x != 0 { continue }
        let mut c = 0;
        while m % x == 0 { m /= x; c += 1; }
        r.push((x, c));
    }
    r
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let p: u64 = sc.cin();
    // trace!(prime_factorize(p));
    put!(prime_factorize(p).iter().map(|&(m, k)| m.pow((k / n) as u32)).product::<u64>());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4476
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC169
{
    /// <summary>
    /// 
    /// </summary>
    static class A
    {
        static void Main(string[] args)
        {
            var a = NextInt();
            var b = NextInt();

            Console.WriteLine(a * b);



        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


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

int main(){
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    int s = 0;
    rep(i, n){
        s+=a.at(i);
    }
    if(s>=h){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;

int d[61][200005];

int main(){
  int n; cin>>n;
  ll k; cin>>k;
  for (size_t i = 1; i <= n; i++)
  {
    cin >> d[0][i];
  }
  
  for (size_t i = 1; i < 61; i++)
  {
    for (size_t j = 1; j <= n; j++)
    {
      d[i][j] = d[i-1][d[i-1][j]];
    }
    
  }
  int ans = 1;
  for (size_t i = 0; i < 61;i++)
  {
    if (k & (1LL<<i))
    {
      ans = d[i][ans];
    }
  }
  cout << ans << endl;
  
  
}

Measured memory_bytes: 51284
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> K;
  //cout << K/2 << " "<<(K+1)/2<<endl;
  ans = (K/2)*((K+1)/2);

  cout << ans << endl;

}


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

int main() {
    int N=0,T=0,A=0,best_num=0;
    cin >> N >> T >> A;
    float best=9999.0;
    for(int i=0; i<N; i++){
        int h=0;
        cin >> h;
        float gap = T-0.006*h - A;
        if(gap*gap < (best-A)*(best-A) ){
            best = T-0.006*h;
            best_num = i+1;
        }
    }
    cout << best_num << endl;
    return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X,N=MI()
    P=set(LI())

    for i in range(N+1):
        if(X-i not in P):
            print(X-i)
            return 
        if(X+i not in P):
            print(X+i)
            return
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 10724
import sys
#sys = stdin.buffer.readline

def main():
    N = int(input())
    s = input()
    MOD = 10**9+7
    base = [1]*N
    
    for i in range(N-1):
        imos = [0]*N
        if s[i] == "<":
            for j in range(N-i-1):
                imos[0] += base[1+j]
                imos[1+j] -= base[1+j]
        else:
            for j in range(N-i-1):
                imos[j] += base[j]
                imos[N-i-1] -= base[j]
        for k in range(N-1):
            imos[k+1] += imos[k]
            imos[k+1] %= MOD
        base = imos
    
    print(base[0]%MOD)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 42092
#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 1e5 + 100;
int H[2][maxn], mx[2], num[2], x, n;
int main()
{
    cin>>n;
    for(int i = 1; i <= n; i++){
        scanf("%d", &x);
        H[i&1][x]++;
    }
    for(int c = 0; c <=1 ; c++)
    for(int i = 1; i <= 1e5; i++){
        if(H[c][i] > mx[c]){
            mx[c] = max(mx[c], H[c][i]);
            num[c] = i;
        }
    }
    if(num[0] == num[1]){
        int temp = mx[0];
        H[0][num[0]] = H[1][num[0]] = 0;
        mx[0] = mx[1] = -1;
        for(int c = 0; c <= 1; c++)
        for(int i = 1; i <= 1e5; i++){
            mx[c] = max(mx[c], H[c][i]);
        }
        cout<<n - max(mx[0], mx[1]) - temp<<endl;
    } else {
        cout<<n - mx[0] - mx[1];
    }
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


int main() {

    int n, m;
    cin >> n >> m;

    vector<vector<int> > matrix(n, vector<int>(m, 0));
    vector<int> v(m, 0);

    rep(y, n) rep(x, m) cin >> matrix[y][x];

    rep(y, m) cin >> v[y];

    rep(y, n) {
        int sum = 0;
        rep(x, m) {
            sum += matrix[y][x] * v[x];
        }
        cout << sum << endl;
    }

}


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

int main () {
  string s, t;
  cin >> s >> t;

  const int R = 50;
  vector<int> sc(R, 0), tc(R, 0);

  int n = s.size();
  for(char c: s) sc[c - 'a'] += 1;
  for(char c: t) tc[c - 'a'] += 1;

  sort(sc.begin(), sc.end());
  sort(tc.begin(), tc.end());

  rep(i,R) if(sc[i] != tc[i]) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 776
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,a,b;
    cin >> N ;
    switch(N){
        case 1:
         cout << "Hello World";
            break;
        case 2:
            cin >> a >> b;
            cout << a + b;
            break;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
const long long inf = 1e18;
 
using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

bool custom_sort(int &x, int &y)
{
    if(x<y)
        return 1;
    else
        return 0;
}

void always_ignore_function_name()
{
    int n;
    cin>>n;
    vll v(n);
    rep(i,n)
    {
        cin>>v[i];
    }
    sort(all(v));
    ll ans=v[n-1];
    int n1=0;
    if(n==2)
    {
        cout<<v[n-1]<<endl;
        return;
    }
    int cnt=0,pos=n-2;
    while(n1<n-2)
    {
        ans+=v[pos];
        cnt++;
        n1++;
        if(cnt==2)
        {
            cnt=0;
            pos--;
        }
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        always_ignore_function_name();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

namespace A___Two_Coins
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_B_C = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = A_B_C[0];
            var B = A_B_C[1];
            var C = A_B_C[2];

            Console.WriteLine(A + B >= C ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

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

		    int n = sc.nextInt();
		    double ans = 0;
		    for(int i=0;i<n;i++) {
		    	ans = ans+(1/sc.nextDouble());
		    }
		    System.out.println(1/ans);


		    sc.close();
	}
}


Measured memory_bytes: 25172
n = int(input())
s = input()

cnt = 0
for i in range(n):
    for j in range(1, (n - 1) // 2 + 1):
        if n - 1 < i + 2 * j:
            break
        
        if s[i] != s[i + j] and s[i + j] != s[i + 2 * j] and s[i + 2 * j] != s[i]:
            cnt += 1
            continue
        
ans = [0] * 3
for word in s:
    if word == 'R':
        ans[0] += 1
    elif word == 'G':
        ans[1] += 1
    else:
        ans[2] += 1

ans_sum = ans[0] * ans[1] * ans[2]
print(ans_sum - cnt)

Measured memory_bytes: 9116
#include<iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	
int d  ;    
cin >> d ;

  if(d==22){
    cout << "Christmas Eve Eve Eve"  ;
  }else if(d==23){
    cout << "Christmas Eve Eve"  ;    
  }else if(d==24){
    cout << "Christmas Eve"  ;
  }else if(d==25){
    cout << "Christmas"  ;
  }

 cout  << endl ;
    
  	return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    Map<Integer, List<PP>> map = new HashMap<>();
    public void solve() {
    	int N = Integer.parseInt(sc.next());
    	int a, x, y;
    	List<PP> list;
    	for (int i = 0; i < N; i++) {
        	a = Integer.parseInt(sc.next());
        	list = new ArrayList<>();
        	map.put(i, list);
        	for (int j = 0; j < a; j++) {
            	x = Integer.parseInt(sc.next()) - 1;
            	y = Integer.parseInt(sc.next());
				list.add(new PP(x, y));
			}
		}
    	int[] J = new int[N];
    	int ans = 0, cnt;
    	for (int i = (1 << N) - 1; i >= 0; i--) {
    		cnt = 0;
    		Arrays.fill(J, -1);
    		LOOP:
			for (int j = 0; j < N; j++) {
				if((i & (1 << j)) == 0)		continue;	// 無視する
				for(PP p : map.get(j)) {
//					if(J[p.key] == -1)		J[p.key] = p.val;
//					else if(J[p.key] != p.val) {
//						cnt = -1;
//						break LOOP;
//					}
					if(p.val == 0) {
						if((i & (1 << p.key)) != 0) {
							cnt = -1;
							break LOOP;
						}
					}
					if(p.val == 1) {
						if((i & (1 << p.key)) == 0) {
							cnt = -1;
							break LOOP;
						}
					}
				}
				cnt++;
			}
    		ans = Math.max(ans, cnt);
		}
    	out.println(ans);
    }    
    // Set に入れるなら　PPKEY　を使う！
    class PP{
    	public int key, val;
    	public PP(int key, int val) {
    		this.key = key;
    		this.val = val;
    	}
		public int getKey() {
			return key;
		}
		public void setKey(int key) {
			this.key = key;
		}
		public int getVal() {
			return val;
		}
		public void setVal(int val) {
			this.val = val;
		}
    }
    // ==================================================================
}



Measured memory_bytes: 27860
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=1;i<=n;i++) cin >> a[i];

  vector<int> sum(n+1,0);
  vector<int> v;
  for(int i=n;i>0;i--){
    if(sum[i]%2 != a[i]){
      v.emplace_back(i);
      for(int j=1;j*j<=i;j++){
        if(i%j==0){
          sum[i/j]++;
          if(i/j !=j){
            sum[j]++;
          }
        }
      }
    }
  }

  cout << v.size() << endl;
  for(int i=0;i<v.size();i++){
    cout << v[i];
    if(i != v.size()-1) cout << " ";
    else cout << endl;
  }
}


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

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

    if (n % 2 == 0) cout << n << endl;
    else cout << n * 2 << endl; 



    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;


int date[12][31];
string day[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};

int main() 
{
    for(int i = 0; i < 12; i++){
        for(int j = 0; j < 31; j++){
            date[i][j] = 0;
        }
    }
    for(int i = 0; i < 12; i++){
        if(i == 3 || i == 5 || i == 8 || i == 10){
            for(int j = 0; j < 30; j++){
                date[i][j] = 1;
            }
        }else if(i == 1){
            for(int j = 0; j < 29; j++){
                date[i][j] = 1;
            }
        }else{
            for(int j = 0; j < 31; j++){
                date[i][j] = 1;
            }
        }
    }
    while(true){
        int cnt = 0;
        int m,d;
        cin >> m >> d;
        if(m==0 && d == 0) break;
        m--; d--;
        for(int i = 0; i < 12; i++){
            for(int j = 0; j < 31; j++){
                if((i < m || (i == m && j <= d)) && date[i][j] == 1){
                    cnt++;
                }
            }
        }
        cnt += 2;
        cout << day[cnt%7] << endl;
    }
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    cin >> N;
    int h[N];
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }
    int ans = 0;
    bool update = true;
    while(update) {
        update = false;
        for(int l = 0; l < N; l++)
            if(h[l]) {
                update = true;
                int hmin = h[l];
                int r;
                for(r = l + 1; r < N && h[r]; r++) {
                    hmin = min(hmin, h[r]);
                }
                ans += hmin;
                for(int i = l; i < r; i++) {
                    h[i] -= hmin;
                }
                break;
            }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int n=nextInt();
		int x=nextInt();
		int a[]=new int[n+1];
		for(int i=1;i<=n;i++)
			a[i]=nextInt();
		long ans=Math.max(0,a[1]-x);
		a[1]-=Math.max(0,a[1]-x);
		for(int i=2;i<=n;i++)
		{
			int curr=Math.max(0,a[i]+a[i-1]-x);
			a[i]-=curr;
			ans+=curr;
		}
		out.println(ans);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 40076
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


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


int main() {

	int K;
	string S;
	int mojityuou;

	cin >> K;
	cin >> S;

	mojityuou = S.length();

	if (mojityuou > K) {
		S = S.substr(0, K);
		S = S.append("...");
	}

	cout<< S << endl;




	system("pause");
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std; typedef long long ll; typedef unsigned long long ull; const int mod = 1e9 + 7;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
//#define int ll

int n, k, h[100001], dp[100001];

signed main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	dp[1]=0;
	for (int i = 2; i <= n; i++)
	{
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		for (int j = 2; j <= k; j++)
		{
			if (i > j)
			{
				dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
			}
		}
	}
	cout << dp[n];
}

Measured memory_bytes: 1024
// JOI 2016 Q3 Refreshment Area - C++

#include <iostream>
using namespace std;

int main()
{

	int N, M, D, pos, ans = 0, cnt = 0;
	char MAP[101][101];

	cin >> N >> M >> D;

	for(int i = 0; i < N; i++) cin >> MAP[i];

	for(int i = 0; i < N; i++) {
		for(int j = 0; j < M; j++) {
			if(D <= M) {
				pos = j;
				for(cnt = 0; cnt < D; cnt++) {
					if(MAP[i][pos] == '#' || pos >= M) break;
					pos++;
				}
				if(cnt == D) ans++;
			}
			if(D <= N) {
				pos = i;
				for(cnt = 0; cnt < D; cnt++) {
					if(MAP[pos][j] == '#' || pos >= N) break;
					pos++;
				}
				if(cnt == D) ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 3100
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-07-11 21:00:33 +0900
# LastModified: 2020-07-11 21:03:48 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    L, R, d = map(int, input().split())
    left = L//d
    cnt = 0
    while (left+1)*d <= R:
        cnt += 1
        left += 1
    if L%d==0:
        cnt += 1
    print(cnt)




if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
<?php
fscanf(STDIN,"%s %s %s",$a,$b,$water);
$radian = 0;  

if($water/$a < $a*$b/2)//最大時に底面をすべてカバーしない
{
  $radian = atan($a*$b*$b/(2*$water));
}
else//する
{
 $radian = atan((2*($b/$a-$water/($a*$a*$a))));
}

echo($radian*180/M_PI);

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int a[100002];
int main()
{
	int n, sum = 0, sum2;

	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for(int i = 0; i <= n; i++)
	{
		sum += abs(a[i + 1] - a[i]);
	}
	for(int i = 1; i <= n; i++)
	{
		sum2 = sum;
		sum2 -= abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
		sum2 += abs(a[i + 1] - a[i - 1]);
		cout << sum2 << endl;
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
    using namespace std;
    #define FOR(i,n) for(int i=0;i<n;i++)
    #define why(n,x) int n;while(cin >>n,n!=x)
    #define iFOR(i,x,n)for(int i=x;i<n;i++)
    #define unless(flg) if ( !(flg) )
    #define read cin<<
    #define echo cout<<
    #define fin <<'\n'
    #define __ <<" "<<
    #define ___ <<" "
    #define bash push_back
    #define ALL(x) x.begin(),x.end()
    #define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
    #define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
    #define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
    #define int long long
    #define abs Abs
    typedef long long ll;
    typedef pair < int , int > pii;
    typedef vector < int > vit;
    typedef map < string , int > mstit;
    typedef vector < pii > vpi ;
    typedef greater < pii > gpi;
    typedef priority_queue < pii , vpi , gpi > dijk ;
    const int INF = 0x3f3f3f3f;
    const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
    const int SMOD = 1000000007;
    const int NMOD = 1000000009;
    int dx[]={1,0,-1,0,1,1,-1,-1};
    int dy[]={0,-1,0,1,-1,1,-1,1};
    ll Abs(ll x){return (x<0 ? -x : x);}
    bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
    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 qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
    int gcd(int a,int b){return b?gcd(b,a%b):a;}
    struct xyz{
    xyz(){
    cin.tie(0), ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    };
    }xyzzy;
     
    int x[10000000];
    signed main(){
    int n;
    cin >> n;
    int i =1;
    x[n]++;
    while(true){
    if(n&1){
    x[3*n+1]++;
    if(x[n=3*n+1]==2) break;
    }else{
    x[n/2]++;
    if(x[n=n/2]==2) break;
    }
    i++;
    }
    cout << i+1 fin;
    return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>
#include <cassert>
using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


class centroid {
private:
	int V;
	vector<vector<int> > G;
	vector<int> sz;
	void dfs(int u,int p, vector<int>& ct){
		bool ok = true;
		sz[u] = 1;
		for(int v : G[u]){
			if(v != p){
				dfs(v, u, ct);
				sz[u] += sz[v];
				if(2*sz[v] > V) ok = false;
			}
		}
		if(ok && V <= 2*sz[u]) ct.push_back(u);
	}

public:
	centroid(int node_size) : V(node_size), G(V), sz(V, 0){}
	void add_edge(int u,int v){
		G[u].push_back(v), G[v].push_back(u);
	}
	vector<int> solve(){
		vector<int> ct;
		dfs(0, -1, ct);
		return ct;
	}
};

vector<vector<pair<int,ll> >  >g;
map<pair<int,int>,ll > mp;
pair<ll,ll> dfs(int a,int pre){
    pair<ll,ll> sm = MP(0,0);
    for(auto x:g[a]){
        if(x.first!=pre){
            pair<ll,ll> p = dfs(x.first,a);
            sm.first += p.first;
            sm.second += 2*x.second*p.first+p.second;
        }
    }
    sm.first++;
    return sm;
}

int main(){
    int n;
    cin >> n;
    centroid cen(n);
    g.resize(n);
    
    rep(i,n-1){
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        g[a].push_back(MP(b,c));
        g[b].push_back(MP(a,c));
        cen.add_edge(a,b);
        mp[MP(a,b)] = c;
        mp[MP(b,a)] = c;
    }
    vector<int> p = cen.solve();
    if(p.size()==1){
        int a = p[0];
        ll sm = 0;
        ll mi = inf;
        for(auto x:g[a]){
            mi = min(mi,x.second);
            pair<ll,ll>b = dfs(x.first,a);
            sm += b.second;
            sm += 2*x.second*b.first;
        }
        sm -= mi;
        cout << sm << endl;
    }else{
        ll res = 0;
        int a = p[0];
        int b = p[1];
        pair<ll,ll> ss = dfs(a,b);
        res += ss.second;
        res += dfs(b,a).second;
        res += (2*ss.first-1)*mp[MP(a,b)];
        cout << res << endl;
    }
    return 0;
}

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

int main(){
  int i,a,n,k,ans=0;
  cin>>n>>k;
  vector<int> b(n+1,0);
  REP(i,n){
    cin>>a;
    b.at(a)++;
  }
  sort(b.rbegin(),b.rend());
  REP(i,n-k) ans+=b.at(i+k);  
  cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
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;
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	vector<int> v(26, 10000);
	int n;
	cin >> n;
	rep(i, n) {
		string s;
		cin >> s;
		vector<int> o(26, 0);
		for (auto x : s) {
			o[x - 'a']++;
		}
		rep(j, 26) {
			v[j] = min(v[j], o[j]);
		}
	}
	string ans = "";
	rep(i, 26) {
		string s(v[i], 'a' + i);
		ans += s;
	}
	cout << ans << endl;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0';
  
  vector<vector<ll>> dp(s.size() + 1, vector<ll>(2, 1e18));
  dp[0][0] = 0;
  dp[0][1] = 1;
  for(int i = 1; i <= s.size(); i++){
    dp[i][0] = min(dp[i - 1][0] + (s[i - 1] - '0'), dp[i - 1][1] + (s[i - 1] - '0') + 1);
    dp[i][1] = min(dp[i - 1][0] + (10 - (s[i - 1] - '0')), dp[i - 1][1] + (10 - (s[i - 1] - '0')) - 1);
  }
  
  cout << min(dp[s.size()][0], dp[s.size()][1]) << '\n';
}

Measured memory_bytes: 55964
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const data = line.slice(1, Number(line[0])+1)
                 .map(x => x.split(' ').map(Number))
                 .map(xs => {
                     return {id: xs[0]-1, point: xs.slice(2).map(x => x-1)};
                 })
                 .reduce((acc, x, _, arr) => {
                    acc[x.id] = x.point.reduce((a, y) => {
                        a[y] = 1;
                        return a;
                    }, [...Array(Number(line[0]))].fill(0));
                    return acc;
                 }, [...Array(Number(line[0]))].fill([]))
                 .map(x => x.join(' '))
                 .join('\n');

console.log(data);



Measured memory_bytes: 17372
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
bc = [[int(i) for i in input().split()] for i in range(m)]
ans = 0
cnt = 0
d = {}

for i in range(n): 
    d[a[i]] = d.get(a[i],0)+1
for k in d: 
    bc.append([d[k],k])
bc.sort(key= lambda x:x[1],reverse=True)

for i in range(len(bc)):
    if cnt < n:
        ans += bc[i][1]*bc[i][0]
        cnt += bc[i][0]
    else:
        ans -= (cnt-n)*bc[i-1][1]
        break
else:
    ans -= (cnt-n)*bc[i][1]

print(ans)


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

int main()
{
  string s;
  cin >> s;
  
  bool can = false;
  if (s.at(0) == '7') can = true;
  if (s.at(1) == '7') can = true;
  if (s.at(2) == '7') can = true;
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

#define TOP 1
#define NORTH 2
#define EAST 3
#define WEST 4
#define SOUTH 5
#define BOTTOM 6

struct dice {
  int num[6 + 1];
  int top, n, e, w, s, bottom;
  int tmp;
};

void dice_init(struct dice *d);
int dice_label(struct dice *d, int n);
int dice_location(struct dice *d, int label);

int main(int argc, char *argv[])
{
  struct dice d;
  int q, i;
  int q_t, q_s;
  int loc_t, loc_s;
  int answer;

  dice_init(&d);

  for (i = 1; i <= 6; i++) scanf("%d", &(d.num[i]));
  scanf("%d", &q);

  for (i = 0; i < q; i++) {
    scanf("%d %d", &q_t, &q_s);

    loc_t = dice_location(&d, dice_label(&d, q_t));
    loc_s = dice_location(&d, dice_label(&d, q_s));

    if (loc_t == TOP) {
      if (loc_s == NORTH) answer = d.num[d.w];
      else if (loc_s == EAST) answer = d.num[d.n];
      else if (loc_s == WEST) answer = d.num[d.s];
      else if (loc_s == SOUTH) answer = d.num[d.e];

    } else if (loc_t == NORTH) {
      if (loc_s == TOP) answer = d.num[d.e];
      else if (loc_s == EAST) answer = d.num[d.bottom];
      else if (loc_s == WEST) answer = d.num[d.top];
      else if (loc_s == BOTTOM) answer = d.num[d.w];

    } else if (loc_t == EAST) {
      if (loc_s == NORTH) answer = d.num[d.top];
      else if (loc_s == TOP) answer = d.num[d.s];
      else if (loc_s == BOTTOM) answer = d.num[d.n];
      else if (loc_s == SOUTH) answer = d.num[d.bottom];

    } else if (loc_t == WEST) {
      if (loc_s == NORTH) answer = d.num[d.bottom];
      else if (loc_s == TOP) answer = d.num[d.n];
      else if (loc_s == BOTTOM) answer = d.num[d.s];
      else if (loc_s == SOUTH) answer = d.num[d.top];

    } else if (loc_t == SOUTH) {
      if (loc_s == TOP) answer = d.num[d.w];
      else if (loc_s == EAST) answer = d.num[d.top];
      else if (loc_s == WEST) answer = d.num[d.bottom];
      else if (loc_s == BOTTOM) answer = d.num[d.e];

    } else if (loc_t == BOTTOM) {
      if (loc_s == NORTH) answer = d.num[d.e];
      else if (loc_s == EAST) answer = d.num[d.s];
      else if (loc_s == WEST) answer = d.num[d.n];
      else if (loc_s == SOUTH) answer = d.num[d.w];
    }

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

  return 0;
}

void dice_init(struct dice *d)
{
  d->top = 1;
  d->n = 5;
  d->e = 3;
  d->w = 4;
  d->s = 2;
  d->bottom = 6;
}

int dice_label(struct dice *d, int n)
{
  int i;

  for (i = 6; i > 0; i--) {
    if (d->num[i] == n) return i;
  }
  return i;
}

int dice_location(struct dice *d, int label)
{
  if (d->top == label) return TOP;
  else if (d->n == label) return NORTH;
  else if (d->e == label) return EAST;
  else if (d->w == label) return WEST;
  else if (d->s == label) return SOUTH;
  else if (d->bottom == label) return BOTTOM;
  else return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
int main (void){
	int x=0;
	int i=0;
	for(i=1;i<10001;i++){
		scanf("%d",&x);
	    if(x == 0){
		break;
		}
		printf("Case %d: %d\n",i,x);
		}
    return 0;
}


Measured memory_bytes: 2036
#!/usr/bin/env python3
import math

N = int(input().split()[0])
X = N / 1.08

# if math.floor(math.ceil(X) * 1.08) == N:
#     ans = math.ceil(X)
# elif math.floor(math.floor(X) * 1.08) == N:
#     ans = math.floor(X)
# else:
#     ans = ":("

if math.floor(math.ceil(X) * 1.08) == N:
    ans = math.ceil(X)
elif math.floor(math.floor(X) * 1.08) == N:
    ans = math.floor(X)
else:
    ans = ":("

print(ans)


Measured memory_bytes: 3064
n,m = map(int,input().split())
li = []
count = 0
ans = 0

for i in range(n):
    a,b = map(int,input().split())
    li.append((a,b))

li.sort(key = lambda x:x[0])

for i in range(len(li)):
    if count > m:
        break
    if count + li[i][1] <= m:
        ans += li[i][0] * li[i][1]
    elif count + li[i][1] > m:
        buf = m - count
        ans += buf * li[i][0]
    count += li[i][1]

print(ans)


Measured memory_bytes: 18180
number = str(input())[::-1]
remainderDictionary = {0: 1}
digitDictionary = {'1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9}

sum = 0
x = 1
for i in number:
  x = (x * 10) % 2019
  sum = (sum + digitDictionary[i] * x) % 2019 
  remainderDictionary[sum] = remainderDictionary.get(sum,0) + 1

ansDictionary = {} # dictionary with the number of occurences and the corresponding N combinations of 2
ans = 0
for i in remainderDictionary:
  remainderOccurences = remainderDictionary[i]
  value = ansDictionary.get(remainderOccurences,-1)
  if value == -1:
    value = remainderOccurences * (remainderOccurences - 1) // 2 # N combinations of 2
    ansDictionary[remainderOccurences] = value
  ans += value
print(ans)

Measured memory_bytes: 9364
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdint(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main(void) {
	int r;
	r = getint();
	if (r < 1200) {
		showstring("ABC");
	} else if (r < 2800){
		showstring("ARC");
	} else {
		showstring("AGC");
	}
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdint(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 128