akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

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

using P = pair<int, int>;
int main() {
    int N, C;
    cin >> N >> C;
    vector<vector<P>> st(C);
    vector<int> T(1e5 + 2);
    for (int i = 0; i < N; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        st[c].push_back(P(s, t));
    }
    for (int i = 0; i < C; i++) {
        sort(ALL(st[i]));
        for (int j = 0; j < (int)st[i].size(); j++) {
            if (j == 0 || st[i][j - 1].second != st[i][j].first) {
                T[st[i][j].first]++;
                T[st[i][j].second + 1]--;
            } else {
                T[st[i][j - 1].second + 1]++;
                T[st[i][j].second + 1]--;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 100001; i++) {
        T[i + 1] += T[i];
        chmax(ans, T[i + 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1920
import java.util.*;

public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int sum = a + b;
			int ans = 0;
			while(sum != 0)
			{
				sum /= 10;
				++ans;
			}
			System.out.println(ans);
		}
	}
}

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



int main (void){
   ll n,m;
   cin >> n >> m;

   ll p;
   string s;
   int kanri[n+5]={};
   ll pena[n+5]={};
   ll ans=0;
   ll sump=0;

   rep(i,m){
       cin >> p >> s;
       if(s=="AC"&&kanri[p]==0){
           kanri[p]=1;
           ans++;
           sump+=pena[p];
       }
       if(s=="WA"&&kanri[p]==0){
           pena[p]++;
       }
   }

cout << ans << " " << sump << endl;

    return 0;
}

Measured memory_bytes: 1408
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

if N < M:
    print('NO')
    exit()

dic = defaultdict(int)

for d in D:
    dic[d] += 1

for t in T:
    dic[t] -= 1
    if dic[t] < 0:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 41700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
int main(void){
	ll i,j,n,m;
	ll s,g,v,pp;
	ll ri[21][21];
	ll leng[21],flg[21];
	ll min,ki,sam;
	PP p[100];
	scanf("%lld %lld",&n,&m);
	for(i=0;i<m;i++) scanf("%lld,%lld,%lld,%lld",&p[i].ff,&p[i].fs,&p[i].sf,&p[i].ss);
	scanf("%lld,%lld,%lld,%lld",&s,&g,&v,&pp);
	sort(p,p+m);
	for(i=0;i<=n;i++) for(j=0;j<=n;j++) ri[i][j]=M;
	for(i=0;i<m;i++) ri[p[i].ff][p[i].fs]=p[i].sf,ri[p[i].fs][p[i].ff]=p[i].ss;
	for(i=0;i<=n;i++) flg[i]=0,leng[i]=M;
	leng[s]=0;
	for(i=0;i<=n;i++){
		min=M;
		for(j=0;j<=n;j++){
			if(flg[j]==0&&leng[j]<min){
				min=leng[j];
				ki=j;
			}
		}
		flg[ki]=1;
		for(j=0;j<=n;j++){
			if(min+ri[ki][j]<leng[j]){
				leng[j]=min+ri[ki][j];
			}
		}
	}
	sam=leng[g];
	//printf("%d\n",leng[g]);
	for(i=0;i<=n;i++) flg[i]=0,leng[i]=M;
	leng[g]=0;
	for(i=0;i<=n;i++){
		min=M;
		for(j=0;j<=n;j++){
			if(flg[j]==0&&leng[j]<min){
				min=leng[j];
				ki=j;
			}
		}
		flg[ki]=1;
		for(j=0;j<=n;j++){
			if(min+ri[ki][j]<leng[j]){
				leng[j]=min+ri[ki][j];
			}
		}
	}
	//printf("%d\n",leng[s]);
	sam=v-pp-leng[s]-sam;
	printf("%d\n",sam);
	return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define LL long long
using namespace std;

template <class T> inline void read(T &x) {
    int t;
    bool flag = false;
    while((t = getchar()) != '-' && (t < '0' || t > '9')) ;
    if(t == '-') flag = true, t = getchar(); x = t - '0';
    while((t = getchar()) >= '0' && t <= '9') x = x * 10 + t - '0';
    if(flag) x = -x;
}


int main(){

    int l,k;
    LL dp[110],sum[110];
    while(~scanf("%d %d",&l,&k))
    {
        memset(dp,0,sizeof(dp));
        memset(sum,0,sizeof(sum));
        dp[0]=0;
        for(int i=1;i<=k;i++)
        {
            dp[i]=(i%2);
        }
        dp[k]++;
        for(int i=k+1;i<=l;i++)
        {
            dp[i]=dp[i-2]+dp[i-k-1];
        }
        for(int i=1;i<=l;i++)
        {
            sum[i]=sum[i-1]+dp[i];
        }
        cout<<sum[l]<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <cmath>
using namespace std;

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    int ans = 1;
    x -= y + 2 * z;
    ans += x / (y + z);
    cout << ans << endl;
}

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


namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			 
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var cl = new int[input[0]];
            int count = 0;
            for(int i =0; i<cl.Length; i++)
            {
                int tmp = int.Parse(Console.ReadLine());
                if (tmp >= input[1] && tmp < input[2]) continue;
                count++;
            }
            Console.WriteLine(count);

		}				 
	}
}

Measured memory_bytes: 2776
#include<bits/stdc++.h>//万能头文件可好 
using namespace std;
#define ll long long
bool a[100005];
int main(){//主函数 
	ll n,k,i,again=0;
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		scanf("%lld",&k);
		if(a[k])again++;
		else a[k]=true;
	}
	again+=again%2;
	printf("%lld",n-again);
	return 0;//over~
}

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

int main()
{

    int n,i,k,sum=0;
    cin>>n>>k;
    int arr[n+3];
    for(i=0; i<n; i++)cin>>arr[i];
    sort(arr,arr+n);
    for(i=0; i<k; i++)sum+=arr[i];
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3636
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n; cin>>n;
    ll ans=0;
    map<ll,ll> mp; ;
    for(int i=1;i<=n;i++){
        ll a; cin>>a;
        ll val=i-a;
        if(mp.count(val)) ans+=mp[i-a];
        mp[i+a]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 16068
<?php
  $temp = trim(fgets(STDIN));
  $temp = str_replace(array("\r\n", "\r", "\n"), "", $temp);
  $input = explode(" ", $temp);
  $flg = false;

  if($input[0] >= $input[1]){
    for($i = $input[1]; $i < $input[0]; $i++){
      if($i == $input[2]){
        $flg=true;
        break;
      }
    }
  } else{ 
    for($i = $input[0]; $i < $input[1]; $i++){
      if($i == $input[2]){
        $flg=true;
        break;
      }
    }
  }

  if($flg){
    echo "Yes"."\n";
  }else{
  	echo "No"."\n";
  }
?>

Measured memory_bytes: 3828
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = Read();
        int[] a = Read(n);
        int max = 0;
        int[] l = new int[n];
        int[] r = new int[n];
        l[0] = 0; r[n - 1] = 0;
        for (int i = 1; i < n; i++)
        {
            l[i] = gcd(l[i - 1], a[i - 1]);
            r[n - 1 - i] = gcd(r[n - i], a[n - i]);
        }
        for (int i = 0; i < n; i++)
        {
            int g = gcd(l[i], r[i]);
            max = (g > max) ? g : max;
        }
        Write(max);
    }

    static void Write(string s) { Console.WriteLine(s); return; }
    static void Write(int n) { Console.WriteLine(n.ToString()); return; }
    static int Read() { return int.Parse(Console.ReadLine()); }
    static int[] Read(int n)
    {
        int[] p = new int[n];
        string[] t = Console.ReadLine().Split(' ');
        for(int i = 0; i < n; i++) { p[i] = int.Parse(t[i]); }
        return p;
    }
    static int abs(int n) { return (n > 0) ? n : -n; }
    static int gcd(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = gcd(p, n[i]); } return p; }
    static int gcd(int a, int b) { return (a==0)?b:gcd(b % a, a); }
    static int lcm(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = lcm(p, n[i]); } return p; }
    static int lcm(int a, int b) { return a * b / gcd(a, b); }
}


Measured memory_bytes: 25820
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

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

void Eratos(vector<char>& p) {
	int i, j;
	p[0] = p[1] = 0;
	for (i = 2; i < p.size(); i++) {
		if (p[i]) {
			for (j = i << 1; j < p.size(); j += i)
				p[j] = 0;
		}
	}
	return;
}

int Existcp(vector<int> &d) {
	int i, j;
	vector<char> a(1000001, 0), p(1000001, 1);
	Eratos(p);
	rep(i, d.size()) {
		if (a[d[i]] && d[i] > 1)
			return true;
		a[d[i]] = 1;
	}
	rep(i, p.size()) {
		if (p[i]) {
			int s = 0;
			for (j = i; j < a.size(); j += i) {
				if (a[j])
					s++;
			}
			if (s > 1)
				return true;
		}
	}
	return 0;
}

int main(void) {
	int num, i, g;
	cin >> num;
	vector<int> d(num);
	rep(i, num)
		cin >> d[i];
	g = d[num - 1];
	rep(i, num - 1)
		g = gcd(g, d[i]);
	if (g > 1)
		printf("not coprime\n");
	else if (Existcp(d))
		printf("setwise coprime");
	else
		printf("pairwise coprime");
	return 0;
}

Measured memory_bytes: 9008
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(N):
    ans = []
    while N > 26:
        k = N % 26
        N //= 26
        if k != 0:
            ans.append(chr(ord('a') + k - 1))
        else:
            ans.append('z')
            N -= 1

    ans.append(chr(ord('a') + N - 1))
    return "".join(ans[::-1])
#
# assert(solve(1) == "a")
# assert(solve(26) == "z")
# assert(solve(27) == "aa")
# assert(solve(701) == "zy")
# assert(solve(702) == "zz")
# assert(solve(475256) == "aaaab")
# assert(solve(475254) == "zzzz")
# assert(solve(475255) == "aaaaa")
# assert(solve(475253) == "zzzy")
# assert(solve(123456789) == "jjddja")
# print("OK")

if __name__ == "__main__":
    S = int(input())
    print(solve(S))


Measured memory_bytes: 9472
n=int(input())
hoge=[]
for i in range(n):
  hoge.append(int(input()))
  
if(sum(hoge)%10!=0):
  print(sum(hoge))
else:
  ans=0
  for i in range(n):
    huga=sum(hoge)-hoge[i]
    if(huga%10!=0):
      ans=max(ans,huga)
  print(ans)

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

signed main(void)
{
	int n, m;
	cin >> n >> m;
	int x[m], y[m];
	int have[n];
	bool b[n];
	rep(i, m) 
	{
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
	}
	rep(i, n) 
	{
		have[i] = 1; 
		b[i] = false;
	}
	b[0] = true;	
	rep(i, m)
	{
		if (b[x[i]])
			b[y[i]] = true;
		have[x[i]]--;
		have[y[i]]++;
		if (have[x[i]] <= 0)
			b[x[i]] = false;
	}
	int cnt = 0;
	rep(i, n)
	{
		if (b[i])
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
	int n, m;
	if(scanf("%d", &n)== 1);
	if(scanf("%d", &m)== 1);
	
	if(n == m){
		printf("Yes");
	}else{
		printf("No");
	}
	
	
    return 0;
}

Measured memory_bytes: 128
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**9 + 1

def precompute(N, M, data):
    data = data.reshape(-1, 3)
    A, B, C = data[:N].T
    D, E, F = data[N:].T
    X = np.unique(np.concatenate([A, B, D, [0, -INF, INF]]))
    Y = np.unique(np.concatenate([C, E, F, [0, -INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B)
    D = np.searchsorted(X, D)
    C = np.searchsorted(Y, C)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F)
    return A, B, C, D, E, F, X, Y

def solve(A, B, C, D, E, F, X, Y):
    H, W = len(X), len(Y)
    N = H * W
    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    def set_ng(A, B, C, D, E, F, H, W):
        ng = np.zeros((H * W, 4), np.bool_)

        for i in range(len(A)):
            for x in range(A[i], B[i]):
                v = x * W + C[i]
                ng[v][1] = 1
                ng[v - 1][0] = 1

        for i in range(len(D)):
            for y in range(E[i], F[i]):
                v = D[i] * W + y
                ng[v][3] = 1
                ng[v - W][2] = 1
        return ng

    ng = set_ng(A, B, C, D, E, F, H, W)
    x0, y0 = np.searchsorted(X, 0), np.searchsorted(Y, 0)
    v0 = x0 * W + y0
    visited = np.zeros(N, np.bool_)
    visited[v0] = 1
    stack = np.empty(N, np.int32)
    p = 0
    ret = 0

    def area(x):
        x, y = divmod(x, W)
        return DX[x] * DY[y]

    def push(x):
        nonlocal p, ret
        stack[p] = x
        visited[x] = 1
        ret += area(x)
        p += 1

    def pop():
        nonlocal p
        p -= 1
        return stack[p]

    push(v0)
    move = (1, -1, W, -W)
    while p:
        v = pop()
        for i in range(4):
            if ng[v][i]:
                continue
            w = v + move[i]
            if visited[w]:
                continue
            x, y = divmod(w, W)
            if x == 0 or x == H - 1 or y == 0 or y == W - 1:
                return 0
            push(w)
    return ret

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    signature = '(i8[:],i8[:],i8[:],i8[:],i8[:],i8[:],i8[:],i8[:])'
    cc.export('solve', signature)(solve)
    cc.compile()

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit()

from my_module import solve

N, M = map(int, readline().split())
data = np.int64(read().split())

x = solve(*precompute(N, M, data))
if x == 0:
    print('INF')
else:
    print(x)

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

int main() {
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < min(a.size(), b.size()); i++) cout << a[i] << b[i];
  cout << (a.size() > b.size() ? a.substr(b.size(), a.size() - 1)
                               : b.substr(a.size(), b.size() - 1));
  cout << endl;
}


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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

template<class M, class N>
constexpr std::common_type_t<M, N> gcd(M m, N n) {
    return n == 0 ? abs(m) : gcd(n, abs(m) % abs(n));
}

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

        int N;
        std::cin >> N;

        vector<int> A(N, 0);
        REP(i, N) {
            std::cin >> A[i];
        }

        vector<int> l_dp(N + 1, 0), r_dp(N + 1, 0);
        for(int i = 1; i < N; i++) {
            l_dp[i] = gcd(A[i - 1], l_dp[i - 1]);
            r_dp[N - i] = gcd(A[N - i], r_dp[N - i + 1]);
        }

        int ans = 0;
        REP(i, N) {
            ans = max(ans, gcd(l_dp[i], r_dp[i + 1]));
        }

        std::cout << ans << std::endl;
    }
    catch(const exception& e) {
        std::cout << e.what() << std::endl;
        exit(1);
    }
    return 0;
}


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

int main() {

        int x;
        cin >> x;
        if (x >= 30) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
}

Measured memory_bytes: 3580
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n,m;
    string s1 ,s2;
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        s1 += to_string(n);
    }
    for (int i = 0; i < n; ++i)
    {
        s2 += to_string(m);
    }
    if(n <= m)
        cout << s1 << "\n"; 
    else
        cout << s2 << "\n";
    return 0;
}


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  map<P,ll>mp;
  rep(i,1,n+1){
    string s=to_string(i);
    mp[MP(s[0]-'0',s.back()-'0')]++;
  }
  for(auto z:mp){
    auto p=z.fi;
    res+=z.se*mp[MP(p.se,p.fi)];
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
17D8101031C 杉山　祥吾 ID:keisei334 java
*/

import java.util.Scanner;
class Main {
    public static int n;
    public static int []A = new int[2000];
    public static void main(String[] av) {
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
	for(int i = 0; i < n; i++) {
	    A[i] = sc.nextInt();
	}
	int q = sc.nextInt();
	for(int i = 0; i < q; i++) {
	    int m = sc.nextInt();
                if(isSolve(0, m)) {
                    System.out.println("yes");
                }else {
                    System.out.println("no");
                }
	}
    }

    public static boolean isSolve(int i, int m) {
	if(m == 0) return true;
	if(i >= n) return false;
	boolean res = isSolve(i + 1, m) || isSolve(i + 1, m - A[i]);
	return res;
    }
}

/*実行結果

*/



Measured memory_bytes: 26788
n=int(input())
p=list(map(int,input().split()))
Ans=0
for i in range(n-2):
    if(p[i]>p[i+1] and p[i+1]>p[i+2]):
        Ans+=1
    if(p[i]<p[i+1] and p[i+1]<p[i+2]):
        Ans+=1

print(Ans)

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  int a;
  int b = 0;
  set<int> S;
  rep(i,n) {
    cin >> a;
    if( 1 <= a && a <= 399 ) {
      S.insert(0);
    } else if( 400 <= a && a <= 799) {
      S.insert(1);
    } else if( 800 <= a && a <= 1199) {
      S.insert(2);
    } else if( 1200 <= a && a <= 1599 ) {
      S.insert(3);
    } else if( 1600 <= a && a <= 1999 ) {
      S.insert(4);
    } else if( 2000 <= a && a <= 2399 ) {
      S.insert(5);
    } else if( 2400 <= a && a <= 2799 ) {
      S.insert(6);
    } else if( 2800 <= a && a <= 3199 ) {
      S.insert(7);
    } else {
      ++b;
    }
  }
  cout << max(1,(int)S.size())  << " " <<(int)S.size()+b   << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>
#include <map>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100000;
ll v[1 + nmax];
ll sum[1 + nmax];
ll pref[1 + nmax], suff[1 + nmax];

int main() {
  int n, k;
  std::cin >> n >> k;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  for(int i = 1;i <= n; i++)
    sum[i] = sum[i - 1] + v[i];
  for(int i = 1; i <= n; i++)
    pref[i] = pref[i - 1] + std::max(0LL, v[i]);
  for(int i = n; 1 <= i; i--)
    suff[i] = suff[i + 1] + std::max(0LL, v[i]);
  ll result = 0;
  for(int i = k; i <= n; i++)
    result = std::max(result, pref[i - k] + suff[i + 1] + std::max(sum[i] - sum[i - k], 0LL));
  std::cout << result;
  return 0;
}


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

int main(){
  unordered_map<int,int> mp;
  set<int> nums;
  int n,num;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> num;
    mp[num]++;
    nums.insert(num);
  }
  
  int res=0;
  for(auto i:nums){
    if(mp[i]==i) continue;
    if(mp[i]>i){
      res += mp[i]-i;
    }
    else{
      res += mp[i];
    }
  }
  cout << res;
  return 0;
}

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

int main(){
    ios_base::sync_with_stdio(0);
    ll x,y;
    cin>>x>>y;
    int ans=1;
    while(2*x<=y){
    	x = x*2;
    	ans++;
    }
    cout<<ans<<endl;
    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef unsigned long long ull;

ull x;

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>x;
    ull y, z=100;
    ull years=0;
    while(z<x){
        y=z/100;
        z+=y;
        years++;
        if(z>=x)break;
    }
    cout<<years;
    return 0;
}

Measured memory_bytes: 3624
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  import MapHelper._
  val n = in.readInt
  val s = in.readLine

  val ans = (1 until n)./:(0)( (acc, i) => {
    val map = mu.HashMap.empty[Char,Int]
    val sf = s.take(i).toSet.toArray
    val sr = s.drop(i).toSet.toArray
    sf.foreach(ch => map.addOrUpdate(ch,1))
    sr.foreach(ch => map.addOrUpdate(ch,1))
    acc max map.values.count(_ == 2)
  })

  println(ans)

  object MapHelper {
    implicit class AddOrUpdate[A](map:mu.HashMap[Char,Int]) {
      def addOrUpdate(key:Char, value:Int):mu.HashMap[Char,Int] =
      {
        if(map.contains(key)) map(key) += value
        else map += (key -> value)
        map
      }
    }
  }
}

Measured memory_bytes: 29236
import math as m
D,G = map(int, input().split())
info = [list(map(int, input().split())) for i in range(D)]
def bfs(list_hoge=[[0,[]]],depth=0):
    queue = []
    for e in list_hoge:
        for b in [0,1]:
            if b == 0:
                score = e[0]
                copy = e[1][:]
                queue.append([score,copy])
            elif b == 1:
                score = e[0] + 100*(depth+1)*info[depth][0] + info[depth][1]
                copy = e[1][:]
                copy.append(depth)
                queue.append([score,copy])
    list_hoge = queue[:]
    if depth == len(info)-1:
        return list_hoge
    return bfs(list_hoge,depth+1)
res = bfs()
ans = float("inf")
for e in res:
    solved = 0
    for i in range(len(e[1])):
        solved += info[e[1][i]][0]
    if e[0] >= G:
        if solved < ans:
            ans = solved
        continue
    for i in range(D-1,-1,-1):
        if not i in e[1]:
            nec = G-e[0]
            haiten = 100*(i+1)
            add_solve = m.ceil(nec/haiten)
            total_solved = solved + m.ceil(nec/haiten)
            if add_solve >= info[i][0]:
                break
            if total_solved < ans:
                ans = total_solved
print(ans)

Measured memory_bytes: 3444
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <functional>
#include <cassert>
#include <cmath>
#define SIZE 200005
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char str[SIZE];
int A[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",&str);
	for(int i=0;i<2*n;i++)
	{
		if(i==0) A[i]=(str[i]=='W'?0:1);
		else A[i]=(str[i]==str[i-1]?0:1);
	}
	int l=0;
	ll ret=1;
	for(int i=0;i<2*n;i++)
	{
		//printf("%d %d\n",A[i],l);
		if(A[i]==0)
		{
			if(l==0)
			{
				puts("0");
				return 0;
			}
			ret=ret*(ll) l%MOD;
			l--;
			A[i+1]^=1;
		}
		else
		{
			l++;
		}
	}
	if(l>0) ret=0;
	for(int i=1;i<=n;i++) ret=ret*(ll) i%MOD;
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	char S[11], T[12];
	
	scanf("%s", S);
	scanf("%s", T);
	
	if (memcmp(S, T, strlen(S)) == 0 &&
		strlen(S) + 1 == strlen(T)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return(0);
}



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

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

		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();
		
		if(u.equals(s))
			a--;
		if(u.equals(t))
			b--;
		
		System.out.println(a+" "+b);
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a*n,b)<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            List<char> cA = Console.ReadLine().Trim().ToCharArray().ToList();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<List<char>> lstCal = new List<List<char>>();                                                       // 考えられる数式一覧
            for (int i = 0; i < Math.Pow(2, cA.Count - 1); i++)
            {
                List<char> oneUsr = new List<char>();
                oneUsr.AddRange(cA);
                lstCal.Add(oneUsr);                                                                                 // Defaultは入力値
            }
            // 数式生成
            for (int i = 0; i < lstCal.Count ; i++)                                                                 // 数値の間に+挿入
            {                                                                                                       // 考えられる場合全て考慮
                List<char> cBin = Convert.ToString(i, 2).ToCharArray().ToList();                                    // 現在の値を2進法で
                cBin.Reverse();                                                                                     // 下の桁からにする為、リバース
                List<int> iIns = new List<int>();                                                                   // + 挿入箇所
                for (int j = 0; j < cBin.Count; j++) { if (cBin[j] == '1') { iIns.Add(j+1); } }                     // 2進法で1の立っている箇所に+挿入
                iIns.Reverse();                                                                                     // 大きいほうからの為、リバース
                for (int j = 0; j < iIns.Count; j++) { lstCal[i].Insert(iIns[j], '+'); }                            // 大きい方から挿入しないとIndexNoがずれる
            }
            // 数式計算
            long lOut = 0L;
            for (int i = 0; i < lstCal.Count; i++)
            {
                string sOne = new String(lstCal[i].ToArray());                                                      // charからStringへ変換
                string[] sAry = sOne.Split('+');
                for (int j = 0; j < sAry.Length; j++)
                {
                    lOut += long.Parse(sAry[j]);
                }
            }

            // 出力
            Console.WriteLine("{0}", lOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine();
            for (int i = 0; i < lstCal.Count; i++)
            {
                string sOut = new String(lstCal[i].ToArray());                                                      // charからStringへ変換
                Console.WriteLine("{0}", sOut.ToString());
            }
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int, int> P;
typedef pair<P, int> P_;

vector<P_> p;
int A[100000];
int B[100000];
int ord_a[100000];
int ord_b[100000];
bool used[100000];

int main(){
    int N;
    cin >> N;
    
    long suma = 0, sumb = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
        p.push_back(P_(P(A[i], i), 0));
        p.push_back(P_(P(B[i], i), 1));
        suma += A[i];
        sumb += B[i];
    }
    long ans = min(suma, sumb);
    sort(p.begin(), p.end());
    bool doubled = false;
    long sum = 0;
    for(int i = 0; i < N; i++){
        int a = p[i].first.first;
        int idx = p[i].first.second;
        int f = p[i].second;
        if(!used[idx]) used[idx] = true;
        else doubled = true;
        if(f == 0) ord_a[idx] = i;
        else ord_b[idx] = i;
        sum += a;
    }
    for(int i = N; i < 2*N; i++){
        int a = p[i].first.first;
        int idx = p[i].first.second;
        int f = p[i].second;
        if(f == 0) ord_a[idx] = i;
        else ord_b[idx] = i;
    }
    if(doubled){
        ans = min(ans, sum);
    }else{
        for(int i = 0; i < N; i++){
            long tmp = sum;
            if(ord_a[i] < N){
                tmp -= A[i];
                if(ord_b[i] == N) tmp += p[N+1].first.first;
                else tmp += p[N].first.first;
            }else{
                tmp -= B[i];
                if(ord_a[i] == N) tmp += p[N+1].first.first;
                else tmp += p[N].first.first;
            }
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
}

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

namespace ABC118_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = nm[0];
            var m = nm[1];

            var cnt = new int[m + 1];
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 1; j < line.Length; j++)
                {
                    cnt[line[j]]++;
                }
            }

            var ans = 0;
            for (int i = 1; i < cnt.Length; i++)
            {
                if (cnt[i] == n) ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
/*---Bismillahir Rahmanir Rahim---*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define pii pair<int, int>
using namespace std;

inline void solve() { 
	int  n,a,b,ans=0;
	cin >> n >> a >> b ; 
	if (b-a>2 and a+1<=n){
		ans = a ; 
		n -= (a-1);
		ans += (n/2)*(b-a);
		if (n&1) ans++;
	}
	else  ans = n+1; 
	cout << ans << endl; 
} 

signed main()
{
	int n = 1;
//	cin >> n;
	while (n--)
		solve();
	return 0;
}
/*
314159265 35897932 384626433
*/


Measured memory_bytes: 3644
N, M = map(int, input().split())

"1 2 3 4 5を配列に"
A = list(map(int, input().split()))
s = sum(A)
ok = s * (1/(4*M))
count = 0

for a in A:
  if a >= ok:
    count += 1

if count >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (1<<18)
#define INIT 0
#define INIT2 0
#define INIT3 0
long long a[(2 * N)];
long long laz[(2 * N)];
int l[(2 * N)];
int r[(2 * N)];

long long f1(long long x, long long y) {
	return (x + y);
}
long long f2(long long k, long long x, long long y) {
	return (((r[k] - l[k])*x) + y);
}
long long f3(long long x, long long y) {
	return (x + y);
}


void init(void) {
	f(i, (2 * N)) {
		a[i] = INIT2;
		laz[i] = INIT;
	}
	l[1] = 0;
	r[1] = N;
	for (int i = 1; i < N; i++) {
		l[(2 * i)] = l[i];
		r[(2 * i)] = (l[i] + r[i]) / 2;
		l[(2 * i) + 1] = (l[i] + r[i]) / 2;
		r[(2 * i) + 1] = r[i];
	}
	return;
}



long long change(int ll, int rr, int k, long long x) {
	long long vl, vr;
	if ((rr <= l[k]) || (r[k] <= ll))return f2(k, laz[k], a[k]);
	if (laz[k] != INIT) {
		a[k] = f2(k, laz[k], a[k]);
		if (k < N) {
			laz[(2 * k)] = f1(laz[k], laz[(2 * k)]);
			laz[(2 * k) + 1] = f1(laz[k], laz[(2 * k) + 1]);
		}
		laz[k] = INIT;
	}
	if ((ll <= l[k]) && (r[k] <= rr)) {
		laz[k] = f1(x, laz[k]);
		return f2(k, laz[k], a[k]);
	}
	else {
		int mm = (l[k] + r[k]) / 2;
		if ((l[k] < rr) && (ll < mm)) {
			vl = change(ll, rr, 2 * k, x);
		}
		else vl = f2((2 * k), laz[(2 * k)], a[(2 * k)]);

		if ((mm < rr) && (ll < r[k])) {
			vr = change(ll, rr, (2 * k) + 1, x);
		}
		else vr = f2((2 * k) + 1, laz[(2 * k) + 1], a[(2 * k + 1)]);

		a[k] = f3(vl, vr);
		return f2(k, laz[k], a[k]);
	}
}


long long search(int ll, int rr, int k) {
	if (laz[k] != INIT) {
		a[k] = f2(k, laz[k], a[k]);
		if (k < N) {
			laz[(2 * k)] = f1(laz[k], laz[(2 * k)]);
			laz[(2 * k) + 1] = f1(laz[k], laz[(2 * k) + 1]);
		}
		laz[k] = INIT;
	}
	long long vl, vr;
	if (rr <= l[k] || r[k] <= ll)return INIT3;
	else if (ll <= l[k] && r[k] <= rr) return f2(k, laz[k], a[k]);
	else {
		vl = search(ll, rr, 2 * k);
		vr = search(ll, rr, (2 * k) + 1);
		a[k] = f3(f2((2 * k), laz[(2 * k)], a[(2 * k)]), f2((2 * k) + 1, laz[(2 * k) + 1], a[(2 * k) + 1]));
		return f3(vl, vr);
	}
}


int main(void) {
	int q;
	int c, x, y;
	long long k;
	init();
	scanf("%d %d", &c, &q);
	f(qq, q) {
		scanf("%d", &c);
		if (c == 0) {
			scanf("%d %d %lld", &x, &y, &k);
			change(x, y + 1, 1, k);
		}
		else if (c == 1) {
			scanf("%d %d", &x, &y);
			k = search(x, y + 1, 1);
			printf("%lld\n", k);
		}
	}
	return 0;
}


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

int N,M;
vector<int> V[100010];
vector<int> pass1,pass2;
bool visit[100001] = {0};

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        V[a].push_back(b);
        V[b].push_back(a);
    }
    int next = 1;visit[1] = 1;pass1.push_back(1);bool flag = 1;
    while(flag)
    {
        flag = 0;
        for(int i = 0; i < V[next].size() + 1; i++)
        {
            if(i == V[next].size())continue;
            if(!visit[V[next][i]])
            {
                pass1.push_back(V[next][i]);
                visit[V[next][i]] = 1;
                next = V[next][i];
                flag = 1;
                break;
            }
        }
    }
    flag = 1;next = 1;
    while(flag)
    {
        flag = 0;
        for(int i = 0; i < V[next].size() + 1; i++)
        {
            if(i == V[next].size())continue;
            if(!visit[V[next][i]])
            {
                pass2.push_back(V[next][i]);
                visit[V[next][i]] = 1;
                next = V[next][i];
                flag = 1;
                break;
            }
        }
    }
    printf("%d\n",pass1.size() + pass2.size());
    for(int i = 0; i < pass1.size(); i++)
    {
        printf("%d",pass1[pass1.size() - 1 - i]);
        if(i != pass1.size() - 1)printf(" ");
    }
    for(int i = 0; i < pass2.size(); i++)
    {
        printf(" %d",pass2[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char a,b;
	cin>>a>>b;
	if (a<b)
		cout<<'<'<<endl;
	else if (a==b)
		cout<<'='<<endl;
	else
		cout<<'>'<<endl;
	return 0;
}

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

int main() {
  vector<int> var(5);
  
  for(int i = 0; i < 5; i++) cin >> var[i];
  
  int ans = 0;
  for(int i = 0; i < 5; i++) {
    ans++;
    if(var[i] == 0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3524
#include <iostream>
#include <string>
#include <set>
#include <vector>

using namespace std;

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

	vector<int> a(n);
	for (auto& e : a) cin >> e;

	int ans =  (n - 1) / (k - 1);
	if ((n - 1) % (k - 1) != 0) ans++;

	cout << ans << endl;
}


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

int main(){
    int n,b,f,r,v;
    cin >> n;
    int a[5][4][11];
    for (int i=1;i<=4;i++){
        for(int j=1;j<=3;j++){
            for(int k=1;k<=10;k++){
                a[i][j][k]=0;
            }
        }
    }
    
    for (int i=0;i<n;i++){
        cin >> b >> f >> r >>v;
        a[b][f][r] += v;
        if (a[b][f][r]<0){
            a[b][f][r]=0;
        }
        else if(a[b][f][r]>9){
             a[b][f][r]=9;
        }
    }
    
    for (int i=1;i<=3;i++){
        for (int j=1;j<=10;j++){
            cout << " " << a[1][i][j];
        }
        cout << endl;
    }
    cout << "####################"<<endl;
    
    for (int i=1;i<=3;i++){
        for (int j=1;j<=10;j++){
            cout << " " << a[2][i][j];
        }
        cout << endl;
    }
    cout << "####################"<<endl;
    
    for (int i=1;i<=3;i++){
        for (int j=1;j<=10;j++){
            cout << " " << a[3][i][j];
        }
        cout << endl;
    }
    cout << "####################"<<endl;
    
    for (int i=1;i<=3;i++){
        for (int j=1;j<=10;j++){
            cout << " " << a[4][i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  double ans = 0;
  REP(i,n){
    double x;
    string u;
    cin >> x >> u;
    if(u=="JPY"){
      ans += x;
    }else{
      ans += 380000*x;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int ans=1e9;
main(){
  string s;
  cin>>s;
  r(i,26){
    char x=i+'a';
    int p=0,t=0;
    r(j,s.size()){
      if(s[j]==x){
        t=max(p,t);
        p=0;
      }
      else p++;
      if(j==s.size()-1)t=max(t,p);
    }
    ans=min(t,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll, ll, ll, ll>T;
#define PI 3.14159265359
#define MOD 1000000007
int main(){
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  ll sum=0;  
  if(A>=K){cout<<K;}
  else{
  	K-=A;
    if(B>=K){cout<<A;}
    else{
    	K-=B;
      	cout<<A-K;
    }
  }  
}

Measured memory_bytes: 3636
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    long sum = 0;

    for(int i = 1;i<=N-1;i++){

    sum = sum + i;

    }

    System.out.println(sum);

  }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.141592653589793238462643383279502884197
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,h;
	cin>>n>>h;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	sort( a.begin(), a.end() );
	int ma = a[ a.size() - 1 ];
	sort( b.begin(), b.end() );
	reverse( b.begin(), b.end() );
	int cnt = 0;
	for(int i=0;i<n;i++){
		if( b[i] > ma && 0 < h ){
			cnt++;
			h -= b[i];
		}
	}
	if( h > 0 ){
		cnt += h/ma;
		if( h % ma != 0 )cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean result = false;
		int m = sc.nextInt();
		int n = sc.nextInt();
		int k = sc.nextInt();

		if (k == 0) {
			System.out.println("Yes");
			return;
		}

		for (int i = 0; i <= m; i++) {
			for (int j = 0; j <= n; j++) {
				int tmp = i * n + j * m - 2 * i * j;
				if (tmp == k) {
					System.out.println("Yes");
					return;
				}
			}
		}

		System.out.println("No");
	}
}

Measured memory_bytes: 23124
#include <iomanip>
#include <iostream>
#include <cmath>
#include <vector>
#include <complex>

using namespace std;
using ld = long double;

const ld PI = acos(-1);
const complex<ld> sixty = polar(1.L, PI / 3);

vector<complex<ld>> koch(complex<ld> s, complex<ld> t) {
    auto v = (t - s) / 3.L;
    return {s, s + v, s + v + v * sixty, t - v};
}

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

    vector<complex<ld>> points({complex<ld>(0, 0), complex<ld>(100, 0)});

    for(int i = 0; i < N; ++i) {
        vector<complex<ld>> npoints;
        for(int i = 0; i < points.size() - 1; ++i) {
            auto res = koch(points[i], points[i + 1]);
            copy(res.begin(), res.end(), back_inserter(npoints));
        }
        npoints.push_back(complex<ld>(100, 0));
        points = npoints;
    }

    for(const auto& p : points) {
        cout << fixed << setprecision(10) << p.real() << " " << p.imag() << endl;
    }
    return 0;
}



Measured memory_bytes: 3344
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<map>
#include<functional>
using namespace std;

const int MAX = 100;

int main() {
	int N;
	int A[2][MAX];

	cin >> N;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			int a;
			int m = 0;
			cin >> a;
			
			if (i != 0)m = max(m, A[i - 1][j]);
			if (j != 0)m = max(m, A[i][j - 1]);
			A[i][j] = a + m;
		}
	}

	cout << A[1][N - 1] << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    string s, t;
    cin >> t >> s;
    for(int j=t.size()-1; j>=0; --j) {
      if(t[j] == 'C') {
        string tmp;
        FOR(i, 1, s.size()) tmp += s[i];
        tmp += s[0];
        s = tmp;
      } else if(t[j] == 'J') {
        string tmp;
        tmp += s[s.size()-1];
        REP(i, s.size()-1) tmp += s[i];
        s = tmp;
      } else if(t[j] == 'E') {
        string tmp;
        FOR(i, s.size()/2 + !!(s.size()%2), s.size()) tmp += s[i];
        if(s.size()%2) tmp += s[s.size()/2];
        REP(i, s.size()/2) tmp += s[i];
        s = tmp;
      } else if(t[j] == 'A') {
        REP(i, s.size()/2) swap(s[i], s[s.size()-1-i]);
      } else if(t[j] == 'M') {
        REP(i, s.size()) {
          if('0' <= s[i] && s[i] <= '8') s[i]++;
          else if(s[i] == '9') s[i] = '0';
        }
      } else if(t[j] == 'P') {
        REP(i, s.size()) {
          if('1' <= s[i] && s[i] <= '9') s[i]--;
          else if(s[i] == '0') s[i] = '9';
        }
      }
      //cout << j << " " << t[j] << " " << s << endl;
    }
    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;cin>>n>>x;
  int a[n];for(int i=0;i<n;i++){cin>>a[i];}
  int cnt=0;
  sort(a,a+n);
  for(int i=0;i<n-1;i++){if(a[i]>x)break;else{x-=a[i];cnt++;}}
  cout<<(x-a[n-1]?cnt:cnt+1)<<endl;
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int ts;
num s, c1, c2, c3, c5;
map<num, num> d;

void inline upd(num &a, num b) {
	if (!a || a > b) a = b;
}

num f(num w) {
	num &cur = d[w];
	if (cur || !w)  return cur;
	num d1, d2, w1, w2;
	d1 = w % 2, d2 = 2 - d1, w1 = w - d1, w2 = w + d2;
	upd(cur, f(w1 / 2) + bool(w1) * c2 + d1 * c1);
	upd(cur, f(w2 / 2) + bool(w2) * c2 + d2 * c1);
	d1 = w % 3, d2 = 3 - d1, w1 = w - d1, w2 = w + d2;
	upd(cur, f(w1 / 3) + bool(w1) * c3 + d1 * c1);
	upd(cur, f(w2 / 3) + bool(w2) * c3 + d2 * c1);
	d1 = w % 5, d2 = 5 - d1, w1 = w - d1, w2 = w + d2;
	upd(cur, f(w1 / 5) + bool(w1) * c5 + d1 * c1);
	upd(cur, f(w2 / 5) + bool(w2) * c5 + d2 * c1);
	if (w <= 5e9) upd(cur, w * c1);
	return cur;
}

void solve() {
	scanf("%lld%lld%lld%lld%lld", &s, &c2, &c3, &c5, &c1);
	printf("%lld\n", f(s));
	d.clear();
}

int main() {
	scanf("%d", &ts);
	cont (cs, ts) {
		solve();
	}
}


Measured memory_bytes: 5064