akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <utility>

using namespace std;

int main() {

	int N, W;
	scanf("%d %d", &N, &W);
	int L[N + 1][W + 1];
	for (int i = 0; i <= W; ++i) {
		L[0][i] = 0;
	}
	for (int i = 0; i <= N; ++i) {
		L[i][0] = 0;
	}

	pair<int, int> items[N + 1];
	for (int i = 1; i <= N; ++i) {
		int v, w;
		scanf("%d %d", &v, &w);
		items[i] = make_pair(v, w);
	}

	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (items[i].second <= j) {
				L[i][j] = max(L[i - 1][j], L[i - 1][j - items[i].second] + items[i].first);
			} else {
				L[i][j] = L[i - 1][j];
			}
		}
	}

	cout << L[N][W] << endl;

	return 0;
}

Measured memory_bytes: 7184
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <cstring>
#include <algorithm>
#include <numeric>
#define maxn 1000000

using namespace std;

int paint[110][110];
int main()
{
    int h,w,n,x=0;
    cin>>h>>w>>n;
    int a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        for(int j=0; j<a[i]; j++)
        {
            if((x/w)%2==0) paint[x/w][x%w]=i+1;
            else paint[x/w][w-(x%w)-1]=i+1;
            x++;
        }
    }
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            if(j==w-1) printf("%d\n",paint[i][j]);
            else printf("%d ",paint[i][j]);
        }
    }
    return 0;
}


Measured memory_bytes: 384
import sys,collections
n = int(sys.stdin.readline())
a = list(map(int,sys.stdin.readline().split()))
q = int(sys.stdin.readline())
m = list(map(int,sys.stdin.readline().split()))
def isOK(rest,i):
  if rest == 0:
    return True
  if i == n or rest < 0:
    return False
  if sum(a[i:]) < rest:
    return False
  if isOK(rest-a[i],i+1):
    return True
  return isOK(rest,i+1)
for mi in m:
  if isOK(mi,0):
    print("yes")
  else:
    print("no")



Measured memory_bytes: 6032
import bisect

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
#print(A)

# Aの累積和を求めておく。
csum = [A[0] for _ in range(N+1)]
for i in range(1,N):
  csum[i] = csum[i-1]+A[i]

# M回以上握手できるとなる最小の幸福度を求める。
# r:M回以上握手ができる最小の幸福度。
# l:M回以上握手が出来ない最大の幸福度。
l = 0
r = 10**6
while (l+1 < r):
  m = (l+r)//2
  p = 0 # 幸福度がm以上になる握手の回数
  for a in A:
    q = bisect.bisect_left(A,m-a)
    #print(q,m-a,A)
    p += N-q
  #print(l,m,r,p)
  if p >= M:
    l = m
  else:
    r = m
#print(l,m,r)

# 幸福度がlのときに握手ができる回数を求め、
# それとMとの差

ans = 0
cnt = 0
for a in A:
  q = bisect.bisect_right(A,l-a)
  if q == 0:
    ans += csum[N-1]+a*N
    cnt += N
  elif q < N:
    ans += csum[N-1]-csum[q-1]+a*(N-q)
    cnt += N-q
  #print(a,q,ans,cnt)
ans +=l*(M-cnt)
print(ans)


Measured memory_bytes: 59028
s = input()
a, b, c, d = int(s[0]), int(s[1]), int(s[2]), int(s[3])

if a+b+c+d == 7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"=7")
elif a+b-c+d == 7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"+"+s[3]+"=7")
elif a+b+c-d == 7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"-"+s[3]+"=7")
elif a+b-c-d == 7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]+"=7")
elif a-b+c+d == 7:
    print(s[0]+"-"+s[1]+"+"+s[2]+"+"+s[3]+"=7")
elif a-b-c+d == 7:
    print(s[0]+"-"+s[1]+"-"+s[2]+"+"+s[3]+"=7")
elif a-b+c-d == 7:
    print(s[0]+"-"+s[1]+"+"+s[2]+"-"+s[3]+"=7")
elif a-b-c-d == 7:
    print(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3]+"=7")


Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int count = 0;
		
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		Arrays.sort(A);
		
		for(int j = 0; j < N - 1; j++){
			if (A[j] == A[j+1]){
				count = 1;
			}
		}
		
		if(count == 0){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 64620
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#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 <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n, h, d;
    cin >> n >> h >> d;

    long long tmp = 1;
    long long sum = 0;
    for(int i=1; i<=n; ++i){
        tmp *= i;
        tmp %= MOD;
        sum += tmp;
        sum %= MOD;
    }

    vector<long long> dp(h+1, 0);
    for(int i=1; i<=d; ++i)
        dp[i] = tmp;
    long long x = 0;
    for(int i=2; i<=h; ++i){
        x += dp[i-1];
        if(i-1-d >= 0)
            x -= dp[i-1-d] - MOD;
        x %= MOD;
        dp[i] += x * sum;
        dp[i] %= MOD;
    }
    cout << dp[h] << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 575;

int T;
ll A[MAX_N], B[MAX_N], C[MAX_N], D[MAX_N];

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

bool solve(ll tmp, int i)
{
  // ll divisor = D[i] % B[i];
  // debug(divisor);
  // ll j = - tmp;
  ll gcdNum = getGcd(B[i], D[i]);
  ll res = B[i] - gcdNum + A[i] % gcdNum;
  // debug(j);
  /*
  if (divisor == 0) {
    return true;
  } else {
    if (j >= C[i]) res = j;
    else {
      res = j;
      while(res <= C[i])
	res += max((C[i] - res) / divisor, 1ll) * divisor ;
    }
    //if (res <= C[i]);
  }
  // debug(res);
  */
  return (res <= C[i]);  
  
}

int main()
{

  cin >> T;
  REP(i, T) {
    cin >> A[i] >> B[i] >> C[i] >> D[i];
  }

  REP(i, T) {
    if (A[i] < B[i]) {
      OK(false);
      continue;
    }
    // cout << A[i] << "," <<  B[i] << ","  << C[i] << "," << D[i] << endl;
    if (B[i] > D[i]) {
      OK(false);
      continue;
    }
    if (C[i] >= B[i]) {
      OK(true);
      continue;
    }
    // debug(tmp);
    OK(solve(A[i], i));
  }

  return 0;
}



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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong A, B, C;

	cin >> A >> B >> C;
	if(A == B && B == C && A&1^1)
		cout << -1 << endl;
	else{
		int i;
		for(i = 0;; i++){
			if(A&1 || B&1 || C&1)
				break;
			llong a,b,c;
			a = (B+C)/2;
			b = (A+C)/2;
			c = (A+B)/2;
			A = a, B = b, C = c;
		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	c-=a-b;
	if(c<0)c=0;
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000;
typedef int64_t ll;
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	int N;
	cin >> N;
	vector<int> B(N - 1);
	rep(i, N - 1) {
		cin >> B.at(i);
	}

	int ans = B.at(0);
	
	for (int i = 0; i < N-2; i++)
	{
		if (B.at(i)<B.at(i+1))
		{
			ans += B.at(i);
		}
		else {
			ans += B.at(i + 1);
		}
	}
	ans += B.at(N -2);
	cout << ans << endl;
}

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

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

int main() {
	long long int n, t, x, a, b, c, d, ans = 0, r[200010] = { 0 };
	char s[1000],T[1000];
	scanf("%lld%lld%lld%lld", &a,&b,&c,&d);
	//scanf("%s", T);
	//for (int i = 0; i + strlen(T) <= strlen(s); i++) {
		//int re = 0;
		///for (int j = 0; j < strlen(T); j++) if (s[i + j] != T[j])re++;
		//if (re < ans)ans = re;
	//}
	ans = a * c;
	n = a * d;
	t = b * c;
	x = b * d;
	if (ans < n)ans = n;
	if (ans < t)ans = t;
	if (ans < x)ans = x;
	printf("%lld",ans);
	return 0;
}

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

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

  vector<int> dp(W + 1, 0);
  for (int i = 0; i < N; i++) {
    int v, w;
    cin >> v >> w;

    for (int j = w; j <= W; j++) {
      dp[j] = max(dp[j], dp[j - w] + v);
    }
  }

  cout << dp[W] << endl;
}



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

using namespace std;

using cnts_t = std::array<int64_t, 5>;

int64_t calc(const cnts_t& cs) {
  if (!cs[2]) {
    return 0;
  }
  int csSize;
  if (!cs[3]) {
    csSize = 3;
  } else if (!cs[4]) {
    csSize = 4;
  } else {
    csSize = 5;
  }
  int64_t ret = 0;
  for (int i = 0; i < csSize; i++) {
    for (int j = i + 1; j < csSize; j++) {
      for (int k = j + 1; k < csSize; k++) {
        ret += cs[i] * cs[j] * cs[k];
      }
    }
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::string s;
  cnts_t cs{};
  for (int i = 0; i < n; ++i) {
    std::cin >> s;
    switch (s[0]) {
      case 'M':
        cs[0]++;
        break;
      case 'A':
        cs[1]++;
        break;
      case 'R':
        cs[2]++;
        break;
      case 'C':
        cs[3]++;
        break;
      case 'H':
        cs[4]++;
        break;
    }
  }
  std::sort(cs.rbegin(), cs.rend());
  std::cout << calc(cs) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

ll dp[3000][3000];
string s;
int n;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n;
	cin >> s;
	if (s[0] == '>') {
		dp[0][0] = 1;
	} else {
		dp[0][1] = 1;
	}
	for (int i = 1; i < n - 1; i++) {
		if (s[i] == '>') {
			for (int j = i; j >= 0; j--) {
				dp[i][j] += dp[i - 1][j];
				dp[i][j] %= MOD;
			}
			for (int j = i - 1; j >= 0; j--) {
				dp[i][j] += dp[i][j + 1];
				dp[i][j] %= MOD;
			}
		} else {
			for (int j = 1; j <= i + 1; j++) {
				dp[i][j] += dp[i - 1][j - 1];
				dp[i][j] %= MOD;
			}
			for (int j = 2; j <= i + 1; j++) {
				dp[i][j] += dp[i][j - 1];
				dp[i][j] %= MOD;
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		ans += dp[n - 2][i];
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 68864
def c():
    N = int(input())
    A = list(map(int, input().split()))

    numBuka = [0] * N
    for i in reversed(range(N-1)):
        numBuka[A[i] - 1] += 1

    for i in range(N):
        print(numBuka[i])


##########
if __name__ == "__main__":
    c()


Measured memory_bytes: 32380
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
int a,b;cin >> a >> b;
if(a>=2*b)cout << a-2*b << endl;
else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

int N, M;
std::vector<int> G[200001];
bool used[200001];

void dfs( int v )
{
  used[v] = true;

  rep( i, G[v].size() ) if( !used[G[v][i]] )
    dfs( G[v][i] );

  return;
}

int main()
{
  scanf( "%d%d", &N, &M );
  rep( i, N )
  {
    int K;
    scanf( "%d", &K );

    rep( j, K )
    {
      int L;
      scanf( "%d", &L );
      --L;
      G[i].push_back( L+N );
      G[L+N].push_back( i );
    }
  }

  dfs( 0 );

  bool fl = true;

  rep( i, N )
    fl &= used[i];

  puts( fl ? "YES" : "NO" );

  return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,e) for(int i = a;i < e;++i)
using LL = long long;

int main() {

	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		a[i]--;
	}
	vector<int> b(N);
	for (int i = 0; i < N; ++i) {
		cin >> b[i];
	}
	vector<int> c(N);
	for (int i = 0; i < N - 1; ++i) {
		cin >> c[i];
	}
	int ans = 0;
	FOR(i, 0, N)ans += b[a[i]];
	FOR(i, 0, N - 1) {
		if (a[i] + 1 == a[i + 1]) {
			ans += c[a[i]];
		}
	}

	cout << ans << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		long count = 0;
		count = (x / 11) * 2;
		long m = x % 11;
		if (m == 0) {
			System.out.println(count);
			return;
		}
		count += (m < 7) ? 1 : 2;
		System.out.println(count);
	}

}


Measured memory_bytes: 35764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <queue>
using namespace std;

int main(){
    bool end = false ;
    int w,h ;
    cin >> w >> h ;
    if (w == 0 && h == 0)
    {
        end = true ;
    }
    
    //外側が全て壁になるように、元の迷路より2マス大きく取る（エラー回避）
    
    while (end == 0)
    {
    vector<vector<int> > a(h+2,vector<int>(w+2,-2)) ;
    pair<int,int> start ;
        for (size_t i = 1; i < h+1; i++)
        {
            for (size_t j = 1; j < w+1; j++)
            {
                char status ;
                cin >> status ;
                if (status == '.')
                {
                    a.at(i).at(j) = -1 ;
                }else if (status == '@')
                {
                    a.at(i).at(j) = 0 ;
                    start.first = i ;
                    start.second = j ;
                }else if (status == '#')
                {
                    a.at(i).at(j) = -2 ;
                }
                
                
                
            }
            
        }
        
        queue<pair<int,int> > wait ;
        int del[4][2] = {
            {1,0},
            {0,1},
            {-1,0},
            {0,-1}
        };
        wait.push(start) ;
        pair<int,int> now ;
        int ans = 0 ;
        while (wait.empty() == 0)
        {
            now = wait.front() ;
            wait.pop() ;
            ans ++;
            for (size_t i = 0; i < 4; i++)
            {
                int look1 = now.first + del[i][0] ;
                int look2 = now.second + del[i][1] ;
                pair <int,int> look = make_pair(look1,look2) ;
                if (a.at(look.first).at(look.second) == -1)
                {
                    a.at(look.first).at(look.second) = 0 ;
                    wait.push(look) ;

                }
                
            }
            
        }
        
        cout << ans << endl ;

        cin >> w >> h ;
        if (w == 0 && h == 0)
        {
            end = true ;
        }
        
    }
    
}



Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<functional>
#include<set>
#include<unordered_map>
using namespace std;

int b[2000005];
signed main(){
	int a; scanf("%d", &a);
	for (int c = 0; c < a; c++) {
		scanf("%d", &b[c]);
	}
	sort(b, b + a);
	for (int i = 0; i < a; i++) {
		if (i)cout << " ";
		cout << b[i];
	}
	puts("");
}

Measured memory_bytes: 10936
#include <stdio.h>
#include <string.h>
int main(){
	int a, b, c, d, s=0;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if(d >= a) s += a, d -= a;
	else s += d, d -= d;
	if(d >= b) s += 0, d -= b;
	else s += 0, d -= d;
	if(d >= c) s -= c, d -= c;
	else s -= d, d -= d;
	printf("%d\n", s);
	return 0;
}

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

// https://ei1333.github.io/luzhiled/snippets/graph/dinic.html
template <typename flow_t>
struct Dinic {
    const flow_t INF;

    struct edge {
        int to;
        flow_t cap;
        int rev;
        bool isrev;
        int idx;
    };

    vector<vector<edge>> graph;
    vector<int> min_cost, iter;

    Dinic(int V) : INF(numeric_limits<flow_t>::max()), graph(V) {}

    void add_edge(int from, int to, flow_t cap, int idx = -1) {
        graph[from].emplace_back((edge){to, cap, (int)graph[to].size(), false, idx});
        graph[to].emplace_back((edge){from, 0, (int)graph[from].size() - 1, true, idx});
    }

    bool bfs(int s, int t) {
        min_cost.assign(graph.size(), -1);
        queue<int> que;
        min_cost[s] = 0;
        que.push(s);
        while (!que.empty() && min_cost[t] == -1) {
            int p = que.front();
            que.pop();
            for (auto &e : graph[p]) {
                if (e.cap > 0 && min_cost[e.to] == -1) {
                    min_cost[e.to] = min_cost[p] + 1;
                    que.push(e.to);
                }
            }
        }
        return min_cost[t] != -1;
    }

    flow_t dfs(int idx, const int t, flow_t flow) {
        if (idx == t) return flow;
        for (int &i = iter[idx]; i < graph[idx].size(); i++) {
            edge &e = graph[idx][i];
            if (e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
                flow_t d = dfs(e.to, t, min(flow, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    flow_t max_flow(int s, int t) {
        flow_t flow = 0;
        while (bfs(s, t)) {
            iter.assign(graph.size(), 0);
            flow_t f = 0;
            while ((f = dfs(s, t, INF)) > 0) flow += f;
        }
        return flow;
    }

    void output() {
        for (int i = 0; i < graph.size(); i++) {
            for (auto &e : graph[i]) {
                if (e.isrev) continue;
                auto &rev_e = graph[e.to][e.rev];
                cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap
                     << ")" << endl;
            }
        }
    }
};

int n;

int main() {
    cin >> n;
    vector<pair<int, int>> red(n), blue(n);
    for (int i = 0; i < n; i++) {
        cin >> red[i].first >> red[i].second;
    }
    for (int i = 0; i < n; i++) {
        cin >> blue[i].first >> blue[i].second;
    }
    Dinic<int> d(2 * n + 2);
    for (int i = 1; i <= n; i++) {
        d.add_edge(0, i, 1);
    }
    for (int i = n + 1; i <= 2 * n; i++) {
        d.add_edge(i, 2 * n + 1, 1);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (red[i].first < blue[j].first && red[i].second < blue[j].second) {
                d.add_edge(i + 1, j + n + 1, 1);
            }
        }
    }
    cout << d.max_flow(0, 2 * n + 1) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  rep(i,N)
  {
    cin >> l[i];
  }
  sort(RALL(l));
  int sum = 0;
  for(int i=0;i<K;i++)
  {
    sum += l[i];
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

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

    vector<int> vt(n, 0);
    for (int i = 1; i < n; ++i) {
        int x;
        cin >> x;
        vt[x - 1]++;
    }

    for (auto x:vt) cout << x << endl;
    return 0;
}


Measured memory_bytes: 4060
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int t=0,w=0;
	a[0]=-111;
	for(int i=1;i<=n;i++)
	{
		if(i==a[i])
			t++;
		if( w+1<i &&a[i-1]==i-1 &&a[i]==i )
		{
			w=i;
			t--;
		}
	}	
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 640
#計算方法の定義
def minkowski(p, X, Y):
    s = 0
    for x, y in zip(X, Y):
        s += abs(x - y)**p
    return s**(1/p)
def chebyshev(X, Y):
    return max(abs(x - y) for x, y in zip(X, Y))

#入力dataの格納
N = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

#計算結果の表示
print(f"{minkowski(1, X, Y):.8f}")
print(f"{minkowski(2, X, Y):.8f}")
print(f"{minkowski(3, X, Y):.8f}")
print(f"{chebyshev(X, Y):.8f}")



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

int main(){
    ll ans = 0;
    string s;
    cin >> s;
    for(auto p : s){
        if(p == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

void solve();

void solve(int A, int P) { cout << (A * 3 + P) / 2 << endl; }

int main() {
  int A, P;
  cin >> A >> P;
  solve(A, P);
  return 0;
}


Measured memory_bytes: 888
def solve():
    N = int(input())
    a = [0 for i in range(N)]
    for i in range(N):
        a[i] = int(input())
    on_light = 1
    cnt = 0
    for i in range(N):
        on_light = a[on_light-1]
        cnt += 1
        if on_light == 2:
            print(cnt)
            return
    print(-1)
    return
    
    
solve()

Measured memory_bytes: 7080
import sys
import math
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    allSum = n * (n + 1) // 2
    threeNum = math.floor(n / 3)
    threeSum = 3 * threeNum * (threeNum + 1) // 2
    fiveNum = math.floor(n / 5)
    fiveSum = 5 * fiveNum * (fiveNum + 1) // 2
    bothNum = math.floor(n / 15)
    bothSum = 15 * bothNum * (bothNum + 1) // 2
    print(allSum + bothSum - threeSum - fiveSum)


if __name__ == '__main__':
    main()


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

#define int long long

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<bool> dp(k + 1);
    for (int i = 1; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            if (a[j] <= i && !dp[i - a[j]]) {
                dp[i] = true;
                break;
            }
        }
    }
    cout << (dp[k] ? "First" : "Second") << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset> 
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
 
template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod 
	ll ans=1;
	while(n){
		if(n&1) ans=(ans*a)%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
string str;


int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	clock_t c1 = clock();
	//===========================================================
    cin>>str;
    rep(i,0,str.length()-1){
        if(i%2==0){
            if(str[i]!='h'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else{
            if(str[i]!='i'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    if(str.length()%2!=0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
	//===========================================================
	std::cerr << "Time:" << clock() - c1 << "ms" << std::endl;
	return 0;
}

Measured memory_bytes: 632
#include <stdio.h>
#define MAX 500001
int H;
int A[MAX];

void maxHeapify(int);
void swap(int, int);

int main(){
  int i;

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

  for(i = H/2; i >= 1; i--) maxHeapify(i);

  for(i = 1; i <= H; i++){
    printf(" %d",A[i]);
  }

  printf("\n");

  return 0;
}

void maxHeapify(int i){
  int l,r,largest;

  l = 2*i;
  r = (2*i)+1;
  if(l <= H && A[l] > A[i]) largest = l;
  else largest =  i;
  if(r <= H && A[r] > A[largest]) largest = r;
  if(largest != i){
    swap(i,largest);
    maxHeapify(largest);
  }
}

void swap(int i, int largest){
  int k;

  k = A[i];
  A[i] = A[largest];
  A[largest] = k;
}
  



Measured memory_bytes: 3668
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int memo[4040][4040] = {};
int main(void){
	string s, t;
	while(cin >> s && s.size()){
		int res = 0;
		cin >> t;
		memset(memo, 0, sizeof memo);
		REP(i, s.size()){
			REP(j, t.size()){
				if(memo[i][j] != 0) continue;
				int cnt = 0;
				if(s[i] == t[j]){
					cnt++;
					memo[i][j] = cnt;
					while(s[i+cnt] == t[j+cnt] && i+cnt < s.size() && j+cnt < t.size()){
						cnt++;
						memo[i+cnt][j+cnt] = cnt;
					}
					res = max(res, cnt);
				}
			}
		}
		cout << res << endl;
	}
}

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;cin >> n;
    vector<int> c(n-1);
    vector<int> s(n-1);
    vector<int> f(n-1);
    REP(i,n-1){
        cin >> c[i] >> s[i] >> f[i]; 
    }
    REP(i,n){
        ll ans = 0;
        FOR(j,i,n-1){
            if(ans<s[j])ans=s[j];
            if((ans-s[j])%f[j]!=0){
                ans += f[j]-(ans-s[j])%f[j];
            }
            ans += c[j];
        }
        COUT(ans);
    }
    return 0;
}

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


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a;
    cin >> n >> a;
    cout << (n % 500 <= a ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


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

	int a[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i]; 
	}
	int min_v = 1000000000;

	for (int p = 1 ; p <= 100; p++) {
		int cur = 0;
		for (int i = 0; i < n; i++) {
			cur += (a[i] - p) * (a[i] - p);
		}
		min_v = min(min_v, cur);
	} 
	cout << min_v << endl;
	
	return 0;
}

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

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var list = Console.ReadLine().Split(' ').Select(x => long.Parse(x));
            Console.WriteLine($"{list.Min()} {list.Max()} {list.Sum()}");
        }
    }
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    string s;
    while(cin >> s, s[0] != '#') {
        int ans = INF;
        bool left = true;
        rep(j, 2) {
            int cnt = 0, l = -1, r = 3;
            rep(i, s.size()) {
                int step = (s[i] - '1') % 3;
                if (left) {
                    if (step < l) {
                        cnt++;
                        l = step;
                    } else {
                        r = step;
                        left = false;
                    }
                } else {
                    if (r < step) {
                        cnt++;
                        r = step;
                    } else {
                        l = step;
                        left = true;
                    }
                }
            }
            minch(ans, cnt);
            left = false;
        }

        cout << ans << endl;
    }

    return 0;
}

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

bool global_flag;

void solve(string hai, bool head) {
  if (global_flag) return;
  if (hai.empty()) {
    global_flag = true;
    return;
  }
  char c = hai[0];
  bool flag = true;
  string line0 = hai, line1 = hai, line2 = hai;
  // q
  for (int i = 0; i < 3; i += 1) {
    int idx = line0.find(c+i);
    if (idx == -1) {
      flag = false;
      break;
    }
    line0.erase(idx, 1);
  }
  if (flag) solve(line0, head);

  // q
  flag = true;
  for (int i = 0; i < 3; i += 1) {
    int idx = line1.find(c);
    if (idx == -1) {
      flag = false;
      break;
    }
    line1.erase(idx, 1);
  }
  if (flag) solve(line1, head);
  
  // ª
  if (!head) {
    flag = true;
    for (int i = 0; i < 2; i += 1) {
      int idx = line2.find(c);
      if (idx == -1) {
        flag = false;
        break;
      }
      line2.erase(idx, 1);
    }
    if (flag) solve(line2, true);
  }
}

int main(int argc, char const* argv[]) {
  string line;
  while (cin>>line) {
    bool printed = false;
    for (char c = '1'; c <= '9'; c += 1) {
      global_flag = false;
      string cline = line + c;
      if (count(cline.begin(), cline.end(), c) > 4) {
        continue;
      }
      
      sort(cline.begin(), cline.end());
      solve(cline, false);
      if (global_flag) {
        if (!printed) {
          printed = true;
          cout<<c;
        } else {
          cout<<" "<<c;
        }
      }
    }
    if (!printed) cout<<0;
    cout<<endl;
  }  
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int gcd1(int a,int b){
	while(a != b){
		if(a>b)
			a = a - b;
		else
			b = b - a;
	}
	return a;
}

int gcd2(int a,int b){
	int w;
	while(b != 0){
		w = a % b;
		a = b; b = w;
	}
	return a;
}

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

int main(void){
	int a,b;
	while(cin >> a >> b){
		cout << gcd2(a,b) << " " <<lcm(a,b) << "\n";//最大公約数
	}
	return 0;
}

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

int main() {
	int a,b;
	string op;
	while(1){
	cin >> a >> op >> b;
	if(op == "+"){
		cout << a+b << endl;
	}
	else if(op == "-"){
		cout << a-b << endl;
	}
	else if(op == "*"){
		cout << a*b << endl;
	}
	else if(op == "/"){
		cout << a/b << endl;
	}
	if(op == "?"){
		break;
	}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vi a(m);
  REP(i,m)cin>>a[i];
  int lval = 0, rval = 0;
  REP(i,m)(a[i]<x ? lval : rval)+=1;
  cout<<min(lval,rval)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  map<ll,ll> mp;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
    mp[A[i]]++;
  }
  map<ll,ll> sum;
  ll ans = 0;
  for(auto m:mp){
    sum[m.first] = m.second*(m.second-1)/2;
    ans += m.second*(m.second-1)/2;
  }
  for(int i=0; i<N; i++){
    ll temp = ans;
    temp -= sum[A[i]];
    temp += (mp[A[i]]-2)*(mp[A[i]]-1)/2;
    cout << temp << endl;
  }
  return 0;
}


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

void Print(char S[], int x, int y)
{
    for(int i = x; i <= y; ++i)
    {
        printf("%c", S[i]);
    }
    printf("\n");
}

void Reverse(char S[], int x, int y)
{
    char t;
    int i = x;
    int j = y;

    while (i <= (x+y)/2)
    {
        t = S[i];
        S[i] = S[j];
        S[j] = t;
        i++;
        j--;
    }
}

void Replace(char S[], char P[], int x, int y)
{
    int i = x, j = 0;

    while(i <= y)
    {
        S[i++] = P[j++];
    }
}

int main()
{
    char str[1000], op[100], p[1000];
    int q, i = 0, a, b;

    scanf("%s", &str);
    scanf("%d", &q);

    while(i < q)
    {
        scanf("%s", op);
        scanf("%d %d", &a, &b);
        if(strcmp(op, "print") == 0)
        {
            Print(str, a, b);
        }
        else if(strcmp(op, "reverse") == 0)
        {
            Reverse(str, a, b);
        }
        else if(strcmp(op, "replace") == 0)
        {
              scanf("%s", p);
              Replace(str, p, a, b);
        }
        i++;
    }
    return 0;
}



Measured memory_bytes: 2692
from __future__ import print_function
import sys


if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    for i in range(len(x)):
        if x[i] == 0:
            print(i+1)
            return
    print(-1)
    return





x = RA()
solve()


Measured memory_bytes: 64960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    if(a<b && b<c){
        cout<<"Yes"<<endl;
        return 0;
    }
    while(k--){
        if(a>=b) b*=2;
        else if(b>=c) c*=2;

        if(a<b && b<c){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;
}



Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(void) {
  int i, j, diff;
  int N, L, min_taste, taste, tmp_taste;
  cin >> N;
  cin >> L;
  // 作る予定のパイの味
  taste = 0;
  for(i = 1; i <= N; i++) {
    taste += L + i - 1;
  }
  // ゴリ押し
  diff = 1000000;
  for(i = 1; i <= N; i++) {
    tmp_taste = 0;
    for(j = 1; j <= N; j++) {
      if(i != j) {
        tmp_taste += L + j - 1;
      }
    }
    if(abs(tmp_taste - taste) < diff) {
      diff = abs(tmp_taste - taste);
      min_taste = tmp_taste;
    }
  }

  cout << min_taste << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;


int K,T;
int a[110];
int ans;
int main(){
	cin>>K>>T;
	int zen=-1;
	int to =-1;
	REP(i,0,T) cin>>a[i];
	REP(i,0,K) {
		int mx=0;
		to=zen;
		REP(j,0,T){
			if(zen==j) continue;
			if(mx<a[j]){
				mx=a[j];
				to=j;
			}
		}
		if(zen==to) ans++;
		a[to]--;
		zen=to;
	}
	p(ans);
	return 0;
}


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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, ans;
    cin >> n;
    ans = (n * (n + 1)) / 2 - ((n / 3) * (3 + (n / 3) * 3)) / 2 - ((n / 5) * (5 + (n / 5) * 5)) / 2 +
          ((n / 15) * (15 + (n / 15) * 15)) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
typedef long long ll;
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll m,d;
  cin >> m >> d;
  ll d0,d1;
  ll sum = 0;
  REP(i,1,m+1){
    REP(j,1,d+1){
      d0 = j % 10;
      d1 = j / 10;
      if(d0 >= 2 && d1 >= 2 && d0*d1==i){
        sum++;
      }
    }
  }
  cout << sum;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
 
using namespace std;

 ll mod=998244353;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

// ll n;
// vector<ll> tree[200005];
// ll a[200005]={0};
// ll ans;

// void func(ll node,ll target,vector<ll>&mpp,vector<ll>&vis)
// {
// 	vis[node]=1;
// 	mpp[a[node]]++;
// 	if(node==target)
// 	{
// 		for(ll i=1;i<=100;i++)
// 		{
// 			if(mpp[i]==0) continue;
// 			ll j=i+1;
// 			if(mpp[i]>1) ans=0;
// 			while(j<=100 && mpp[j]<1) j++;
// 			ans=min(ans,j-i);

// 		}
// 		return ;
// 	}
// 	for(auto x:tree[node])
// 	{
// 		if(!vis[x])
// 		{
// 			func(x,target,mpp,vis);
// 			mpp[a[x]]--;
// 			// if(mpp[a[x]]==0) mpp.erase(a[x]);
// 		}
// 	}
// }

int main()
{
    
    // #ifndef ONLINE_JUDGE
    //     freopen ("data.in","r",stdin);
    //     freopen ("E.out","w",stdout);
    // #endif
    cin.sync_with_stdio( false );
    int tests=1;
    // cin>>tests;
    while(tests--)
    {
   		ll ans,a;
   		string b;
   		cin>>a>>b;
   		string temp1,temp2;
   		ll turn=0;
   		for(auto x:b)
   		{
   			if(x=='.')
   			{
   				turn=1;
   				continue;
   			}
   			if(turn ==0)
   				temp1.pb(x);
   			else temp2.pb(x);
   		}
   		ans=(ll)stoi(temp1) *a;
   		ans+=((ll)stoi(temp2) *a)/100LL;
   		cout<<ans;


   	}
    	return 0;
    
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a;
    for (int i = 0; i < h; i++) {
        a.push_back(vector<int>(w));
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    vector<vector<int>> list;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w - 1; j++) {
            if (a[i][j] % 2 != 0) {
                a[i][j+1]++;
                ans++;
                vector<int> l(4);
                l[0] = i+1;
                l[1] = j+1;
                l[2] = i+1;
                l[3] = j+2;
                list.push_back(l);
            }
        }
    }
    for (int i = 0; i < h - 1; i++) {
        if (a[i][w-1] % 2 != 0) {
            a[i+1][w-1]++;
            ans++;
            vector<int> l(4);
            l[0] = i+1;
            l[1] = w;
            l[2] = i+2;
            l[3] = w;
            list.push_back(l);
        }
    }
    cout << ans << endl;
    for (int i = 0; i < list.size(); i++) {
        cout << list[i][0] << " "
             << list[i][1] << " "
             << list[i][2] << " "
             << list[i][3] << endl;
    }
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] mtHight = new int[10];
        for (int i = 0; i < 10; i++){
            mtHight[i] = sc.nextInt();
        }
        Arrays.sort(mtHight);
        System.out.println(mtHight[9]);
        System.out.println(mtHight[8]);
        System.out.println(mtHight[7]);
    }
}



Measured memory_bytes: 26152
n = int(input())

a = []
b = []
for i in range(n):
    a_num, b_num = map(int, input().split())
    a.append(a_num)
    b.append(b_num)
    
cnt = 0
for i in reversed(range(n)):
    a[i] += cnt
    
    if (a[i]) % b[i] == 0:
        continue
    
    r = a[i] // b[i] + 1
    cnt += r * b[i] - a[i]
    
print(cnt)

Measured memory_bytes: 15020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    long n = Integer.parseInt(sl[0]);

    s = r.readLine();
    int a[] = new int[4000];
    long z[] = new long[3];
    for(int i = 0; i < n; i++)
    {
      char c = s.charAt(i);
      int t = c == 'R' ? 0 : (c == 'G' ? 1 : 2);
      a[i] = t;
      z[t]++;
    }

    long v = z[0] * z[1] * z[2];

    for(int d = 1; d <= 1999; d++)
    {
      for(int i = 0; i + 2 * d < n; i++)
      {
        if(a[i] != a[i + d] && a[i + d] != a[i + 2 * d] && a[i + 2 * d] != a[i])
        {
          v--;
        }
      }
    }



    System.out.println(v);
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}


Measured memory_bytes: 34716
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N ;
  vector<int> A(N), ans(N);
  for(int i=0; i<N; i++) cin >> A[i];
  
  iota(ans.begin(), ans.end(), 0);
  sort(ans.begin(), ans.end(), [&](int i, int j){return A[i] < A[j];});
  for(auto i: ans)
    cout << i+1 << " ";
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1664
A, B, C, K = map(int, input().split())

cnt = K
sum_ = 0
if K <= A:
    print(K)
    exit()
else:
    sum_ += A
    cnt -= A

if cnt <= B:
    print(sum_)
    exit()
else:
    cnt -= B

print(sum_ - min(cnt, C))



Measured memory_bytes: 9180
#include <stdio.h>

#define MAX_N 1000000
#define MAX_Q 50000

int binary_search2(int* s, int n, int x) {
  int left = 0;
  int right = n;

  while(left < right) {
    int mid = (left + right) / 2;

    if(s[mid] == x) {
      return mid;
    } else if(s[mid] > x) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return -1;
}

int binary_search(int* s, int n, int x) {
  int max = n-1;
  int min = 0;

  int avg = 0;
  int avg_ = -1;
  while(avg != avg_) {
    avg_ = avg;
    avg = (max+min)/2;

    if(s[avg] > x) {
      max = avg;
    } else if(s[avg] < x) {
      min = avg;
    } else {
      return avg;
    }
  }

  if(s[avg+1] == x) {
    return avg+1;
  }
  return -1;
}

int main() {
  int n, q;
  int s[MAX_N], t[MAX_Q];
  scanf("%d", &n);
  for(int i=0; i<n; i++) {
    scanf("%d", &s[i]);
  }

  scanf("%d", &q);
  for(int i=0; i<q; i++) {
    scanf("%d", &t[i]);
  }

  int cnt = 0;
  for(int i=0; i<q; i++) {
    if (binary_search2(s, n, t[i]) != -1)
      cnt++;
  }

  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 3164