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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int x, y; cin >> x >> y;

  cout << x + (y/2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int main() {
  ll D, T, S;
  cin >> D >> T >> S;
  if (T * S >= D) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
#include<queue>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF = 1e9;
const long long mod = 2019;
#define ll long long


int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	if (n % 2 == 0) {
		if (k > n / 2) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
		}
	}
	else {
		if (k > n / 2 + 1) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
		}
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<ll> l(n);
	for (auto &v : l) {
		cin >> v;
	}
	sort(begin(l), end(l));

	ll ans = 0;
	for (int a = 0; a < n; a++) {
		for (int b = a + 1; b < n; b++) {
			ll r = lower_bound(begin(l), end(l), l[a] + l[b]) - begin(l);
			ll s = b + 1;
			ans += r - s;
		}
	}
	cout << ans << endl;

	// 0 1 2 3
	// b s   r

	return 0;
}


Measured memory_bytes: 256
<?php

main();

function main() {

	$c = array('A' => 1, 'B' => 0, 'C' => 0);

	while($line = trim(fgets(STDIN))) {
		list($i, $j) = explode(',', $line);
		swap($c, $i, $j);
	}

	foreach ($c as $k => $v) {
		if ($v == 1) {
			echo $k . "\n";
			break;
		}
	}
}

function swap(&$c, $i, $j) {
	$tmp = $c[$i];
	$c[$i] = $c[$j];
	$c[$j] = $tmp;
}

Measured memory_bytes: 6624
import java.util.Scanner;

public class Main { //YES! (Pay attention to indexing variables when debugging)
	//You tend to get them mixed up; Don't doubt your algorithmic thinking cuz you're a beast!

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int M = input.nextInt();
		int X = input.nextInt();
		long[][] data = new long[N][M+1]; //Extra slot for cost
		for (int i = 0; i < N; i++) {
			data[i][0] = input.nextInt();
			for (int j = 1; j <= M; j++) {
				data[i][j] = input.nextInt();
			}
		}
		long cost = Integer.MAX_VALUE;
		String[] possibilities = Recur(N).split(" ");
		for (int i = 0; i < possibilities.length; i++) {
			String x = possibilities[i];
			long[] cmp = new long[M];
			long curcost = 0;
			for (int j = 0; j < N; j++) {
				if (x.charAt(j)=='Y') {
					curcost+=data[j][0];
					for (int k = 1; k<=M; k++) {
						cmp[k-1]+=data[j][k];
					}
				}
			}
			boolean exceeded = true;
			for (int j = 0; j < M; j++) {
				if (cmp[j]<X) {
					exceeded=false;
					break;
				}
			}
			if (exceeded) cost = Math.min(cost, curcost);
		}
		if (cost!=Integer.MAX_VALUE) System.out.println(cost);
		else System.out.println(-1);
	}
	public static String Recur(int N) {
		if (N==1) return "Y N ";
		String[] arr = Recur(N-1).trim().split(" ");
		String ans = "";
		for (int i = 0; i < arr.length; i++) {
			ans+=arr[i]+"Y ";
		}
		for (int i = 0; i < arr.length; i++) {
			ans+=arr[i]+"N ";
		}
		return ans.trim();
	}
}

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


int main(){
  string S;
  int ans,stind,enind;
  cin>>S;

  for(int i = 0;i<S.size();i++){
    if(S.at(i)=='A'){
      stind = i;
      break;
    }
  }

  for(int i = S.size()-1 ;i>-1;i--){
    if(S.at(i)=='Z'){
      enind = i;
      break;
    }
  }
  ans = enind-stind+1;
  cout<<ans<<endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> d;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		auto it = upper_bound(d.begin(), d.end(), a, greater<>());
		if (it == d.end()) d.push_back(a);
		else *it = a;
	}
	cout << d.size() << endl;
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<long double, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 3000000000.0
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

struct edge { 
	int to;
	long double cost;
};

int N;
vector<edge> G[1010];
long double d[1010];

void dikstra(int s) {
	priority_queue<pii, vector<pii>, greater<pii> >que;
	REP(i, N + 3)d[i] = INF;

	d[s] = 0.0;
	que.push(pii(0.0, s));
	while (!que.empty()) {
		
		pii p = que.top();
		que.pop();
		int v = p.second;
		//cout << v << " " << d[v] << " " << p.first << endl;

		//cout << v << endl;
		//REP(i, N + 2)cout << d[i] << " ";
		//cout << endl;


		if (d[v] < p.first)continue;
		REP(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				//cout << v << endl;
				d[e.to] = d[v] + e.cost;
				que.push(pii(d[e.to], e.to));
			}
		}
	}
}

long double dis(int a, int b, int c, int d) {
	return pow((a - c)*(a - c) + (b - d)*(b - d), 0.5);
}

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

	int sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy >> N;
	VI X(N), Y(N), R(N);
	REP(i, N) cin >> X[i] >> Y[i] >> R[i];
	X.push_back(sx);
	X.push_back(gx);
	Y.push_back(sy);
	Y.push_back(gy);
	R.push_back(0);
	R.push_back(0);
	REP(i, N + 2) {
		REP(j, N + 2) {
			if (i == j)continue;

			long double dist = max((long double)0.0, dis(X[i], Y[i], X[j], Y[j]) - R[i] - R[j]);
			//cout << i << " " << j << " " << dist << endl;
			G[i].push_back((edge) { j, dist });
			G[j].push_back((edge) { i, dist });
		}
	}


	dikstra(N);
	
	//cout << d[N + 1] << endl;
	//eREP(i, N + 1)cout << d[i] << endl;
	printf("%.12llf\n",d[N + 1]);

	return 0;
}



Measured memory_bytes: 74988
#include<stdio.h>
 
#define H 250
int main(){

  int i, j, id, n;
  int A[H];

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++){
    scanf("%d",&A[i]);
  }

  for(i = 1 ; i <= n ; i++){
    if(i == 1){
      printf("node %d: key = %d, left key = %d, right key = %d, ",i, A[i], A[i*2], A[i*2+1]);
    }
    else if(i*2 <= n && i*2+1 <= n){
      printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, ",i,A[i],A[i/2],A[i*2],A[i*2+1]);
    }
    else if(i*2 <= n && i*2+1 > n){
      printf("node %d: key = %d, parent key = %d, left key = %d, ",i,A[i],A[i/2],A[i*2]);
    }
    else {
      printf("node %d: key = %d, parent key = %d, ",i,A[i],A[i/2]);
    }
  printf("\n");
  }

  return 0;
}

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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    int w;
    cin >> S >> w;
    for (int i = 0; i < S.size(); ++i) {
        if (i % w == 0) cout << S[i];
    }
    cout << endl;
    
    return 0;
}

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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N, a, b, c = 0;
    cin >> N;
    vector<int> A(N), P(N), Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    rep(i, N) A[i] = i + 1;
    do {
        c++;
        bool f = true;
        rep(i, N) if (A[i] != P[i]) f = false;
        if (f) a = c;
        f = true;
        rep(i, N) if (A[i] != Q[i]) f = false;
        if (f) b = c;
    } while (next_permutation(A.begin(), A.end()));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
key = input()
n = len(key)

key_list = list()
count = 0
while count < n:
    key_list.append(key[count])
    count += 1

ok_list = list()
for i in key_list:
    if i == '?':
        ok_list.append('D')
    else:
        ok_list.append(i)
ok_list = ''.join(ok_list)
print(ok_list)

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

int main()
{
	int dish_time[5];

	for (int i = 0; i < 5; i++)
		scanf("%d", &dish_time[i]);
	
	int min_time = 130 * 5;
	
	do {
		int now = 0;
		
		for (int i = 0; i < 5; i++) {
			now += dish_time[i];
			int tmp = now % 10;
			if (tmp != 0 && i != 5 - 1)
				now += (10 - tmp);
		}
		if (now < min_time)
			min_time = now;
	} while (next_permutation(dish_time, dish_time + 5));
	
	printf("%d\n", min_time);
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
    "bufio"
    "fmt"
    "io"
    "os"
)

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    NextInt() int
    NextInt64() int64
    NextString() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
    impl.Scan()
    bb := impl.Bytes()
    i := 0
    for _, b := range bb {
        i *= 10
        i += int(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextString() string {
    impl.Scan()
    return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
    x := reader.NextInt64()
    writer.Printf("%d\n", sol(x))
}

func sol(x int64) int64 {
    h500 := x / 500
    x = x % 500
    h5 := x / 5
    return (h500 * 1000) + (h5 * 5)
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

int n;
vector<int> g[111111];

int solve(int a, int par) {
  int x = 0;
  for (auto&& t : g[a]) {
    if (t != par) {
      x ^= (solve(t, a) + 1);
    }
  }
  return x;
}

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n-1; i++) {
    int a, b; scanf("%d%d", &a, &b);
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  bool w = solve(0, -1);
  puts(w == 1 ? "Alice" : "Bob");
  return 0;
}


Measured memory_bytes: 10624
#include<stdio.h>
#include<stdlib.h>
int main()
{
  int i,x;
  char s[999];
  for(;~scanf("%s",s);puts(""))
    {
      i=0;
      for(i=0;s[i]!='\0';i++)
	if(s[i]!='@')
	  putchar(s[i]);
	else
	  {
	    x=s[i+1]-'0';
	    for(;x--;)
	      putchar(s[i+2]);
	    i+=2;
	  }
    }
  exit(0);
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int N;

int main() {
    cin >> N;
    long long pre[2];
    pre[0] = 1; pre[1] = 2;
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 1; i < N; i++) {
        long long tmp = pre[0] + pre[1];
        pre[1] = pre[0];
        pre[0] = tmp;
    }
    cout << pre[0] << endl;
}   


Measured memory_bytes: 888
#include <tuple>
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;


tuple<int,int> get_max_count(unordered_map<int, int> m) {

	int max = -1;
	int index = -1;
	unordered_map<int, int>::iterator p;
	for (p = m.begin(); p != m.end(); p++) {
		if (p->second > max) {
			max = p->second;
			index = p->first;
		}
	}
	return tie(max, index);
}

int main()
{
	int n;
	vector<int> v;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int c;
		cin >> c; v.push_back(c);
	}

	int k = n / 2;
	unordered_map<int, int> aodd;
	unordered_map<int, int> aeven;

	for (int i = 0; i < n; i++) {
		unordered_map<int, int>& amap = i % 2 == 0 ? aeven : aodd;
		int c = v[i];
		if (amap.count(c) == 0) amap.insert(pair<int,int>(c, 1));
		else amap[c]++;
	}
	
	auto meven = get_max_count(aeven);
	auto modd = get_max_count(aodd);

	int ieven = get<1>(meven);
	int iodd = get<1>(modd);
	int needchange;
	if (ieven != iodd) {
		needchange = (k - get<0>(meven)) + (k - get<0>(modd));
	}
	else{
		if (aodd.size() == 1 && aeven.size()==1 ) {
			needchange = k;
		}
		else if (aodd.size() == 1) {
			aeven[ieven] = 0;
			auto meven_ex = get_max_count(aeven);
			needchange = (k - get<0>(meven_ex)) + (k - get<0>(modd));
		}
		else if (aeven.size() == 1) {
			aodd[iodd] = 0;
			auto modd_ex = get_max_count(aodd);
			needchange = (k - get<0>(meven)) + (k - get<0>(modd_ex));
		}
		else {
			aeven[ieven] = 0;
			auto meven_ex = get_max_count(aeven);
			int needchange1 = (k - get<0>(meven_ex)) + (k - get<0>(modd));

			aodd[iodd] = 0;
			auto modd_ex = get_max_count(aodd);
			int needchange2 = (k - get<0>(meven)) + (k - get<0>(modd_ex));

			needchange = min(needchange1, needchange2);
		}
	}
	
	cout << needchange;
	return 0;
}


Measured memory_bytes: 6800
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,k,h,c=0;
    cin>>n>>k;
    for(ll i=0;i<n;i++){
        cin>>h;
        if(h>=k) c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

vector<vector<int>> edge;
vector<vector<ll>> dp;
ll mod = 1e9+7;

void dfs(int now, int par) {
    for (int nxt : edge[now]) {
        if (nxt == par) continue;
        dfs(nxt, now);
        dp[now][0] *= dp[nxt][0]+dp[nxt][1];
        dp[now][1] *= dp[nxt][0];
        dp[now][0] %= mod;
        dp[now][1] %= mod;
    }
    return;
}

int main() {
    int N;
    cin >> N;
    edge.resize(N);
    dp = vector<vector<ll>>(N, vector<ll>(2, 1));
    for (int i = 0; i < N-1; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    dfs(0, -1);
    cout << (dp[0][0]+dp[0][1])%mod << endl;
    return 0;
}

Measured memory_bytes: 19800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ten[6],ans=0;
    for(int i=0;i<6;i++)cin>>ten[i];
    for(int i=0;i<3;i++){
        int kawa=0;
        for(int j=1;j<4;j++)if(ten[kawa]<ten[j])kawa=j;
        ans+=ten[kawa];
        ten[kawa]=-1;
    }
    ans+=max(ten[4],ten[5]);
    cout<<ans<<endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
 
int main()
{
  int N[6];
  int i = 0;
  while (i < 6)
  {
  	scanf("%d",&N[i]);
    i++;
  }
  i = 0;
  while (i < 5)
  {
    //printf("%d",N[i]-N[0]);
  	if (N[i] - N[0] > N[5])
    {
  		printf(":(");
      	return (0);
    }
    i++;
  }
  printf("Yay!");                                     
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long ll;
ll a[10010];
int n;
ll ans = 0;
int f(ll x)
{
	if ((x - (x / 2) * 2) == 0)
		return 2;
	else
		return 1;
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		while( f(a[i])==2)
		{ 
			ans++;
			a[i] = a[i] / 2;
		}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
 
int main(){
    char p[5][6] =
    {{'a','f','k','p','u','z'},
     {'b','g','l','q','v','.'},
     {'c','h','m','r','w','?'},
     {'d','i','n','s','x','!'},
     {'e','j','o','t','y',' '}};
    string s;   
    while(cin >> s){
        bool flag = false;
        for(size_t i=0;i<s.size();i+=2){
            if(s[i]>'6' || s[i]<'1' || s[i+1]>'5' || s[i]<'1')
                flag = true;
        }
        if(flag||s.size()%2){
            cout << "NA" << endl;
        }else{
            for(size_t i=0;i<s.size();i+=2){
                cout << p[s[i+1]-'0'-1][s[i]-'0'-1];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 1176
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    long n, x, y;
    long p, q;
    long ans = 0, tmp;
    scanf("%ld %ld", &n, &x);
    y = n - x;
    if (x > y) { tmp = x; x = y; y = tmp; }
    while (1) {
        p = y / x;
        q = y % x;
        if (q != 0) {
            ans += 2 * p * x;
            y = x;
            x = q;
        } else {
            ans += (2 * p - 1) * x;
            break;
        }
    }
    printf("%ld\n", ans + n);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <unordered_set>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N;
  std::cin >> N;
  std::unordered_set<std::string> set;
  for (int i: range(0, N)) {
    std::string S;
    std::cin >> S;
    set.insert(S);
  }
  std::cout << set.size() << '\n';
  return 0;
}


Measured memory_bytes: 17612
"""
Bellman-Ford
始点と終点が決められているとき、
経由する閉路のみを確認する必要がある。
"""
def Bellman_Ford2(g,start,goal):
    n = len(g)    
    dist = [float("inf")]*n
    dist[start] = 0
    a0 = float("inf")
    for i in range(2*n):
        updated = False
        for v in range(n):
            for to, cost in g[v]:
                if dist[to] <= dist[v] + cost: continue
                if i < n:
                    dist[to] = dist[v] + cost
                else:
                    dist[to] = -float("inf")
                updated = True
        if not updated: break
    if dist[goal] == -float("inf"): return None, False
#    if negative[-1]: return None, False
    return dist, True
 

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,m = [int(i) for i in readline().split()]
g = [[] for _ in range(n)]
for i in range(m):
    a,b,c = [int(i) for i in readline().split()]
    g[a-1].append((b-1,-c))
#    g[b-1].append((a-1,c))

dist, TF = Bellman_Ford2(g,0,-1)

if TF: print(-dist[-1])
else: print("inf")


Measured memory_bytes: 3316
#include <stdio.h>

int main (void)
{
	int N=0,R=0;
  	
  	scanf("%d %d",&N,&R);
	
  	if(N>=10)
    {
    	printf("%d",R);
    }
  
  	else
    {
      	R=R+1000-100*N;
    	printf("%d",R);
    }
  
  return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }

  int ans = 0;
  bool kill = true;
  while (kill) {
    int vmin = INT_MAX;
    kill = false;

    for (int v : A) {
      if (v == 0) continue;
      vmin = std::min(vmin, v);
    }
    ans = vmin;

    for (int& v : A) {
      if (v == 0 || v == vmin) continue;
      kill = true;
      v %= vmin;
    }

#if 0
    for (int v : A) {
      std::cout << v << " ";
    }
    std::cout << std::endl;
#endif
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 640
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,m;
bool isP(string s){
	m = sz(s);
	int i=0,j=m-1;
	while(i<j){
		if(s[i]==s[j])i++,j--;
		else break;
	}
	return i>=j;
}
void solve(){
	 string s;
	 cin>>s;
	 n = sz(s);
	 string s1 = s.substr(0,(n-1)/2),s2 = s.substr((n+3)/2-1);
	 cout<< (isP(s)&&isP(s1)&&isP(s2)?"Yes":"No");
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll A[5];
ll i, j, k, ans;
int main(){
    fornum(i,0,2){
        ll a = 0;
        scanf("%lld", &a);
        A[a]++;
    }
    fornum(i,0,3)
    {
        if(A[i+1]==0){
            printf("%lld", i + 1);
        }
    }
    


    return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    string s;
    cin >> s;
    int len = s.size();
    if (s[len - 1] == 's')
    {
        cout << s << "es" << "\n";
    }
    else
    {
        cout << s << "s" << "\n";
    }
    
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

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

int main(){
 ll N;
  cin >> N;
 string ans;
 
 while(N){
   N--;
   ans += 'a'+N%26;
   N /=26;
 }
 reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
   
}
    
  
  
    


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

#define SIZE 10000

using namespace std;
long long int cinq(long long int n) {
  long long int s;
  s = n*n;
  return (s*s*n);
}

int main() {
    long long int i,j,k,N,M,K,Q,X;
  //  long long int A[100][100];

   cin >> X;

  long long int A[SIZE];
  long long int C[SIZE]; // cumulatif
  long long int actuel;
long encore;

  // on cherche d'abord les solutions positifs ;

  i=0;
  actuel = cinq(i);
  A[i] = actuel;
  if (A[i] == X) {
    cout << i << " " << 0 << endl;
  }
  else {
      encore = 1;
      i++;
      while ((actuel <= X) && (encore)) {
        actuel = cinq(i);
        A[i]=actuel;
        if (A[i] == X) {
          cout << i << " " << 0 << endl;
          encore = 0;
        }
        for (j=0;(j<=i) && encore;j++) {
          if ((A[i]+A[j]) == X) {
            encore = 0;
            cout << i << " " << -j<< endl;
          }
        }
        i++;
      }
     if (encore) {
  i = 0;
  actuel = cinq(i)-cinq(i-1);
  A[i] = actuel;
  C[i] = actuel;

  encore = 1;
  if (C[i] == X) {
    encore = 0;
    cout << i << " " << -1 << endl;
  }
  else if (A[i] == X) {
    encore = 0;
    cout << i << " " << i-1 << endl;
  }
  i++;
  while ((actuel <= X) && (encore)) {
    actuel = cinq(i)-cinq(i-1);
    A[i] = actuel;
    C[i] = actuel+C[i-1];
    // cerr << i << " " << A[i] << " " << C[i] << endl;
    if (A[i] == X) {
      encore = 0;
      cout << i << " " << i-1 << endl;
    //  cerr << "checkA "  << cinq(i)-cinq(i-1) << endl;

    }
    else if (C[i] == X) {
      encore = 0;
      cout << i << " " << -1 << endl;
    //  cerr << "checkC "  << i*i*i*i*i+1 << endl;

    }
    else {
    for (j=0;(j<i) && encore;j++) {
      if ((C[i] -C[j]) == X) {
        encore = 0;
        cout << i << " " << j<< endl;
      //  cerr << "checkD "  << i*i*i*i*i-j*j*j*j*j << endl;
      }
    }
  }
    i++;
  }
}
}
  return 0;
}


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

int L[200];
int N;

int main()
{
  cin >> N;

  for (int i = 0; i < 2 * N; i++){
    cin >> L[i];
  }

  sort(L, L + (2 * N));

  int sum = 0;
  for (int i = 0; i < 2 * N; i += 2){
    sum += L[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    string a;
    cin>>a;
    ll gre=0,sma=0;
    for(ll i=0; i<a.size(); i++)
    {
        if(a[i]=='>')
            gre++;
        else
            sma++;
    }
    if(sma==a.size() || gre==a.size())
    {
        ll si=a.size();
        ll ans=(si*(si+1))/2;
        cout<<ans<<endl;
        return 0;
    }
    char ch=a[0];
    ll count=01,sum=0;
    vector<ll>v;
    for(ll i=1; i<a.size(); i++)
    {
        if(ch==a[i])
        {
            count++;
        }
        else
        {
            v.push_back(((count)*(count+1))/2);
            count=01;
            ch=a[i];
        }
    }
    v.push_back(((count)*(count+1))/2);
    for(ll i=0; i<v.size(); i++)
        sum+=v[i];
        //cout<<sum<<endl;
    if(a[0]=='<')
    {
        for(ll i=1; i<v.size(); i+=2)
        {
            ll mi=min(v[i],v[i-1]);
            mi*=2;
            ll sq=sqrt(mi);
            sum-=sq;
        }
        cout<<sum<<endl;
    }
    else
    {

        for(ll i=2; i<v.size(); i+=2)
        {
            ll mi=min(v[i],v[i-1]);
            mi*=2;
            ll sq=sqrt(mi);
            sum-=sq;
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 3068
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 2018-10-6 20:58:24
# Powered by Visual Studio Code
#

n = gets.to_i

if n == 1
  puts "Hello World"
else
  a = gets.to_i
  b = gets.to_i
  puts a+b
end

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println((a + b) % 2 == 0 ? (a + b) / 2 : (a + b + 1) / 2);
    }
}

Measured memory_bytes: 21844
package main

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

const (
	MOD = 1000*1000*1000 + 7
	N   = 3*1000*1000*10 + 10
)

func main() {
	in := IOInitialize()
	C1 := IntArray(in, 3)
	C2 := IntArray(in, 3)
	C3 := IntArray(in, 3)
	a1, a2, a3, b1, b2, b3 := 0, 0, 0, 0, 0, 0

	for a1 = 0; a1 <= 100; a1++ {
		b1 = C1[0] - a1
		b2 = C1[1] - a1
		b3 = C1[2] - a1
		for a2 = 0; a2 <= 100; a2++ {
			if C2[0] != a2+b1 {
				continue
			}
			if C2[1] != a2+b2 {
				continue
			}
			if C2[2] != a2+b3 {
				continue
			}
			for a3 = 0; a3 <= 100; a3++ {
				if C3[0] != a3+b1 {
					continue
				}
				if C3[1] != a3+b2 {
					continue
				}
				if C3[2] != a3+b3 {
					continue
				}
				fmt.Println("Yes")
				return
			}
		}

	}

	fmt.Println("No")
}

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

func IOInitialize() *bufio.Scanner {
	t := bufio.NewScanner(os.Stdin)
	t.Split(bufio.ScanWords)
	return t
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("\t\tThere is a FALSE not to want.")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("\t\tError:Failed to convert text to int,")
	}
	return value
}

func IntArray(s *bufio.Scanner, size int) []int {
	deepArray := make([]int, size)
	for i := range deepArray {
		deepArray[i] = Int(s)
	}
	return deepArray
}

func GraphSetByEdge(s *bufio.Scanner, v int) [][]int {
	g := make([][]int, v)
	for i := range g {
		g[i] = make([]int, 0)
	}
	for xxNonUsedInLoopI := 0; xxNonUsedInLoopI < v-1; xxNonUsedInLoopI++ {
		a, b := Int(s)-1, Int(s)-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	return g
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 100010
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int main(){
//	freopen("a.in","r",stdin);
	ll x=read(),ans=0;
	ans+=x/11*2;x%=11;
	if(x>6) ans+=2;
	else if(x>0) ans+=1;
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<cstdio>

using namespace std;

#define rep(i, n) for(long int i = 0; i < n; i++)

int main(){
    int n, k;
    cin >> n >> k;
    int h[n];
    rep(i, n) cin >> h[i];
    int ans = 0;
    rep(i, n) {
        if (h[i] >= k){
            ans++;            
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
n = int(input())
list = list(map(int,input().split()))
flist = []
avr = sum(list)/n

for i in range(n):
    flist.append(max(list[i], avr) - min(list[i], avr))

d = flist.count(min(flist))

if d == n:
    print("0")
else:
    index = flist.index(min(flist))
    print(index)


Measured memory_bytes: 3060
N, T = [int(i) for i in input().split(" ")]
t = [int(j) for j in input().split(" ")]

dt = []
for i in range(N - 1):
  dt.append(t[i + 1] - t[i])
else:
  dt.append(T)

print(sum([min([dti, T]) for dti in dt]))

Measured memory_bytes: 30884
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string s;
    cin>>s;
    reverse(all(s));
    if(s[0]=='2'||s[0]=='4'||s[0]=='5'||s[0]=='7'||s[0]=='9'){
        cout<<"hon"<<endl;
    }else if(s[0]=='3'){
        cout<<"bon"<<endl;
    }else{
        cout<<"pon"<<endl;
    }
    
}


Measured memory_bytes: 3612
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

double getD(double T, double x) {
    return T - x * 0.006;
}

int main() {

    int N;
    cin >> N;

    double T, A;
    cin >> T >> A;

    vector<double> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    int index = 0;
    for (int i = 0; i < N; i++) {
        if (abs(getD(T, H[index]) - A) > abs(getD(T, H[i]) - A)) index = i;
    }

    cout << index + 1 << endl;

    return 0;
}











































































Measured memory_bytes: 256
#define ll long long
#define pb push_back
#include<bits/stdc++.h>
#define vi vector<int>
#define N 500000
// G = 0, W = 1
using namespace std;
int n, q, a, b, time_;
vi adj[N];
int tout[N], tin[N], color[N];
struct Node{
	int lazy, prior, sz, val, numG;
	Node *l, *r;
	Node(int val){
		this->val = val; prior = rand() % N; l = r = NULL; sz = 1; lazy = 0;
		if(this->val == 0) this->numG = 1;
		else this->numG = 0;
	}
};
typedef Node* pnode;
int sz(pnode t){
	return t ? t->sz : 0;
}
void updz(pnode t){
	if(t) t->sz = 1 + sz(t->l) + sz(t->r);
}
int getG(pnode t){
	return t ? t->numG : 0;
}
void reset(pnode t){
	if(!t) return;
	t->numG = t->val == 0 ? 1 : 0;
}
void lazy(pnode t){
	if(!t || t->lazy == 0) return;
	t->lazy = 0;
	t->val ^= 1;
	if(t->l) t->l->lazy ^= 1;
	if(t->r) t->r->lazy ^= 1;
	t->numG = sz(t) - t->numG;
}
void combine(pnode &t, pnode l, pnode r){
	if(!l || !r) return void(t = l ? l : r);
	t->numG = l->numG + r->numG;
}
void operation(pnode& t){
	if(!t) return;
	lazy(t);
	reset(t);
	lazy(t->l); lazy(t->r);
	combine(t, t->l, t); combine(t, t, t->r);
}
void split(pnode t, pnode &l, pnode &r, int pos, int add = 0){
	if(!t) return void(l = r = NULL);
	lazy(t);
	int cur_pos = 1 + sz(t->l) + add;
	if(cur_pos <= pos) split(t->r, t->r, r, pos, cur_pos), l = t;
	else split(t->l, l, t->l, pos, add), r = t;
	updz(t); operation(t);
}
void merge(pnode &t, pnode l, pnode r){
	lazy(l); lazy(r);
	if(!r || !l) return void(t = l ? l : r);
	if(l->prior > r->prior) merge(l->r, l->r, r), t = l;
	else merge(r->l, l, r->l), t = r;
	updz(t); operation(t);
}
pnode root = 0;
void dfs(int u, int p_ = -1){
	tin[u] = time_++;  
	//cout << u << endl;
	Node* cur = new Node(color[u]); //cout << color[u] << endl;
	merge(root, root, cur);
	for(int v : adj[u]) if(v != p_){
		dfs(v, u);
	}
	tout[u] = time_;
}
void query(int l, int r){
	pnode M, L, R;
	split(root, L, R, l - 1); 
	split(R, M, R, r - l + 1);
//	cout << "Query dang: " << sz(M) << endl;
	M->lazy ^= 1;
	merge(R, M, R); merge(root, L, R);
}
void answer(int l = 1, int r = time_){
	pnode L, R, M;
	split(root, L, R, l - 1);
	split(R, M, R, r - l + 1);
	int numG = M->numG, numW = sz(M) - numG;
//	cout << "G: " << numG << " and W: " << numW << " in " << sz(M) <<  endl;
	if(numG > numW) cout << "broccoli" << endl;
	else cout << "cauliflower" << endl;
	merge(R, M, R); merge(root, L, R);
}
void solve(){
	time_ = 1; root = 0;
	cin >> n >> q;
	for(int i = 1; i <= n; i++) adj[i].clear();
	for(int i = 2; i <= n; i++){
		cin >> a; 
		adj[a].pb(i);
	}
	string s;
	for(int i = 1; i <= n; i++){
		cin >> s;
		if(s[0] == 'G') color[i] = 0;
		else color[i] = 1;
	}
	dfs(1); //cout << "Time: " << time_ << endl;
	for(int i = 1; i <= q; i++){
		cin >> a;
		int l = tin[a], r = tout[a] - 1; 
		query(l, r);
		answer();
	}
}
int main(void){
	int t = 1;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 28560
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

int n, h, w, y, x;
string s, t;

bool solve(int len, int pos, vector<int> v, vector<bool> f)
{
    int L = 1, R = len;
    for (int i = v.size() - 1; i >= 0; i--)
    {
        if (f[i])
        {
            if (v[i] == 1)
                R--;
            else
                L++;
        }
        else
        {
            if (v[i] == 1)
                L = max(L - 1, 1LL);
            else
                R = min(R + 1, len);
        }
        if (L > R)
            return false;
    }
    return (L <= pos && pos <= R);
}

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

    cin >> h >> w >> n >> y >> x >> s >> t;
    vector<int> v_h, v_w;
    vector<bool> f_h, f_w;
    rep(i, n)
    {
        if (s[i] == 'U')
        {
            v_h.push_back(-1);
            f_h.push_back(true);
        }
        if (s[i] == 'D')
        {
            v_h.push_back(1);
            f_h.push_back(true);
        }
        if (s[i] == 'L')
        {
            v_w.push_back(-1);
            f_w.push_back(true);
        }
        if (s[i] == 'R')
        {
            v_w.push_back(1);
            f_w.push_back(true);
        }
        if (t[i] == 'U')
        {
            v_h.push_back(-1);
            f_h.push_back(false);
        }
        if (t[i] == 'D')
        {
            v_h.push_back(1);
            f_h.push_back(false);
        }
        if (t[i] == 'L')
        {
            v_w.push_back(-1);
            f_w.push_back(false);
        }
        if (t[i] == 'R')
        {
            v_w.push_back(1);
            f_w.push_back(false);
        }
    }
    bool f = solve(h, y, v_h, f_h) && solve(w, x, v_w, f_w);
    cout << (f ? "YES" : "NO") << endl;
}

Measured memory_bytes: 7300
#include "bits/stdc++.h"
using namespace std;
long long a[5] = {}, total = 0;
int main()
{
    int n;
    char inp[10];
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("\n%s", inp);
        switch (inp[0])
        {
            case 'M':
                ++a[0];
                break;
            case 'A':
                ++a[1];
                break;
            case 'R':
                ++a[2];
                break;
            case 'C':
                ++a[3];
                break;
            case 'H':
                ++a[4];
                break;
            default:
                break;
        }
    }
    for (int i = 0; i < 5; ++i)
    {
        for (int j = i + 1; j < 5; ++j)
        {
            for (int k = j + 1; k < 5; ++k)
            {
                total += a[i] * a[j] * a[k];
            }
        }
    }
    printf("%lld\n", total);
}



Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}

main :: IO ()
main = do
  n <- readLn
  putStrLn $ if solve n then "Yes" else "No"

solve :: Int -> Bool
solve n
  | n < 0 = False
  | n - 4 == 0 || n - 7 == 0 = True
  | otherwise = solve (n - 4) || solve (n - 7)


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

using namespace std;

int a[10000];
//int a[6] = {1,2,3,4,5,6};

int binary_search(int val,int ini,int tam){
	int l = ini, h = tam, mid , res = tam;
	while(l<=h){
		mid = (l+h)/2;
		if(a[mid] <= val){
			//res = mid;
			l = mid+1;
		}
		else if(a[mid]>val){
			res = mid;
			h = mid-1;
		}
	}
	return res;
}

int main(){


	//cout<<binary_search(6,0,5);


	int n;
	cin>>n;
	for(int i =0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	/*for(int i =0;i<n;i++){
		cout<<a[i]<<endl;
	}*/
	int triangulos =0,ind;
	for(int i =0;i<n;i++){
		for(int j =i+1;j<n;j++){
			//cout<<"i "<<i<<" j "<<j<<" "<<a[i]+a[j]-1<<" "<<j<<" "<<n<<endl;
			ind = binary_search(a[i]+a[j]-1,j,n);
			//cout<<"j="<<j<<" "<<ind<<endl;
			/*if(ind == -1){

			}*/
			//else{
				triangulos += (ind-j-1);
			//}
			//cout<<"triangulos "<<triangulos<<endl;
		}
	}
	cout<<triangulos<<endl;	

	return 0;
}

Measured memory_bytes: 256
/*Infor {{{
 ******************************************************
 * > File Name: a.cpp
 * > Author: samcompu
 * > Mail: admin@samcompu.com
 * > Created Time: 2018年07月01日 星期日 19时30分41秒
 ******************************************************
}}}*/

#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define cini(a) scanf("%d", &(a))
#define cinc(a) scanf("%c", &(a))
#define cinl(a) scanf("%lld", &(a))
#define cins(a) scanf("%s", (a))
#define cind(a) scanf("%lf", &(a))
#define coui(a) printf("%d", (a))
#define couc(a) printf("%c", (a))
#define coul(a) printf("%lld", (a))
#define cous(a) printf("%s", (a))
#define coud(a) printf("%f", (a))
#define SPA printf(" ")
#define LIN printf("\n")
#define ull unsigned long long int
/*}}}*/

/*Constant {{{*/
/*}}}*/

/*Class {{{*/
/*}}}*/

/*Variable {{{*/
/*}}}*/

/*Declare {{{*/
/*}}}*/

/*Main {{{*/
int main() {
  int n;
  cini(n);
  if (n % 2) coui(n * 2), LIN;
  else coui(n), LIN;
  return 0;
}
/*}}}*/

/*Define {{{*/
/*}}}*/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>

using namespace std;

struct UnionFind {
    vector<int> parent;
    vector<int> myrank;
    //親は小さい
    UnionFind(int n) : parent(n,-1), myrank(n,0) { }
    bool Find(int x, int y){
        return find_root(x) == find_root(y); 
    }
    int find_root(int x){
        if(parent[x] < 0){
            return x;
        }else{
            return parent[x] = find_root(parent[x]);
        }
    }
    bool Union(int x, int y){
        x = find_root(x); y = find_root(y);

        if(x != y){
            if(myrank[y] < myrank[x]){
                swap(x,y);
            }
            parent[x] += parent[y]; parent[y] = x;
            if(myrank[x] == myrank[y]) myrank[x]++;
            return true;
        }else{
            return false;
        }
    }
    int size(int x){
        return -parent[find_root(x)];
    }
};

struct UEdge {
    int a, b;
    double len=1.0;
    
    UEdge(int a, int b, double len) : a(a), b(b), len(len) {}

    bool operator <(const UEdge &rhs) const{
        if (len != rhs.len) return len < rhs.len;
        if (a != rhs.a) {return a < rhs.a;}
        return b < rhs.b;
    }
    bool operator >(const UEdge &rhs) const{
        if (len != rhs.len) return len > rhs.len;
        if (a != rhs.a) {return a > rhs.a;}
        return b > rhs.b;
    }
    bool operator <=(const UEdge &rhs) const{
        if (len != rhs.len) return len < rhs.len;
        if (a != rhs.a) {return a < rhs.a;}
        return b <= rhs.b;
    }
    bool operator >=(const UEdge &rhs) const{
        if (len != rhs.len) return len > rhs.len;
        if (a != rhs.a) {return a > rhs.a;}
        return b >= rhs.b;
    }
};

struct Point {
    double a, b;

    Point(double a, double b) : a(a), b(b) {}

};
double dist(Point &p1, Point &p2){
    return sqrt((p1.a - p2.a)*(p1.a - p2.a) + (p1.b - p2.b)*(p1.b-p2.b));
}


int main(){
    int N, M;
    double x, y;
    double tmp,total=0;
    int a, b;
    vector<UEdge> edges; 
    vector<Point> points;
    cin >> N >> M;
    for(int i=0; i< N; i++){
        cin >> x >> y;
        points.push_back(Point(x,y));
    }
    for(int i=0; i< M; i++){
        cin >> a >> b;
        a--;b--;
        tmp = dist(points[a],points[b]);
        total += tmp;
        edges.push_back(UEdge(a,b,-tmp));
    }
    sort(edges.begin(), edges.end());
    UnionFind uf(N);
    int count = 0;
    for(vector<UEdge>::iterator itr = edges.begin(); count < N-1 && itr != edges.end() ; itr++){
        if( !uf.Find(itr->a, itr->b)){
            uf.Union(itr->a, itr->b);
            total += itr->len;
            count++;
        }
    }
    cout << fixed << setprecision(5) << total << endl;

    return 0;
}



Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

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

    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);

    rep(i, N)
    {
        cin >> A[i];
    }

    rep(i, N)
    {
        cin >> B[i];
    }

    rep(i, N)
    {
        cin >> C[i];
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    // i番目の要素が"B[i]より大きいCの要素の数"であるような配列
    vector<int> C_larger(N);
    rep(i, N)
    {
        C_larger[i] = C.size() - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
    }

    // i番目の要素が,B[i]より大きいCの要素の数 + ... +B[N-1]より大きいCの要素の数 であるような配列
    vector<ll> cumalative_sum(N);
    cumalative_sum[0] = C_larger[N - 1];
    for (int i = 1; i < N; i++)
    {
        cumalative_sum[i] = cumalative_sum[i - 1] + C_larger[N - 1 - i];
    }

    reverse(cumalative_sum.begin(), cumalative_sum.end());

    ll ans = 0;
    rep(i, N)
    {
        // A[i]より大きいBの要素の中で最小の要素のインデックス
        int ind = upper_bound(B.begin(), B.end(), A[i]) - B.begin();
        ans += cumalative_sum[ind];
    }

    cout << ans << endl;
}


Measured memory_bytes: 2688
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if(0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

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

using namespace std;

int main(void) {
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3628