akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(unused_variables)]

use proconio::input;
use std::cmp::{max, min};

fn main() {
  input! {
    n: i32,
  }
  let mut x = 1;
  while x <= n {
    let rest = x * 8 / 100;
    if x + rest == n {
      println!("{}", x);
      return;
    }
    x += 1;
  }
  println!(":(");
}


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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    for(int i=0;i<n;i++){
        cin>>b.at(i);
    }
    for(int i=0;i<n-1;i++){
        cin>>c.at(i);
    }
    int ans=0;
    
    ans=b.at(a.at(0)-1);
    
    for(int i=1;i<n;i++){
        ans+=b.at(a.at(i)-1);
        if(a.at(i)-1==a.at(i-1)){
            ans+=c.at(a.at(i-1)-1);
        }
        
        //cout<<ans<<endl;
        
    }
    cout<<ans<<endl;
}

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

using namespace std;

class Solution {
public:
	/* time: O(n), space: O(1), where n = |S| */
	bool tapDance(const string& s) {
		const int n = s.size();
		for (int i = 1; i <= n; ++i) {
			const char c = s[i - 1];
			if (i % 2) {
				if (c == 'L')
					return false;
			} else {
				if (c == 'R')
					return false;
			}
		}
		return true;
	}
};

int main() {
	string s;
	cin >> s;

	Solution sol;
	bool ans = sol.tapDance(s);
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
X, Y = map(int, input().split())

B = (Y / 2) - X
A = X - B

if(not B.is_integer()):
    print("No")
    exit()
if(B < 0):
    print("No")
    exit()
if(A < 0):
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 9184
n=int(input())
a=list(map(int,input().split()))
count=0
for i in range(n):
  if a[i]%2==0:
    j=1
    while True:
      if a[i]%(2**j)==0:
        j+=1
      else:
        count+=j-1
        break
print(count)

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

using namespace std;

#define int long long
 
const int    mod = 1e9 + 7;

vector<int> d, f;
int n, k;

int qpow(int a,int exp) {
	int ans = 1;
	while(exp)  {
		if(exp & 1) ans = ans * a % mod;
		a = a * a % mod;  exp >>= 1;
	}
	return ans;
}
 
signed main()   {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	cin >> n >> k;
	
	for(int i = 1 ; i * i <= n ; ++i) 
		if (n % i == 0) {
			d.push_back(i);
			if (i < (n / i)) 
				d.push_back(n / i);	
		}
	sort(d.begin(),d.end());
	
	f.resize(d.size());
	
	int ans = 0;
	
	for(int i = 0 ; i < d.size() ; ++i) {
		f[i] = qpow(k,(d[i] + 1) / 2);
		for(int j = 0 ; j < i ; ++j)
			if(d[i] % d[j] == 0)
				f[i] = (f[i] - f[j] + mod) % mod;
		ans = (ans + f[i] * (d[i] & 1 ? d[i] : d[i] / 2)) % mod;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int sum(int n)
{
    int ret = 0;
    while (n)
    {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}
int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, a, b;
    while (cin >> n >> a >> b)
    {
        int ans = 0;
        for (int i = 1; i <= n; i++)
        {
            int s = sum(i);
            if (a <= s && s <= b)
                ans += i;
        }
        cout << ans << '\n';
    }
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, x;
	cin >> a >> b >> x;
	if (a > x)cout << x % MOD << endl;
	else cout << (((x - a) / (a - b) % MOD + 1)*(a%MOD) % MOD + b % MOD + (x - a) % (a - b) % MOD) % MOD << endl;

}


Measured memory_bytes: 3184
s = gets.chomp

head_is_A = s[0] == 'A'
include_C = s[2..-2].split('').count('C') == 1
other_is_lower = s.split('').count{|x| x =~ /[A-Z]/} == 2

if head_is_A && include_C && other_is_lower
  puts "AC"
else
  puts "WA"
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)

#define vi vector<int>
#define pb push_back

typedef long long ll;
using namespace std;



int main(){
    int n;
    while(cin >> n,n) {
        int tmp;
        vi a;
        rep(i,n){
            cin >> tmp;
            a.pb(tmp);
        }
        sort(a.begin(),a.end());
        int mn = a[1] - a[0];
        rep(i,n - 1) mn = min(mn,a[i + 1] - a[i]);
        cout << mn << endl;
    }
    return 0;
}



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

const int INF = 2e9;

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

Measured memory_bytes: 3924
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<queue>
using namespace std;
typedef long double ld;
typedef long long int ll;
const ll INF = (1LL << 63);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0; i < n;i++)
const int MAX = 1000000010;
const ll MOD = 1000000007;
int n, m,k,sum = 0,l; string s;
int main() {
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        if (i == 0 || i == n - 1) continue;
        if (a[i] != max(a[i], max(a[i + 1], a[i - 1])) && a[i] != min(a[i], min(a[i - 1], a[i + 1]))) sum++;
    }cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int>   PI;
typedef vector<int> VI;
typedef long long int LL;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    char o='0',f='1';
    string ans="";
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='0')
        ans=ans+o;
        else  if(s[i]=='1')
        ans=ans+f;
        else
        {
            string r="";
            if(ans.size()>0)
            {
            for(int i=0;i<ans.size()-1;i++)
            {
                r=r+ans[i];
            }
            }
            ans=r;
        }
    }
    
    cout<<ans;
	return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#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))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;
  ll n = s.size();

  vvll dp(2, vll(2019, 0));
  ll ans = 0;
  rep(i, n) {
    ll now = s[i] - '0';
    ans += dp[i%2][(2019 - now)%2019];
    rep(j, 2019) { 
      dp[(i+1)%2][10*(now + j) % 2019] = dp[i%2][j];
      //if (dp[i][j] > 0) printf("add %lld at %lld\n", dp[i][j], j);
    }
    dp[(i+1)%2][10*now] += 1;
    //cout << "i=" << i << endl;
    //rep(kk, 2019) cout << kk << ":"<< dp[i+1][kk] << endl;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;

int main() {
    cin >> n;
    Vi s(n);
    REP(i, n) cin >> s[i];

    sort(ALL(s));

    int sum = 0;
    REP(i, n) sum += s[i];
    if (sum%10 != 0) {
        cout << sum << '\n';
        return 0;
    }
    REP(i, n) {
        if (s[i]%10 != 0) {
            cout << sum-s[i] << '\n';
            return 0;
        }
    }
    cout << 0 << '\n';

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i

def checker(n)
  a = n/4
  b = n/7
  (0..a).each do |a|
    (0..b).each do |b|
      if n == (a*4) + (b*7)
        return true
        break
      end
    end
  end
  return false
end

puts checker(n) ? "Yes" : "No"

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector a(n, 0L);
    for (auto&& aa : a) {
        cin >> aa;
    }

    for (auto i : irange(0L, k)) {
        vector b(n, 0L);

        priority_queue<int64_t> q;
        for (auto j : irange(0L, n)) {
            q.push(-(j + a[j]));
            b[j] += q.size();
            while (!q.empty() && -q.top() == j) {
                q.pop();
            }
        }
        q = decltype(q)();
        for (auto j : irange(0L, n) | reversed) {
            b[j] += q.size();
            q.push(j - a[j]);
            while (!q.empty() && q.top() == j) {
                q.pop();
            }
        }

        if (a == b) {
            break;
        }

        a = std::move(b);
    }

    const auto* delim = "";
    for (auto aa : a) {
        cout << delim << aa;
        delim = " ";
    }
    cout << endl;
}

Measured memory_bytes: 10036
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] str = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();//2つ以上のスペース区切り入力の取得
        Print(str);
        for(int i = 1; i < n; i++)
        {
            int key = str[i];
            int j = i - 1;
            while(j >= 0 && str[j] > key)
            {
                str[j+1] = str[j];
                j--;
            }
            str[j+1] = key;
            Print(str);
        }
    }

    public static void Print(IEnumerable<int> collection)
    {
        Console.WriteLine(string.Join(" ", collection.Select(i => i.ToString()).ToArray()));
    }
}


Measured memory_bytes: 9744
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	x := a * b
	y := c * d
	var res int
	if x > y {
		res = x
	} else {
		res = y
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
let solve h w c =
  let v0 = Array.make w 0 in
  let v1 = Array.make w 0 in
  let r = ref 0 in
  for i = 0 to h - 1 do if c.(i).(0) = 0 then r := 1 done;
  for j = 0 to w - 1 do if c.(0).(j) = 0 then begin v0.(j) <- 1; r := 1 end done;
  for i = 1 to h - 1 do
    if c.(i).(0) = 0 then v1.(0) <- 1;
    for j = 1 to w - 1 do
      if c.(i).(j) = 1 then v1.(j) <- 0
      else begin
        let t = if v0.(j) < v1.(j-1) then v0.(j) else v1.(j-1) in
        v1.(j) <- if v0.(j-1) < t then v0.(j-1) + 1 else t + 1;
        r := if v1.(j) > !r then v1.(j) else !r;
      end
    done;
    Array.iteri (fun i e -> v0.(i) <- e) v1
  done;
  !r * !r

let () =
  let (h, w) = Scanf.scanf "%d %d\n" (fun h w -> (h, w)) in
  let c = Array.make_matrix h w 0 in
  let rec read = function
    | (i, _) when i = h -> ()
    | (i, j) when j = w -> read (i + 1, 0)
    | (i, j) ->
      c.(i).(j) <- Scanf.scanf "%d " (fun i -> i);
      read (i, j + 1) in
  read (0, 0);
  Printf.printf "%d\n" (solve h w c)

Measured memory_bytes: 20132
N = int(input())
L = [list(map(int, input().split())) for i in range(N)]
c = 0
H = 0
for i in range(101):
    for j in range(101):
        c = 0
        for k in range(N):
            #print(i,j,max(H - abs(L[k][0] - i) - abs(L[k][1] - j), 0))
            if L[k][2] != 0:
                H = L[k][2] + abs(L[k][0] - i) + abs(L[k][1] - j)
                break
        for k in range(N):
            #print(i,j,k)
            if max(H - abs(L[k][0] - i) - abs(L[k][1] - j), 0) != L[k][2]:
                c = 1
                break
        if c == 0:
            print(i, j, H)
            exit()
print(L)


Measured memory_bytes: 3064
/* Focus your enery towards light */

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define ford(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define inf 1e18

/******************************************************************************************************/
void file() {
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
}
/******************************************************************************************************/

// const ll nax = 2e5 + 1;
// const ll mod = 1e9 + 7;



int main() {

    sync

    int testCases = 1;
    // cin >> testCases;

    while (testCases--) {
        ll n, m, k;
        cin >> n >> m >> k;
        int ans = 0;
        vector<ll> a(n + 1), b(m + 1);
        fore (i, 1, n) {
            cin >> a[i];
            a[i] += a[i - 1];
        }
        fore (i, 1, m) {
            cin >> b[i];
            b[i] += b[i - 1];
        }
        fore(i, 0, n) {
            ll temp = a[i];
            if (temp > k) break;
            temp = k - temp;
            int lel = upper_bound(all(b), temp) - b.begin() - 1;
            ans = max(ans, i + lel);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 6336
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

ans =[]
#O(N^2)
#スタート地点
for i in range(N-1):
    t = S[i]
    #乗り換え地点
    for j in range(i,N-1):
        if t >= S[j]:
            pass
        else:
            t = S[j]
        if t % F[j] == 0:
            t += C[j]
        else:

            b = t % F[j]
            t += F[j] - b
            t += C[j]
    ans.append(t)

ans.append(0)
for i in range(N):
    print(ans[i])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const double PI  = acos(-1.0);
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{

    string S;
    cin >> S;
    int l = S.size();
    if (S[l-1] == 's'){
        cout << S + "es";
    } else {
        cout << S + "s";
    }
    return 0;
}



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

const int N = 2000 + 5;
const int M = 2000 + 5;

char g[N][M];

struct Data {
    int l, r, u, d;

    Data () {}
} stat[N][M];

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> g[i][j];
        }
    }   
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            stat[i][j].l = (g[i][j] == '#' ? 0 : stat[i][j - 1].l + 1);
        }
    }
    for (int i = n; i >= 1; i--) {
        for (int j = m; j >= 1; j--) {
            stat[i][j].r = (g[i][j] == '#' ? 0 : stat[i][j + 1].r + 1);
        }
    }
    for (int j = 1; j <= m; j++) {
        for (int i = 1; i <= n; i++) {
            stat[i][j].u = (g[i][j] == '#' ? 0 : stat[i - 1][j].u + 1);
        }
    }
    for (int j = m; j >= 1; j--) {
        for (int i = n; i >= 1; i--) {
            stat[i][j].d = (g[i][j] == '#' ? 0 : stat[i + 1][j].d + 1);
        }
    }
    int mx = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            int lit = stat[i][j].l + stat[i][j].r + stat[i][j].u + stat[i][j].d - 4 + 1;
            mx = max(mx, lit);
        }
    }
    cout << mx << '\n';
}

Measured memory_bytes: 66944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main() {
    int c[3][3];
    int a[3], b[3];

    for(int i=0; i<3; i++) for(int j=0; j<3; j++) cin >> c[i][j];
    a[0] = 0;
    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            if(a[i] + b[j] != c[i][j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3632
program main
integer :: N, i, j
integer,allocatable :: a(:), b(:), ans(:)
read(*, *)N
allocate(a(N))
allocate(ans(N))
read(*, *)a

do i = N, 1, -1
    do j = i, 1, -1
        if (a(j) == j)then
            ans(i) = j
            exit
        endif
    enddo
    if(j == 0)then
        write(*, '(i0)') -1
        stop
    endif
    b = [a(1:j - 1), a(j + 1: i)]
    a = b
enddo

write(*, '(*(i0, :, /))') ans


end program main

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s,t;
  ll a,b,c,d=0,i,k=0;
    cin>>a;
for(i=1;i<=a;i++)
{
cin>>b;d=max(d,b);
    k+=b;}
k-=d;
k+=(d/2);
cout<<k<<endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    H = list(map(int, input().split()))

    dp = [0 for _ in range(N)]

    for i in range(N):
        if i == 0:
            dp[i] = 0
        elif i == 1:
            dp[i] = abs(H[0] - H[1])
        else:
            dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 13924
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

move :: [Int] -> Bool
move [t, x, y] = abs x + abs y <= t && (x + y) `mod` 2 == t `mod` 2
move _ = False

main :: IO ()
main = do
    n <- fst . fromJust . B.readInt <$> B.getLine
    route <- replicateM n $ map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    putStrLn $ if all move (scanl (\[t, x, y] [tn, xn, yn] -> [tn - t, xn - x, yn - y]) [0, 0, 0] route)
                then "Yes"
                else "No"


Measured memory_bytes: 28028
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 7;
string lst[Max];

int main()
{
	map<char, int> ma;
	string str;
	cin >> str;
	int f = 0;
	for (int i = 0; i <= str.size() - 1; i++)
	{
		if (ma[str[i]])
		{
			f = 1; break;
		}
		ma[str[i]]++;
	}
	if (f)cout << "no";
	else cout << "yes";
}

Measured memory_bytes: 5348
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define MOD 1e9+7;
using namespace std;
using Graph = vector<vector<int>>;
typedef vector<vector<char>> field_t;
typedef  unsigned long long int ull;
typedef pair<int, int> point_t;
typedef long long ll;
ll N,Q;
ll chr[100001];




signed main()
{
    cin >> N;
    vector<ll> a(N);
    ll sum=0;
    rep(i,N){
        cin >> a[i];
        sum+=a[i];
        chr[a[i]]++;
    }
    cin >>Q;
    rep(i,Q){
        ll b,c;
        cin >> b >> c;
        ll det=c-b;
        if(chr[b]>0){
            sum+=det*chr[b];
            chr[c]+=chr[b];
            chr[b]=0;
        }
        cout << sum <<endl;
    }
    return 0;
}

Measured memory_bytes: 4732
n = int(input())
a = list(map(int, input().split()))
a = [0] + a
l = [0]*(n + 1)

for i in range(n, 0, -1):
    if i > 0 - -n//2:
        l[i] = a[i]
    else:
        if a[i] != sum(l[i::i])%2:
            l[i] = 1

print(l.count(1))

for i in range(1, n + 1):
    if l[i] == 1:
        print(i)

Measured memory_bytes: 13752
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
ll cnt[10];
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cnt[a]++;
	cnt[b]++;
	cnt[c]++;
	cnt[d]++;
	if(cnt[1]==1 && cnt[7]==1 && cnt[9]==1 && cnt[4]==1){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    #a,b=list(map(int,input().split()))
    a,op,b=input().split()
    while op!="?":
        if op=="/":op="//"
        print(eval(a+op+b))
        a, op, b = input().split()

main()



Measured memory_bytes: 5572
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const char newl = 10;
const string sep = "\n_____\n";
const ll MOD = 1000000007; // 998244353
const int maxN = 1000005;
const double PI = atan(1.0)*4;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void run(){
   int r;
   cin >> r;
   cout << setprecision(10) << fixed << 2*r*PI;
}
int main(){
   ios_base::sync_with_stdio(0);cin.tie(0);
   cout.tie(0);
   // stress(); return 0;
   int t = 1;
   // cin >> t;
   for (int tc = 1; tc <= t; tc++) {
      // cout << "Case #" << tc << ": ";
      run();
      cout << newl;
   }
   return 0;
}


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define Fi(n) for(int i=0;i<n;++i)
#define Fj(n) for(int j=0;j<n;++j)
const int MOD=1e9+7;

void wf(vector<vector<int> > &dist, int n){
  for(int k=0; k<n; k++){
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  return;
}

int main(){
    long h,w;
    const int sz=10;
    vector<vector<int> > c(sz,vector<int>(sz));
    cin >> h >> w;
    Fi(sz) Fj(sz) cin >> c[i][j];
    wf(c,sz);
    long long sum=0;
    Fi(h){
        Fj(w){
            int a;
            cin >> a;
            if(a>=0) sum += c[a][1];
        }
    }
    cout << sum << endl;
    return 0;
}

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

void input(int& rnNum, int& rnTrg, vector<int>& rvnCandls)
{
  cin >> rnNum >> rnTrg;
  rvnCandls.resize(rnNum);

  for (int& rnCandls : rvnCandls)
    cin >> rnCandls;
}

int calcMinPutonTime(int nNum, int nTrg, const vector<int>& cnrvnCandls)
{
  int nMinPutonTime = INT_MAX;
  int nBgn = 0;
  int nEnd = nBgn + nTrg - 1;

  while ( nBgn < nNum &&
          nEnd < nNum    )
  {
    int nPutonTime =  min( abs(cnrvnCandls[nBgn]), abs(cnrvnCandls[nEnd]) )
                    + cnrvnCandls[nEnd] - cnrvnCandls[nBgn];
    nMinPutonTime = min(nMinPutonTime, nPutonTime);

    ++nBgn;
    ++nEnd;
  }
  return nMinPutonTime;
}
 
int main()
{
  int nNum, nTrg;
  vector<int> vnCandls;

  input(nNum, nTrg, vnCandls);
  cout << calcMinPutonTime(nNum, nTrg, vnCandls) << endl;

  return 0;
}

Measured memory_bytes: 3700
#include<stdio.h>

int main(void){
	double n;
	
	while(scanf("%lf",&n)!=EOF){
		if(n<=48.00)printf("light fly\n");
		else if(n<=51.00)printf("fly\n");
		else if(n<=54.00)printf("bantam\n");
		else if(n<=57.00)printf("feather\n");
		else if(n<=60.00)printf("light\n");
		else if(n<=64.00)printf("light welter\n");
		else if(n<=69.00)printf("welter\n");
		else if(n<=75.00)printf("light middle\n");
		else if(n<=81.00)printf("middle\n");
		else if(n<=91.00)printf("light heavy\n");
		else printf("heavy\n");
	}
	
	return 0;
}

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

int main()
{
    long long s = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i%3 == 0 || i%5 == 0) continue;
        s += i;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cmath>
#include <array>
#include <vector>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
	string s;
	cin >> s;
	if ((s.at(0) == s.at(1)) && (s.at(1) == s.at(2)))
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n,p;
	int stone[50];
	while(scanf("%d %d",&n,&p),n) {
		for(int i=0;i<n;i++) stone[i]=0;
		int k=0,x=p;
		while(stone[k]<p) {
			if(x>0) {
				x--;
				stone[k]++;
			}else {
				x+=stone[k];
				stone[k]=0;
			}
			k=(k+1)%n;
		}
		printf("%d\n",k);
	}
}

Measured memory_bytes: 1028
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 1e16;
const string sp = " ";
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = max(a, b);
		return true;
	}
	return false;
}
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = min(a, b);
		return true;
	}
	return false;
}

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

int n,p;
string s;
signed main() {
	cin>>s;
	n=s.size();
	rep(i,n) {
		if(s[i]=='p') p++;
	}
	cout<<n/2-p<<endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        for(int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '0') {
                count++;
            }
        }
        System.out.println(Math.min(s.length() - count, count) * 2);
    }
}


Measured memory_bytes: 24648
using System;

namespace CS_Repo
{
    class Program1
    {
        static void Main(string [] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sum = 0;
            int temp;
            Calculate cal = new Calculate();
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    for (int k = 1; k <= n; k++)
                    {
                        temp = cal.gcd(j,k);
                        sum = sum + cal.gcd(i,temp);
                    }
                }
            }
            Console.WriteLine(sum);
        }
        
    }
    class Calculate
    {
        public int gcd(int a, int b)
        {
            if(a%b == 0) return b;
            return gcd(b, a%b);
        }
    }
}

Measured memory_bytes: 27524
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

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

int main()
{
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll as = a%c;
	ll bs = a%d;
	ll A = b-a+1;
	ll C = A-(c-a%c==c?0:c-a%c);
	C = (C+c-1)/c;
	
	ll D = A-(d-a%d==d?0:d-a%d);
	D = (D+d-1)/d;
	//cout<<D<<endl;
	ll lcm = d/gcd(d,c)*c;
	ll LCM = A-(lcm-a%lcm==lcm?0:lcm-a%lcm);
	//cout<<LCM<<endl;
	LCM = (LCM+lcm-1)/lcm;
	//cout<<LCM<<endl;
	cout<<A-C-D+LCM<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int A[100000];
int partition(int p, int r){
    int i,j,t,x;
    x = A[r];
    i = p-1;
    for(j = p; j < r; j++){
        if(A[j] <= x){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;
    return i+1;
}
 
int main(){
    int n, i, q;
     
    scanf("%d",&n);
    for(i = 0; i < n; i++) scanf("%d",&A[i]);
    q = partition(0, n-1);
    for(i = 0; i < n; i++){
        if(i == q) printf("[");
        printf("%d",A[i]);
        if(i == q) printf("]");
        if(i != n-1) printf(" ");
    }
    printf("\n");
     
    return 0;
}

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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  double diff = 1000.0;
  int ans;

  for (int i=0 ; i<N ; i++) {
    int H;
    cin >> H;
    if (diff > abs(T - H*0.006 - A)) {
      ans = i + 1;
      diff = abs(T - H*0.006 - A);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int N = NextInt();
        int[] T = LineInt();
        int[] A = LineInt();
        int[] M = new int[N];
        M[0] = T[0];
        M[N - 1] = A[N - 1];
        for (int i = 1; i < N; i++)
            if (T[i - 1] != T[i])
                M[i] = T[i];
        for (int i = 0; i < N - 1; i++)
            if (A[i] != A[i + 1])
            {
                if (M[i] != 0 && M[i] != A[i]) { Console.WriteLine(0); return; }
                else M[i] = A[i];
            }
        if(N == 1 && A[0] != T[0]) { Console.WriteLine(0); return; }
        //0の場所に何を入れるかによってかわる
        long ans = 1;
        for (int i = 0; i < N; i++)
        {
            if (M[i] != 0)
            {
                if (T[i] < M[i] || A[i] < M[i]) { Console.WriteLine(0); return; }
                continue;
            }
            ans *= Math.Min(A[i], T[i]);
            ans %= INF;
        }
        //M.ToList().ForEach(v => Console.Write(v + " "));
        //Console.WriteLine();
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>constexpr bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>constexpr bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
//GCD(a, b)==GCD(b, a%b)らしいので調べる
//ABC131Cでバグった.人によってはこれでも通るけど
//constexpr int GCD(int a, int b){return b ? GCD(b, a%b) : a;}
//constexpr int LCM(int a, int b){return a / GCD(a, b) * b;}

// auto mlcm=[](int p,int q){return p/__gcd(p,q)*q;};使う
//__detail::__lcm(p,q);もあり

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int INF = 1001001001;
constexpr long long LINF = 1001001001001001001ll;//Don't use int64_t
constexpr int MOD = 1e9 + 7; //10^9
constexpr int EPS = 1e-9;
constexpr int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



#define int long long
signed main()
{
    int a,b,c,d; cin >> a >>b >> c >> d;
    auto mlcm=[](int p,int q){return p/__gcd(p,q)*q;};
    int e = mlcm(c,d);
    a--;
    auto f = [&](int x){return b/x-a/x;};
    cout << b-a-f(c)-f(d)+f(e);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def is_enough(n: int, d: int, B: int, h: "List[int]"):
    count = 0
    for hi in h:
        rest = hi - B * n
        if rest <= 0:
            break
        count += (rest + d - 1) // d
        if count > n:
            return False
    return n >= count


def solve(N: int, A: int, B: int, h: "List[int]"):
    h.sort(reverse=True)
    d = A - B

    right = (h[0] + B - 1) // B
    left = (h[0] - 1) // A
    
    while right - left > 1:
        mid = left + (right - left) // 2
        if is_enough(mid, d, B, h):
            right = mid
        else:
            left = mid
    
    print(right)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, B, h)

if __name__ == '__main__':
    main()


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

vector<int> depth(1e5, -1);
vector<vector<int>> G(1e5);

int depthG(int n) {
  if (depth[n] != -1) return depth[n];

  int ans = 0;
  for (auto& y : G[n])
  {
    ans = max(ans, depthG(y) + 1);
  }
  return depth[n] = ans;
}

int main() {
  int N, M; cin >> N >> M;
  vector<int> dp(N, 0);

  for (int i = 0; i < M; i++)
  {
    int x, y; cin >> x >> y;
    x--; y--;
    G[x].push_back(y);
  }

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    ans = max(ans, depthG(i));
  }
  cout << ans << endl;
}

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

int main(){
  int n,T;
  cin >> n >> T;
  vector<pair<int,int>> vtc(n,pair<int,int>(0,0));
  for(auto& tc : vtc)
    cin >> tc.first >> tc.second;
  sort(vtc.begin(),vtc.end());
  int ans = 0;
  for(auto& tc:vtc){
    if(tc.second <= T){
      ans = tc.first;
      cout << ans << endl;
      break;
    }
  }
  if(ans==0)
    cout << "TLE" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

ll ans = 0;
int n, m, q;
struct p{
  int a;
  int b;
  int c;
  int d;
};

vector<p> pa;

int f(vector<int> a,int idx) {
  if(idx==n){
    ll sum = 0;
    for (int i = 0; i < q; i++) {
      if(a[pa[i].b-1]-a[pa[i].a-1]==pa[i].c){
        //cout << "!" << endl;
        sum += pa[i].d;
      }
    }
    ans = max(ans, sum);
    return 0;
  }
  for (int i = a[idx - 1]; i <= m;i++){
    a[idx] = i;
    f(a, idx + 1);
  }

  return 0;
}



int main() {
  
  cin >> n >> m >> q;
  pa.resize(q);
  for (int i = 0; i < q; i++) {
    cin >> pa[i].a >> pa[i].b >> pa[i].c >> pa[i].d;
  }
  vector<int> a(n,0);
  for (int i = 1; i <= m;i++){
    a[0] = i;
    f(a, 1);
  }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
a.sort()

cnt = 1; ans = 0
for i in range(1, n):
    if a[i] == a[i-1]:
        cnt ^= 1
    else:
        ans += cnt
        cnt = 1
ans += cnt
print(ans)

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

int main()
{
	string s;
  cin >> s ;
	
  if( s.substr(s.size()-1,1) == "s" ){
    s.append("es");
  }
  else{
    s.append("s");
  }
  
  cout << s << endl;

  return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    ll ans=0;
    ll n;cin>>n;
    FOR(i,1,n){
        if (i%3!=0 && i%5!=0) ans+= i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;  //このネームスペースを使う

int main(){
  int a,b;
  int i,d,x;
  cin >> a >> b ;
  
  d=b-a;

  for(i=1;i<d;i++){
    x+=i;
  }

  cout << x-a << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

int P[110000];
int Q[110000];
vector<int>mul(vector<int>a,vector<int>b){
	int n=a.size();
	vector<int>ret(n);
	for(int i=0;i<n;i++){
		ret[i]=a[b[i]];
	}
	return ret;
}
vector<int>pw(vector<int>a,int b){
	int n=a.size();
	vector<int>ret(n);
	for(int i=0;i<n;i++)ret[i]=i;
	while(b){
		if(b%2){
			vector<int>tmp(n);
			for(int i=0;i<n;i++){
				tmp[i]=ret[a[i]];
			}
			ret=tmp;
		}
		b/=2;
		vector<int>tmp(n);
		for(int i=0;i<n;i++){
			tmp[i]=a[a[i]];
		}
		a=tmp;
	}
	return ret;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",P+i);P[i]--;
	}
	for(int i=0;i<a;i++){
		scanf("%d",Q+i);Q[i]--;
	}
	vector<int>p(a);
	vector<int>q(a);
	vector<int>pi(a);
	vector<int>qi(a);
	for(int i=0;i<a;i++){
		p[i]=P[i];
		q[i]=Q[i];
		pi[P[i]]=i;
		qi[Q[i]]=i;
	}
	if(b==1){
		for(int i=0;i<a;i++){
			printf("%d ",P[i]+1);
		}printf("\n");
		return 0;
	}else if(b==2){
		for(int i=0;i<a;i++){
			printf("%d ",Q[i]+1);
		}printf("\n");
		return 0;
	}
	int Llen=b/3*2;
	if(b%3==2)Llen++;
	int Rlen=b/3*2-2;
	Rlen+=b%3;
	vector<int>L(a);
	vector<int>R(a);
	for(int i=0;i<a;i++){
		L[i]=R[i]=i;
	}
	vector<int>cycle=mul(mul(pi,q),mul(p,qi));
	vector<int>Lcycle=mul(mul(q,pi),mul(qi,p));
	
	R=pw(cycle,Rlen/4);
	if(Rlen%4>0)R=mul(qi,R);
	if(Rlen%4>1)R=mul(p,R);
	if(Rlen%4>2)R=mul(q,R);
	L=pw(Lcycle,Llen/4);
	if(Llen%4>0)L=mul(L,q);
	if(Llen%4>1)L=mul(L,pi);
	if(Llen%4>2)L=mul(L,qi);
	
	vector<int>ret=mul(L,R);
	for(int i=0;i<a;i++)printf("%d ",ret[i]+1);printf("\n");
}

Measured memory_bytes: 6480
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define inf 1<<30
#define il inline 
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;

#define N 100010
#define lowbit(x) x&-x
int c[N*10];
int n,a[N],s[N*10];
void add(int x){
    for(int i=x;i<=2*N;i+=lowbit(i))c[i]++;
}
ll query(int x){
    ll sum=0;
    for(int i=x;i>0;i-=lowbit(i))sum+=c[i];
    return sum;
}
bool check(int x){
    for(int i=1;i<=2*N;i++)c[i]=0;
    s[0]=0;
    for(int i=1;i<=n;i++)
        s[i]=s[i-1]+(a[i]>=x?1:-1);
    ll sum=0;
    for(int i=0;i<=n;i++){
        sum+=query(s[i]+N);
        add(s[i]+N);
    }
    return sum>=1ll*n*(n+1)/4;
}
int main(){
    read(n);
    int l=0,r=0;
    for(int i=1;i<=n;i++){
        read(a[i]);
        r=max(r,a[i]);
    }
    int ans=0;
    while(l<=r){
        int mid=(l+r)>>1;
        if(check(mid)) l=mid+1;
        else r=mid-1;
    }
    printf("%d\n",r);
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

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

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 2003;

int a[MAX_N][MAX_N],node[MAX_N][MAX_N],edgex[MAX_N][MAX_N],edgey[MAX_N][MAX_N];
string S[MAX_N];

int main(){
  int N,M,Q; cin >> N >> M >> Q ;
  fill(node[0],node[MAX_N-1],0);
  fill(edgex[0],edgex[MAX_N-1],0);
  fill(edgey[0],edgey[MAX_N-1],0);
  rep(i,N) cin >> S[i];
  rep(i,N) rep(j,M) a[i+1][j+1] = int(S[i][j]=='1');
  REP(i,1,N+1) REP(j,1,M+1) node[i][j] = a[i][j] + node[i-1][j] + node[i][j-1] - node[i-1][j-1];
  REP(i,1,N+1) REP(j,1,M+1){
    edgex[i][j] = (a[i][j]&a[i-1][j]) + edgex[i-1][j] + edgex[i][j-1] - edgex[i-1][j-1];
    edgey[i][j] = (a[i][j]&a[i][j-1]) + edgey[i-1][j] + edgey[i][j-1] - edgey[i-1][j-1];
  }
  // rep(i,N+1){
  //   rep(j,M+1) cout << edge[i][j] << " ";
  //   cout << "" << endl;
  // }
  rep(i,Q){
    int x1,y1,x2,y2;
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    int n = node[x2][y2] - node[x1-1][y2] - node[x2][y1-1] + node[x1-1][y1-1];
    int ex = edgex[x2][y2] - edgex[x1][y2] - edgex[x2][y1-1] + edgex[x1][y1-1];
    int ey = edgey[x2][y2] - edgey[x1-1][y2] - edgey[x2][y1] + edgey[x1-1][y1];
    // cout << n << " "<< ex << " " << ey << endl;
    cout << n - (ex + ey) << endl;
  }
  return 0;
}

Measured memory_bytes: 68608