akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
  int n;
  int shain[2000000];
  for(int i=1; i<=n; i++){
    shain[i] = 0;
  }
  cin >> n;
  int a;
  for(int i=1; i<=n-1; i++){
    cin >> a;
    shain[a] += 1;
  }
  for(int i=1; i<=n; i++){
    cout << shain[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 4380
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(input())
res = 0
for i in range(N):
    if T[i] == 'r':
        res += P
        if i + K < N and T[i + K] == 'r':
            T[i + K] = 'x'
    if T[i] == 's':
        res += R
        if i + K < N and T[i + K] == 's':
            T[i + K] = 'x'
    if T[i] == 'p':
        res += S
        if i + K < N and T[i + K] == 'p':
            T[i + K] = 'x'
print(res)


Measured memory_bytes: 10032
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

s = 0
n.times do |i|
  s += b[a[i]-1]
  s += c[a[i-1]-1].to_i if i > 0 && a[i-1] + 1 == a[i]
end
puts s

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout <<  H * W - (H * w + h * W - h * w) << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
// D
fscanf(STDIN, '%d %d', $n, $x);
$cnt = [1];
$cnt_p = [1];
for ($i = 1; $i <= $n; $i++) {
    $cnt[] = $cnt[$i - 1] * 2 + 3;
    $cnt_p[] = $cnt_p[$i - 1] * 2 + 1;
}
echo f($n, $x);

function f($n, $x)
{
    global $cnt, $cnt_p;

    if ($n === 0) return min(1, $x);

    if ($x <= 1) return 0;
    if ($x <= ($cnt[$n] - 3) / 2 + 1) {
        return f($n - 1, $x - 1);
    }
    if ($x === ($cnt[$n] - 3) / 2 + 2) {
        return f($n - 1, $x - 2) + 1;
    }
    if ($x < $cnt[$n] - 1) {
        return $cnt_p[$n - 1] + 1 + f($n - 1, $x - (($cnt[$n] - 3) / 2 + 2));
    }
    return $cnt_p[$n - 1] * 2 + 1;
}

Measured memory_bytes: 4984
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map(Integer::parseInt)
    var ans = mutableMapOf<Int, Int>()

    for(i in  0  until n){
        ans[a[i]] = i + 1
    }
    val result = mutableListOf<Int>()
    for(i in 1..n){
        result.add(ans[i]!!)
    }
    println(result.joinToString(" "))
}


Measured memory_bytes: 61944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	deque<int> d;
 	rep(i,n){
		 int p=lower_bound(all(d),a[i])-d.begin();
		 if(p==0){
			 d.push_front(a[i]);
		 }
		 else d[p-1]=a[i];
	 }
	 cout<<d.size()<<endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  double ans=0,t;
  string s;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> t >> s;
    if(s == "JPY") {
      ans += t;
    } else {
      ans += t*380000.0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3828
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

#define mod 1000000007

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int t;
        cin >> t;
        if(a > t || t >= b) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

constexpr char nl = '\n';

int ceildiv(int a, int b) {
    return (a + b - 1) / b;
}

int main() {
    int N;
    cin >> N;
    for (int x = ceildiv(100 * N, 108); x < ceildiv(100 * (N + 1), 108); x++) {
        if (x * 108 / 100 == N) {
            cout << x << nl;
            return 0;
        }
    }
    cout << ":(" << nl;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  char a[105];
  int r = 0, b = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] == 'R') r++;
    else b++;
  }
  if(r>b) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    ll N;
    cin >> N;
    ll H[N],h,d = 0;
    cin >> H[0];
    for(ll i = 1; i < N; i++){
        cin >> H[i];
        h = H[i] - H[i-1];
        if(h == -1)d -= 1;
        else if(h < -1){
            cout << "No" << endl;
            return 0;
        }else if(h > 0)d = 0;
        if(d < -1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
namespace whatever{
	int readu(){
		char ch=getchar();
		while(!isdigit(ch))
			ch=getchar();
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value;
	}
	void writeull(long long n){
		if(n<10)
			putchar(n+'0');
		else{
			writeull(n/10);
			putchar(n%10+'0');
		}
	}
	void run(){
		int n=readu();
		int k=readu();
		long long result;
		if(k%2==1)
			result=(long long)(n/k)*(n/k)*(n/k);
		else{
			int even=n/k;
			int odd=(n+k/2)/k;
			result=(long long)even*even*even+(long long)odd*odd*odd;
		}
		writeull(result);
		putchar('\n');
	}
}
int main(){
	whatever::run();
}

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

k = int(N**0.5) + 1
ans = N

for a in range(2, k):
    tmp = 0
    if N % a == 0:
        tmp = N//a + a
        if ans > tmp:
            ans = tmp

if ans < N:
    print(ans - 2)
else:
    print(N - 1)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	P := sc.nextIntSlice(N)
	min := P[0]
	ans := 0
	for i := 0; i < N; i++ {
		if P[i] < min {
			min = P[i]
		}
		if P[i] <= min {
			ans++
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 3584
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt()
    val a = readListOfInt()

    val sMap = mutableMapOf<Int, Int>()
    a.forEach { ca ->
        val isMultipleOf4 = (ca % 4 == 0) 
        val isMultipleOf2 = (ca % 2 == 0)
        val key = if(isMultipleOf4) 4
            else if(isMultipleOf2) 2
            else 1
        sMap[key] = if(sMap.contains(key)) sMap[key]!! + 1 else 1
    }
    val num4 = sMap[4]?: 0
    val num2 = sMap[2]?: 0
    
    val isAble = ((num4 * 2 + num2) >= n) || (num4 >= n/2)
    println(if(isAble) "Yes" else "No")
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


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

using namespace std;

string words[] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    int start = 0;
    for (int i=0; i<4; i++) {
        reverse(words[i].begin(), words[i].end());
    }
    for (int i=0; i<S.size(); i++) {
        bool isEnd = true;
        for (string word: words) {
            if (S.size() < word.size()) {
                continue;
            }
            if (S.find(word, start) == start) {
                start += word.size();
                isEnd = false;
                break;
            }
        }
        if (start == S.size()) {
            cout << "YES" << endl;
            return 0;
        }
        if ((start > S.size()) | (isEnd)) {
            break;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	int x = 0;
	rep(i, n) x += a[i];
	if (a[m - 1]*4*m >= x) cout << "Yes";
	else cout << "No";
	return 0;
}










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

using namespace std;
using ll = long long;

int main(){
    int n, k = 2; cin >> n;
    //cin >> k;
    vector<int> heights(n), ans(n, INT_MAX);
    for(int i=0; i<n; i++){
        cin >> heights[i];
        if(!i) ans[i] = 0;
        else
            for(int j=i-1; j>=max(0,i-k); j--){
                ans[i] = min(ans[j] + abs(heights[i] - heights[j]), ans[i]);
            }
    }
    cout<<ans[n-1]<<endl;
}


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

const int N = 2e5 + 7;

int a[N];
int cnt[N];
int c[N];
int ans;
int n, m;

void relax(int x, int val)
{
	if (x < 0)
		return;
	if (c[x] == 0)
		ans--;
	c[x] += val;
	if (c[x] == 0)
		ans++;
}
void modif(int x, int val)
{
	if (x > n)
		return;
	if (val == -1)
		relax(x - (cnt[x]--), val);
	else
		relax(x - (++cnt[x]), val);
}

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

	cin >> n >> m;
	ans = n;
	for (int i=0; i<n; i++)
	{
		int x;
		cin >> x;
		modif(x, 1);
		a[i] = x;
	}
	for (int i=0; i<m; i++)
	{
		int ind, val;
		cin >> ind >> val;
		ind--;
		modif(a[ind], -1);
		a[ind] = val;
		modif(a[ind], 1);
		cout << ans << "\n";
	}

	return 0;
}


Measured memory_bytes: 3840
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){
    return *(ll *)a>*(ll *)b?1:*(ll *)a<*(ll *)b?-1:0;}

int main(void){
    ll n,i;
    scanf("%lld",&n);
    ll a[n+2],cost=0;
    a[0]=0;
    a[n+1]=0;
    for(i=0;i<n;i++){
        scanf("%lld",&a[i+1]);
        cost+=ABS(a[i+1]-a[i]);
        // b[i]=a[i];
        // mi=min2(mi,a[i]);
        // ma=max2(ma,a[i]);
    }
    cost+=ABS(a[n+1]-a[n] );
    // qsort(b,n,sizeof(ll),compare);
    // mi2=min2(b[1],0);
    // ma2=max2(b[n-2],0);
    for(i=0;i<n;i++){
        // if(a[i]==ma){
        //     printf("%lld\n",(ma2-mi)*2 );
        // }else if(a[i]==mi){
        //     printf("%lld\n",(ma-mi2)*2 );
        // }else{
        //     printf("%lld\n",(ma-mi)*2 );
        // }
        printf("%lld\n",cost-ABS(a[i+1]-a[i])-ABS(a[i+1]-a[i+2])+ABS(a[i]-a[i+2]) );
    }
    return 0;
}


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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main(){
  int n; 
  string s;
  cin >>s;
  bool flag = true;
  for(int i = 0; i < s.size(); ++i){
    if(i%2 == 0){
      if(s[i] =='L') flag = false;
    }else{
      if(s[i] =='R') flag = false;
    }
    if(flag == false) break;
  }
  if(flag) cout << "Yes";
  else cout << "No";
}




Measured memory_bytes: 256
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty)
a, b = map(int, raw_input().split())
ans = egcd(a, b)
for i in ans: print i,

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

int main() {
  int N;
  int64_t sum = 0;
  cin >> N;
  vector<int64_t> vec(N);
 
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
    sum = sum ^ vec.at(i); 
  }
  for(int i = 0; i < N; i++){
    int c = sum ^ vec.at(i);
    cout << c << ' ';
  }
}







Measured memory_bytes: 4688
#include <iostream>

int main(void){
    int k, a, b;
    std::cin >> k;
    std::cin >> a >> b;
    if(0 == a % k) std::cout << "OK";
    else if((b / k - a / k) > 0) std::cout << "OK";
    else std::cout << "NG";
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i;
  int64_t sum=0;
  cin >> i;
  for (int count=1;count<=i;count++) {
    if(count%3==0 || count%5==0){
    } else { 
      sum = sum + count;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;
pii w[N];
string s;
int p[N], c[N], vis[N];
vector<int> path[N];
int cor;
void dfs(int x){
	vis[x] = cor;
	path[cor].pb(x);
	if(!vis[p[x]]) dfs(p[x]);
}
int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n>>k;
	for(int i = 1; i <= n; i++){
		cin>>p[i];
	}
	for(int i = 1; i <= n; i++) cin>>c[i];
	for(int i = 1; i <= n; i++){
		if(vis[i]) continue;
		++cor;
		dfs(i);
	}
	for(int cc = 1; cc <= cor; cc++){
		vector<int> cop = path[cc];
		for(auto e: cop) path[cc].pb(e);
	}
	int anss =-(2e18);
	for(int cc = 1; cc <= cor; cc++){
		int sum = 0;
		for(auto w: path[cc])sum += c[w];
		sum /= 2;
		for(int resto = 0; resto < sz(path[cc])/2; resto ++){
			vector<int> pref;
			int opt = -(2e18);
			if(resto == 0) opt = 0;
			for(int i = 0; i < sz(path[cc]); i++){
				if(!pref.empty())pref.pb(pref.back() + c[path[cc][i]]);
				else pref.pb(c[path[cc][i]]);
				if(i >= resto - 1){
					int sum = pref[i] - (i-resto>=0?pref[(i - resto)]:0);
					opt=max(opt, sum);
				}
			}
			if(resto > k) continue;
			int resp;
			int loop = (k - resto)/(sz(path[cc])/2);
			if(resto == 0){
				if(loop >= 1) resp = max(sum, loop*sum) + opt;
              else resp = -(2e18);
			}
			else resp = max(0LL, loop*sum) + opt;
			// cout<<"resto "<<resto<<" "<<opt<<" "<<resp<<"\n";
			anss = max(anss, resp);
		}
	}
	cout<<anss<<"\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

Measured memory_bytes: 11096
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>

using namespace std;

int main() {

    int N;
    cin >> N;

    string S = to_string(N);

    int num = 0;
    for (int i = 0; i < S.size(); ++i) {
        num += stoi(S.substr(i, 1).c_str());
    }

    if (N % num == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

typedef long long Lu;

int main() {
    Lu A_cookie, B_cookie, K;
    cin >> A_cookie >> B_cookie >> K;

    if(A_cookie - K > 0) {
        A_cookie = A_cookie - K;
    }
    else if(A_cookie - K == 0) {
        A_cookie = 0;
    }
    else if(A_cookie - K < 0) {
        Lu Extra = K - A_cookie;
        A_cookie = 0;
            if(B_cookie - Extra > 0) {
                B_cookie -= Extra;
            }
            else if(B_cookie - Extra <= 0){
                B_cookie = 0;
            }
    }

    cout << A_cookie << " " << B_cookie;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

const int INF = 2000000000;
const double pi = 3.1415926;
const int base = 1000000007;

string s;


int main()
{
    //ifstream cin ("input1.txt");
    //ifstream fin ("output1.txt");
    //ofstream cout ("output1.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(25);
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
    return 0;
}

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

string s, t;

int main() {
  cin >> s;
  t = s;
  reverse(t.begin(), t.end());
  int n = s.size(), res = 0;
  for (int l = 0, r = 0; l < n || r < n;) {
    int cntl = 0, cntr = 0;
    while (l < n && s[l] == 'x') ++l, ++cntl;
    while (r < n && t[r] == 'x') ++r, ++cntr;
    res += abs(cntl - cntr);
    if (l < n && r < n && s[l] != t[r]) {
      cout << -1 << endl;
      return 0;
    }
    ++l, ++r;
  }
  cout << res / 2 << endl;
  return 0;
}

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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n, q = map(int, input().split())
    s = input().rstrip()
    before = ''
    start_cumsum = []
    end_cumsum = []
    now_val = 0
    for (i, c) in enumerate(s):
        end_cumsum.append(now_val)
        if c == 'A':
            before = 'A'
        elif c == 'C' and before == 'A':
            now_val += 1
            before = ''
        else:
            before = ''
        start_cumsum.append(now_val)
    end_cumsum.append(now_val)
    # imos法を使う
    for _ in range(q):
        l, r = map(int, input().split())
        print(start_cumsum[r - 1] - start_cumsum[l - 1])


if __name__ == '__main__':
    main()


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

int main(){
  ll n;
  cin >> n;
  ll a[n+1];
  ll count[n+1] = {0};
  set<ll> st;
  for(ll i=1;i<n+1;i++){
    cin >> a[i];
    st.insert(a[i]);
    count[a[i]]++;
  }

  ll main[n+1] = {0};
  ll sub[n+1] = {0};
  for(auto p : st){
    main[p] = count[p] * (count[p]-1) / 2;
    // sub[p] = (count[p]-1) * (count[p]-2) / 2;
  }
  ll sum = 0;
  for(auto p : st){
    sum += main[p];
  }

  for(ll i=1;i<n+1;i++){
    ll ans = sum;
    // ans -= main[a[i]];
    ans -= count[a[i]] - 1;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 14976
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        s: chars,
    }
    let mut count = 0;
    for i in 1..n {
        if s[i - 1] != s[i] {
            count += 1;
        }
    }
    println!("{}", count + 1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  string ans[8]={"AAA","AA","A","B","C","D","E","NA"};
  double n,m;
  while(cin >> n >> m){
  int cnt1=0,cnt2=0;
  if(n>=35.50){
    cnt1++;
  }
  if(n>=37.50){
    cnt1++;
  }
  if(n>=40.00){
    cnt1++;
  }
  if(n>=43.00){
    cnt1++;
  }
  if(n>=50.00){
    cnt1++;
  }
  if(n>=55.00){
    cnt1++;
  }
  if(n>=70.00){
    cnt1++;
  }
  if(m>=71.00){
    cnt2++;
  }
  if(m>=77.00){
    cnt2++;
  }
  if(m>=83.00){
    cnt2++;
  }
  if(m>=89.00){
    cnt2++;
  }
  if(m>=105.00){
    cnt2++;
  }
  if(m>=116.00){
    cnt2++;
  }
  if(m>=148.00){
    cnt2++;
  }
  cout << ans[max(cnt1,cnt2)] << endl;
  }
  return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  int ret = 0;
  for (int i = 0; i <= 100; i++) {
    int cnt = (h[0] > i) ? 1 : 0;
    for (int j = 1; j < N; j++) {
      if (h[j-1] <= i && h[j] > i) {
        cnt++;
      }
    }
    ret += cnt;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

#include <atcoder/fenwicktree>

using namespace std;
using namespace atcoder;
#define rep(i,l,r) for(int i = l; i < r; ++i)

int main() {
    int n, q, a;
    cin >> n >> q;

    fenwick_tree<unsigned long long> ft(n);
    rep(i, 0, n) {
        cin >> a;
        ft.add(i, a);
    }

    rep(i, 0, q) {
        int t, x, y;
        cin >> t >> x >> y;

        if (t == 0) {
            ft.add(x, y);
        } else {
            cout << ft.sum(x, y) << endl;
        }
    }
}


Measured memory_bytes: 8232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 10000005;
const int mod = 998244353;
const int mx = 2e9;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x ;
    x %= 10;
    if (x == 3) {
        cout << "bon\n";
    }
    else if (x == 0 || x == 1 || x == 6 || x == 8) {
        cout << "pon\n";
    }
    else {
        cout << "hon\n";
    }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
map<int,int>m;
int main()
{
	int x,n,temp,ans;
	cin>>x>>n;
	for (int i=0;i<n;i++)
	{
		cin>>temp;
		m[temp]=1;
	}
	int p,q;
	q=p=x;
	while (1)
	{
		if (!m[p]) 
		{
			ans=p;
			break;
		}
		else if (!m[q])
		{
			ans=q;
			break;
		}
		p--;
		q++;
	}
	cout<<ans;
	return 0;
} 

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

int a[1 << 15][15];
int f[1 << 15][15];
int C[1 << 15];

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

    int n;  cin >> n;
    int m;  cin >> m;

    for(int i = 0 ; i < m ; ++i)    {
        int x;  cin >> x;   --x;
        int y;  cin >> y;   --y;
        int c;  cin >> c;

        a[1 << y][x] = c;
        a[1 << x][y] = c;
    }
    for(int i = 0 ; i < n ; ++i)
    for(int m = 1 ; m < (1 << n) ; ++m)  {
        f[m][i] = 2e9;
        a[m][i] = a[m - (m & -m)][i] + a[m & -m][i];
    }
    f[1][0] = 0;

    for(int S = 1 ; S < (1 << n) ; S += 2)  {
        int m = (1 << n) - 1 - S;

        vector<int> subMask;    for(int x = m ; x ; x = (x - 1) & m)    subMask.pb(x);
        reverse(all(subMask));

        for(int t = 0 ; t < n ; ++t)    if (S >> t & 1) {
            for(int u = 0 ; u < n ; ++u)    if(!(S >> u & 1) && a[1 << t][u])
                f[S ^ (1 << u)][u] = min(f[S ^ (1 << u)][u],f[S][t] + a[S ^ (1 << t)][u]);
            
            for(int x : subMask)    {
                int i = __builtin_ctz(x);

                C[x] = C[x ^ (1 << i)] + a[S ^ (1 << t)][i];
                f[S ^ x][t] = min(f[S ^ x][t],f[S][t] + C[x]);
            }
        }
    }
    cout << f[(1 << n) - 1][n - 1] << endl;
}

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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == ',') cout << ' ';
        else cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>  
using namespace std;  
 
  
const int MAX_NUM = 100;  
const int MAX_WEIGHT = 10000;  

  
int weight[MAX_NUM];  
int value[MAX_NUM];  
 
int dp[MAX_WEIGHT];  
  

void Solve( int n, int w )  
{     
    for( int i=1; i<=n; i++ )  
    {  
        for( int j=w; j>=weight[i]; j-- )  
        {             
            if( dp[j-weight[i]] + value[i] > dp[j] )  
                dp[j] = dp[j-weight[i]] + value[i];           
        }  
    }  
    cout << dp[w] << endl;  
}  

int main()  
{    
    int n, w;  
    cin >> n >> w;        
    for( int i=1; i<=n; i++ )  
    {  
        cin >> value[i] >> weight[i];  
    }  
    Solve( n, w );  
 
    return 0;  
}  

Measured memory_bytes: 3136
#include <stdio.h>

int  trans(char A) {
int a ;
   switch (A) {
      case 'A':  
         a = 10; break;
      case 'B': 
           a = 11; break;
      case 'C':  
           a = 12; break;
      case 'D': 
           a = 13; break;
      case 'E': 
           a = 14; break;
      case 'F': 
             a = 15; break;
      default:
              break;
  }
return  a;
}

int main()
{
  char x, y;
  scanf("%c %c",  &x, &y);

 if (trans(x) > trans(y)) {
   printf(">");
} else if (trans(x) == trans(y)){
   printf("=");
} else {
   printf("<");
}
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int t=0;t<T;t++) {
			int n = sc.nextInt(), k = sc.nextInt();
			int d[] = new int[n];
			int x = sc.nextInt();
			
			for(int i=1;i<n;i++) {
				int nx = sc.nextInt();
				d[i] = nx-x;
				x = nx;
			}
			
			sort(d);
			
			int sum = 0;
			for(int i=0;i<=n-k;i++) sum += d[i];
			
			System.out.println(sum);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

using namespace std;

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

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
char s[32525];
char t[3];

int main(){
    scanf("%d%s",&n,s);
    int ans = 0;
    REP(i,1000){
        t[0] = '0' + (i/100);
        t[1] = '0' + ((i/10)%10);
        t[2] = '0' + (i%10);
        int x = 0;
        REP(j,n){
            if(x<3 && s[j]==t[x])x++;
        }
        ans += x==3;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))

tikai = 1e9
idx = 1e9
for i in range(len(H)):
    tmp = t - H[i] * 0.006
    if tikai > abs(a - tmp):
        idx = i + 1
        tikai = abs(a - tmp)
print(idx)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static int n;
    static int[] A;

    public static void main(String[] args) {
        input();
        solve();
    }

    static void solve() {
        int ans = 0;

        for(int i = 0; i < n; i++) {
            ans += A[i] - 1;
        }

        print(ans);
    }

    static void input() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        A = new int[n];
        for(int i = 0; i < n; i++) A[i] = in.nextInt();
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }

    static void printArray2D(int[][] array, char del) {
        int r = array.length;
        int c = array[0].length;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                System.out.format("%3d", array[i][j]);
                if(j != c-1) System.out.print(del);
                else System.out.print('\n');
            }
        }
    }
}

Measured memory_bytes: 25972
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<ll>vec(n);
  rep(i,n) cin >> vec[i];
  int ans = 0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(vec[i]+vec[j]>vec[k] && vec[j]+vec[k]>vec[i] && vec[k]+vec[i]>vec[j]){
          if(vec[i]!=vec[j] && vec[j]!=vec[k] && vec[k]!=vec[i])ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().solve();

	}

	private long[][] arrayItem;
	private long[][] arrayMemo;
	private int itemNum = 0;
	private int weightTotalNum = 0;

	private void solve() {
		Scanner scanner = null;

		try {
			scanner = new Scanner(System.in);
			itemNum = scanner.nextInt();
			weightTotalNum = scanner.nextInt();

			arrayItem = new long[itemNum][2];
			arrayMemo = new long[itemNum + 1][weightTotalNum + 1];
			for (int i = 0; i < arrayItem.length; i++) {
				arrayItem[i][0] = scanner.nextInt();
				arrayItem[i][1] = scanner.nextInt();
			}

			for (int i = itemNum - 1; i >= 0; i--) {
				for (int j = 0; j <= weightTotalNum; j++) {
					if (j < arrayItem[i][0]) {
						arrayMemo[i][j] = arrayMemo[i + 1][j];
					} else {
						arrayMemo[i][j] = Math.max(arrayMemo[i + 1][j],
								arrayMemo[i + 1][j - (int) arrayItem[i][0]] + (int) arrayItem[i][1]);
					}
				}

			}
			//			for (int i = 0; i < arrayMemo.length; i++) {
			//				StringBuilder builder = new StringBuilder();
			//				builder.append(i + ": ");
			//				for (int j = 0; j <= weightTotalNum; j++) {
			//					builder.append(" ");
			//					builder.append(arrayMemo[i][j]);
			//					builder.append(" ");
			//				}
			//				System.out.println(builder.toString());
			//			}
			System.out.println(arrayMemo[0][weightTotalNum]);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

#A = [ i**2 % M for i in range(M) ]
A = []
B = {}
a = X
i_repeat = 0
for i in range(N):
    if a in B.keys():
        i_repeat = B[a]
        break
    A.append(a)
    B.update({ a : i })
    a = a**2 % M
    i += 1

repeat_size = i - i_repeat
repeat_interval = N - i_repeat

num_repeats = repeat_interval // repeat_size
num_red = repeat_interval % repeat_size


res = sum(A[:i_repeat])
res += sum(A[i_repeat:i]) * num_repeats
res += sum(A[i_repeat:i_repeat+num_red])

print(res)



Measured memory_bytes: 82848
# 入力　数字1つ（文字列として扱う）
N = input()

# ３つ以上連続でYes
if N[0] == N[1] and N[1] == N[2] :
    print("Yes")
elif N[1] == N[2] and N[2] == N[3] :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

int main(){
    int n, m;
    scanf("%d %d\n", &n, &m);

    vector<vector<int> > s;
    s.resize(m);
    for(int i = 0; i < m; ++i){
        int k;
        cin >> k;
        s.at(i).resize(k);
        for(int x = 0; x < k; ++x){
            int si;
            cin >> si;
            s.at(i).at(x) = si;
        }
    }

    vector<int> p;
    p.resize(m);
    for(int i = 0; i < m; ++i){
        int pi;
        cin >> pi;
        p.at(i) = pi;
    }

    int ans = 0;
    for(int x = 0; x < (1 << n); ++x){
        bool flag = true;
        for(int i = 0; i < m; ++i){
            int tmp = 0;
            for(int si : s.at(i)){
                if((x >> (si - 1)) % 2){
                    tmp++;
                }
            }
            if(tmp % 2 != p.at(i)){
                flag = false;
                break;
            }
        }
        if(flag){ ans++; }
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;
	int a[55];
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i ++)
		cin >> a[i];
	int s = 0;
	for (int i = 1; i <= n; i ++)
	{
		for (int j = i + 1; j <= n; j ++)
			s += (a[i] * a[j]);
	}
	cout << s;
}



Measured memory_bytes: 256
n = int(input())
s = list(input())

res = 0

for k in range(1,n):
    d = [0]*n
    for i in range(n-k):
        if i+k <= n-1 and s[i] == s[i+k]:
            d[i] = min(k,d[i-1]+1)
            res = max(res,d[i])
print(res)


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

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  
  double S;
  S = W*H;
  cout << S/2 << endl;
  if ((W/2 == x)&&(H/2 == y)){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
# 偶数が1つでもあれば0
# 全て奇数ならa, b, cのうち小さい2つの数で構成される面 * 1列の個数

nums = list(map(int, input().split()))

if any([v % 2 == 0 for v in nums]):
    print(0)
else:
    sorted_nums = sorted(nums)
    print(sorted_nums[0] * sorted_nums[1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int a[20000011],p=1000000007;
int pow1(int rarac,int d){
  long long c; 
  if(d==1)
    return rarac;
  else{
    c=pow1(rarac,d/2);
    if(d%2==0){
      c*=c;
      c%=p;
    }
    else{
      c*=c;
      c%=p;
      c=c*rarac;
      c%=p;
    }
  }
  return c;
}
int jandaba(int n,int m){
  long long  A=a[n+m];
  long long B=((long long)a[n]*a[m])%p;
  return (A * pow1(B,p-2))%p;
}
int datvla(int x,int y){
  long long k=0;
    k+=jandaba(x+1,y+1);
    k%=p;
  return k;
}
int main() {
  int r1,c1,r2,c2;
  long long ans=0;
  cin>>r1>>c1>>r2>>c2;
  long long x=1;
  for(int i=1;i<=2000010;i++){
    x*=i;
    x%=p;
    a[i]=x;
  }
  a[0]=1;
  ans+=datvla(r2,c2);
  ans%=p;
  ans-=datvla(r1-1,c2);
  ans%=p;
  ans-=datvla(r2,c1-1);
  ans%=p;
  ans+=datvla(r1-1,c1-1);
  ans%=p;
  cout<<(ans+p)%p;
}

Measured memory_bytes: 8448
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <iostream>
#include <limits>
#include <random>
#include <utility>
#include <vector>

namespace procon {
  class UnionFind {
  private:
    struct nodeinfo {
      int par;
      int rank;
      nodeinfo(int par) : par(par), rank(0) {}
    };
    std::vector<nodeinfo> node;

  public:
    UnionFind(int n) : node() {
      node.reserve(n);
      for (int i = 0; i < n; ++i) {
	node.push_back(nodeinfo(i));
      }
    }
    int root(int x) {
      if (node[x].par == x) {
	return x;
      }
      return node[x].par = root(node[x].par);
    }
    void unite(int x, int y) {
      x = root(x);
      y = root(y);
      if (x == y) {
	return;
      }
      if (node[x].rank < node[y].rank) {
	node[x].par = y;
      } else {
	node[y].par = x;
	if (node[x].rank == node[y].rank) {
	  ++node[x].rank;
	}
      }
    }
    bool is_same_set(int x, int y) { return root(x) == root(y); }
  };
}
  
int main(void) {
  int size, n_query;
  std::cin.read((char *)&size, sizeof(int));
  std::cin.read((char *)&n_query, sizeof(int));

  std::vector<uint64_t> query(n_query);
  std::cin.read((char *)query.data(), sizeof(uint64_t) * n_query);

  const int mask = (1 << 30) - 1;

  uint64_t res = 123456789;
  procon::UnionFind uf(size);
  for (uint64_t q : query) {
    const int com = q >> 60;
    const int x = (q >> 30) & mask;
    const int y = (q >> 0) & mask;
    assert(0 <= x && x < size);
    assert(0 <= y && y < size);
    if (com) {
      res = res * 17 + (uf.is_same_set(x, y) ? 1 : 0);
    } else {
      uf.unite(x, y);
    }
  }
  std::cout << res << std::endl;
  return 0;
}



Measured memory_bytes: 269824
N,M =(input()).split()
x = (input()).split()
a = 0
k = []
b = 0
for i in (x):
    k.append(i)
for j in k:
    b = int(j) + b
v = int(N)-b
if v <0:
    n = -1
else:
    n = v
print (n)


Measured memory_bytes: 9612
#include <bits/stdc++.h>
#define int long long
using namespace std;

main()
{
    int n;
    scanf("%lld",&n);
    int dp[n+1];
    dp[0]=0;
    int a[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++){
        int b,c;
        b=abs(a[i]-a[i-1])+dp[i-1];
        c=abs(a[i]-a[i-2])+dp[i-2];
        dp[i]=min(b,c);
    }
    printf("%lld",dp[n]);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n,m,k;
  cin>>n>>m>>k;
  vector<ll> suma(n+1,0),sumb(m+1,0);
  vector<ll> a(n),b(m);
  for(ll i=0;i<n;i++){
    cin>>a[i];
    suma[i+1]+=a[i]+suma[i];
  }
  for(ll i=0;i<m;i++){
    cin>>b[i];
    sumb[i+1]+=b[i]+sumb[i];
  }
  ll lastj=m,ans=0;
  for(ll i=0;i<=n;i++){
    if(suma[i]>k){
      break;
    }
    for(ll j=lastj;j>=0;j--){
      if(suma[i]+sumb[j]<=k){
        ans=max(i+j,ans);
        break;
      }
      lastj=j;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 9576
N, M = map(int, input().split())
ab = []
for _ in range(M):
    ab.append(tuple(map(int, input().split())))

ab.sort(key = lambda x:x[1])
#print(ab)
end = ab[0][1]
cursol = 0
end = ab[0][1]
cnt = 1
while cursol < M -1:
    cursol += 1
    if end <= ab[cursol][0]:
        end = ab[cursol][1]
        cnt += 1
print(cnt)

Measured memory_bytes: 18252
#include <bits/stdc++.h>
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) x.begin(),x.end()
using namespace std;


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

    int d,n;
    cin >> d >> n;
    if(d == 0) {
        if (n != 100) cout << n << endl;
        else cout << 101 << endl;
    }
    else if (d == 1) {
        if (n != 100) cout << n*100 << endl;
        else cout << 10100 << endl;
    }
    else {
        if (n != 100) cout << n*10000 << endl;
        else cout << 1010000 << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
N = int(input())
b = []

for i in range(N):
  a = [-1] * N
  for j in range(int(input())):
    temp = list(map(int, input().split()))
    a[temp[0]-1] = temp[1]
  b.append(a)
  
ans = 0

for i in range(2 ** N):
  temp = list(map(int, list(str(format(i, 'b')).zfill(N))))
  num = 0
  for j, var in enumerate(temp):
    if var == 1:
      for k, var2 in enumerate(b[j]):
        if var2 == -1:
          pass
        elif var2 != temp[k]:
          num = -1
          break
      if num == -1:
        break
      else:
        num += 1
  if num > ans:
    ans = num
print(ans)
        
  
  

Measured memory_bytes: 74356