akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+7;
const ll inf_l = 1e18;
const int MAX = 1e6;

int main() {
    int n; cin >> n;
    int sz = -1;
    for (int i = 2; i*(i-1)/2 <= n; i++) {
        if (i*(i-1)/2 == n) sz = i;
    }
    if (sz == -1) {cout << "No" << endl; return 0;}
    vvint ans(sz,vint(sz-1,-1));
    int now = 1;
    rep(i,sz) {
        rep(j,sz-1-i) {
            ans[i][j+i] = now;
            ans[i+j+1][i] = now++;
        }
    }
    cout << "Yes" << endl;
    cout << sz << endl;
    rep(i,sz) {
        cout << sz-1 << " ";
        rep(j,sz-1) printf("%d%s",ans[i][j],j==sz-2?"\n":" ");
    }
}

Measured memory_bytes: 2176
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}
	count := 0
	for i := 0; i < n-2; i++ {
		if (list[i] > list[i+1] && list[i+1] > list[i+2]) || (list[i] < list[i+1] && list[i+1] < list[i+2]) {
			count++
		}

	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<atcoder/all>

#define ll long long
#define ld long double

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>

#define all(a) a.begin(), a.end()

#define endl '\n'
using namespace std;
using namespace atcoder;

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=10000007;//998244353
const ll INF=1e18;
const int inf=1e9;
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=3e5+10;

//mapping (f,x)=f(x);
//composition 関数合成
//id 恒等写像（単位元）
using mint = modint998244353;
struct S{
  mint x, w;
  S(mint x=0, mint w=1):x(x),w(w) {}//単位元的なのを事前に入れるやつ
};
S op(S a, S b){
  return S(a.x*b.w+b.x, a.w*b.w);
}
S e(){ return S();}
S mapping(int f,S a){
  if(f == 0) return a;
  return S((a.w-1)/9*f,a.w);
}
int composition(int f,int g){
  if(f == 0) return g;
  return f;
}
int id(){ return 0;}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,q;
  cin >> n >> q;
  
  lazy_segtree<S,op,e,int,mapping,composition,id> tree(n);
  rep(i,n) tree.set(i,S(1,10));
  
  while(q--){
    int l,r,d;
    cin >> l >> r >> d;
    l--;
    tree.apply(l,r,d);
    S ans = tree.all_prod();
    cout << ans.x.val() << endl;
  }
                       
  return 0;
}


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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

/*class Point{
	public:
		double x, y;

		Point(double x = 0, double y = 0): x(x), y(y) {}

		Point operator + (Point p){ return Point(x + p.x, y + p.y); }
		Point operator - (Point p){ return Point(x - p.x, y - p.y); }
		Point operator * (double a){ return Point(a * x, a * y); }
		Point operator / (double a){ return Point (x / a, y / a); }

		double abs(){ return sqrt(norm()); }
		double norm(){ return x * x + y * y; }

		bool operator < (const Point &p) const{
			return x != p.x ? x < p.x : y < p.y;
		}

		bool operator == (const Point &p) const{
			return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
		}
};

class Segment{
	public:
		Point p1, p2;
		Segment(Point p1 = Point(), Point p2 = Point()): 
			p1(p1), p2(p2) {}
};

class Circle{
	public:
		Point c;
		double r;
		Circle(Point c = Point(), double r = 0.0): c(c) , r(r) {}
};

typedef Segment Line;
typedef vector<Point> Polygon;
typedef Point Vector;

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}
*/

int main(){
	int n; cin >> n;
	vector<int> A;
	
	A.resize(n);

	for(int i = 0; i < A.size(); i++) A[i] = 0;

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

	for(int i = 0; i < A.size(); i++){
		cout << A[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<pair<T, T> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	int sz = s.size();
	cout << s[0] << sz - 2 << s[sz - 1] << "\n";

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	/*
	a を b 回繰り返した文字列は a で始まり、b を a 回繰り返した文字列は b で始まるため、
	a < b ならば常に a を b 回繰り返した文字列の方が辞書順で小さいですし、
	a > b ならば常に b を a回繰り返した文字列の方が辞書順で小さいです。
	また、a = b なら二つの文字列が等しくなるのでどちらを出力しても同じになります
	*/
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		sc.close();
		
		int A = Integer.parseInt(a);
		int B = Integer.parseInt(b);
		
		StringBuffer ans = new StringBuffer();
		if(A < B) {
			for(int i = 0; i < B; i++) {
					ans.append(A);
			}
		}else {
			for(int i = 0; i < A; i++) {
					ans.append(B);
			}
		}
		System.out.println(ans.toString());
	}
}

Measured memory_bytes: 21844
def main():
    import re
    s = input()
    s = s.replace('BC', 'D')

    obj = re.findall('[AD]+', s)
    ans = 0

    for x in obj:
        cnt = 0
        for i in x:
            if i == 'A':
                cnt += 1
            if i == 'D':
                ans += cnt

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5284
let () = Scanf.scanf "%d %d" (fun k s ->
  let arr = Array.init (k+1) (fun i -> i) in
  Array.fold_left (fun a i ->
    let b = Array.fold_left (fun a j -> if 0 <= s-i-j && s-i-j <= k then a+1 else a) 0 arr
    in a+b) 0 arr) |> Printf.printf "%d\n"


Measured memory_bytes: 512
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int f(int i){
	return i * (i + 1) / 2;
}
int main(){
	FIO
	
	int n,k;cin >> n >> k;
	int a[n];forn(i, n)cin >> a[i];
	ld ans = 0.0, sum = 0.0;
	for(int i = 0; i < k;i++){
		sum += (f(a[i]) / (ld)a[i]);
	}
	ans = max(ans, sum);
	for(int i = k; i < n;i++){
		sum -= (f(a[i - k]) / (ld)a[i - k]);
		sum += (f(a[i]) / (ld)a[i]);
		ans = max(ans, sum);
	}
	cout << fixed << setprecision(16) << ans;
	return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val vList = readLine()!!.split(" ").map{ it.toInt() }
    val cList = readLine()!!.split(" ").map{ it.toInt() }
    
    var ans = 0
    for(i in 0 until n){
        val cost = vList[i] - cList[i]
        if(cost > 0) ans+=cost
    }
    
    println(ans)
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    int count = 0;
    for(int i = 0; i < N; i++) {
        cin >> h.at(i);
        if(h.at(i) >= K) count++;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n,lun=0,l=0;
    cin>>n;
    vector<int>arr(n,0);
    for(int i=0;i<n;i++)cin>>arr[i];
    for(int i=1;i<n;i++)
    {
      if(arr[i]<=arr[i-1])
      lun++;
      else lun=0;
      if(lun>l)l=lun;
    }
    cout<<l;
    return 0;
}


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

int main(void){
    ll ans=0,money=100,X;
    cin >> X;
    while(X > money){
        ans++;
        money += money/100;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
solve :: Int -> Int -> IO ()
solve c n  = do
  if n < c then return ()
  else do
    v1 <- readLn :: IO Integer
    v2 <- readLn :: IO Integer
    if (v1+v2) >= 10^80 then putStrLn "overflow"
    else print (v1+v2)
    solve (c+1) n

main :: IO ()
main = do
  n <- readLn :: IO Int
  solve 1 n

Measured memory_bytes: 4396
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int d,t,s;
    scanf("%d%d%d",&d,&t,&s);
    if ((t*s)>=d)
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define N 200012
typedef long long ll;
struct node{ll x,y;friend bool operator<(node a,node b){return (a.x^b.x)?a.x<b.x:a.y<b.y;}};
int n,a[N];
map<node,ll>dp[22][22];
ll cal(int l,int r,ll x,ll y)
{if(l==r-1)return 0;if(dp[l][r].count((node){x,y}))return dp[l][r][(node){x,y}];
	ll ret=4e18;
	for(int i=l+1;i<r;i++)
	{
		ret=min(ret,cal(l,i,x,x+y)+cal(i,r,x+y,y)+1ll*(x+y)*a[i]);
	}return dp[l][r][(node){x,y}]=ret;
}
int main()
{
    scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	printf("%lld\n",cal(1,n,1,1)+a[1]+a[n]);
}


Measured memory_bytes: 16640
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


int digits(int n) {
	int ans = 0;
	while (n) {
		++ans;
		n /= 10;
	}
	return ans;
}

int main() {
	int a, b;
	while (cin >> a && cin >> b) {
		cout << digits(a + b) << endl;
	}
}


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int k, s, count = 0;

	scanf("%d%d", &k, &s);
	for(int i=0; i <= k; i++) {
		for(int j=0; j <= k; j++) {
            int l = s - i - j;
			if(l >= 0 && l <= k)
				count++;
		}
	}
	printf("%d", count);

	return 0;
}


Measured memory_bytes: 128
//AtCoder ABC075 B - Minesweeper
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
using Mat=vector<vector<ll>>;
int main() {
    ll H,W;
    cin>>H>>W;
    vector<string> mt(H);
    for(auto& m:mt){
        cin>>m;
    }
    auto check_bom = [&](ll x,ll y){
        if (x<0||x>=W) return 0;
        if (y<0||y>=H) return 0;
        if (mt[y][x]=='#') return 1;
        return 0;
    };
    Mat ans(H,vector<ll>(W,0));
    for(ll y=0;y<H;++y){
        for(ll x=0;x<W;++x){
            if (!check_bom(x,y)) {
                ans[y][x] += check_bom(x-1,y-1);
                ans[y][x] += check_bom(x,y-1);
                ans[y][x] += check_bom(x+1,y-1);
				ans[y][x] += check_bom(x-1, y);
				ans[y][x] += check_bom(x+1, y);
				ans[y][x] += check_bom(x-1, y+1);
				ans[y][x] += check_bom(x, y+1);
				ans[y][x] += check_bom(x+1, y+1);
            } else {
                ans[y][x] = -1;
            }
        }
    }
    for(auto&& yt:ans){
        for(auto && x: yt){
            cout<<(char)(x>=0?('0'+x):'#');
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define float long double 

int32_t main()
{
  IOS;
 string s,t;
 cin>>s>>t;

int cnt = 0;
for(int i=0; i<s.length(); i++)
{
  if(s[i]!=t[i]) cnt++;
}
cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 5 * 100500
#define oo ll(1e16)
#define ft first
#define sd second
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
using namespace std;
typedef long long ll;
typedef long double ld;

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

//    in("input.txt");

    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC";
        else cout << "ABC";
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <deque>
#include <map>
using namespace std;
int main() {
	int n, k;
	long long ans = 1;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		ans *= k;
		if (i == 0) {
			k--;
		}
	}
	cout << ans << endl;
}


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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=1000000007LL;
const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};




int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n;cin>>n;
  vl vec;
  n--;
  while(n>=0){
    vec.pb(n%26);
    n-=(n%26+1);
    if(n<=0)break;
    n/=26;
    //if(n==0)break;
  }
  reverse(vec.begin(),vec.end());
  rep(i,vec.size())cout<<abc[vec[i]];
  cout<<endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <string.h>
#include<iterator>
#include <map>
using namespace std;
int  used[200500];
// bool cmp(long long a, long long b){
//     return a > b;
// }
long long counted = 0;
void dfs(set<long long>* sets, int current, long long count){
    used[current] = 1;
    for (auto it:sets[current]){
        if (used[it] != 1) {
            counted++;
            dfs(sets, it, count);
        }
    }
}
string str[10];
char str_arr[5][5];
int matr[25][25], saved_matr[5][5], ish_matr[5][5];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long t, ch, i, curr, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, ans = 0;
    long long a, b;
    int fl, fl1, fl2, fl3;
    string s, s1;
//    cin >> t;
    long long f, size_f, size_s, weight1, weight2;
    long long sum, k_min, k_max;
//    for (auto test_case = 0; test_case < t; test_case++) {
//    }
    long long d;
    cin >> n >> m;
    set<long long>* sets = new set<long long>[n + 5];
    for (i = 0; i < m; i++){
        cin >> x >> y;
        sets[x].insert(y);
        sets[y].insert(x);
    }
    ans = 0;
    long long maxim = 0;
    for (i = 1; i <= n; i++){
        if (used[i] != 1){
            counted = 1;
            dfs(sets, i, counted);
//            cout << counted << " " << maxim << endl;
            maxim = max(maxim, counted);
        }
    }
    cout << maxim;
    return 0;
}

Measured memory_bytes: 41776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 2e5 + 5;
const double eps = 1e-9;

int f[1000][1000];

int main() {
    //freopen("test.txt", "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a, b; cin >> a >> b;
    if(abs(a - b) <= 1) cout << "Brown\n";
    else cout << "Alice\n" << endl;
    return 0;
    rep(d, 0, 100) {
        rep(i, 0, d + 1){
            int j = d - i;
            if(i < j) continue;
            for (int k = 1; 2 * k <= i; k ++) {
                a = i - 2 * k;
                b = j + k;
                if(a < b) swap(a, b);
                f[i][j] |= (1 - f[a][b]);
            }
            for (int k = 1; k * 2 <= j; k ++) {
                a = i + k;
                b = j - 2 * k;
                f[i][j] |= (1 - f[a][b]);
            }
        }
    }
    rep(i, 0, 20) {
        rep (j, 0, i + 1) cout << f[i][j] << ' ';
        cout << endl;
    }
}




Measured memory_bytes: 256
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
    int a[5];

    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }

    int sa[5];
    int maxi;
    int max = -1;
    int ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = 1; j <= 13; j++) {
            if (j * 10 >= a[i]) {
                sa[i] = j * 10 - a[i];
                break;
            }
        }
    }

    for (int i = 0; i < 5; i++) {
        if (max < sa[i]) {
            max = sa[i];
            maxi = i;
        }
    }
    for (int i = 0; i < 5; i++) {
        if (i != maxi) {
            ans += sa[i] + a[i];
        }
    }
    ans += a[maxi];

    
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int * h;
int * dp;
bool * v;
int solve(int n, const int& max){
	if (n == max -1)
		return 0;
	
	if (n == max){
		return	1e9;
	}
	
	if (v[n]) return dp[n];
	int cost = dp[n] = min(solve(n+1, max) + abs(h[n]  - h[n+1]), solve(n+2, max) + abs(h[n] - h[n+2]));
	v[n] = 1;

	return cost;
}

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

	h = new int[N];	
	dp = new int[N];
	v = new bool[N];

	fill(dp, dp + N, 0);
	fill(v, v + N, 0);

	for(int i= 0; i < N;i++){
		cin >> h[i];
	}


	cout << solve(0, N) << endl;
	return 0;
}


Measured memory_bytes: 6804
#include<bits/stdc++.h>
using namespace std;
long long s[555555],a[555555],ans;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		s[i]=s[i-1]+x;
		a[i]=a[i-1]^x;
	}
	int l=1;
	for(int r=1;r<=n;r++)
	{
		for(;(s[r]-s[l-1])!=(a[r]^a[l-1]);l++);
		ans+=r-l+1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3840
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int N = sc.nextInt();
        int K = sc.nextInt();
        var S = sc.next();
        var c = S.ToCharArray();
        c[K- 1] = Convert.ToChar(S[K-1].ToString().ToLower());
        WriteLine(new String(c));
    }
}


class Scanner {
    string[] s;
    int i;

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

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

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

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

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

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

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

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

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define e cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
int n,m;
ll x,y;
int a;
ll ans=0;
ll sum=0;

int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		sum+=i;
		if(sum>n)break;
	}
	a=i;
	if(n==1){
		p(1);
	}else{
		for(i=1;i<=a;i++){
			if(i!=sum-n)p(i);
		}
	}
	return 0;
}

Measured memory_bytes: 4992
class Segment_tree():
    def __init__(self, n, s):
        self.alphabet_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
        self.key = dict()
        self.k = 1
        for value in self.alphabet_list:
            self.key[value] = self.k
            self.k *= 2
        self.inf = pow(2, 32)
        self.n = n
        self.s = s
        self.N = 1
        while self.N < self.n:
            self.N *= 2
        self.size = self.N * 2
        self.size -= 1
        self.N -= 1
        self.segment = [0]*(self.N) + [self.key[self.s[i]] for i in range(self.n)] + [0]*(self.size-self.N-self.n)
        for i in range(self.N-1, -1, -1):
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]

    def update(self, i, x):
        i += (self.N-1)
        self.segment[i] = self.key[x]
        while i > 0:
            i = (i-1)//2
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]
        
    def find(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.segment[k]
        else:
            find_l = self.find(a, b, 2*k+1, l, (l+r)//2)
            find_r = self.find(a, b, 2*k+2, (l+r)//2, r)
            return find_l|find_r


n = int(input())
s = input()
segment = Segment_tree(n, s)
q = int(input())
N = 1
while N < n:
  N *= 2
for i in range(q):
    quer = [x for x in input().split()]
    if quer[0] == "1":
        i, c = int(quer[1]), quer[2]
        segment.update(i, c)
    else:
        l, r = int(quer[1]), int(quer[2])
        key = segment.find(l-1, r, 0, 0, N)
        ans = 0
        for i in range(26):
            if (key>>i)&1:
                ans += 1
        print(ans)

Measured memory_bytes: 92836
N, Q = map(int, input().split())
S =input()
AC_list = [0]*N
count = 0
for i in range(1,N):
  if (S[i-1] + S[i]) == "AC":
    count +=1
  AC_list[i] = count

for i in range(Q):
  l, r = map(int, input().split())
  print(AC_list[r-1] - AC_list[l-1])

  
  

Measured memory_bytes: 51416
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define FORI(n) for(int i = 0; i < n; i++)
#define FORJ(n) for(int j = 0; j < n; j++)
#define FORK(n) for(int k = 0; k < n; k++) 
#define FOR2I(a, B) for(int i = 0; i < a; i ++) for(int j = 0; j < b; j++)
#define FORIT(S) for(auto it = S.begin(); it != S.end(); it++)

using namespace std;

int main(){
	string a, b; 
	cin >> a;
	cin >> b;
	FORIT(b) a+= *it;
	double num = stoi(a); 

	bool flag = false; 
	if(sqrt(num) - (int) sqrt(num) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll INF=1e18;
int main()
{
    int n; cin>>n;
    ll l[5010], r[5010];
    vector<int> ind(n);
    iota(ind.begin(), ind.end(), 0);
    for(int i=0; i<n; i++) cin>>l[i]>>r[i];
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    sort(ind.begin(), ind.end(), [&](int i, int j){ return l[i]+r[i]>l[j]+r[j];});
    ll dp[2][5010];
    dp[0][0]=0;
    for(int i=0; i<n; i++){
        int t=ind[i];
        for(int j=0; j<=i+1; j++) dp[(i+1)&1][j]=INF;
        for(int j=0; j<=i; j++){
            dp[(i+1)&1][j]=min(dp[(i+1)&1][j], dp[i&1][j]+(i-j)*(l[t]+r[t])+l[t]);
            dp[(i+1)&1][j+1]=min(dp[(i+1)&1][j+1], dp[i&1][j]+j*(l[t]+r[t])+r[t]);
        }
    }
    ll ans=INF;
    for(int i=0; i<=n; i++) ans=min(ans, dp[n&1][i]);
    if(n%2==0){
        cout<<ans<<endl;
        return 0;
    }
    ll dp2[2][2][5010];
    dp2[0][0][0]=0, dp2[0][1][0]=INF;
    for(int i=0; i<n; i++){
        int t=ind[i];
        for(int j=0; j<=i+1; j++) dp2[(i+1)&1][0][j]=dp2[(i+1)&1][1][j]=INF;
        for(int j=0; j<=i; j++){
            for(int k=0; k<2; k++){
                dp2[(i+1)&1][k][j]=min(dp2[(i+1)&1][k][j], dp2[i&1][k][j]+(i-j)*(l[t]+r[t])+l[t]);
                dp2[(i+1)&1][k][j+1]=min(dp2[(i+1)&1][k][j+1], dp2[i&1][k][j]+j*(l[t]+r[t])+r[t]);
            }
            dp2[(i+1)&1][1][j]=min(dp2[(i+1)&1][1][j], dp2[i&1][0][j]+(n-1)/2*(l[t]+r[t]));
        }
    }
    ans=min(ans, dp2[n&1][1][(n-1)/2]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int main() {
    int N; scanf("%d", &N);
    vector<ll> A(N);
    ll sum = 0;
    for(int i=0; i<N; i++) scanf("%lld", &A[i]), sum ^= A[i];
    for(int i=0; i<N; i++) A[i] &= ~sum;

    ll ans = sum, r = 0;
    for(int k=59; k>=0; k--) {
        int j;
        for(j=r; j<N; j++) {
            if(A[j] >> k & 1) {
                swap(A[r], A[j]);
                break;
            }
        }

        if(j == N) continue;
        for(int i=0; i<N; i++) {
            if(i == r) continue;
            if(A[i] >> k & 1) A[i] ^= A[r];
        }
        r++;
    }

    /*
    for(int i=0; i<N; i++) fprintf(stderr, "%lld ", A[i]);
    fprintf(stderr, "\n");
    */

    ll x = 0;
    for(int i=0; i<N; i++) x ^= A[i];
    ans += (x << 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

fn lcm(x: i64, y: i64) -> i64 {
    x * (y / gcd(x, y))
}

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

fn main() {
    let n: i64 = read();
    let m: i64 = read();

    println!("{}", lcm(n, m));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int l[300000],d[300000];
int main()
{
	int n,x;
	cin>>n>>x;

	for (int i = 1; i <= n; ++i)
	{
		cin>>l[i];
	}
	d[1] = 0;
	int cnt = 1;
	for (int i = 2; i <= n+1; ++i)
	{
		d[i] = d[i-1] + l[i-1]; 
		if(d[i]>x)
		{
			break;
		}
		cnt++;
	}
	cout<<cnt<<endl;

	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>

#define int long long
#define CONTAINS(v,n) (find((V).begin(), (V).end(), (n)) != (V).end())
#define SORT(v) sort((V).begin(), (V).end())
#define RSORT(v) sort((V).rbegin(), (V).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (V.erase(remove((V).begin(), (V).end(), (a)), (V).end()))
#define REVERSE(v) (reverse((V).begin(), (V).end()))
#define LOWER_BOUND(v,a) (lower_bound((V).begin(), (V).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((V).begin(), (V).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N;
int A[100000];
int B[100000];
int C[100000];

int bcnt[100000];

signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];
	REP(i, N) cin >> B[i];
	REP(i, N) cin >> C[i];

	ARY_SORT(A, N);
	ARY_SORT(B, N);
	ARY_SORT(C, N);

	int c_index = N - 1;
	for (int b = N - 1; b >= 0; b--)
	{
		int cc = 0;
		for (int c = c_index; c >= 0; c--)
		{
			if (C[c] <= B[b])
			{
				cc = c + 1;
				break;
			}
		}
		c_index = cc - 1;
		bcnt[b] = N - cc;
		if (b < N - 1)
		{
			bcnt[b] += bcnt[b + 1];
		}
	}

	int ans = 0;
	int b_index = N - 1;
	for (int a = N - 1; a >= 0; a--)
	{
		int bb = 0;
		for (int b = b_index; b >= 0; b--)
		{
			if (B[b] <= A[a])
			{
				bb = b + 1;
				break;
			}
		}
		b_index = bb - 1;
		if (bb < N)
		{
			ans += bcnt[bb];
		}
	}

	cout << ans << endl;
}



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

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}
	int a, b;
	cin >> a >> b;
	cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()

	as := make([]int, n)
	for i := range as {
		as[i] = getInt()
	}

	ans1 := solve(as, 1)
	ans2 := solve(as, 0)

	fmt.Println(min(ans1, ans2))
}

func solve(as []int, r int) int {
	ans := 0
	sum := 0
	for i, a := range as {
		if i%2 == r {
			if sum+a <= 0 {
				ans += abs(sum+a) + 1
				sum = 1
			} else {
				sum += a
			}
		} else {
			if sum+a >= 0 {
				ans += abs(sum+a) + 1
				sum = -1
			} else {
				sum += a
			}
		}
	}
	return ans
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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



int main(){

    int N; cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];

    string ans = "APPROVED";
    rep(i, N){
        if(A[i]%2==0){
            if(A[i]%3 != 0 && A[i]%5 != 0) ans = "DENIED";
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<utility>
 
 
int main(){
    int h,w;
    char evenc,oddc;
    while(scanf("%d %d",&h,&w) && (h != 0 || w != 0)){
        evenc = '.',oddc = '#';
        for(int i=1;i <= h;i++){
            for(int j=1;j <= w;j++){
                if(j % 2 == 0){
                    printf("%c",evenc);
                } else{
                    printf("%c",oddc);
                }
            }
            printf("\n");
            std::swap(evenc,oddc);
        }
        printf("\n");
    }
    return 0;
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S[0] == S[1] && S[1] == S[2]) cout << NO << endl;
    else cout << YES << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int t=0;
void print(int a[],int n){
	int i;
	for(i=0;i<n;i++){
		if(i>0)
		printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
}
void bubble(int a[],int n){
	int flag=1,i,mid;
	while(flag){
		flag=0;
		for(i=n-1;i>0;i--){
			if(a[i]<a[i-1])
			{
				mid=a[i];
				a[i]=a[i-1];
				a[i-1]=mid;
				t++;
				flag=1;
			}
		}
	}
}
int main(){
	int i,n;
	scanf("%d",&n);
	int a[n+1];
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	bubble(a,n);
	print(a,n); 
	printf("%d\n",t);
	return 0;
}


Measured memory_bytes: 2144
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i]-=1

roop = [0]
for i in range(3*n):
    roop.append(a[roop[i]])
cnt =[0]*n
d = []
for i in range(len(roop)):
    cnt[roop[i]]+=1
    if cnt[roop[i]]>=3 and cnt[roop[i]]<4:
        d.append(roop[i])
for i in range(len(roop)):
    if roop[i] == d[0]:
        check = i
        break
if check == 0:
    k%=len(d)
    print(d[k]+1)
else:
    if k<check + len(d):
        print(roop[k]+1)
    else:
        k-=check
        k%=len(d)
        print(d[k]+1)

Measured memory_bytes: 33928
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    int cnt=0;
    int now=0;
    rep(i,n){
        if(a[i]>=now){
            now=a[i];
            cnt ++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
def main():
    n, x, y = map(int, input().split())
    ans = [0]*(n)
    for i in range(1, n):
        for j in range(i+1, n+1):
            ans[min(j-i, abs(x-i)+abs(y-j)+1)] += 1
    for v in ans[1:]:
        print(v)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template
int ans;
int dcount(int x){
    int c = 0;
    for(int i=1;i<=x;i++){
        if(x%i==0)c++;
    }
    return c;
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    for(int i=1;i<=n;i+=2){
        if(dcount(i)==8)ans++;
    }
    cout<<ans<<newl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String input1 = sc.nextLine();
        int length = Integer.valueOf(input1);
        input1 = sc.nextLine();
        String[] inputs = input1.split(" ");
        int[] numbers = new int[length];
        for(int i=0;i<length;i++) {
            numbers[i] = Integer.valueOf(inputs[i]);
        }
        int sum = 0;
        boolean allZero = false;
        int start = 0;
        int k = 0;
        boolean minFound = false;
        while(allZero==false) {
            allZero=true;
            int min = Integer.MAX_VALUE;
            start = 0;
            for(int i = 0; i<length;i++) {
                if(numbers[i]!=0)
                {
                    if( numbers[i]< min ) {
                        min = numbers[i];
                        minFound = true;
                    }
                    allZero=false;
                }

                if(numbers[i]==0 || i==length-1)
                {
                    int end = i-1;
                    if(numbers[i]!=0) {
                        end = end+1;
                    }
                    //System.out.println("min: "+ min);
                    for(int j = start ; j<=end;j++) {
                        //System.out.println(j+": "+numbers[j]);
                        numbers[j] = numbers[j]-min;
                        //System.out.println(j+": "+numbers[j]);
                        //System.out.println();
                    }

                    if(minFound) {
                        minFound = false;
                        sum = sum + min;
                    }
                    start = i+1;
                    min = Integer.MAX_VALUE;
                }

            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23124
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase
#include <ctime>    // clock

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, n;
    cin >> x >> n;
    int p[n];
    int ans = 1000;
    for(int i=0; i<n; i++) cin >> p[i];
    for(int i=0; i<102; i++)
    {
        bool ok = true;
        if(abs(x-i) < abs(x-ans))
        {
            for(int j=0; j<n; j++) if(p[j] == i) ok = false;
            if(ok) ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

vector<vector<ll>> d;
//ll ans = LINF;
//
//void rec(ll start, map<ll, ll> done, ll sum) {
//    for (auto town : done) {
//        if (town.second == 1) continue;
//
//        done[town.first] = 1;
//        rec(town.first, done, sum += d[start][town.first]);
//        done[town.first] = 0;
//    }
//
//    ans = min(ans, sum);
//};

int main() {

    ll n, m, r; cin >> n >> m >> r;
    vector<ll> t(r);
    for (ll i = 0; i < r; ++i) {
        cin >> t[i];
        t[i]--;
    }

    d.resize(n, vector<ll>(n, LINF));
    for (int i = 0; i < n; ++i) {
        d[i][i] = 0;
    }
    for (ll i = 0; i < m; ++i) {
        ll a, b, c; cin >> a >> b >> c;
        --a; --b;

        d[a][b] = c;
        d[b][a] = c;
    }

    // ワーシャルフロイド
    for (ll k = 0; k < n; ++k) {
        for (ll i = 0; i < n; ++i) {
            for (ll j = 0; j < n; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

//    map<ll, ll> done;
//    for (ll i = 0; i < r; ++i) {
//        done[t[i]] = 0;
//    }
//
//    for (ll i = 0; i < r; ++i) {
//        done[t[i]] = 1;
//        rec(t[i], done, 0);
//        done[t[i]] = 0;
//    }

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

    cout << ans << endl;
}

Measured memory_bytes: 3956
<?php
$n = trim(fgets(STDIN));
for($i=0; $i<$n; $i++){
    $arr[] = trim(fgets(STDIN));
    $a = str_split($arr[$i]);
    natsort($a);
    $str[] = implode($a);
}

$ans = 0;
$count = array_count_values($str);

foreach ($count as $value) {
    if($value > 1){
        for($s=1; $s<$value; $s++){
            $ans += $value-$s;    
        }
    }
}

print_r($ans);

?>  

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

int main(){

    int N,K;
    cin >> N >> K;
    int x[N];
    for(int i = 0; i < N; i++){cin >> x[i];}

    int ans = 2147483647;
    int tmp;

    for(int i = 0; i < N-K+1; i+=1){

        tmp = x[i+K-1] - x[i] + min(abs(x[i]), abs(x[i+K-1]));

        //cout << tmp << endl;

        ans = min(tmp,ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
n, q = map(int, input().split())
A = [set([]) for _ in range(n+1)]
for _ in range(n-1):
    a, b = map(int, input().split())
    A[a].add(b)
C = [0]*(n+1)
for _ in range(q):
    p, x = map(int, input().split())
    C[p] += x
for i in range(1, n+1):
    c = C[i]
    for a in A[i]:
        C[a] += c
print(*C[1:])

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

int main(){
    string S, T;
    cin >> S >> T;
    bool check = false;
    if (T.length() - S.length() == 1) {
        check = true;
        for (int i = 0; i < S.length(); i++) {
            if (T[i] != S[i]) {
                check = false;
            }
        }
    }
    if (check) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
} 

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n;
  string s, t;
  cin >> n >> s >> t;
  auto parse = [&] (string & str) {
    vector<int> res;
    for (int i = 1; i < str.size(); i++) {
      if (str[i] != str[i - 1]) {
        res.push_back(i);
      }
    }
    return res;
  };
  vector<int> a = parse(s), b = parse(t);
  int ans = INT_MAX, na = a.size(), nb = b.size();
  for (int i = -na - 1; i <= nb + 1; i++) {
    if ((i & 1) != (s[0] == t[0])) {
      int sum = 0;
      for (int j = min(-i, 0); j < max(na, nb - i); j++) {
        auto calc = [&] (vector<int> &x, int p) {
          return p < 0 ? 0 : p >= x.size() ? n : x[p];
        };
        sum += abs(calc(a, j) - calc(b, j + i));
      }
      ans = min(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#!/usr/bin/ruby

require 'pp'

N  = gets.chomp.to_i
A  = gets.chomp.split(" ").map(&:to_i)

A.each{|n|
  if n%2 == 0
    if n % 3 == 0 || n % 5 == 0
      next
    else
      puts 'DENIED'
      exit
    end
  end

}

puts "APPROVED"


Measured memory_bytes: 4092