akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,k,x,y,dir[4][2]={1,0,-1,0,0,1,0,-1},u[850][850];
char a[850][850];
struct node {
    int x;
    int y;
    int step;
};
int judge(int x,int y){
    if(x<1 || x>n || y<1 || y>m)
        return 1;
    if(u[x][y] == 1 || a[x][y] == '#')
        return 1;
    return 0; 
}
void bfs(){
    node init;
    queue<node> q;
    node next;
    init.x = x;
    init.y = y;
    init.step = 0;
    u[x][y] = 1;
    q.push(init);
    while(!q.empty()){
        node tmp = q.front();
        q.pop();
        for(int i=0;i<4;i++){
            next.x = tmp.x+dir[i][0];
            next.y = tmp.y+dir[i][1];
            if(judge(next.x,next.y)) continue;
            a[next.x][next.y]='c';
            next.step = tmp.step+1;
            u[next.x][next.y] = 1;
            if(next.step<k)q.push(next);
        }
    }
}
int main(){
    while(cin>>n>>m>>k){
        memset(u,0,sizeof(u));
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                cin>>a[i][j];
                if(a[i][j]=='S')x=i,y=j;
            }
        }
        bfs();
        int ans=1000;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(a[i][j]=='S'||a[i][j]=='c'){
                    for(int l=0;l<4;l++){
                        int num=0;
                        if(a[i+dir[l][0]][j+dir[l][1]]=='#'||a[i][j]=='c')num=1;
                        if(a[i+dir[l][0]][j+dir[l][1]]=='c'&&a[i][j]=='S')continue;
                        int numx=0,numy=0;
                        if(dir[l][0]==-1)numx=i-1;
                        else if(dir[l][0]==1)numx=n-i;
                        if(dir[l][1]==-1)numy=j-1;
                        else if(dir[l][1]==1)numy=m-j;
                        num+=(numx+numy)/k;
                        if((numx+numy)%k)num++;
                        //cout<<i<<" "<<j<<" "<<l<<" "<<num<<" "<<numx<<" "<<numy<<endl;
                        ans=min(ans,num);
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
n= int(input())
st=list(map(int,input().split()))
#print(st)
list =[[0]*2 for i in range(n)]
    
for j in range(len(list)):
    list[j][0]=j+1
    list[j][1]=st[j]
    
list.sort(key=lambda x: x[1])
#print(list)

for k in range(len(list)):
    print(list[k][0],end=' ')

Measured memory_bytes: 22268
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000005
#define MAX 5001
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[6] = {500, 100, 50, 10, 5, 1};
int solve(int n){
	int ans = 0;
	while(1){
		for(int i = 0;i < 6;i++){
			if(n >= a[i]){
				n -= a[i];
				ans++;
				break;
			}
		}
		if(n == 0)break;
	}
	return ans;
}

int main(){
	int n;
	while(cin >> n, n){
		cout << solve(1000-n) << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int h, w;
char s[55][55];
int dist[55][55];
queue < pair < int, int > > q;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> h >> w;
    int all = 0;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> s[i][j];
            if (s[i][j] == '.') all++;
        }
    }
    for (int i = 1; i <= 50; i++) {
        for (int j = 1; j <= 50; j++) dist[i][j] = -1;
    }
    dist[1][1] = 0;
    q.push(make_pair(1, 1));
    while (!q.empty()) {
        pair < int, int > v = q.front();
        q.pop();
        int x = v.first;
        int y = v.second;
        for (int k = 0; k < 4; k++) {
            int tox = x + dx[k];
            int toy = y + dy[k];
            if (1 <= tox && tox <= h && 1 <= toy && toy <= w) {
                if (s[tox][toy] == '#') continue;
                if (dist[tox][toy] != -1) continue;
                dist[tox][toy] = dist[x][y] + 1;
                q.push(make_pair(tox, toy));
            }
        }
    }
    if (dist[h][w] == -1) {
        cout << -1;
    }
    else {
        cout << all - dist[h][w] - 1;
    }
    return 0;
}


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

namespace AOJ_ICPC1 {
	class Program {
		static void Main(string[] args) {

			while (true) {
				string[] str1 = Console.ReadLine().Split(' ');
				int n = int.Parse(str1[0]);
				int p = int.Parse(str1[1]);
				if (n == 0 && p==0 ) break;

				Console.WriteLine(result(n, p).ToString());
			}
		}

		static int result(int n, int p) {
			int cup = p;
			int[] stone = new int[n];
			int man = 0;
			while (true) {
				if (cup == 0) {
					cup = stone[man];
					stone[man] = 0;
				}
				else {
					cup--;
					stone[man]++;
				}

				if (stone[man] == p) return man;

				man = (man+1)%n;
			}
		}
	}
}

Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s, t, u;
	int a, b;

	cin >> s >> t >> a >> b >> u;
	if(s==u) cout << a - 1 << " " << b << endl;
	else cout << a << " " << b - 1 << endl;
}

Measured memory_bytes: 256
##### 解けた #####

M1,D1=list(map(int,input().split(" ")))
M2,D2=list(map(int,input().split(" ")))

if M1==M2: # もし同じ月なら、月末日ではない
    print(0)
else: # 違う月なら月末日である
    print(1)

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

const int MOD = (int)1e9+7;

int main(){
  int N,K;
  cin >> N >> K;

  int count=0;
  for(int i=1;i<=N;i+=2){
    count++;
  }
  if(count>=K)  cout << "YES" << endl;
  else  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())

op = []

for i in range(q):
    a, b, c, d = map(int, input().split())
    op.append([a, b, c, d])

array = [i for i in range(1, m + 1)]

ans = 0
for arr in combinations_with_replacement(array, n):
    score = 0
    for a, b, c, d in op:
        if arr[b - 1] - arr[a - 1] == c:
            score += d
    ans = max(ans, score)

print(ans)

Measured memory_bytes: 9068
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

/* see https://github.com/pllk/cphb/ */
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;

typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> w(n);
    ll s2=0;
    fori(n) {
        cin>>w[i];
        s2+=w[i];
    }
    ll s1=0;

    ll ans=s2;
    for(int i=0; i<n; i++) {
        ans=min(ans, abs(s1-s2));
        s1+=w[i];
        s2-=w[i];
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second > b.second; }

int main(){
    int N; cin >> N;
    vl A(N);
    rep(i,N) cin >> A[i], A[i] *= 2;
    //x0=0と置いてしまう
    ll offset = 0;
    rep(i,N) offset = A[i] - offset;
    ll x = offset / 2;

    ll cur=x;
    rep(i,N){
        cout<<cur<<" ";
        cur=A[i]-cur;
    }
    cout<<endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[101][100001];
ll knapsack(ll wt[],ll v[],ll n,ll W)
{
  if(n==0||W==0)
    return 0;
  if(dp[n][W]!=-1)
    return dp[n][W];
  if(wt[n-1]<=W)
    return dp[n][W]=max(v[n-1]+knapsack(wt,v,n-1,W-wt[n-1]),knapsack(wt,v,n-1,W));
  else return dp[n][W]=knapsack(wt,v,n-1,W);
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,W;
  cin>>n>>W;
  ll wt[n],v[n];
  for(int i=0;i<n;++i)
    cin>>wt[i]>>v[i];
  memset(dp,-1,sizeof(dp));
  cout<<knapsack(wt,v,n,W)<<"\n";
  return 0;
}

Measured memory_bytes: 82472
#include<stdio.h>
#include<string.h>

int main()
{
  char s[100001];
  int i,l;
  scanf("%s",s);
  l=strlen(s);
  i=l-1;
  while(1){
    if(i==-1){
      printf("YES");
      return 0;
    }
    else if(i>=6 && s[i]=='r' && s[i-1]=='e' && s[i-2]=='m' && s[i-3]=='a' && s[i-4]=='e' && s[i-5]=='r' && s[i-6]=='d'){
      i-=7;
    }
    else if(i>=5 && s[i]=='r' && s[i-1]=='e' && s[i-2]=='s' && s[i-3]=='a' && s[i-4]=='r' && s[i-5]=='e'){
      i-=6;
    }
    else if(i>=4 && s[i]=='m' && s[i-1]=='a' && s[i-2]=='e' && s[i-3]=='r' && s[i-4]=='d'){
      i-=5;
    }
    else if(i>=4 && s[i]=='e' && s[i-1]=='s' && s[i-2]=='a' && s[i-3]=='r' && s[i-4]=='e'){
      i-=5;
    }
    else{
      printf("NO");
      return 0;
    }
  }
}


Measured memory_bytes: 1824
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using vll = vector<ll>;
const ll INF = 1e15 + 5;

const ll mod = 1e9 + 7;
int main() {
	int h, w; cin >> h >> w;
	vector<vector<char>> grid(h, vector<char>(w));
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin >> grid[i][j];
		}
	}
	vector<vll> dp(h, vll(w));
	dp[0][0] = 1;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (grid[i][j] == '#') continue;
			if (i > 0) dp[i][j] += dp[i - 1][j];
			if (j > 0) dp[i][j] += dp[i][j - 1];
			dp[i][j] %= mod;
		}
	}
	cout << dp[h - 1][w - 1] << endl;
}


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        if(k <= a){
            System.out.print((a - k) + " ");
            System.out.println((b));
        }else if(k <= (a + b)){
            System.out.print(0 + " ");
            System.out.println((a + b - k));
        }else{
            System.out.print(0 + " ");
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 22484
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n,d;
  cin >> d >> n;
  for(int i=1;;i++){
    ll cnt = 0,tmp=i;
    while(tmp%100==0){
      tmp /= 100;
      cnt++;
    }
    if(cnt==d){
      n--;
      if(n==0){
        cout << i << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from fractions import gcd
def resolve():
    a,b=map(int,input().split())
    print(a*b//gcd(a,b))
resolve()

Measured memory_bytes: 66028
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N,K;
  cin >> N >> K;

  cout << (ll)K*(ll)pow(K-1,N-1) << endl;

  return 0;
}


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

int main() {
	int H,W;
	while(1){
	cin >>H>>W;
	if (H==0 && W==0) break;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(i==0){
				cout << "#";
			}
			else if(j==0){
				cout << "#";
			}
			else if(j==W-1){
				cout << "#";
			}
			else if(i==H-1){
				cout << "#";
			}
			else {
			cout <<".";
			}
		}
		cout << endl;
	
	}
	cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    S = list(Scanner.string())
    ans = 0
    while len(S) > 1:
        if S[0] == S[-1]:
            S.pop(0)
            S.pop(-1)
        elif S[0] == 'x':
            ans += 1
            S.pop(0)
        elif S[-1] == 'x':
            S.pop(-1)
            ans += 1
        else:
            print('-1')
            return
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 6100
N = int(input())
for h in range(1, 3501):
    for n in range(h, 3501):
        ok = 0
        ng = 3501
        while abs(ok-ng)>1:
            w = (ok+ng)//2
            if 4*h*n*w<=N*(n*w+w*h+h*n):
                ok = w
            else:
                ng = w
        if 4*h*n*ok==N*(n*ok+ok*h+h*n):
            print(h, n, ok)
            exit()

Measured memory_bytes: 43216
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    val split = a / b
    val remainder = a % b
    val spritDouble = a.toDouble() / b.toDouble()
    println("%d %d %.8f\n".format(split, remainder, spritDouble))
}



Measured memory_bytes: 34068
fun main(args: Array<String>) {
    val (A, B, C, X, Y) = listOfLong()
    val p1 = A * X + B * Y
    val p2 = when {
        (X > Y) -> Y * 2 * C + (X - Y) * A
        (X < Y) -> X * 2 * C + (Y - X) * B
        else -> (X + Y) * C
    }
    val p3 = Math.max(X, Y) * 2 * C
    val ans = listOf(p1, p2, p3).min()!!
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfLong(d: Int = 0) = listOfString().map { it.toLong() + d }


Measured memory_bytes: 38064
#include<cstdio>
int main(){
    int n,x,l[101];
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;i++)scanf("%d",&l[i]);
    int d=0,cnt=1;
    for(int i=1;i<=n;i++){
        d+=l[i];
        if(d<=x)cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int N, K, H;
long long ans;
priority_queue <int, vector<int>, greater<int> > Q;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> H;
		Q.push(H);
	}
	for (int i = 0; i < N - K; i++)
	{
		ans += Q.top();
		Q.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
// ABC170 B - Crane and Turtle
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  // 初期値
  int X, Y; //動物の総数X、足の総数Y 
  bool exists = false;
  cin >> X >> Y;
  
  // Main loop
  for (int i = 0; i < 100; i++) { // 鶴の数
    for (int j = 0; j < 100; j++) { // 亀の数
      if (i + j == X){
      	if ((i * 2) + (j * 4) == Y){
          exists = true;
          break;
        }
      }
    }
  }

  if (exists == true) {
    cout << "Yes";
  } else {
    cout << "No";
  }
      
  return 0;
}

Measured memory_bytes: 3636
// Aizu Vol-2 0286: Computation of Salary
// 2017.8.20

#include <stdio.h>

#define MAX 10000
#define MAX2 1000000

typedef struct { int n, nxt, end; } WAK;
typedef struct { int nxt, t, e; } LNK;

WAK wak[MAX+5];
LNK lnk[MAX2+5]; int used;
int b[MAX+5];

int main()
{
	int N, M, L, s, t, e;
	int i, j, k, ans;
	WAK *w;

	scanf("%d%d", &N, &M);
	while (1) {
		scanf("%d%d%d", &s, &t, &e);
		if (!s) break;
		lnk[used].t = t, lnk[used].e = e;
		w = wak + s;
		if (w->n == 0) w->nxt = used;
		else lnk[w->end].nxt = used;
		w->end = used++, w->n++;
	}
	scanf("%d", &L);
	while (L--) {
		for (i = 1; i <= M; i++) scanf("%d", b+i);
		for (w = wak+1, i = 1; i <= N; i++, w++) {
			if (i > 1) putchar(' ');
			if (w->n == 0) { putchar('0'); continue; }
			for (ans = 0, k = w->nxt, j = w->n; j > 0; j--, k = lnk[k].nxt)
				ans += lnk[k].e * b[lnk[k].t];
			printf("%d", ans);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

struct Root
{
    int from, to, cost;
};


struct Edge
{
    int to, cost;
};

int V, E, r;
vector<Root> root;
vector<vector<Edge> > g;



bool Find_Negative_Root(){
    vector<int> dist(V, MM);
    int cnt = 0;
    queue<int> que;
    dist[r] = 0;
    for (int i = 0; i < V; i++){
        for (int j = 0; j < E; j++){
            Root cur = root[j];
            if (dist[cur.from] != MM && dist[cur.to] > dist[cur.from] + cur.cost){
                dist[cur.to] = dist[cur.from] + cur.cost;
                if (i == V-1){
                    return true;
                }
            }
        }
    }
    return false;
}


int main(){
    cin >> V >> E >> r; 
    g.resize(V);
    vector<int> Cost(V, MM);
    root.resize(E);
    for (int i = 0; i < E; i++){
        int s, t, d; cin >> s >> t >> d; 
        Edge e; e.to = t; e.cost = d;
        Root now; now.from = s, now.to = t, now.cost = d;
        root[i] = now;
        g[s].push_back(e);
    }

    if (g[r].size() == 0){
        for (int i = 0; i < V; i++){
            if (i == r) cout << 0 << endl;
            else cout << "INF" << endl;
        }
        return 0;
    }
    if (Find_Negative_Root()){
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }

    Cost[r] = 0;
    queue<int> que;
    que.push(r);
    while (que.size()){
        int now = que.front();
        que.pop();
        for (int i = 0; i < g[now].size(); i++){
            Edge cur = g[now][i];
            if (Cost[cur.to] > Cost[now] + cur.cost){
                Cost[cur.to] = Cost[now] + cur.cost;
                que.push(cur.to);
            }
        }
    }
    for (int i = 0; i < V; i++){
        if (Cost[i] == MM) cout << "INF" << endl;
        else cout << Cost[i] << endl;
    }
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define st first
#define nd second

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

int main(){
	int n, m, sum = 0, x;
	scanf("%d %d",&m, &n);
	for(int i =1; i<=n;i++){
		scanf("%d", &x);
		m -= x;
		if(m < 0) return !printf("-1");
	}
	printf("%d", m);


}

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

int  main() {
	int x, q = 0, w = 0, e = 0, r = 0;
	string a = "AC", b = "WA", c = "RE", t = "TLE",m;
	cin >> x;
	for (size_t i = 0; i < x; i++)
	{
		cin >> m;
		if (m==a)
		{
			q++;
		}
		else if (m == b) {
			w++;
		}
		else if (m == t) {
			e++;
		}
		else if (m == c) {
			r++;
	}
	}
	cout << "AC x " << q << endl;
	cout << "WA x " << w << endl;
	cout << "TLE x " << e << endl;
	cout << "RE x " << r << endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define BUFSIZE 1000000

char N,K;
int  hoge[BUFSIZE]={0};
long long V,W,T;
int count = 0;
int x;
int A[BUFSIZE] = {0};
int X;


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int cal(){

}

int main(void){

  scanf("%c",&N);
  N = (int)N;
  if(N >= 65 && N <= 90){
    printf("A");
  }else if(N >= 97 && N <= 122){
    printf("a");
  }else exit(0);
  /*
  qsort(A,N,sizeof(int),compare_int);
*/
/*
cal();


  for(int i = 0;i < N;i++){
        printf("%d",A[i]);
      }
  return 0;
*/
}


Measured memory_bytes: 1592
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;
    int oy = dx, ox = -dy;
    int x3 = x2 + ox, y3 = y2 + oy;
    int x4 = x3 - dx, y4 = y3 - dy;
    cout << x3 _ y3 _ x4 _ y4;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
bool good(char c) {
	return c == 'A' || c == 'T' || c == 'G' || c == 'C';
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	string s;
	cin >> s;
	int cur = 0, answer = 0;
	for (char c : s) {
		if (good(c)) {
			++cur;
		} else {
			answer = max(answer, cur);
			cur = 0;
		}
	}
	answer = max(answer, cur);
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  int ans=n*800-n/15*200;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++){
        if(i%2==0){
            string x = s.substr(i,1);
            cout << x;
        }
    }
    cout << endl;
}

Measured memory_bytes: 512
//Δ_A
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 111;
int n,s,a[N];
pair<int,int> p[N];
int main()
{
	int i;
	cin>>n;
	for(i=0;i<n;i=i+1)
		cin>>a[i],s+=a[i],a[i]*=n;
	for(i=0;i<n;i=i+1)
		p[i]=make_pair(max(s-a[i],a[i]-s),i);
	sort(p,p+n);
	cout<<p[0].second;
	return 0;
}

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

int main() {
    string N;
    cin >> N;
    
    int ans = 0;
    for (int i = 0; i < N.size(); i++) {
        if (N.at(i) != '0' && N.at(i) != '9') {
            ans = ans + N.at(i) - '0';
            ans = ans % 9;
        }
    }

    if (ans == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3744
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

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

    int n;
    cin >> n;

    vector<int> as(n);
    map<int, int64> counter;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        counter[as[i]]++;
    }

    int64 sum = 0;
    for (auto& mp : counter) {
        sum += mp.second * (mp.second - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
        int64 ans = sum - counter[as[i]] * (counter[as[i]] - 1) / 2;
        ans += (counter[as[i]] - 1) * (counter[as[i]] - 2) / 2;
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define INF 1e9
#define pii pair<int, int>
#define pt(xx) cout << "\n" \
                    << xx << "\n"
#define debugv(x, n)               \
    cout << "\n"                   \
         << #x << ": ";            \
    rep(i, n) cout << x[i] << " "; \
    cout << endl
#define debug2d(x, m, n)            \
    cout << "\n"                    \
         << #x << " is: \n";        \
    for (int i = 0; i < m; ++i)     \
    {                               \
        for (int j = 0; j < n; ++j) \
        {                           \
            cout << x[i][j] << " "; \
        }                           \
        cout << endl;               \
    }
#define nl cout << endl

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

int N, M, K;
int ans;

vector<vector<int>> e(2505);
vector<bool> visited(55, false);
int cnt = 0;
int dfsc = 0;
int pp = 0;
vector<pii> edg(55);
void dfs(int v, int before, int j)
{
    //cout << "dfs[" << v << "], cnt=" << cnt << endl;
    if (visited[v])
    {
        return;
    }
    visited[v] = true;
    for (auto x : e[v])
    {
        if (!(x==edg[j].first && v==edg[j].second) && 
            !(v==edg[j].first && x==edg[j].second)
        )
        {
            dfs(x, v, j);
        }
    }
}

signed main()
{
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //==============================================
    cin >> N >> M;

    //vector<pair<int,int>> e(M);

    int a, b;
    rep(i, M)
    {
        cin >> a >> b;
        --a;
        --b;
        edg[i].first = a;
        edg[i].second = b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    cnt=0;
    for (int i = 0; i < M; ++i)
    {
        //debug(i);
        for (auto x : visited)
        {
            x = false;
        }
        dfs(0, 0, i);
        //debugv(visited,visited.size());

        bool res = false;

        rep(k,N) if (!visited[k]) {res=true;break;}


        if (res) cnt++;

        //debug(cnt);

    }

    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#define MN 100005
using namespace std;
int n,a[MN],I[MN],cnt,mn=1e9;
long long ans[MN];
struct node{int st,v;}b[MN];
bool cmp(int u,int v){return a[u]!=a[v]?a[u]>a[v]:u<v;}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),I[i]=i;
    sort(I+1,I+1+n,cmp);
    for(int i=1;i<=n;){
        int j=i;
        while(a[I[j]]==a[I[i]]) j++;
        b[++cnt].st=I[i]; b[cnt].v=j-1;
        i=j;
    }
    for(int i=1;i<=cnt;i++){
        mn=min(mn,b[i].st);
        ans[mn]+=1LL*b[i].v*(a[b[i].st]-a[b[i+1].st]);
    }
    for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    i64 Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    N *= 4;

    i64 cost[9];
    cost[1] = Q;
    cost[2] = min(H, cost[1]*2);
    cost[4] = min(S, cost[2]*2);
    cost[8] = min(D, cost[4]*2);

    i64 ans = 0;
    ans += (N / 8) * cost[8]; N %= 8;
    ans += (N / 4) * cost[4]; N %= 4;  
    ans += (N / 2) * cost[2]; N %= 2;  
    ans += (N / 1) * cost[1];
    cout << ans << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>

using namespace std;
int abs(int x){
    if(x<0) return -x;
    else return x;
}
int sum_keta(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int main() {
    int n;
    cin>>n;
    if(n%sum_keta(n)==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int n;
string s;
bool cnt[1001];
bool dp[30005][4][100];

int main(void){
	scanf("%d",&n);
	cin >> s;
	memset(dp,false,sizeof(dp));
	dp[0][0][0]=true;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<100;k++){
				if(!dp[i][j][k])continue;
				dp[i+1][j][k]=true;
				if(j+1<3){
					dp[i+1][j+1][k*10+(s[i]-'0')]=true;
				}
				
				if(j+1==3){
					cnt[k*10+(s[i]-'0')]=true;
				}
			}
		}
	}
	int ans=0;
	for(int i=0;i<1000;i++){
		if(cnt[i])ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 12032
function Main(inputData) {
	init(inputData);
	
	var a = inI();
	var b = inI();
	var h = inI();
	
	
	out((a+b)*h/2);
}

////////////////////////////////////////////////////////////////////////////////////
var input,inputCnt;

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
	Main(document.getElementById("input").value);
}

function init(inputData){
    //配列inputに順番に代入
	input = inputData.replace( /\n/g , " " );
	input = input.split(" ");
	inputCnt = 0;
}
//output
const out = (output) => { console.log(output) }
const outln = (output) => { console.log(output+"\n") }

//input
const inS = () => {return input[inputCnt++]};
const inI = () => {return parseInt(inS(), 10)};
const inF = () => {return parseFloat(inS())};

//prototype
Array.prototype.rsort = function(){
  return this.sort(function(a,b){return (a<b ? 1:-1);});
}

Array.prototype.max = function(){
  return Math.max.apply(null, this);
}

Array.prototype.min = function(){
  return Math.min.apply(null, this);
}

//function
function values(array) {
    var values = [];
    if(array)for(var key in array)values.push(array[key]);
    return values;
};

function keys(array) {
    var keys = [];
    if(array)for(var key in array)keys.push(key);
    return keys;
};

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


int main(){
  int n;
  cin >> n;
  vector<int>p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int ans=0;
  for(int i=0;i<(n-2);i++){
    if(p[i]<p[i+1]&&p[i+1]<p[i+2]){
      ans++;
    }
    if(p[i]>p[i+1]&&p[i+1]>p[i+2]){
      ans++;
    }
  }
  cout << ans << endl;
    
}
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n; cin >> n;
    bool flag = 1;
    for (int i = 0; i < n; ++i) {
        int tmp; cin >> tmp;
        if (tmp % 2 == 0)
            flag &= (tmp % 3 == 0 || tmp % 5 == 0);
    }
    cout << (flag? "APPROVED": "DENIED") << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int MOD=1e9+7ll;
int n,a,b,ans1,ans2,ans3,ans;

inline int pow(int a,int n)
{
	int res=1ll;
	while (n)
	{
		if (n&1ll) res=res*a%MOD;
		a=a*a%MOD;
		n>>=1ll;
	}
	return res;
}

inline int C(int n,int m)
{
    if (m>n) return 0ll;
	if (m<n-m) m=n-m;	
	int a=1ll;
	for (register int i=m+1ll; i<=n; ++i) a=a*i%MOD;
	int b=1ll;
	for (register int i=2ll; i<=n-m; ++i) b=b*i%MOD;
    return a*pow(b,MOD-2ll)%MOD;
}

inline int Lucas(int n,int m)
{
	if (n<m) return 0ll;
	if (!m) return 1ll;	
	return C(n%MOD,m%MOD)*Lucas(n/MOD,m/MOD)%MOD;
}

signed main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	ans1=pow(2ll,n); 
	ans2=Lucas(n,a);
	ans3=Lucas(n,b);
	ans=((ans1-ans2-ans3-1ll)%MOD+MOD)%MOD;
	printf("%lld\n",ans); 
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 1000005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef map<ll, ll> Map;

int main(void) {
    ll N, K;
    cin >> N >> K;
    ll x, y;
    char c;
    ll i, j;
    ll cnt[4*K+2][4*K+2];
    ll sum[4*K+2][4*K+2];
    memset(cnt, 0, sizeof(cnt));
    memset(sum, 0, sizeof(sum));
    
    for(i=0; i<N; i++) {
        cin >> x >> y >> c;
        if(c=='W') {
            y+=K;
        }
        x%=2*K; y%=2*K;
        x++; y++;
        cnt[x][y]++;
        cnt[x][y+2*K]++;
        cnt[x+2*K][y]++;
        cnt[x+2*K][y+2*K]++;
    }
    
    
    
    
    for(i=1; i<=4*K; i++) {
        for(j=1; j<=4*K; j++) {
            sum[i][j]=cnt[i][j]+sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1];
        }
    }
    
    ll ans=0;
    for(i=1; i<=2*K; i++) {
        for(j=1; j<=2*K-1; j++) {
            ll sqr1=sum[i+K-1][j+K-1]-sum[i-1][j+K-1]-sum[i+K-1][j-1]+sum[i-1][j-1];
            ll sqr2=sum[i+2*K-1][j+2*K-1]-sum[i+K-1][j+2*K-1]-sum[i+2*K-1][j+K-1]+sum[i+K-1][j+K-1];
            ans=max(ans, sqr1+sqr2);
        }
    }
    
    prin(ans);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for(int i=(l);i<(r);i++)
#define forb(i,r,l) for(int i=(r);i>(l);i--)
#define log2i(x) 32 - __builtin_clz((x)) - 1
#define log2ll(x) 64 - __builtin_clzll((x)) - 1
#define Pi acos(-1.0)
#define sz(x) (int)x.size()
#define pw(x,y) trunc(exp(log((x))*(y)))
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

ll n,a,b;

int main() {
#ifndef ONLINE_JUDGE
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
#endif
    fastIO;
    cin >> n >> a >> b;
    cout << n/(a+b)*a+min(a,n%(a+b));
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/
 
int32_t main()
{
	fastio();
	int n;
	cin>>n;
	vector<int> v(5,0);
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		if(s[0]=='M')
		{
			v[0]++;
		}
		else if(s[0]=='A')
		{
			v[1]++;
		}
		else if(s[0]=='R')
		{
			v[2]++;
		}
		else if(s[0]=='C')
		{
			v[3]++;
		}
		else if(s[0]=='H')
		{
			v[4]++;
		}
	}
	int ans=0;
	for(int i=0;i<5;i++)
	{
		for(int j=i+1;j<5;j++)
		{
			for(int k=j+1;k<5;k++)
			{
				ans+=v[i]*v[j]*v[k];
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <vector>
#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<iomanip>
#define sqr(x) (x)*(x)
#define ll long long
using namespace std;
ll num[300001],l[300001],r[300001],ans=-1152921504606846976,n,i,j;
priority_queue<int,vector<int>,greater<int>/**/> le;
priority_queue<ll> ri;
int main()
{
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>num[i];
		l[n]+=num[i];
		le.push(num[i]);
	}
	for (i=n+1;i<=n*2;i++)
	{
		cin>>num[i];
	}
	for (i=n*2+1;i<=n*3;i++)
	{
		cin>>num[i];
		r[2*n+1]+=num[i];
		ri.push(num[i]);
	}
	for (i=n+1;i<=n+n;i++)
	{
		l[i]=l[i-1];
		if (le.top()<num[i])
		{
			l[i]=l[i]-le.top()+num[i];
			le.pop();
			le.push(num[i]);
		}
	}
	for (i=n+n;i>n;i--)
	{
		r[i]=r[i+1];
		if (ri.top()>num[i])
		{
			r[i]=r[i]-ri.top()+num[i];
			ri.pop();
			ri.push(num[i]);
		}
	}
	for (i=n;i<=n+n;i++)
	{
		ans=max(ans,l[i]-r[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7284
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
 
int32_t main() 
{
    IO;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    vector<int> dp(n,0);
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
    }
    cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int x,n,p[100],flg,w,y,i,c,t;
	scanf("%d %d",&x,&n);
	flg=0;
	w=x;
	y=x;
	if(n==0){
		printf("%d\n",x);
		flg=1;
	}
	else if(flg==0){
		for(i=0;i<n;i++){
			scanf("%d",&p[i]);
		}
		while(1){
			c=0;
			t=0;
			for(i=0;i<n;i++){
				if(w==p[i]) {
					c++;
				}
				if(y==p[i]){
					t++;
				}
			}
			if(c==0&&t==0){
				printf("%d\n",y);
				break;
			}
			else if(c==0){
				printf("%d\n",w);
				break;
			}
			else if(t==0){
				printf("%d\n",y);
				break;
			}
			w=w+1;
			y=y-1;
		}
	}
	return 0;
}


Measured memory_bytes: 1728
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include <forward_list>
using namespace std;

int main() {
	int X, A;

	cin >> X >> A;

	if (X < A)
		cout << 0;
	else
		cout << 10;

}




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

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

    std::valarray<double> x(n), y(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> y[i];
    }

    auto vec = x - y;
    std::cout << std::fixed << (std::abs(vec)).sum() << std::endl;
    std::cout << std::fixed << std::sqrt((vec * vec).sum()) << std::endl;
    std::cout << std::fixed << std::cbrt((std::abs(vec * vec * vec)).sum()) << std::endl;
    std::cout << std::fixed << (std::abs(vec)).max() << std::endl;
}



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

typedef pair<int,int> P;

int dx1[] = {-1,-1,0,1,1,0},dy1[] = {0,1,1,1,0,-1};
int dx2[] = {-1,0,1,1,0,-1},dy2[] = {0,1,0,-1,-1,-1};

int main(){
	int w,h;
	bool field[102][102] = {},used[102][102] = {};
	cin >> w >> h;
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			cin >> field[i][j];
		}
	}
	used[0][0] = true;
	queue<P> que;
	que.push(P(0,0));
	while(!que.empty()){
		P p = que.front();que.pop();
		for(int i = 0;i < 6;i++){
			int x,y;
			if(p.first % 2){
				x = p.first + dx1[i];
				y = p.second + dy1[i];
			}else{
				x = p.first + dx2[i];
				y = p.second + dy2[i];
			}
			if(x >= 0 && x <= h + 1 && y >= 0 && y <= w + 1 && !used[x][y]){
				used[x][y] = true;
				if(!field[x][y]) que.push(P(x,y));
			}
		}
	}
	for(int i = 0;i <= h + 1;i++){
		for(int j = 0;j <= w + 1;j++){
			if(!used[i][j]) field[i][j] = true;
		}
	}
	int cnt = 0;
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			if(field[i][j]){
				for(int k = 0;k < 6;k++){
					if(i % 2){
						if(!field[i + dx1[k]][j + dy1[k]]) cnt++;
					}else{
						if(!field[i + dx2[k]][j + dy2[k]]) cnt++;
					}
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

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

namespace ALDS1_4_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToList();
            var q = int.Parse(Console.ReadLine());
            var T = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToList();
            int count = 0;
            foreach (var t in T)
            {
                if (LinerSearch(S, n, t))
                    count++;
            }
            Console.WriteLine(count);
        }

        static bool LinerSearch(List<int> S,int n,int key)
        {
            S.Add(key);
            int i = 0;
            while (S[i] != key)
            {
                i++;
                if (i == n)
                    return false;
            }
            return true;
        }
    }
}



Measured memory_bytes: 18316
N,M,V,P = map(int, input().split())

A = list(map(int, input().split()))


A.sort(reverse=True)
ok = P-1
"""
indexはN-1までなので、ngはN-1の気がするのだが......
[ok,ng)か？
*****  okは条件を満たす（選ばれうる）し、ngは条件を満たさない（選ばれない）ので、ng=N-1とすると、そこを最初からきりすててしまうから！  *****
最終的なokとngの境界で選ばれるか選ばれないか分かれ、境界の先は単調に選ばれうる
"""
ng = N 
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    curr_max = A[mid] + M

    if curr_max < A[P-1]:
        ng = mid
        continue

    cnt = 0
    # midと上位P-1位に＋Mした分
    cnt += M + (P-1) * M
    for i in range(P-1, N):
        if i == mid: continue

        cnt += min(M, max(0, curr_max - A[i]))

    if cnt >= M*V:
        ok = mid
    else:
        ng = mid

print(ok + 1)

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

int main() {
 
  string S ;
  cin >>S ;
  if(S[0]==S[1]&&S[1]==S[2]&&S[2]==S[3]){
  cout << "No" << endl;
}else if(S[0]==S[1]&&S[2]==S[3]){
  cout << "Yes" << endl;
}else if(S[0]==S[2]&&S[1]==S[3]){
    cout << "Yes" << endl;
  }else if(S[0]==S[3]&&S[1]==S[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
H,W,K = map(int,input().split())
array = [ list(input()) for t in range(H) ]
ans = 0
for bit_row in range( 2 ** H ):
  for bit_line in range( 2 ** W ):
    count = 0
    for i in range(H):
      for j in range(W):
        if ( bit_row >> i ) & 1 == 0 and ( bit_line >> j ) & 1 == 0:
          if array[i][j] == '#':
            count += 1
    if count == K:
      ans += 1
print(ans)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   
    int n, d, x, y, cnt = 0;
    cin >> n >> d;
    for(int i = 0; i < n; i++)
    {
	cin >> x >> y;
	if(hypot(x,y) <= d) cnt++;
    }
cout << cnt;
return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,prime[1000000]={0};
  int count=0;
  while(cin>>n/*入力（EOF）*/){
    for(int i=2/*0と１は素数ではないため２から始める。*/;i<=sqrt(n)/*ルートn*/;i++){
      for(int j=i*2/*i*2は必ず素数ではない*/;j<=n;j+=i/*j<=nまでi*aをする。*/){
	prime[j]=1;/*jは素数ではない。*/
      }
    }
    for(int i=2;i<=n;i++){
      if(prime[i]==0){/*もし素数だったら*/
	count++;
      }
    }
  cout<<count<<endl;
  count=0;
  }
  return 0;
}

Measured memory_bytes: 5072