akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int main(){
  int i,n;
  double sita;
  while(scanf("%d",&n)){
    if (n==-1)
      break;
    sita=0;
    for (i=1;i<n;i++)
      sita+=atan2(1,sqrt(i))/M_PI*180;
    printf("%.2f\n%.2f\n",sqrt(n)*cos(sita*M_PI/180),sqrt(n)*sin(sita*M_PI/180));
  }
  return 0;
}

Measured memory_bytes: 704
N = int(input())
Word = []
tail = ""
for i in range(N):
    W = list(input())
    head = W[0]
    W = ''.join(W)
    if i != 0:
        if tail != head or (W in Word):
            print("No")
            exit()
    tail = W[-1]
    Word.append(W)
print("Yes")

Measured memory_bytes: 38384
import numpy as np
a,b,h,m = map(int,input().split())
pos1 = [b*np.sin(np.radians(6*m)),b*np.cos(np.radians(6*m))]
pos2 = [a*np.sin(np.radians(30*h+m*(360/(12*60)))),a*np.cos((np.radians(30*h+m*(360/(12*60)))))]
d = ((pos1[0]-pos2[0])**2+(pos1[1]-pos2[1])**2)**0.5
print(d)
#print(pos1)
#print(pos2)

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

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

int main() {
  const int p = 2019;

  string s;
  cin >> s;

  int n = s.size();
  vector<int> v(n+1, 0);
  int d = 1;
  for(int i = n-1; i >= 0; i--) {
    int t = s[i] - '0';
    int m = (t * d) % p;
    v[i] = (v[i + 1] + m) % p;
    d = (d * 10) % p;
  }

  vector<int> cnt(p, 0);
  ll res = 0;
  for(int i = n; i >= 0; i--) {
    res += cnt[v[i]];
    cnt[v[i]] += 1;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 4376
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int N = int.Parse(line);
            long[] A = new long[N];
            line = Console.ReadLine();
            string[] strs = line.Split(' ');
            for (int i = 0; i < N; i++)
            {
                A[i] = long.Parse(strs[i]);
                if (A[i] == 0)
                {
                    Console.WriteLine(0);
                    return;
                }
            }
            long sum = A[0];
            long MAX = 1;
            for (int i = 0; i < 18; i++) MAX *= 10;
            for(int i = 1; i < N; i++)
            {
                if (A[i] > MAX / sum)
                {
                    Console.WriteLine(-1);
                    return;
                }
                sum *= A[i];
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 40564
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;

int main() {
    int N, L, i, j, k;
    int org_flv = 0, opt_flv = 1987654321;

    scanf("%d%d", &N, &L);

    for(i = 0; i < N; i ++) org_flv += L + i;

    for(i = 0; i < N; i ++) { // except the ith apple
        int s = 0;
        for(j = 0; j < N; j ++) if(i != j) s += L + j;
        if(abs(org_flv - s) < abs(org_flv - opt_flv)) {
            opt_flv = s;
        }
    }

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

    return 0;
}

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

void solve(int n){
    if(n == 0){
        cout << "0";
    }else{
        if(n/4){
            solve(n/4);
        }
        cout << n%4;
    }
}

int main(){
    int n;
    int result;

    while(cin >> n, n != -1){
        solve(n);
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>


int main(void){
	char moji[4][4];
	int i,j;

	for(i=0;i<3;i++){
		scanf("%s", moji[i]);
	}

	putchar(moji[0][0]);
	putchar(moji[1][1]);
	putchar(moji[2][2]);

	puts("");

	return 0;
}

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

int main(){
    int n, m, x, y, l;
    bool t[21][21];
    char d;
    while(true){
	cin >> n;
	if(n == 0)return 0;
	memset(t, false, sizeof(t));
	int xx = 10, yy = 10;
	for(int i = 0;i < n;i++){
	    cin >> x >> y;
	    t[x][y] = true;
	}

	cin >> m;
	for(int i = 0;i < m;i++){
	    cin >> d >> l;
	    int xs = 0, ys = 0;
	    if(d == 'N')ys = 1;
	    if(d == 'E')xs = 1;
	    if(d == 'S')ys = -1;
	    if(d == 'W')xs = -1;
	    while(l--){
		xx += xs, yy += ys;
		t[xx][yy] = false;
	    }
	}

	bool comp = true;
	for(int i = 0;i <= 20;i++)
	    for(int j = 0;j <= 20;j++)
		if(t[i][j])
		    comp = false;
	if(comp)
	    cout << "Yes" << endl;
	else
	    cout << "No" << endl;
    }
}

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

void solve2() {
	string s;
	cin >> s;
	map<char, int> m;
	for (int i = 0; i < s.size(); i++)
	{
		m[s[i]]++;
	}
	for (auto it = m.begin(); it != m.end(); it++)
	{
		if (it->second % 2 != 0) {
			cout << "No" << endl;
			return;
		}

	}
	cout << "Yes" << endl;
	return;
}

void solve1() {
	int K, N,X,Y;
	cin >> N >> K >> X >> Y;
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (i < K) {
			ans += X;
		}
		else
			ans += Y;
	}
	cout << ans << endl;
}

int main() {
	solve2();
	return 0;
}

Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())
heap = list(map(lambda x: -1*int(x), input().split()))
heapq.heapify(heap)

while M > 0:
    x = heapq.heappop(heap)
    heapq.heappush(heap, int(x/2))
    M -= 1
print(sum(heap)*(-1))

Measured memory_bytes: 20260
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll; 

int N;
const int MAX_N = 10;
double x[MAX_N];
string u[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> x[i]>> u[i];

    double ans = 0.0;
    for (int i = 0; i < N; i++){
        if (u[i] == "JPY") ans += x[i];
        else ans += 380000.0 * x[i];
    }

    cout << ans << endl;
    
    return 0;    
}

Measured memory_bytes: 888
//A
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str,str1;
    cin>>str>>str1;
    if(str1.substr(0,str1.length()-1)==str)puts("Yes");
    else puts("No");
    
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int dp[n + 1];
    rep(i, 0, n + 1) dp[i] = INF;
    dp[0] = 0;
    rep(i, 0, n + 1) {
        for (int j = 1; i + j <= n; j *= 6) {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
        for (int j = 1; i + j <= n; j *= 9) {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)g
#define INF 999999999
using namespace std;

#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head, tail,n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail+1)%LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1)% LEN;
	return x;
}


int main(){
	int elaps = 0,c;
	int i,q;
	P u;
	cin >> n>>q;
	FOR(i,1,n+1){
		cin >> Q[i].name>>Q[i].t;
	}
	head = 1;
	tail = n+1;


	while (head != tail ){
		u = dequeue();
		c = min(q,u.t);
		u.t -= c;
		elaps += c;
		if(u.t > 0) enqueue(u);
		else{
			cout <<u.name<<" "<<elaps<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 13260
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	long[] sum = new long[N+1];
	for (int i = 1; i <= N; i++) {
	    long a = Long.parseLong(scan.next());
	    sum[i] = sum[i-1] + a;
	}

	long min = Long.MAX_VALUE;
	for (int i = 1; i < N; i++) {
	    long point = Math.abs(2*sum[i] - sum[N]);
	    if(point < min) min = point;
	}

	System.out.println(min);
	scan.close();
    }
}


Measured memory_bytes: 59532
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

#pragma region Combination
const int MAX = 1000000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
#pragma endregion

int main()
{
	ll n, m, k; cin >> n >> m >> k;
	ll res = 0;
	vector<ll> a(n + 1);
	a[0] = 1;
	rep(i, n)
	{
		a[i + 1] = (m - 1)*a[i];
		a[i + 1] %= MOD;
	}
	COMinit();
	rep(i, k + 1)
	{
		ll tmp = m * a[n - 1 - i];
		tmp %= MOD;
		tmp *= COM(n - 1, i);
		res += tmp;
		res %= MOD;
	}
	cout << res << endl;
}

Measured memory_bytes: 28340
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int s[4];
  s[0]=S[0]-'0',s[1]=S[1]-'0',s[2]=S[2]-'0',s[3]=S[3]-'0';
  for(int i=0;i<8;i++){
    int sum=s[0];
    for(int j=0;j<3;j++){
      if(i&1<<j)sum+=s[j+1];
      else sum-=s[j+1];
    }
    if(sum==7){
      cout<<s[0]<<(i&1?"+":"-")<<s[1]<<(i&1<<1?"+":"-")<<s[2]<<(i&1<<2?"+":"-")<<s[3]<<"=7"<<endl;
      return 0;
    }
  }
  return 0;
}


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

int main() {
	int N,S=0;
	cin>>N;
	int x=N;
	for(int i=0;i<10;i++){
		S+=x%10;
		x/=10;
	}
	if(N%S==0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char a = sc.next().charAt(0);
        char b = sc.next().charAt(0);
        System.out.println((a=='H'&&b=='H')||(a=='D'&&b=='D')?'H':'D');
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;
    if(500*k >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<pii>> xy(N, vector<pii>(N));
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
        for(int j = 0; j < A[i]; ++j) {
            cin >> xy[i][j].first >> xy[i][j].second;
            xy[i][j].first--;
        }
    }

    int ans = 0;
    for(int i = 0; i < (1 << N); ++i) {
        bool flag = false;
        int tmp = 0;
        for(int j = 0; j < N; ++j) {
            if(i & (1 << j)) {
                tmp++;
                for(int k = 0; k < A[j]; ++k) {
                    if(xy[j][k].second == 0) {
                        if(i & (1 << xy[j][k].first)) {
                            flag = true;
                            break;
                        }
                    } else if(!(i & (1 << xy[j][k].first))) {
                        flag = true;
                        break;
                    }
                    if(flag)
                        break;
                }
            }
            if(flag)
                break;
        }
        if(!flag)
            ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
#define er erase
#define in insert
#define pi pair <int, int>
# define sz(x) (int)((x).size())
#define int long long

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

const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1999999973;
const int N = 2e5 + 11;

int dp[N],n,k,x;
vector<int>v;

int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);

//ifstream cin("flip.in");
//ofstream cout("flip.out");

    cin >> n >> k;

    forn(i,1,n)cin>>x, v.pb(x);

    for(int i = 1; i <= k; i++){
        for(auto it: v){

            if(i >= it && !dp[i - it]) dp[i] = 1;

        }
    }

    rc((dp[k] ? "First" : "Second"));

return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int M = Integer.parseInt(in.next());
            long[][] AB = new long[N][2];
            for (int i = 0; i < N; i++) {
                AB[i][0] = Long.parseLong(in.next());
                AB[i][1] = Long.parseLong(in.next());
            }
            Arrays.sort(AB, (x, y) -> Long.compare(x[0], y[0]));
            long ans = 0;
            for (int i = 0; i < N; i++) {
                long k = AB[i][1];
                M -= k;
                if (M > 0) {
                    ans += AB[i][0] * k;
                } else {
                    ans += AB[i][0] * (M + k);
                    break;
                }
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 65592
N,K = map(int,input().split())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
C = sorted(list(C.items()),key=lambda x:x[1],reverse=True)
if len(C)<=K:
    print(0)
else:
    cnt = 0
    for i in range(K,len(C)):
        cnt += C[i][1]
    print(cnt)

Measured memory_bytes: 122616
def CountingSort(n, input_line, max_num):
    max_num += 1
    count_list = [0 for i in range(max_num)]
    output_line = [0 for i in range(n)]
    for i in range(n):
        count_list[input_line[i]] += 1
    for i in range(1,max_num):
        count_list[i] = count_list[i] + count_list[i-1]
    for i in range(n-1,-1, -1):
        output_line[count_list[input_line[i]]-1] = str(input_line[i])
        count_list[input_line[i]] -= 1
    return output_line

n = int(input())
input_line = [int(i) for i in input().split()]
max_num = max(input_line)
output_line = CountingSort(n, input_line, max_num)
print(' '.join(output_line))


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

int main(){
    int H,W,N,result;

    cin >> H >> W >> N;
    int tmp;
    if(H>W){
      tmp = H;
    }else{
      tmp = W;
    }

    if(N%tmp == 0){
    result = N / tmp;
    }else{
      result = N / tmp +1;
    }


    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    int n;
    cin >> n;
    int64 mx = 1e18;
    vec64 arr (n);
    int64 rs = 1;
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    for (int i = 0; i < n; i++){
        int j = i;
        // db(rs);
        // db(mx / rs);
        // db (arr[i]);
        if (mx / rs < arr[i]){
            ctn(-1);
            return 0;
        }
        rs *=arr[i];
        if (rs == 0){
            ctn(0);
            return 0;
        }
    }
    if (rs > 1e18){
        ctn("-1");
        return 0;
    }
    ctn(rs);
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N, P;
	cin >> N >> P;
	vector<int>A(N);
	int x=0, y=0;
	rep(i, N) {
		cin >> A[i];
		if (A[i] % 2 == 0)x++;
		else y++;
	}
	ll ans = 0;
	ll xe = 1, ye = 1;
	while (x != 0) {
		xe *= 2;
		x--;
	}
	while (y != 0) {
		ye *= 2;
		y--;
	}
	if (P == 0) {
		if (ye != 1)ye /= 2;
		ans = xe*ye;
	}
	else {
		ye /= 2;
		ans = xe*ye;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
var ab = require('fs').readFileSync('/dev/stdin', 'utf8').split(' ').map(Number);
var a = ab[0];
var b = ab[1];

var d = Math.floor(a / b);
var r = a % b;
var f = (a / b).toFixed(5);

console.log(d + ' ' + r + ' ' + f);

Measured memory_bytes: 15620
using System;

class Program
{
    static void Main()
    {
        int i = 0;
        while (i == 0)
        {
            string[] HW = Console.ReadLine().Split();
            int H = int.Parse(HW[0]);
            int W = int.Parse(HW[1]);

            if (H == 0 && W == 0)
                break;

            for (int j = 0; j < H; j++)
            {
                for (int k = 0; k < W; k++)
                {
                    if (j == 0 || j == (H - 1) || k == 0 || k == (W - 1))
                        Console.Write("#");
                    else
                        Console.Write(".");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8744
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

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

Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	map<int, int>f;
	int ans = 0;
	rep(i, n) {
		cin >> a[i];
		if(a[i]<=n) f[a[i]]++;
		else ans++;
	}
	for (auto p : f) {
		int x = p.first;
		int m = p.second;
		if (m < x)ans += m;
		else ans += m - x;
	}
	cout << ans << endl;
	return 0;
}





Measured memory_bytes: 640
module DoublyLinkedList = struct
  type t = {
    mutable data : int;
    mutable next : t;
    mutable prev : t;
  }

  let make () =
    let rec head = { data = 0; next = head; prev = head } in
    head

  let insert data head =
    let x = { data = data; next = head.next; prev = head } in
    head.next.prev <- x;
    head.next <- x

  let delete x =
    x.next.prev <- x.prev;
    x.prev.next <- x.next

  let delete_first head = delete head.next

  let delete_last head = delete head.prev

  let delete_node data head =
    let rec doit ite =
      if ite == head then None
      else if ite.data = data then Some ite
      else doit ite.next
    in
    match doit head.next with
    | None -> ()
    | Some ite -> delete ite

  let iteri head ~f =
    let rec doit i ite =
      if ite == head then ()
      else (f i ite.data; doit (i + 1) ite.next)
    in
    doit 0 head.next
end

module L = DoublyLinkedList

let () =
  let n = read_int () in
  let head = L.make () in
  let rec read i =
    if i >= n then ()
    else begin
      match Str.split (Str.regexp " ") (read_line ()) with
      | ["insert"; n] -> (L.insert (int_of_string n) head; read (i + 1))
      | ["delete"; n] -> (L.delete_node (int_of_string n) head; read (i + 1))
      | ["deleteFirst"] -> (L.delete_first head; read (i + 1))
      | ["deleteLast"] -> (L.delete_last head; read (i + 1))
      | _ -> exit 1
    end
  in
  read 0;
  L.iteri head ~f:(fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n);
  print_newline ()

Measured memory_bytes: 40076
#include <bits/stdc++.h>
#define mx (ll)1e9+7
using namespace std;
typedef long long int ll;

bool p[1000010]={0};
ll n;
vector<ll> v;

void sieve(){
    for(ll i=2 ; i*i<=1000000 ; i++){
        if(p[i] == false){
            for(ll j=2*i ; j<=1000000 ; j += i){
                p[j] = true;
            }
        }
    }
    for(ll i=2 ; i<=1000000 ; i++){
        if(p[i] == false){
            v.push_back(i);
        }
    }
}

int main(){
    cin >> n;
    ll r = 1;
    sieve();
    for(ll i=0 ; i<v.size() ; i++){
        if(v[i] > n){
            break;
        }
        ll curr = v[i];
        ll sum = 0;
        while(curr <= n){
            sum += (n / curr);
            curr *= v[i];
        }
        r *= (sum+1);
        r = r % (1000000007);
    }
    cout << r%(1000000007);
    return 0;
}


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

int main(){
  int S;
  cin >> S;
  if (S / 100 < 13 && S % 100 < 13 && S / 100 > 0 && S % 100 > 0) {
    cout << "AMBIGUOUS" << endl;
  }
  else if (S % 100 < 13 && S % 100 > 0) {
    cout << "YYMM" << endl;
  }
  else if (S / 100 < 13 && S / 100 > 0) {
    cout << "MMYY" << endl;
  }
  else {
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;
 
using namespace std;

int main(){
    int n,a[110];
    cin>>n;
    REP(i,n) cin>>a[i];
    int sum=0;
    REP(i,n) sum+=a[i];
    int ans=200,tmp=114514;
    REP(i,n){
        int sa=abs(a[i]*n-sum);
        if(sa<tmp){
            ans=i,tmp=sa;
        }
        if(sa=tmp){
            ans=min(ans,i);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    

    string pos = "Possible";
    string imp = "Impossible";

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        List<int> l = new List<int>();
        for (int i = 0;; i++)
        {
            if (i * (i + 1) / 2 < N) continue;
            int nokori = N;
            for (int j = i; j >= 1; j--)
            {
                if (nokori >= j)
                {
                    l.Add(j);
                    nokori -= j;
                }
            }
            break;
        }
        l.Reverse();
        foreach (var item in l)
        {
            Console.WriteLine(item);
        }
    }


        
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}
 

Measured memory_bytes: 13268
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

for x in [A, B, C]:
    x.sort()

i = -1
j = 0
result = 0
for b in B:
    while i < N - 1 and A[i + 1] < b:
        i += 1
    while j < N and C[j] <= b:
        j += 1
    result += (i+1) * (N - j)
print(result)


Measured memory_bytes: 23328
x,n = map(int,input().split())
y = x
if n==0:
  print(x)
  exit()
p = list(map(int,input().split()))
for i in range(1000):
    if y not in p:
        print(y)
        exit()
    if x not in p:
        print(x)
        exit()
    else:
        x += 1
        y -= 1

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const int INF = 100001;

int a;

int main()
{
    cin >> a;
    
    if(a%2){
        cout << 2*a << endl;
    }else{
        cout << a << endl;
    }
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(c-a)<=d)
    cout << "Yes" << endl;
  else if ((abs(b-a)<=d)&&(abs(c-b)<=d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fill(x,c) memset(x,c,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int SIZE = 1e6+10;
ll a[SIZE];
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	string s;
	int t;
	cin>>n;
	map<string,ll> m;
	ll sum = 0;
	while(n--){
		cin>>s>>t;
		sum+=t;
		m[s] = sum;
	}
	cin>>s;
	cout<<sum-m[s]<<endl;
  	return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

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

    ll ans=0;
    ans += min(B,C) * 2;
    if(B < C) ans += min(A+1,C-B);
    else ans += B - C;

    pl(ans)

    return 0;
}

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

int main()
{
	int price = 0;
	cin >> price;
	constexpr double tax_rate = 1.08;
	int predic = price / tax_rate;
	
	for (int i = 0; i <= 1; i++)
	{
		int temp = (predic + i) * tax_rate;
		if (temp == price)
		{
			cout << predic + i;
			return 0;
		}
	}
	cout << ":(";
	return 0;
}

Measured memory_bytes: 256
A, V = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())

if A > B:
    Ax = A - V*T
    Bx = B - W*T
    if Ax <= Bx:
        print('YES')
    else:
        print('NO')
else:
    Ax = A + V*T
    Bx = B + W*T
    if Ax >= Bx:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    long long int N;
    cin >> N;
    vector<long long int> A(N);
    for(long long int n=0; n<N; n++) {
        long long int a;
        cin >> a;
        A[n] = a-(n+1);
    }

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

    long long int b, b1;
    if(N%2==0) {
        if(A[N/2]+A[N/2-1]%2==0) {
            b=(A[N/2]+A[N/2-1])/2;
        } else {
            b = A[N/2];
        }
    } else {
        b=A[N/2];
    }
    
    long long int ans=0, ans1=0;
    for(int n=0; n<N; n++) {
        ans += abs(b-A[n]);
    }
    
    cout << ans << endl;

    return 0;
    
}

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

#if __has_include("print.hpp")
#include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<ll, ll> p;

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

ll lcm(ll a, ll b)
{
  ll g = gcd(a, b);
  return a / g * b;
}

int main(){
  ll n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  ll l = lcm(n, m);
  // ll g = gcd(n, m);
  if(n < m){
    swap(s, t);
    swap(n, m);
  }

  int save = 0;
  for (int i = 0; i < n; i++) {
    int s_num = i * l / n;
    char s_c = s[i];
    for (int j = save; j < m; j++) {
      int t_num = j * l / m;
      char t_c = t[j];
      // cout << s_num << endl;
      // cout << s_c << endl;
      // cout << t_num << endl;
      // cout << t_c << endl;
      if(s_num == t_num && s_c != t_c){
        cout << -1 << endl;
        return 0;
      }
      if(t_num >= s_num) {
        save = j;
        break;
      }
    }
  }

  cout << l << endl;

}


Measured memory_bytes: 512
import heapq
N, M = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for _ in range(M):
	tmp = heapq.heappop(a)
	heapq.heappush(a, int(tmp/2))
print(-sum(a))


Measured memory_bytes: 14180
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[101];
	int sum=0;
	int min=101;
	int flag=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
		if(a[i]<=min&&a[i]%10)
		{
			min=a[i];
			flag=1;
		}
	}
	if(sum%10)
	{
		cout<<sum<<endl;
	}
	else
	{
		if(flag==0)
		{
			cout<<"0"<<endl;
		}
		else
		{
			cout<<sum-min<<endl;
		}
	}
	return 0;
}

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

int main(){
  int a, b, c, x;
  int result=0;
  cin >> a >> b >> c >> x;

  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(500*i+100*j+50*k==x) result++;
      }
    }
  }

  cout << result << endl;

  return 0;
}


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

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;
std::vector<P>v[100010];

int main() {
	ll h, w, ans = INF2;
	std::cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0) {
		std::cout << 0 << std::endl;
		exit(0);
	}
	if (h == 2 && w == 2)ans = 1;
	for (int i = 1;i < w - 1;i++) {
		ll a, b, c, max = 0, min = INF;
		a = h*i;
		b = h*((w - i) / 2);
		c = h*(w - (i + (w - i) / 2));
		max = std::max(a, std::max(b, c));
		min = std::min(a, std::min(b, c));
		ans = std::min(max - min, ans);
	}
	for (int i = 1;i < w-1;i++) {
		ll a, b, c, max = 0, min = INF;
		a = h*i;
		b = (w-i)*(h / 2);
		c = (w-i)*(h - h / 2);
		max = std::max(a, std::max(b, c));
		min = std::min(a, std::min(b, c));
		ans = std::min(max - min, ans);
	}
	for (int i = 1;i < h-1;i++) {
		ll a, b, c, max = 0, min = INF;
		a = w*i;
		b = w*((h - i) / 2);
		c = w*(h - (i + (h - i) / 2));
		max = std::max(a, std::max(b, c));
		min = std::min(a, std::min(b, c));
		ans = std::min(max - min, ans);
	}
	for (int i = 1;i < h - 1;i++) {
		ll a, b, c, max = 0, min = INF;
		a = w*i;
		b = (h-i)*(w / 2);
		c = (h-i)*(w - w / 2);
		max = std::max(a, std::max(b, c));
		min = std::min(a, std::min(b, c));
		ans = std::min(max - min, ans);
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 2560
def main():
    n = int(input())
    ans = ['']
    for i in range(1, n + 1):
        x = i
        if x % 3 == 0:
            if i not in ans:
                ans.append(i)
        else:
            while x > 0:
                if x % 10 == 3:
                    if i not in ans:
                        ans.append(i)
                x //= 10
    print(' '.join(map(str, ans)))


main()



Measured memory_bytes: 6100
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int a, b;

int main() {
  init_ios();
  cin >> a >> b;
  if (b%a == 0) {
    cout<<a+b<<"\n";
  }
  else {
    cout<<b-a<<"\n";
  }
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <string.h>  
#include <stdlib.h>  
#include <iostream>  
#include <algorithm>  
#include <time.h>  
#include<cstdio>
#include<vector>
#include<functional>


using namespace std;

int main() {
	int r,g,b;
	scanf("%d%d%d", &r, &g, &b);
	int num = 100 * r + 10 * g + b;
	if (num % 4 == 0)printf("YES");
	else
		printf("NO");
	return 0;
}

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

int n, k, m, r;
int a[10005];

void inverse( int n )
{
	int m = 1;

	for( int i = 0; i < 10005; i++ )
	{
		a[i] += m / n;
		m %= n;
		m *= 10;
	}

	for( int i = 10004; i >= 0; i-- )
	{
		a[i-1] += a[i] / 10;
		a[i] %= 10;
	}

	return;
}

void show( int r )
{
	for( int i = 0; i <= r; i++ )
	{
		if( !i )
			std::cout << a[i] << ".";
		else
			std::cout << a[i];
	}

	std::cout << std::endl;

	return;
}

int main()
{
	while( std::cin >> n >> k >> m >> r, n + k + m + r )
	{
		memset( a, 0, sizeof( a ) );

		inverse( n );
	
		if( m )
			for( int i = 1; i < n; i++ )
				inverse( i * n );

		show( r );
	}

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6


 
int main(){
	fast;
	int a, b, c;
	cin>>a>>b>>c;
	if((a==b && b!=c) || (a==c && b!=c) || (c==b && b!=a)) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        String odd = "RUD";
        String even = "LUD";
        boolean rslt = true;

        for (int i = 1; i <= s.length(); i++) {
            if (i%2==0) {
                if (!even.contains(s.substring(i-1, i))) {
                    rslt = false;
                    break;
                }
            } else {
                if (!odd.contains(s.substring(i-1, i))) {
                    rslt = false;
                    break;
                }
            }
        }
        System.out.println(rslt? "Yes": "No");
    }
}

Measured memory_bytes: 23892
N = int(input())

x = N // 3
y = N // 5
z = N // 15

p = N * (N + 1) / 2
q = 3 * x * (x + 1) / 2
r = 5 * y * (y + 1) / 2
s = 15 * z * (z + 1) / 2
Sum = p - q - r + s
print(int(Sum))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    int h, w; cin >> h >> w;
    vector<string> field(h);
    for(auto& e : field) cin >> e, e.push_back('.');
    field.push_back(string(w + 1, '.'));
    int sum = 0;
    rep(y, h) rep(x, w) if(field[y][x] == '#') sum++;

    int x, y;
    x = y = 0;

    int cnt = 0;
    while(1){
        field[y][x] = '.';
        cnt++;

        if(field[y][x + 1] == '#') x++;
        else if(field[y + 1][x] == '#') y++;
        else break;
    }

    cout << (cnt == sum ? "Possible":"Impossible") << endl;

    return 0;
}


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

int main(){
    string ans = "AKIHABARA";
    string s;
    cin >> s;
    if (s.size() > 9){
        cout << "NO" << endl;
        return 0;
    }
    int now = 0;
    for (int i = 0; i < ans.size(); i++){
        if (i - now > s.size()){
            cout << "NO" << endl;
            return 0;
        }
        if (i - now == s.size() || s[i - now] != ans[i]){
            if (ans[i] == 'A') now++;
            else {
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    if (s.size() + now != 9) cout << "NO" << endl;
    else cout << "YES" << endl;
}

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

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a + 2), t(b + 2), x(q), invs(a + 2), invt(b + 2);
    s[0] = t[0] = invs[0] = invt[0] = -infl;
    s[a + 1] = t[b + 1] = invs[a + 1] = invt[b + 1] = infl;
    for (int i = 1; i <= a; ++i) {
        cin >> s[i];
        invs[a - i + 1] = -s[i];
    }
    for (int i = 1; i <= b; ++i) {
        cin >> t[i];
        invt[b - i + 1] = -t[i];
    }
    for (int i = 0; i < q; ++i) {
        cin >> x[i];
    }

    for (ll query : x) {
        ll ans = inf;
        auto slb = lower_bound(s.begin(), s.end(), query);
        auto tlb = lower_bound(t.begin(), t.end(), query);
        auto sub = lower_bound(s.rbegin(), s.rend(), query, greater<ll>());
        auto tub = lower_bound(t.rbegin(), t.rend(), query, greater<ll>());

        ans = min({abs(*slb - query) + min(abs(*tlb - *slb), abs(*tub - *slb)),
                   abs(*sub - query) + min(abs(*tlb - *sub), abs(*tub - *sub)),
                   abs(*tlb - query) + min(abs(*slb - *tlb), abs(*sub - *tlb)),
                   abs(*tub - query) + min(abs(*slb - *tub), abs(*sub - *tub))});

        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec b(N); readv(b);

    vec ans(N);
    //bool f = true;
    IREP(i, N){
        int i0 = -1;
        REP(j, N) if(b[j] == j + 1){
            i0 = j;
        }
        if(i0 == -1){
            cout << -1 << endl;
            return 0;
        }
        ans[i] = i0;
        FOR(j, i0, N - 1) b[j] = b[j + 1];
        b[N - 1] = -1;
    }
    REP(i, N) cout << ans[i] + 1 << endl;

    return 0;
}


Measured memory_bytes: 256