akhauriyash/Code-Regression huggingface dataset:
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    public void solve() {
    	int N = ni();
    	int[] P = ndi(N);
    	int ans = 0, min = P[0];
    	for (int i = 0; i < N; i++) {
			if(P[i] <= min) {
				ans++;
				min = P[i];
			}
		}
    	out.println(ans);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 79584
# 深さ優先探索（行きがけ、帰りがけ）
import sys
input = sys.stdin.readline
from collections import deque

# グラフの作成(無向グラフでは#を消す)
N = int(input())
graph = [deque([]) for _ in range(N + 1)]
for _ in range(N):
    u, k, * v = [int(x) for x in input().split()] # uは頂点番号、kは隣接頂点の個数
    v.sort()
    for i in v:
        graph[u].append(i)
        # graph[i].append(u) # 無向グラフ

time = 0
arrive_time = [-1] * (N + 1) # 到着時刻
finish_time = [-1] * (N + 1) # 探索終了時刻

# 深さ優先探索
def dfs(v):
    global time
    time += 1
    stack = [v]
    arrive_time[v] = time
    while stack:
        v = stack[-1]
        if graph[v]:
            w = graph[v].popleft()
            if arrive_time[w] < 0:
                time += 1
                arrive_time[w] = time
                stack.append(w) 
        else:
            time += 1
            finish_time[v] = time
            stack.pop()          
    return [arrive_time, finish_time]

# 孤立している頂点対策
for i in range(N):
    if arrive_time[i + 1] < 0:
        ans = dfs(i + 1)

# 頂点番号、到着時刻、終了時刻
for j in range(N):
    temp = [j + 1, ans[0][j + 1], ans[1][j + 1]]
    print(* temp)



Measured memory_bytes: 6084
n,h = map(int,input().split())
al=[]
bl=[]
for _ in [0]*n:
  a,b = map(int,input().split())
  al.append(a)
  bl.append(b)
al.sort()
bl.sort()
ans = 0
while h>0:
  if len(bl)>0 and bl[-1]>al[-1]:
    h-=bl[-1]
    ans+=1
    del bl[-1]
  else:
    ans += -(-h//al[-1])
    h=0
print(ans)

Measured memory_bytes: 11788
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; j < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int inputs[5];
  cin >> inputs[0];
  cin >> inputs[1];
  cin >> inputs[2];
  cin >> inputs[3];
  cin >> inputs[4];
  int maxdelay = 0;
  int sumtime = 0;
  rep(i,5){
    if(inputs[i] % 10 != 0) {
      maxdelay = max(maxdelay, 10 - inputs[i] % 10);
    }
    
    if(inputs[i] % 10 == 0) {
      sumtime += inputs[i];
    } else {
      sumtime += (inputs[i] - (inputs[i] % 10)) + 10;
    }
  }
  cout << sumtime - maxdelay << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int K;
    cin >> K;
    int A, B;
    cin >> A >> B;
    for(int i = A; i <= B; i++) {
        if(i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll int n,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    cout<<sum<<endl;
 
     return EXIT_SUCCESS;
}

Measured memory_bytes: 3624
s = input()
_ = input()

# 1: false, 2: true
isFlip = 1
first = last = ""

from sys import stdin

try:
  for line in stdin:
    lineArray = line.split()
    if len(lineArray) == 1:
      isFlip ^= 3
    else:
      if (int(lineArray[1]) - isFlip) == 0:
        first += lineArray[2]
      else:
        last += lineArray[2]
except EOFError:
  pass

if isFlip == 2:
  print(last[::-1] + s[::-1] + first)
else:
  print(first[::-1] + s + last)

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(n) cin >> a[i];
    sort(all(a));
    cout << accumulate(a.begin(), a.begin()+(n-1), 0) + a[n-1]/2 << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
def f(n):
  dp = list(range(n+1))
  for a, b in zip(A, B):
    for i in range(n+1):
      if i-a >= 0:
        dp[i] = max(dp[i], dp[i-a]+b)
  return max(dp)
m = f(n)
A, B = B, A
ans = f(m)
print(ans)

Measured memory_bytes: 261796
// A.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	string ans = n < 1200 ? "ABC" : (n < 2800 ? "ARC" : "AGC");
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int n,k;
    cin >> n >> k;
    vector<int> q;
    priority_queue<int, vector<int>, greater<int> > pq; 
    rep(i,n){
        int tmp;
        cin >> tmp;
        q.push_back(tmp);
    }
    int res=INT_MIN;
    rep(i,k+1){
        for(int j=0;i+j<=k;j++){
            for(int l=0;i+j+l<=k;l++){
                int tmp=0;
                rep(ii,i){
                    if(ii>=n)break;
                    tmp += q[ii];
                    pq.push(q[ii]);
                }
                rep(ii,j){
                    if(n-1-ii>=n)continue;
                    if(n-1-ii<i)break;
                    tmp += q[n-1-ii];
                    pq.push(q[n-1-ii]);
                }
                rep(ii,l){
                    if(pq.empty()||pq.top()>=0)break;
                    tmp -= pq.top();
                    pq.pop();
                }
                if(tmp>res){
                DEBUG{printf("%d %d %d %d\n", i, j, l, tmp);}
                    res=tmp;
                }
                while (!pq.empty())pq.pop();
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(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; }


const int MAX = 42;




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

  int ans;

  if(X <= 599){
    ans = 8;
  }else if(X <= 799){
    ans = 7;
  }else if(X <= 999){
    ans = 6;
  }else if(X <= 1199){
    ans = 5;
  }else if(X <= 1399){
    ans = 4;
  }else if(X <= 1599){
    ans = 3;
  }else if(X <= 1799){
    ans = 2;
  }else if(X <= 1999){
    ans = 1;
  }

  cout << ans << endl;

  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<map>

#define TGT 10000000

using namespace std;

int main(void) {
	vector<int> triangle(5000);
	int sum = 0, N, i;

	cin >> N;

	for (i = 0; sum < N; i++) {
		sum += i;
	}

	for (i--; N > 0; i--) {
		if (i <= N) {
			N -= i;
			cout << i << endl;
		}
	}


	//system("pause");

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  vector<pair<int,int> > pii;
  int a,b;
  vector<int> vi;
  while(scanf("%d,%d",&a,&b),a+b){
    pii.push_back(make_pair(a,b));
    vi.push_back(b);
  }
  int ans[vi.size()+10]={};
  int anscnt=1;
  sort(vi.begin(),vi.end(),greater<int>());
  for(int i=30;i>=0;i--){
    int flag=0;
    for(int j=0;j<pii.size();j++){
      if(pii[j].second==i){
	ans[pii[j].first]=anscnt;
	flag=1;
      }
    }
    if(flag)
      anscnt++;
  }
  int n;
  while(cin>>n)
    cout<<ans[n]<<endl;
  return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
 int main(void)
{
     int n,i,x,j;     int card[4][13]={};     char M;           scanf("%d",&n);     for(i = 0;i < n+1;i++){         scanf("%c %d%*c",&M ,&x);         if(M == 'S'){             card[0][x-1]=1;         }else if(M =='H'){             card[1][x-1]=1;         }else if(M == 'C'){             card[2][x-1]=1;         }else if(M == 'D'){             card[3][x-1]=1;         }     }     for(i = 0;i < 4;i++){         for(j = 0;j < 13;j++){             if(card[i][j] == 0){             if(i == 0){                 printf("S %d\n",j+1);         }else if(i == 1){             printf("H %d\n",j+1);         }else if(i == 2){             printf("C %d\n",j+1);         }else if(i == 3){             printf("D %d\n",j+1);         }         }     }     } return 0; } 

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m;  cin >> n >> m;
	vector<int> s[m];
	for( int i = 0; i < m; ++i ){
		int k; cin >> k;
		for( int j = 0; j < k; ++j ){
			int tmp; cin >> tmp;
			--tmp;
			s[i].push_back(tmp);
		}
	}
	int p[m];
	int ans = 0;
	for( int i = 0; i < m; ++i ) cin >> p[i];
	for( int bit = 0; bit < (1<<n); ++bit ){
		bool flag = true;
		for( int i = 0; i < m; ++i ){
			int res = 0;
			for( auto cand : s[i] ){
				if( bit & (1<<cand) ){
					res += 1;
				}
			}
			if( res % 2 != p[i] ) flag = false;
		}
		if( flag ) ++ans;
	}
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

ll MOD = (ll) 10399;
const ll MAXN = (ll) 1e3 + 10;
const ll INF = (ll) LONG_LONG_MAX / 100;
const ld EPS = (ld) 1e-8;
const ll P = 104107;

ll mul(ll a, ll b){
	return (a * b) % MOD;
}

ll pw(ll b, ll p){
	if(p == 0) return 1;
	if(p & 1) return mul(b, pw(b, p - 1));
	return pw(mul(b, b), p / 2);
}
ll inv(ll x){
	return pw(x, MOD - 2);
}

int main(){
	ll n, k;
	cin >> n>> k;
	cout << n -k+1;
	return 0;
}


/*
fuck hashal
*/



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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int h, w, n;
	cin >> h >> w >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int idx = 0;
	int ans[h][w];
	for (int i = 0; i < h; i++) {
		if (i%2==0) {
			for (int j = 0; j < w; j++) {
				ans[i][j] = idx+1;
				a[idx]--;
				if (a[idx]==0) {
					idx++;
				}
			}
		} else {
			for (int j = w-1; j >= 0; j--) {
				ans[i][j] = idx+1;
				a[idx]--;
				if (a[idx]==0) {
					idx++;
				}
			}
		}

	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w-1; j++) {
			cout << ans[i][j] << " ";
		}
		cout << ans[i][w-1] << "\n";
	}
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[5];
  for(int i=0;i<5;i++)cin>>a[i];
  int k;
  cin>>k;
  string wrong=":(";
  if(a[4]-a[0]>k)cout<<wrong<<endl;
  else cout<<"Yay!\n";
}

Measured memory_bytes: 256
/*|In The Name of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6+5;

int n;
int m;
char A[100][100];
char B[100][100];

bool can(int I , int J){
     int JJ = J;
     for(int i = 1; i <= m; i++){
        for(int j = 1; j <= m; j++){
            if(A[I][J] == B[i][j]){
               if(J == n){
                  I++;
                  J = JJ;
               } else {
                  J++;
               }
            } else {
               return 0;
            }
        }
     }
     return 1;
}

int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> A[i][j];
        }
    }
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= m; j++){
            cin >> B[i][j];
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(can(i , j)){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}


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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  int i1,i2;
  i1=a.size()-1;
  i2=b.size()-1;
  if(a.at(i1)==b.at(0)&&b.at(i2)==c.at(0))
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.push("");
var n=Arr.shift()-0;
for(var I=0;I<n;I++){
   var yx=[];
   var dp=[];
   for(var i=0;i<5;i++){
      var v=Arr.shift().split(" ").map(Number);
      yx.push(v);
      dp.push([]);
   }
   for(var y=0;y<5;y++){
      for(var x=0;x<5;x++){
         if(y==0)dp[y][x]=(yx[y][x]==1)?1:0;
         else dp[y][x]=(yx[y][x]==1)?dp[y-1][x]+1:0;
      }
   }
   var max=0;
   for(var y=0;y<5;y++){
      for(var i=0;i<5;i++){
         for(var j=i;j<5;j++){
            var min=Infinity;
            for(var k=i;k<=j;k++)min=Math.min(min,dp[y][k]);
            max=Math.max(max,min*(j-i+1));
         }
      }
   }
   console.log(max);
   Arr.shift();
}

Measured memory_bytes: 10496
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN	 100
int N[MAXN+5],n;
int C(int a){
	int sum=0;
	for(int i=1;i<=n;i++)
		sum+=(a-N[i])*(a-N[i]);
	return sum;
}
int main(){
	int m1=0,m2,m3;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&N[i]),m1+=N[i];
	sort(N+1,N+n+1);
	m1/=n,m2=m1+1,m3=m1-1;
	printf("%d",min(C(m1),min(C(m2),C(m3))));
	return 0;
}

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

typedef long long ll;

typedef pair<ll, ll> P;

ll N, K;

ll cnt[100010] = {}, T[100010], D[100010];

ll sum = 0, var = 0;

priority_queue<P, vector<P>, greater<P> >Q;

int main(){
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>T[i]>>D[i];
        sum += D[i];
        if(cnt[T[i]]==0)var++;
        cnt[T[i]]++;
        Q.push(P(D[i],i));
    }
    while(N!=K){
        ll score = Q.top().first;
        ll id = Q.top().second;
        Q.pop();
        ll reval = D[id];
        if(cnt[T[id]]==1)reval += var*2-1;
        if(reval!=score){
            Q.push(P(reval, id));
            continue;
        }
        sum -= D[id];
        cnt[T[id]]--;
        if(cnt[T[id]]==0)var--;
        N--;
    }
    cout << sum + var*var <<endl;

    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  int distance = 0;
  for (int i = 0; i < N; i++) {
    distance += min(x.at(i), K - x.at(i)) * 2;
  }
  cout << distance << endl;
  return 0;
}


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

using namespace std;

int main() {
	int m;
	cin >> m;
	int tp = 0, hp = 0;
	for (int i = 0; i < m; i++) {
		string t, h;
		cin >> t >> h;
		if (t > h) tp += 3;
		else if (t < h) hp += 3;
		else {
			tp++; hp++;
		}
	}
	cout << tp << " " << hp << endl;
	return 0;
}



Measured memory_bytes: 3160
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      int n = scanner.nextInt();
      if (n == 0) {
        break;
      }
      scanner.nextLine();
      int[][] f = new int[n + 1][n + 1];
      int t = 0;
      for (int ii = 0; ii < n; ii++) {
        int rsum = 0;
        for (int jj = 0; jj < n; jj++) {
          f[ii][jj] = scanner.nextInt();
          rsum += f[ii][jj];
          t += f[ii][jj];
        }
        f[ii][n] = rsum;
      }

      for (int ii = 0; ii < n; ii++) {
        int csum = 0;
        for (int jj = 0; jj < n; jj++) {
          csum += f[jj][ii];
        }
        f[n][ii] = csum;
      }

      f[n][n] = t;

      for (int ii = 0; ii <= n; ii++) {
        String out = "";
        for (int jj = 0; jj <= n; jj++) {
          out += String.format("%5d", f[ii][jj]);
        }
        System.out.println(out);
      }
    }
  }
}

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

 


int main() {
 int N,W;
  cin >>N>>W;
 vector<int>v(N+1);
 vector<int>w(N+1);
 long int dp[N+1][W+1]; 
  rep(i,N+1){
   rep(j,W+1){
   	dp[i][j]=0;
   }
  }
 rep(i,N){
 cin >> v[i+1] >> w[i+1];
 }
 for(int i=1;i<=N;i++){
 	for(int j=1;j<=W;j++){
    	if(w[i]<=j){
        dp[i][j]=max(dp[i][j-w[i]]+v[i],max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]));
        }
    	else{dp[i][j]=dp[i-1][j];}
    }
 } 
  long int ans=0;
  rep(i,W+1){
  ans=max(ans,dp[N][i]);
  }
  cout<<ans<<endl;
  
}


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

void print_calc_result(int a, int b, char op)
{
  if (op == '+')
  {
    cout << a + b << endl;
  }
  if (op == '-')
  {
    cout << a - b << endl;
  }
  if (op == '*')
  {
    cout << a * b << endl;
  }
  if (op == '/')
  {
    cout << a / b << endl;
  }
}

int main()
{
  int a, b;
  char op;
  while (true)
  {
    cin >> a >> op >> b;
    if (op == '?')
    {
      break;
    }
    print_calc_result(a, b, op);
  }
}



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

using namespace std;

typedef long long ll;
const int MAX=1e9+7;
int a[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
        sort(a,a+n);
        int m=a[n-1]/2;

    if(n==2)
        printf("%d %d\n",a[1],a[0]);
    else
    {
        int t,cnt,mim=a[n-1];
        for(int i=0;i<n-1;i++)
        {
            t=m-a[i];
            if(t<0) t=-t;
            if(t<=mim)
            {
                if(t==mim )
                {
                    if(a[i]>t)
                         mim=t,cnt=a[i];
                }
                if(a[i]>cnt)
                mim=t;cnt=a[i];
//                printf("%d\n",cnt);
            }
            if(mim==0) break;
        }
        //
       printf("%d %d\n",a[n-1],cnt);

    }

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,x[110000];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	int l=1e9,r=0;
	for (int i=1;i<=n;i++) l=min(l,x[i]),r=max(r,x[i]);
	if (l==r){
		int L=1,R=n/2;
		if (l==n-1){
			printf("Yes\n"); return 0;
		}
		if (l>R||l<L){
			printf("No\n"); return 0;
		}
		printf("Yes\n"); return 0;
	}
	if (r-l>1){
		printf("No\n"); return 0;
	}
	int tot=0;
	for (int i=1;i<=n;i++) if (x[i]==l) tot++;
	int L=tot+(tot!=n),R=tot+(n-tot)/2;
	if (r>R||r<L){
		printf("No\n"); return 0;
	}
	printf("Yes\n"); return 0;
}

Measured memory_bytes: 640
from sys import stdin, stdout
def gmi(): return map(int, stdin.readline().strip().split())
def gms(): return map(str, stdin.readline().strip().split())
def gari(): return list(map(int, stdin.readline().strip().split()))
def gars(): return list(map(int, stdin.readline().strip().split()))
def gs(): return stdin.readline().strip()
def gls(): return list(stdin.readline())
def gi(): return int(stdin.readline())

d, t, s = gmi()
if d/t <= s:
    print("Yes")
else:
    print("No")








Measured memory_bytes: 61876
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;



int main(){
  ios_base::sync_with_stdio(false);

  int r;
  
  cin >> r;

  if(r < 1200){
    cout << "ABC" << endl;
  } else if(r < 2800){
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <assert.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

double HeronFormula(double a, double b, double c) {
    double s = (a + b + c) / 2.0;
    return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main ()
{
    double A,B,C;
    cin >> A >> B >> C;

    cout << HeronFormula(A, B, C) << endl;

    return 0;
}


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

/*
親切さが大きい人から入っていく
最初が最大 -> +0
次の人の隣は最大しかいないので -> +An
その次の人は最大と次の最大の人の間なので、次の最大 -> +An-1
その次はもう一回最大と次の最大の人の間に挟まれる -> +An-1
*/

int	main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	long long ans = a[n - 1];
	for (int i = 2; i < n; i++)
	{
		ans += a[n - i / 2 - 1];
	}
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 4028
#include<stdio.h>
#include<string.h>
int main(){
	char S[4];
	char T[4];
	int i=0;

	scanf("%s %s",S,T);

	if(strncmp(&S[0],&T[0],1)==0){
		i++;
	}
	if(strncmp(&S[1],&T[1],1)==0){
		i++;
	}
	if(strncmp(&S[2],&T[2],1)==0){
		i++;
	}

    printf("%d",i);

    return 0;

}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//降順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int a,b;
    int sum=1;
    int i=0;
    scanf("%d%d",&a,&b);
    while(sum<b){
        sum--;
        sum+=a;
        i++;
    }
    printf("%d",i);
}


Measured memory_bytes: 1684
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);
    let mut v: Vec<u32> = Vec::with_capacity(n);
    let mut org: Vec<u32> = Vec::with_capacity(n);
    let mut i = 0;
    while (i < n) {
        let a = parse_line!(u32);
        v.push(a);
        org.push(a);
        i = i + 1;
    }
    v.sort();
    let one = &v[n - 1];
    let two = &v[n - 2];
    for x in org {
        if x == *one {
            println!("{}", two);
        } else {
            println!("{}", one);
        }
    }
}


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

int main(void){
   int n,m;
   cin >> n >> m;
   
   vector<int> k(n);
   vector<vector<int>> a(n,vector<int>(m));
   vector<int> t(m);
   for(int i = 0;i < n;i++){
       cin >> k[i];
       for(int j = 0;j < k[i];j++){
           cin >> a[i][j];
           a[i][j]--;
           t[a[i][j]]++;
       }
   }
   int ans = 0;
   for(int i = 0;i < m;i++){
       if(t[i] == n)ans++;
   }
   cout << ans << endl;
   
   
   
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int h[n],dp[n];
  for(int i = 0;i < n;i++){
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for(int i = 2;i < n;i++){
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  }
  cout << dp[n-1] << endl;
}

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

using namespace std;
#define rep(j,n) for(int j=0;j<(n);j++)

using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main(int, char**)
{
    string s, t;
    cin >> s >> t;
  
  	int ans = 0;
  	rep(i,s.size()) if (s[i] != t[i]) ans++;
  
  	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3912
#include <stdio.h>
#include <math.h>
#define EPS (1e-12)

bool can(int n, double v) {
    double h = 5*n-5;
    return 9.8*sqrt(h/4.9) > v-EPS;
}

int main() {
    double v;
    while (scanf("%lf", &v) != EOF) {
        int l = 1, r = 1<<28;
        while (r-l>1) {
            const int mid = (l+r) / 2;
            if (can(mid, v)) r = mid;
            else l = mid;
        }
        printf("%d\n", r);
    }
    return 0;
}

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

const int INF = 1e9;

const int MAXK = 1.1e5;
int K;
int dist[MAXK];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> K;
	auto digitSum = [&](int v) -> int {
		int s = 0;
		while (v) {
			s += v % 10;
			v /= 10;
		}
		return s;
	};
	for (int r = 0; r < K; r++) {
		dist[r] = INF;
	}
	for (int v = 1; v < 10; v++) {
		dist[v % K] = min(dist[v % K], digitSum(v));
	}

	set<pair<int, int>> s;
	for (int r = 0; r < K; r++) {
		if (dist[r] != INF) {
			s.emplace(dist[r], r);
		}
	}
	while (!s.empty()) {
		int d, v; tie(d, v) = *s.begin();
		s.erase(s.begin());
		for (int x = 0; x < 10; x++) {
			int nv = (10 * v + x) % K;
			if (d + x < dist[nv]) {
				s.erase({dist[nv], nv});
				dist[nv] = d + x;
				s.emplace(dist[nv], nv);
			}
		}
	}
	cout << dist[0] << '\n';

	return 0;
}

Measured memory_bytes: 4480
#include<stdio.h>
int main()
{
    unsigned long long int n,i,j,min,a[10];
    scanf("%llu",&n);
    scanf("%llu",&a[0]);
    min=a[0];
    for(i=2;i<=5;i++)
{
    scanf("%llu",&a[i]);
    if(a[i]<min) min=a[i];
}
if(n%min==0)
    printf("%llu\n",(n/min)+4);
else    printf("%llu\n",(n/min)+5);
return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




ll gcd(ll a, ll b){
    return b? gcd(b, a % b) : a;
}

int main() {
    ll n, x, a;
    cin >> n >> x >> a;
    a = abs(x - a);
    REP(i, n - 1){
        ll t;
        cin >> t;
        a = gcd(a, abs(x - t));
    }
    cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
//#include <tuple>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

typedef long long ll;

using namespace std;

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

int main(void){
	int n; cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];

	rep(i, n-1){
		for(int j=i; j<n; j++){
			swap(p[i], p[j]);
			bool flag = true;
			rep(k, n-1){
				if(p[k] > p[k+1]){
					flag = false;
					break;
				}
			}
			if(flag){
				cout << "YES" << endl;
				return 0;
			}
			swap(p[i], p[j]);
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

lst = [0] * (N + 1)

for _ in range(M):
    a, b = map(int, input().split())
    lst[a] += 1
    lst[b] += 1

for i in lst:
    if i % 2 == 1:
        print ('NO')
        exit()

print ('YES')

Measured memory_bytes: 3828
void bubbleSort(int A[], const int N)
{
    int i;
    int flag = 1, cnt = 0;

    while( flag ){ //ここを消して下2行でも可 (1)
    //int j;
    //for( j = 0; flag; ++j ){
        flag = 0;

        for( i = N-1; 0 < i; --i ) //ここを消して下1行でも可 (1)
        //for( i = N-1; j < i; --i )
            if( A[i] < A[i-1] ){
                int tmp = A[i];
                A[i] = A[i-1];
                A[i-1] = tmp;

                flag = 1;
                ++cnt;
            }
    }

    for( i = 0; i < N; ++i ){
        if( 0 < i ) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", cnt);
}

int main()
{
    int i;

    int N;
    scanf("%d", &N);
    int A[N];
    for( i = 0; i < N; ++i )
        scanf("%d", &A[i]);

    bubbleSort(A, N);

    return 0;
}


Measured memory_bytes: 2108
using System;
using System.Linq;
using System.Text;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int h = arr[0];
    int w = arr[1];
    var s = new string[h + 2];
    s[0] = new string(' ', w + 2);
    for (int i = 1; i <= h; i++) {
      s[i] = " " + Console.ReadLine() + " ";
    }
    s[h + 1] = new string(' ', w + 2);
    StringBuilder sb = new StringBuilder();
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        int cnt = 0;
        if (s[i][j] == '.') {
          if (s[i - 1][j - 1] == '#') cnt++;
          if (s[i - 1][j] == '#') cnt++;
          if (s[i - 1][j + 1] == '#') cnt++;
          if (s[i][j - 1] == '#') cnt++;
          if (s[i][j + 1] == '#') cnt++;
          if (s[i + 1][j - 1] == '#') cnt++;
          if (s[i + 1][j] == '#') cnt++;
          if (s[i + 1][j + 1] == '#') cnt++;
          sb.Append(cnt);
        } else {
          sb.Append("#");
        }
      }
      sb.AppendLine();
    }
    Console.Write(sb);
  }
}

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

int main() {
    string N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N.size(); i++) {
        ans += int(N.at(i)) - int('0');
    }
    for (int i = 0; i < N.size(); i++) {
        if (N.at(i) == '0') continue;
        int s = int(N.at(i)) - int('0') - 1 + 9 * (N.size() - i - 1);
        for (int j = 0; j < i; j++) {
            s += int(N.at(j)) - int('0');
        }
        ans = max(ans, s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import copy
a,b,c=map(int,input().split())
d=[]
for i in range(c):
    i=int(input())
    d.append(i)
d=[i-1 for i in d]
e=[b]*a

e=[i-len(d) for i in e]
for i in d:
    e[i]+=1
    
for i in e:
    if i>0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 58200
#include <stdio.h>
void swap(int* array, int i, int j) {
    int temp;
    temp = array[i];
    array[i] = array[j];
    array[j] = temp;
}
int main(void) {
    int n, l[400];
    int i, j;

    scanf("%d", &n);
    for (i = 0; i < n * 2; i++) {
        scanf("%d", &l[i]);
    }
    for (i = 0; i < 2 * n - 1; i++) {
        for (j = i + 1; j < 2 * n; j++) {
            if (l[i] > l[j]) {
                swap(l, i, j);
            }
        }
    }
    int ans = 0;
    for (i = 0; i < 2 * n; i += 2) {
        ans += l[i];
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner (System.in);
      	int n = scan.nextInt();	
      	int ans = 0;
        if(n >= 100000 ){
        	ans += 90000;
        }
      	if(n >= 10000 && n < 100000){
        	ans += (n - 10000) + 1;
        }
      	if(n >= 1000){
        	ans += 900;
        }
      	if(n >= 100 && n < 1000){
        	ans += (n - 100) + 1;
        }
      	if(n >= 10){
        	ans += 9;
        }
      	if (n < 10){
        	ans += n;
        }
      System.out.print(ans);
    }
}


Measured memory_bytes: 22740
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while (x != NIL){
    y = x;
    if (z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
    z->parent = y;
    if (y == NIL)
      root = z;
    else if (z->key < y->key)
      y->left = z;
    else
      y->right = z;
}

void inorder(Node u){
  if (u == NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if (u == NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Node treeSearch(Node u, int k){
  if (u == NIL || k == u->key)
    return u;
  if (k < u->key)
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}



Measured memory_bytes: 20456
w, h, n = map(int, input().split())

l, r = 0, w
high, low = h, 0

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        l = max(l, x)
    if a == 2:
        r = min(r, x)
    if a == 3:
        low = max(low, y)
    if a == 4:
        high = min(high, y)
w = r - l
h = high - low

print(w * h if w > 0 and h > 0 else 0)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int count0 = 0;
            int count1 = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if ( s[i] == '0')
                {
                    count0++;
                }
                else
                {
                    count1++;
                }
            }

            Console.WriteLine(Math.Min(count0, count1) * 2);
        }
    }
}


Measured memory_bytes: 13112
o=input()
e=input()
#print(o,e)
pwd=''
if len(o)==len(e):
  for i in range(len(o)):
    pwd=pwd+o[i]
    pwd=pwd+e[i]  
else:
  for i in range(len(o)-1):
    pwd=pwd+o[i]
    pwd=pwd+e[i]  
  pwd=pwd+o[-1]
  
print(pwd)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
	int a,b,c,d,e;

	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<c+e || b<d+e || c<0 || d<0)
		printf("No\n");
	else
		printf("Yes\n");

	return 0;
}

Measured memory_bytes: 580
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int min = Integer.MAX_VALUE;
		int sum =0;
		int s;
		for (int i = 0;i < n; ++i){
			s = Integer.parseInt(scan.next());
			if (s%10 != 0){
				min = Math.min(min,s);
			}
			sum+=s;
		}

		if (min != Integer.MAX_VALUE && sum%10 ==0){
			sum-=min;
		}
		if (sum%10 ==0){
			System.out.print(0);
		}else{
			System.out.print(sum);
		}


	}
}
//end


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
	ll res=0;
	rep1(i, N){
		if(i%3 == 0 || i%5 == 0) continue;
		res += i;
	}

	cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7752
/*
 _____ ____ _____   ___   ___   ___   ___ 
|_   _/ __ \_   _| |__ \ / _ \ |__ \ / _ \
  | || |  | || |      ) | | | |   ) | | | |
  | || |  | || |     / /| | | |  / /| | | |
 _| || |__| || |_   / /_| |_| | / /_| |_| |
|_____\____/_____| |____|\___/ |____|\___/ 
*/
#include <bits/stdc++.h>
#include <fstream>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
// assert(x==y); gives run time when false
using namespace std;
int main(){
    int n;
    cin >> n;
    string x;
    cin >> x;
    int counto = 0;
    rep(i,0,n-2){
        if(x[i]=='A' && x[i+1] == 'B'&& x[i+2]=='C'){
            counto++;
        }
    }
    cout << counto;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
ns = list(map(int, input().split()))
min_n = 10 ** 10
max_n = 0
max_l = []
for i in ns[::-1]:
    max_n = max(max_n, i)
    max_l.append(max_n)
max_l.reverse()
l = []
for i in range(n):
    l.append(ns[i]-min_n)
    min_n = min(min_n, ns[i])
print(l.count(max(l)))

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

int A[5][5];
bool C[5][5];
int B[20];

int main(){
  rep(i, 3){
    rep(j, 3){
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  rep(i, N) cin >> B[i];
  rep(i, 3){
    rep(j, 3){
      rep(k, N){
        if (A[i][j]==B[k]) C[i][j] = true;
      }
    }
  }
  bool bingo = false;
  rep(i, 3){
    if (C[i][0] && C[i][1] && C[i][2]) bingo = true;
  }
  rep(i, 3){
    if (C[0][i] && C[1][i] && C[2][i]) bingo = true;
  }
  if (C[0][0] && C[1][1] && C[2][2]) bingo = true;
  if (C[0][2] && C[1][1] && C[2][0]) bingo = true;
  if (bingo) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
  	int N,M,K;
    cin >> N >> M ;
    int count[M]={};
    int count2,total = 0;
    for(int i = 0;i<N;i++){
        cin >> K;
        for(int j = 0; j<K;j++){
            cin >> count2 ;
            count[count2-1]++;
        }
        
    }
  	for(int i = 0;i<M;i++){
  		if(count[i] == N)total++;
    }
  	if(N == 1){
    	cout << K <<endl;
    }else{
    	cout << total <<endl;
    }
}

Measured memory_bytes: 256
a1 , b1 , c1 = (int(i) for i in input().split())
a2 , b2 , c2 = (int(i) for i in input().split())
a3 , b3 , c3 = (int(i) for i in input().split())
am = min(a1,a2,a3)
bm = min(b1,b2,b3)
cm = min(c1,c2,c3)
a = [a1-am,a2-am,a3-am]
b = [b1-bm,b2-bm,b3-bm]
c = [c1-cm,c2-cm,c3-cm]
if a == b == c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

string judge(double x);

int main(void) {
	double kg;
	while(cin >> kg) {
		cout << judge(kg) << endl;;
	}
	
	return 0;
}

string judge(double x) {
	if(x <= 48.00)							return "light fly";
	else if(x > 48.00 && x <= 51.00)		return "fly";
	else if(x > 51.00 && x <= 54.00)		return "bantam";
	else if(x > 54.00 && x <= 57.00)		return "feather";
	else if(x > 57.00 && x <= 60.00)		return "light";
	else if(x > 60.00 && x <= 64.00)		return "light welter";
	else if(x > 64.00 && x <= 69.00)		return "welter";
	else if(x > 69.00 && x <= 75.00)		return "light middle";
	else if(x > 75.00 && x <= 81.00)		return "middle";
	else if(x > 81.00 && x <= 91.00)		return "light heavy";
	else									return "heavy";
}

Measured memory_bytes: 1228
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)


def gcd(a, b):
    r = a % b
    return b if 0 == r else gcd(b, r)


def lcm(a, b):
    return (a * b) // gcd(a, b)


def lcm_s(my_list):
    g = lcm(my_list[0], my_list[1])
    for i in range(2, len(my_list)):
        g = lcm(g, my_list[i])
    return g

def f(m, my_list):
  result = 0
  for a_i in my_list:
    result += m % a_i
  return result

print(f(lcm_s(a) - 1, a))


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

int main(){
  int N,ans=0;
  cin >> N;
  for(int i=1; i<=N; i += 2){
    int cnt = 0;
    for(int j=1; j<=N; j++){
        if(i % j == 0){
          cnt++;
        }
    }
    if(cnt == 8) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612