akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <queue>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
using namespace std;

int main()
{
    const int INF = 10000;
    int w, h, n, si, sj, ni, nj, ti, tj, s_d, next_itr;
    pair<int, int> tmp_p;
    cin >> h >> w >> n;
    vector<string> field(h);
    vector<vector<int>> d;
    vector<pair<int, int>> cheeze(n+1);
    d.resize(h);
    queue<pair<int, int>> q;
    for(int i=0; i<h; ++i){
        cin >> field[i];
        d[i].resize(w);
        for(int j=0; j<w; ++j){
            d[i][j] = INF;
            if(field[i][j] == 'S'){
                si = i;
                sj = j;
            }
            if(0 <= field[i][j] - '1' && field[i][j] - '1' <= '9' - '1'){
                cheeze[field[i][j] - '1' + 1] = make_pair(i, j);
                // cout << "pair: " << (abs(field[i][j] - '1') + 1) << " (" << i << ", " << j << ")" << endl;
            }
        }
    }
    // push start point
    q.push(make_pair(si, sj));
    d[si][sj] = 0;
    s_d = -1;
    next_itr = 1;
    ti = cheeze[next_itr].first;
    tj = cheeze[next_itr].second;
    while(!q.empty()){
        tmp_p = q.front();
        q.pop();
        ni = tmp_p.first;
        nj = tmp_p.second;
        // cout << ni << " " << nj << ":" << d[ni][nj] << endl;
        if(ni == ti && nj == tj){
            s_d = d[ni][nj];
            queue<pair<int, int>>().swap(q);
            // cout << "Clear S_d is " << s_d << endl;
            q.push(make_pair(ni, nj));
            for(int i=0; i<h; ++i){
                for(int j=0; j<w; ++j){
                    if(i == ni && j == nj){
                        continue;
                    }
                    d[i][j] = INF;
                }
            }
            if(next_itr >= n){
                break;
            }
            else {
                next_itr++;
                ti = cheeze[next_itr].first;
                tj = cheeze[next_itr].second;
            }
        }
        // up
        if(0 <= ni-1 && d[ni-1][nj] == INF && field[ni-1][nj] != 'X'){
            d[ni-1][nj] = d[ni][nj] + 1;
            q.push(make_pair(ni-1, nj));
        }
        // down
        if(ni+1 < h && d[ni+1][nj] == INF && field[ni+1][nj] != 'X'){
            d[ni+1][nj] = d[ni][nj] + 1;
            q.push(make_pair(ni+1, nj));
        }
        // left
        if(0 <= nj-1 && d[ni][nj-1] == INF && field[ni][nj-1] != 'X'){
            d[ni][nj-1] = d[ni][nj] + 1;
            q.push(make_pair(ni, nj-1));
        }
        // right
        if(nj+1 < w && d[ni][nj+1] == INF && field[ni][nj+1] != 'X'){
            d[ni][nj+1] = d[ni][nj] + 1;
            q.push(make_pair(ni, nj+1));
        }
    }
    cout << d[ti][tj] << endl;
    return 0;
}


Measured memory_bytes: 7984
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

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

    int minv = INT_MAX;
    for (int i = 0; i < s.size() - 2; ++i) {
        int v = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0';
        minv = min(minv, abs(753 - v));
    }

    cout << minv;

    return 0;
}


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

int main(){
  int N;
  std::cin >> N;
  std::vector<int> L_arr(N);
  for(int i = 0; i < N; i++) std::cin >> L_arr[i];

  std::sort(L_arr.begin(), L_arr.end());

  long long int n_count = 0;
  for(int i = 2; i < N; i++){
    for(int j = 1; j < i; j++){
      int low_limit = L_arr[i]-L_arr[j];
      int nc = std::distance(std::upper_bound(L_arr.begin(), L_arr.end(), low_limit), L_arr.begin()+j);
      if(nc > 0) n_count += nc;
    }
  }

  std::cout << n_count << std::endl;

  return 0;
}



Measured memory_bytes: 768
n,ww=map(int,input().split())
waight=[0]
value=[0]
for _ in range(n):
    a,b=map(int,input().split())
    waight.append(a)
    value.append(b)
dp=[[0]*(ww+1) for _ in range(n+1)]
for i in range(n):
    for w in range(ww+1):
        if w-waight[i+1]>=0:
            dp[i+1][w]=max(dp[i][w],dp[i][w-waight[i+1]]+value[i+1])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[-1][-1])

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

typedef struct{
	int num;
	char suit;
	int id;
}Card;

void BubbleSort(Card card[], int n){
	int i, j;
	Card tmp;
	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){
			if(card[j].num<card[j-1].num){
				tmp=card[j];
				card[j]=card[j-1];
				card[j-1]=tmp;
			}
		}
	}
	for(i=0; i<n; i++){
		if(i<n-1){
			printf("%c%d ", card[i].suit, card[i].num);
		}else{
			printf("%c%d", card[i].suit, card[i].num);
		}
	}
	printf("\nStable\n");
}

void SelectionSort(Card card[], int n){
	int i, j, minj;//, sta=0;
	Card tmp;

	for(i=0; i<n-1; i++){
		minj=i;
		for(j=i; j<n; j++){
			if(card[j].num<card[minj].num){
				minj=j;
			}
		}
		tmp=card[minj];
		card[minj]=card[i];
		card[i]=tmp;
	}
	for(i=0; i<n; i++){
		if(i<n-1){
			printf("%c%d ",card[i].suit,card[i].num);
		}else{
			printf("%c%d",card[i].suit,card[i].num);
		}
	}
}

void isStable(const Card *bd,const Card *c, int n){
	int i, stai=0;
	for(i=0; i<n; i++){
		if(bd[i].suit!=c[i].suit){
			stai=1;
		}
	}
	if(stai==1){
		printf("\nNot stable\n");
	}else{
		printf("\nStable\n");
	}
}

int main(){

	int n, i;
	scanf("%d", &n);
	Card card[n], bcard[n];
	
	for(i=0; i<n; i++){
		scanf(" %c%d", &card[i].suit,&card[i].num);
		card[i].id=i;
		//strcpy(bcard[i].suit,card[i].suit);
		bcard[i].suit=card[i].suit;
		bcard[i].num=card[i].num;
	}
	
	/*for(i=0; i<n; i++){
		printf("%c%d %d \n", card[i].suit,card[i].num, card[i].id);
	}*/
	
	BubbleSort(bcard, n);
	SelectionSort(card, n);
	isStable(bcard,card, n);
	
	return 0;
}


Measured memory_bytes: 2032
#include<bits/stdc++.h>
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
typedef long long ll;
#define  pii pair<int,int>
#define  pll pair<ll,ll>
#define  vi vector<int>


using namespace std;
const int maxn=2e5+100;
int n,t;

int main(){
//	freopen("in.txt","r",stdin);
//    ios::sync_with_stdio(false);
//    cin.tie(0);
 int x;
 cin>>x;
 if(x<=599&&x>=400)cout<<8;
 else  if(x<=599&&x>=400)cout<<8;
 else  if(x<=799&&x>=600)cout<<7;
 else  if(x<=999&&x>=800)cout<<6;
 else  if(x<=1199&&x>=1000)cout<<5;
 else  if(x<=1399&&x>=1200)cout<<4;
 else  if(x<=1599&&x>=1400)cout<<3;
 else  if(x<=1799&&x>=1600)cout<<2;
 else  if(x<=1999&&x>=1800)cout<<1;
 
 
 
 
    return 0;
}

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

int main(){
    long long s,c;
    while(scanf("%lld%lld",&s,&c)==2){
        long long scc;
        if(s>=c)
        {
            scc=c/2;
            printf("%lld\n",scc);
        }
        else
        {
            c-=s*2;
            scc=s+c/4;
            printf("%lld\n",scc);
        }
    }
    return 0;
}



Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if (i * 500 + j * 100 + k * 50) == X:
                count += 1

print(count)

Measured memory_bytes: 3060
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

vector<Int> len, bread, patty;

Int f(Int n, Int x) {
    if (n == 0) {
        if (x <= 0) {
            return 0;
        } else {
            return 1;
        }
    } else if (x <= 1 + len[n - 1]) {
        return f(n - 1, x - 1);
    } else {
        return patty[n - 1] + 1 + f(n - 1, x - 2 - len[n - 1]);
    }
}

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

    Int n, x;
    cin >> n >> x;

    int c = 51;
    len = bread = patty = vector<Int>(c + 1);
    len[0] = 1;
    bread[0] = 0;
    patty[0] = 1;
    for (int i = 1; i <= c; i++) {
        bread[i] = bread[i - 1] * 2 + 2;
        patty[i] = patty[i - 1] * 2 + 1;
        len[i] = bread[i] + patty[i];
    }

    cout << f(n, x) << endl;

    return 0;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if ( n <= m ) {
        ans = 1;
    }

    cout << ( ans ? "unsafe" : "safe" ) << endl;
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> dp(n, INT_MAX);
    vector<int> h(n);
    for (int i=0; i<n; i++) cin >> h[i];

    dp[0] = 0;
    for (int i=0; i<n; i++)
        for (int j=1; j<=min(i, k); j++)
            dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j]);

    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

const int N=200010;

typedef long long ll;

int n,prd;
int fail[N];
char a[N];
ll l,r,pre[N][30];

inline ll fib(ll p,int c){
  if(p<=n) return pre[p][c];
  if(p<=n*2) return pre[n][c]+pre[p-n][c];
  ll ret1=pre[n][c]+pre[prd][c],ret2=pre[n][c],a=n+prd,b=n;
  while(p>a+b){
    ll c=ret1; ret1+=ret2; ret2=c;
    c=a; a+=b; b=c;
  }
  return ret1+fib(p-a,c);
}

inline ll calc(ll p,int c){
  if(p<=n) return pre[p][c];
  if(n%prd==0){
    ll ret=1LL*(p-n)/prd*pre[prd][c]+pre[n][c];
    p-=n; p%=prd;
    return ret+pre[p][c];  
  }
  else return fib(p,c);
}

int main(){
  scanf("%s",a+1); n=strlen(a+1)/2;
  for(int i=1;i<=n;i++){
    for(int j=0;j<26;j++) pre[i][j]=pre[i-1][j];
    pre[i][a[i]-'a']++;
  }
  scanf("%lld%lld",&l,&r);
  int k=0;
  for(int i=2;i<=n;i++){
    while(k&&a[k+1]!=a[i]) k=fail[k];
    if(a[k+1]==a[i]) k++;
    fail[i]=k;
  }
  prd=n-fail[n];
  for(int i=0;i<26;i++)
    printf("%lld ",calc(r,i)-calc(l-1,i));
  return 0;
}


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

long s, mod500, mod5, happy = 0; 

int main(){
	cin >> s;
  	mod500 = s % 500;
  	happy = (s - mod500)/500 * 1000;
  	mod5 = mod500 % 5;
  	happy += (mod500 - mod5)/5 * 5;
  	cout << happy << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val graph = Array(n) {
        mutableListOf<Int>()
    }
    val colorMap = mutableMapOf<Points, Int>()
    val used = mutableMapOf<Points, Boolean>()

    val input = Array(n - 1) {
        readLine()!!.split(" ").map { it.toInt() - 1 }
    }
    input.forEach { list ->
        val (a, b) = list
        graph[a].add(b)
        used[Points(a, b)] = false
        graph[b].add(a)
        used[Points(b, a)] = false
    }
    fun bfs(from: Int, v: Int, color: Int) {
        //println("from:$from to:$v")
        if (from != -1) {
            used[Points(from, v)] = true
            used[Points(v, from)] = true
            colorMap[Points(from, v)] = color
            colorMap[Points(v, from)] = color
        }

        var toColor = 1
        graph[v].forEach { u ->
            if (used[Points(v, u)]!!) return@forEach
            if (color == toColor) {
                toColor++
                bfs(v, u, toColor)
                toColor++
            } else {
                bfs(v, u, toColor)
                toColor++
            }
        }
    }
    bfs(-1, 0, 0)
    println(graph.map { it.size }.max()!!)
    input.forEach { list ->
        val (a, b) = list
        println(colorMap[Points(a, b)])
    }
}

data class Points(val u: Int, val v: Int)

Measured memory_bytes: 132712
N = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
res = 0
last_menu = -1
for i in range(len(a)):
    res += b[a[i] - 1]
    if 0 < i and 1 < a[i] and a[i] - a[i-1] == 1:
        bonus = c[a[i-1] - 1]
        res += bonus
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n + 1);
    for(int i = 0; i < n; i++)
        cin >> a[i + 1];
    set<int> s;
    s.insert(1);
    int p = 1;
    while(true){
        if(s.find(a[p]) == s.end()){
            s.insert(a[p]);
            p = a[p];
        }
        else{
            break;
        }
    }
    p = a[p];
    int cnt = 0;
    int q = 1;
    while(true){
        if(a[q] != p){
            cnt ++;
            q = a[q];
        }
        else 
            break;
    }
    cnt ++;
    int l = s.size();
    int ans = 1;
    if(cnt == l){
        k %= l;
        for(int i = 0; i < k; i++)
            ans = a[ans];
    }
    else if(k <= cnt){
        for(int i = 0; i < k; i++)
            ans = a[ans];
        
    }
    else{
        k -= cnt;
        l -= cnt;
        k %= l;
        for(int i = 0; i < cnt; i++)
            ans = a[ans];
        for(int i = 0; i < k; i++)
            ans = a[ans];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<vector<int>> data(N,vector<int>(2));
    for (int i = 0; i < N; i++) {
        cin >> data.at(i).at(0) >> data.at(i).at(1);
    }
 
    int ans;
    sort(data.begin(), data.end());
    for (int i = 0; i < N; i++) {
        ans = data.at(i).at(0);
        K -= data.at(i).at(1);
        if (K <= 0) {
            break;
        }
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>

using namespace std;

bool compare_F(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second > b.second;
  }
}

bool compare_S(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second > b.second;
  } else {
    return a.first > b.first;
  }
}

template <typename T>
void ArrayInput(vector<T> &A) {
  for (auto itr = A.begin(); itr != A.end(); ++itr) {
    cin >> *itr;
  }
}
template <typename T>
void ArrayPut(vector<T> &A) {
  for (auto itr = A.begin(); itr != A.end(); ++itr) {
    cout << *itr << " ";
  }
  cout << endl;
}

using Graph = vector<vector<uint32_t>>;
vector<bool> seen;
vector<uint32_t> dis, A_dis, T_dis;

void dfs(Graph &G, uint32_t v) {
  seen[v] = true;

  for (auto itr = G[v].begin(); itr != G[v].end(); ++itr) {
    if (seen[*itr]) continue;
    dis[*itr] = dis[v] + 1;
    dfs(G, *itr);
  }
}

int main() {
  uint64_t N, A, B;
  cin >> N >> A >> B;
  uint64_t res = 0;
  if ((B - A) & 0x01) {
    if ((N - B) > A - 1) {
      res += A;
      A = 1;
      B -= res;
    } else {
      res += (N - B) + 1;
      B = N;
      A += res;
    }
    res += (B - A) / 2;
    cout << res << endl;
  } else {
    cout << (B - A) / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define _USE_MATH_DEFINES

int main()
{
    int n=0,best_n=0,T=0,A=0,height_i[1001]={0},temp_average=0,temp_diff_from_a=0,new_temp_diff_from_a=0;
    scanf("%d",&n);
    scanf("%d %d",&T,&A);
    for(int i=0;i<n;i++)
	scanf("%d",&height_i[i]);

    temp_average=1000*T-height_i[0]*6;
    temp_diff_from_a=abs(1000*A-temp_average);


    for(int i=1;i<n;i++){
	temp_average=1000*T-height_i[i]*6;
	new_temp_diff_from_a=abs(1000*A-temp_average);

	if(new_temp_diff_from_a<temp_diff_from_a){
	    temp_diff_from_a=new_temp_diff_from_a;
	    best_n=i;
	}

    }
    printf("%d",best_n+1);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a = 0, b = 0, c = 0, h, n, w = 0, ans = 0, count = 0;
  string t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vs s(n);
  rep(i, 0, n)
  {
    cin >> s[i];
    if (s[i] == "AC")
    {
      a++;
    }
    else if (s[i] == "WA")
    {
      b++;
    }
    else if (s[i] == "TLE")
    {
      c++;
    }
    else if (s[i] == "RE")
    {
      w++;
    }
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << w << endl;
}

Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

signed main(){
  /*
  random_device rd;
  mt19937 mt(rd());
  Int n=10;
  vector<Int> a(n,2);
  for(Int i=0;i<n-1;i++){
    a[i+1]=mt()%(a[i]+(mt()%a[i])-1)+2;
  }
  */
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  reverse(a.begin(),a.end());
  //sort(v.begin(),v.end());
  Int c=2,d=2,x=0;
  for(Int i=0;i<n-1;i++){
    Int e=c;
    Int f=d+a[i]-1;
    Int nc=(e+a[i+1]-1)/a[i+1]*a[i+1];
    Int nd=f/a[i+1]*a[i+1];
    if(1&&(c>nc||nd>d)){
      x=1;
      //c=d=-1;break;
    }
    c=nc;d=nd;
    //cout<<c<<" "<<d<<endl;
  }
  d+=a.back()-1;
  //for(Int i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
  reverse(a.begin(),a.end());
  Int t=c;
  for(Int j=0;j<n;j++) t=t/a[j]*a[j];
  if(t!=2){
    cout<<-1<<endl;
    return 0;
  }
  //for(Int i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
  cout<<c<<" "<<d<<endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		String S=next();
		if(S.equals("RRR"))
			System.out.println(3);
		else
			if(S.equals("SRR")||S.equals("RRS"))
				System.out.println(2);
			else
				if(S.indexOf("R")!=-1)
					System.out.println(1);
				else
					System.out.println(0);
	}
	public static long lmod(long i, long j) {
	     return (i%j)<0?(i%j)+0+(j<0?-j:j):(i%j+0);
	 }
	static boolean isOK(int index,int key,int[]a){
		if (a[index]>=key) return true;
	    else return false;
	}
	static int binary_search(int key,int[] a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.length; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



Measured memory_bytes: 32492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=1000;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;cin >> s;
	string d5="dream",d7="dreamer";
	string e5="erase",e6="eraser";
	string s5="dream",s6="eraser",s7="dreamer";
	int l,now;
	l=s.size();
	now=l-1;
	while(1){
		if(now<4 && now!=-1){
			cout<<"NO"<<endl;
			return 0;
		}else if(now==-1){
			cout<<"YES"<<endl;
			return 0;
		}
		FOR(i,0,5)s5[i]=s[now-4+i];
		if(now>=5){
			FOR(i,0,6)s6[i]=s[now-5+i];
		}
		if(now>=6){
			FOR(i,0,7)s7[i]=s[now-6+i];
		}
		if(s5==d5 || s5==e5){
			now -= 5;
			continue;
		}else if(s6==e6 && now>=5){
			now -= 6;
			continue;
		}else if(s7==d7 && now>=6){
			now -= 7;
			continue;
		}
		cout<<"NO"<<endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 512
S = raw_input()
T = raw_input()
N = len(S)
ks = {}
kt = {}
xs = 0
xt = 0
ys = []
yt = []
for i in range(N):
  if S[i] not in ks:
    ks[S[i]] = xs
    xs += 1
  ys.append(ks[S[i]])
  if T[i] not in kt:
    kt[T[i]] = xt
    xt += 1
  yt.append(kt[T[i]])
print "Yes" if ys==yt else "No"

Measured memory_bytes: 12660
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
 
        if(b == 1){
          System.out.println(0);
          return;
        }
        if(a >= b){
          System.out.println(1);
          return;
        }
        
        int num = a;
        int count = 2;
      
        while(true){
          num += a - 1;
          if(num >= b){
            break;
          }
          count++;
        }
		// 出力
		System.out.println(count);
	}
}

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

 

int main()
{
    int card[52];
    int n, i, rank, s;
    char suit;
    
    for(i=0; i<52; i++)
        card[i] = 0;
        
    cin >> n;
    for(i=1; i<=n; i++)
    {
        cin >> suit;
        cin >> rank;
        if(suit == 'S')
            s = 0;
        else if(suit == 'H')
            s = 13;
        else if(suit == 'C')
            s = 26;
        else
            s = 39;
        
        s = s + rank - 1;
        card[s] = 1;
    }
    
    for(i=0; i<52; i++)
    {
        if(card[i]==0)
        {
            if(i >= 39)
            {
                suit = 'D';
                rank = i - 39 + 1;
            }
            else if(i >= 26)
            {
                suit = 'C';
                rank = i - 26 + 1;
            }
            else if(i >= 13)
            {
                suit = 'H';
                rank = i - 13 + 1;
            }
            else
            {
                suit = 'S';
                rank = i + 1;
            }
            cout << suit << " " << rank << endl;
        }
    }
}


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

int main(){
    int a,b,c,k;
    int sum=0;
    cin>>a>>b>>c>>k;
    if(k<=a) sum=k;
    else if(k<=b) sum=a;
    else sum=a-(k-a-b);
    cout<<sum<<endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
    return 0;
  }
  bool used[26] = {};
  for (int i = 0; i < S.size(); i++) {
    used[S[i] - 'a'] = true;
  }
  for (int i = 0; i < 26; i++) {
    if (!used[i]) {
      cout << S << char('a' + i) << endl;
      return 0;
    }
  }

  for (int i = S.size() - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      used[j] = false;
    }
    for (int j = 0; j <= i; j++) {
      used[S[j] - 'a'] = true;
    }
    for (int j = 0; j < 26; j++) {
      if (!used[j] && S[i] - 'a' < j) {
        cout << S.substr(0, i) << char('a' + j) << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
  int i, test[5], sum = 0, average = 0;
  for(i = 0;i < 5;i++){
    scanf("%d", &test[i]);
    if(test[i] < 40){
      test[i] = 40;
    }
    sum += test[i];
  }
  average = round((double)sum / 5);
  printf("%d\n", average);
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

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

    OP(800*n-200*(n/15));
    return 0;
}

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

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;
typedef vector<ll>		VLL;
typedef vector<VLL>		VVLL;
typedef vector<VVLL>	VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	string a, b;
	cin >> a >> b;
	string sVal = a + b;
	int val = atoi(sVal.c_str());

	string ans = "No";
	REP(i, 1000) {
		if (i * i == val) {
			ans = "Yes";
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int64_t N;
  cin>>N;
  vector<int64_t> K(N+1,0);
  for(int64_t i=0;i<N;i++){
    int64_t j;
    cin>>j;
    K[i+1]=K[i]+j;
  }
  sort(K.begin(),K.end());
  int64_t j=0,k=1000000001,l=0;
  for(int64_t i=0;i<=N;i++){
    if(k==K[i])
      l++;
    else{
      j+=l*(l-1)/2;
      k=K[i];
      l=1;
    }
  }
  cout<<j+l*(l-1)/2<<endl;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    long long N;
    vector<long long> A, c;

    cin >> N;
    for (long long i = 0; i < N; i++)
    {
        long long t;
        cin >> t;
        A.push_back(t);
    }

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

    long long b = 0;
    for (long long i = 0; i < N; i++)
    {
        b += A[i];
        c.push_back(b);
    }

    long long count = 0;
    for (long long i = 0; i < N - 1; i++)
        if (2 * c[i] >= A[i + 1])
            count++;
        else
            count = 0;

    cout << count + 1 << endl;
}

Measured memory_bytes: 2548
N = gets.chomp.to_i
H = gets.chomp.split(" ").map(&:to_i)

if N == 1
  puts "Yes"
  exit
end
if H[0] > H[1] + 1
  puts "No"
  exit
end

prev_h = H[0] - 1
1.upto(N-1) do |i|
  if H[i] < prev_h
    puts "No"
    exit
  end
  prev_h = [prev_h, H[i] - 1].max
end
puts "Yes"


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

using namespace std;

typedef long long int ll;

const ll MAXN = 205;

vector < vector < ll > > d(MAXN, vector < ll > (MAXN, 1e16));

vector < ll > v, r;

ll ans = LLONG_MAX;

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

  ll n, m, nr;
  cin >> n >> m >> nr;
  for(int i = 0; i < nr; i++){
    ll a;
    cin >> a;
    r.push_back(a);
  }
  for(int i = 0; i < m; i++){
    ll u, v, wt;
    cin >> u >> v >> wt;
    d[u][v] = wt;
    d[v][u] = wt;
  }

  for(int k = 1; k <= n; k++){
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n; j++){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

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

  do{
    ll sum = 0;
    for(int i = 1; i < r.size(); i++){
      sum += d[r[i]][r[i - 1]];
    }
    ans = min(ans, sum);
  }while(next_permutation(r.begin(), r.end()));

  cout << ans << '\n';
}


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

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    
    vector<int> cnt(N + 1, 0);
    bool prev = false;
    for(int i=0; i<S.size(); ++i) {
        cnt[i + 1] = cnt[i];
        if(prev && S[i] == 'C') {
            ++cnt[i + 1];
            prev = false;
        } else if(S[i] == 'A') {
            prev = true;
        } else {
            prev = false;
        }
    }

    for(int i=0; i<Q; ++i) {
        int l, r;
        cin >> l >> r;
        int res = cnt[r] - cnt[l - 1];
        if(l > 1 && S[l - 2] == 'A' && S[l - 1] == 'C') --res;
        cout << res << endl;
    }
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <chrono>
#include <complex>
#include <cstdint>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = int64_t;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll x;;
        in >> x;
        ll ans = x / 11 * 2;
        ll remain = x % 11;
        if (remain == 0) {
        }
        else if (remain <= 6) {
            ans += 1;
        }
        else {
            ans += 2;
        }
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int margin = 3;
const int paper_size = 10;
int cordx[] = {0,  0, -1, 0, 1, -1, -1, 1,  1,  0, -2, 0, 2};
int cordy[] = {0, -1,  0, 1, 0, -1,  1, 1, -1, -2,  0, 2, 0};

int main(int argc, char **argv)
{
  vvi paper(paper_size+margin*2, vi(paper_size+margin*2, 0));
  int x, y, size;
  char com;
  for (;;) {
    cin >> x >> com >> y >> com >> size;
    if (cin.eof())
      break;

    for (int i = 0; i < 1+4*size; i++) {
      paper[margin+x+cordx[i]][margin+y+cordy[i]]++;
    }
  }

  int empty_nr = 0;
  int max_score = 0;
  for (int i = margin; i < margin+paper_size; i++) {
    for (int j = margin; j < margin+paper_size; j++) {
      if (paper[i][j]) {
        max_score = max(max_score, paper[i][j]);
      } else {
        empty_nr++;
      }
    }
  }
  cout << empty_nr << endl;
  cout << max_score << endl;

  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
using namespace std;
int main() 
{
  int k;
  cin>>k;
  int a,b;
  cin>>a>>b;
  int y = 0;
  for(int i = a;i <= b;i++)
  {
    if(i % k == 0)
      y = 1;
  }
  if(y == 1)
    cout<<"OK";
  else cout<<"NG";
  
 return 0; 
}

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

ll N, H[16], W[16];
char S[4][4];
const char Z[] = "RGB";
ll dp[1 << 16];

int main(void) {
  scanf("%d", &N);
  REP(i, 0, N) scanf("%d %d", H + i, W + i);
  REP(i, 0, 4) scanf("%s", S[i]);

  REP(i, 0, 1 << 16) dp[i] = -1;
  dp[0] = 0;
  queue<ll> q;
  q.push(0);
  while(q.size()) {
    if(dp[(1 << 16) - 1] != -1) break;
    ll s = q.front(); q.pop();
    REP(i, 0, N) {
      REP(py, -H[i] + 1, 4) REP(px, -W[i] + 1, 4) REP(c, 0, 3) {
        ll n = s;
        REP(y, max(py, 0), min(py + H[i], 4)) REP(x, max(px, 0), min(px + W[i], 4)) {
          if(S[y][x] == Z[c]) n = n | (1 << (y * 4 + x));
          else n = n & (~(1 << (y * 4 + x)));
        }
        if(dp[n] == -1) {
          dp[n] = dp[s] + 1;
          q.push(n);
        }
      }
    }
  }
  printf("%d\n", dp[(1 << 16) - 1]);
}



Measured memory_bytes: 3680
def main():
    n = int(input())
    a = list(map(int, input().split()))

    from heapq import heapify, heappushpop

    # first half
    fh = []
    l = a[:n]
    fh.append(sum(l))
    heapify(l)
    for i in a[n:2*n]:
        if l[0] < i:
            fh.append(fh[-1] + i - heappushpop(l, i))
        else:
            fh.append(fh[-1])

    # latter half
    lh = []
    l = [-i for i in a[2*n:]]
    lh.append(sum(l))
    heapify(l)
    for i in a[2*n-1:n-1:-1]:
        if l[0] < -i:
            lh.append(lh[-1] - i - heappushpop(l, -i))
        else:
            lh.append(lh[-1])

    ans = fh[0] + lh[n]
    for i in range(1, n+1):
        if ans < fh[i] + lh[n-i]:
            ans = fh[i] + lh[n-i]

    print(ans)

main()

Measured memory_bytes: 117220
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int main() {
    // source
    string s;
    cin >> s;
    bool ans = false;
    ans = s[0] == 'A';
    int index;
    int cnum = 0;
    repd(i, 2, s.size() - 1) {
        if (s[i] == 'C') {
            cnum++;
            index = i;
        }
    }
    ans &= cnum == 1;

    rep(i, s.size()) {
        if ('A' <= s[i] && s[i] <= 'Z') {
            if (i != index && i != 0) {
                ans = false;
            }
        }
    }

    if (ans) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
        long long h,w;
      
        scanf("%lld %lld",&h,&w);
        if(h==1||w==1){
          printf("1\n");
          return 0;
        }
        printf("%lld\n",(h*w+1)/2);
    }

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int check(int a, int x) {
  int lb = 1, ub = x+1;
  while(lb+1 < ub) {
    int mb = (lb+ub)/2;
    if((a+mb)*(x+1-mb) > (a+mb-1)*(x+1-mb+1)) lb = mb;
    else ub = mb;
  }
  return lb;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int q;
  cin >> q;
  rep(i, q) {
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    int ans = a-1; // (a-i,b+i) (1<=i<=a-1)
    int lb = 0, ub = b;
    while(lb+1 < ub) {
      int mb = (lb+ub)/2;
      int x = check(a, mb);
      if((a+x)*(mb+1-x) < a*b) lb = mb;
      else ub = mb;
    }
    cout << ans+lb << endl;
  }

  return 0;
}


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

int main() {
  string s,t;
  cin>>s>>t;
  int mx = 0;
  for(int i=0;i<=s.length()-t.length();i++){
    int cnt=0;
    for(int j=0;j<t.length();j++){
      if(s[i+j]==t[j]) cnt++;
    }
    mx = max(mx,cnt);
  }
  cout<<t.length()-mx<<endl;
  return 0;
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
)

type line struct {
	s string
}

func main() {
	var n int
	n = 3
	// fmt.Scan(&n)

	lines := []line{}
	for i := 0; i < n; i++ {
		l := line{}
		fmt.Scan(&l.s)
		lines = append(lines, l)
	}
	// fmt.Println(lines)

	test := func(lines []line) string {
		s := ""
		for i, l := range lines {
			s += string([]rune(l.s)[i])
		}
		return s
	}

	fmt.Println(test(lines))
}


Measured memory_bytes: 512
a = int(input())
min_steps=a
if a==2:
    print(1)
elif a==3:
    print(2)
else:
    j=2
    while(1):
        if j*j>=a:
            break
        else:
            j+=1

    for i in range(2, j+1):
            if a%i==0:
                b=i+int(a/i)-2
                if b<min_steps:
                    min_steps=b
    if (min_steps==a):
        min_steps-=1
    print(min_steps)


Measured memory_bytes: 3060
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 0;
    rep(i,1,N+1){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    print(ans);
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
int main(){
    int n,x;
    std::cin >> n >> x;
    std::vector<int> d(n+1);
    d[0] = 0;
    for(int i = 0; i < n;i++){
        int t;
        std::cin >> t;
        d[i+1] = d[i] + t;
    }
    int cnt = 0;
    for(int t : d){
        if(t<=x)cnt++;
        else break;
    }
    std::cout << cnt <<std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    int64 N, K; cin >> N >> K;
    vector<int64> L(N); rep(i, N) {
        cin >> L[i];
        L[i]--;
    }

    vector<int64> r;
    vector<bool> al(N);
    while(true) {
        if (r.empty()) {
            r.push_back(L[0]);
            al[L[0]] = true;
        } else {
            int64 last = *(r.end()-1);
            if (al[L[last]]) break;
            al[L[last]] = true;
            r.push_back(L[last]);
        }
    }

    int64 last = *(r.end()-1);
    int64 next = L[last];
    int index = 0;
    rep(i, r.size()) {
        if (r[i] == next) {
            index = i;
            break;
        }
    }

    if (K <= index) {
        cout << r[K-1]+1 << endl;
        exit(0);
    }

    int p = r.size() - index;
    // cout << r << endl;
    // cout << p << endl;
    if ((K - index) % p == 0) {
        cout << r[r.size()-1]+1 << endl;
        exit(0);
    }
    // cout << (K - index) % p - 1 + index << endl;
    cout << r[(K - index) % p - 1 + index]+1 << endl;
}

// 6 5 2 5 3 2

// 1 4 2
// 5 1 4 2 1 (4) 2 1 4 2

Measured memory_bytes: 6924
n=int(input())
s=input()
ans=0
r=[]
g=[]
b=[]
for i in range(n):
  if s[i]=="R":
    r.append(i+1)
  elif s[i]=="G":
    g.append(i+1)
  elif s[i]=="B":
    b.append(i+1)
count=0
j=0
rcount=[]
gcount=[]
sb=set(b)
for i in r:
  for j in g:
    if j>i and j+(j-i) in sb:
      count+=1
    elif i>j and i+(i-j) in sb:
      count+=1
sr=set(r)
for i in g:
  for j in b:
    if j>i and j+(j-i) in sr:
      count+=1
    elif i>j and i+(i-j) in sr:
      count+=1
sg=set(g)
for i in r:
  for j in b:
    if j>i and j+(j-i) in sg:
      count+=1
    elif i>j and i+(i-j) in sg:
      count+=1

print(len(r)*len(g)*len(b)-count)

Measured memory_bytes: 9528
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll H, W, D;
  cin >> H >> W >> D;

  map<ll, P> m;

  rep(i, H) {
    rep(j, W) {
      ll a;
      cin >> a;
      m[a] = {i, j};
    }
  }

  vector<vector<ll>> dist(D);
  rep(i, D) {
    ll index = i;
    if (i == 0) {
      index = D;
    }
    while (index <= H * W) {
      if (index == i || index == D) {
        dist[i].pb(0);
      } else {
        P before_cordinate = m[index - D];
        P cordinate = m[index];
        ll distance = abs(before_cordinate.first - cordinate.first) +
                      abs(before_cordinate.second - cordinate.second);
        dist[i].pb(distance + dist[i].back());
      }
      index += D;
    }
  }

  ll Q;
  cin >> Q;
  rep(i, Q) {
    ll L, R;
    cin >> L >> R;
    ll m = L % D;
    ll l = L / D;
    ll r = R / D;

    if (m == 0) {
      l = max((ll)0, l - 1);
      r = max((ll)0, r - 1);
    }
    // debug(m);
    // debug(l);
    // debug(r);
    ll ans = dist[m][r] - dist[m][l];
    COUT(ans);
  }

  return 0;
}

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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i,N){
    cin >> d[i];
  }
  int sum = 0;
  for(int i = 0;i<N;i++){
    for(int j = i+1;j<N;j++){
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
 }

Measured memory_bytes: 256