akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#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;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    string s; cin>>s;

    if(n % 2){
        cout << "No" << endl;
        return 0;
    }

    string t1 = s.substr(0, n / 2);
    string t2 = s.substr(n / 2, n / 2);

    if(t1 == t2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

bool check(char c){
  
  return c=='A' || c=='T' || c=='G' || c=='C';
}


int main(){
  
  string s;
  cin>>s;
  int ans = 0;
  int tmp = 0;
  for(char it : s){
    if(check(it))
      tmp++;
    else tmp = 0;
    ans = max(ans,tmp);
  }
  cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;
 
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };
 
int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	string s;
	cin >> s;
 
	int n = s.size();
 
	vector<int> ans(n);
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != 'R' || s[i + 1] != 'L') {
			continue;
		}
 
		for (int j = i; j >= 0 && s[j] == 'R'; j--) {
			ans[i + (i - j)%2]++;
		}
 
		for (int j = i + 1; j < n && s[j] == 'L'; j++) {
			ans[i + (j - i)%2]++;
		}
	}
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1104
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

vector<int> ls[2];
int main() {
	string s;
	cin >> s;
	int x[2];
	cin >> x[0] >> x[1];
	int c=0;
	int f=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='F'){
			c++;
		}
		else{
			if(i==c){
				x[0]-=c;
			}
			else if(c){
				ls[f].push_back(c);
			}
			c=0;
			f^=1;
		}
	}
	if(c){
		if(c==s.size()){
			x[0]-=c;
		}
		else{
			ls[f].push_back(c);
		}
	}
	//cerr << ls[0].size() << endl;
	for(int k=0;k<2;k++){
		vector<int> cur,nex;
		cur.push_back(0);
		for(int v:ls[k]){
			nex.clear();
			for(auto p:cur){
				nex.push_back(p-v);
				nex.push_back(p+v);
			}
			sort(nex.begin(),nex.end());
			nex.resize(unique(nex.begin(),nex.end())-nex.begin());
			swap(cur,nex);
		}
		auto it=lower_bound(cur.begin(),cur.end(),x[k]);
		/*
		for(int p:cur){
			cerr << p << " ";
		}
		cerr << endl;
		*/
		if(it==cur.end()||*it!=x[k]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}



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

using namespace std;

int main(){
  int N,K; cin >> N >> K;
 vector<int> vec(11);
  for(int i = 0; i < K; i++){ int k; cin >> k; vec[k]++;}
  int ans;
  for(int x = N; x < 10000000; x++){
    //xが答えなりうるかを調べる
    int tmp = x; bool flag = true;
    while(tmp > 0){ 
      int c = tmp% 10; 
      if( vec[c] > 0){ flag = false; }
      tmp /= 10;}
    
    if( flag ){  ans = x; break;}
  }
  
  cout << ans << endl; return 0;}

Measured memory_bytes: 256
main=do
 [n,k]<-map read.words<$>getLine
 xyc<-map((\[x,y,c]->(x,y,c)).map read.words).lines<$>getContents
 print$f 0.0 1000000.0 xyc k
f l r xyc k
 |r-l<=0.00000001=r
 |otherwise=do
  let m=(l+r)/2
  let xy=(map(\(x,y,c)->(x,y))xyc)++concat[[(ax+ri*cos(t+a),ay+ri*sin(t+a)),(ax+ri*cos(t-a),ay+ri*sin(t-a))]|(ax,ay,ac)<-xyc,(bx,by,bc)<-xyc,let d=(ax-bx)^2+(ay-by)^2,let ri=m/ac,let rj=m/bc,let yy=4*ri^2*d-(ri^2+d-rj^2)^2,yy>=0,let a=atan2(sqrt yy)(ri^2+d-rj^2),let t=atan2(by-ay)(bx-ax)]
  if null(filter(\(tx,ty)->length(filter(\(x,y,c)->(tx-x)^2+(ty-y)^2<(m/c)^2+0.000000001)xyc)>=k)xy) then f m r xyc k else f l m xyc k

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)     for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N,M);
    int sum=0;
    rep(i,M){
        int a;cin>>a;
        sum+=a;
    }
    printf("%d\n",sum<=N?N-sum:-1);

    return 0;
}


Measured memory_bytes: 3752
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;
	auto M = RD;
	auto ans = new long[](N);
	ans[] = -1;
	bool ok = true;
	foreach (i; 0..M)
	{
		auto s = RD-1;
		auto c = RD;
		if (ans[s] != -1 && ans[s] != c)
			ok = false;
		ans[s] = c;
	}
	if (N != 1 && ans[0] == 0)
		ok = false;
	
	if (!ok)
		writeln(-1);
	else
	{
		if (ans[0] == -1)
			write(N == 1 ? 0 : 1);
		else
			write(ans[0]);
		foreach (i; 1..N)
		{
			if (ans[i] == -1)
				write(0);
			else
				write(ans[i]);
		}
	}

	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#gets;a=0
#gets.split.map(&:to_i).each_cons(3){|_|a+=_.sort[1]==_[1]?1:0}
#p a

def each_cons(x, size):
    return [x[i:i+size] for i in range(len(x)-size+1)]
input();a=0
print([sorted(i)[1]==i[1]for i in each_cons(list(map(int,input().split())),3)].count(True))

Measured memory_bytes: 3060
#include <stdio.h>
#define MAX 2000001

int n;
int A[MAX] = {0};
int B[MAX] = {0};

void CountingSort(int A[], int B[], int k) {
	int i;
	int C[MAX] = {0};
//	for (i = 0; i < k; ++i) C[i] = 0;
	for (i = i; i < n; ++i) {
		C[A[i+1]]++;
	}

	for (i = 1; i <= k; ++i) {
		C[i] = C[i] + C[i-1];
	}

	for (i = n; i > 0; --i) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}
	return;
}

int main(void) {

	int i;
	int max = 0;

	
	scanf("%d", &n);

	for (i = 0; i < n; ++i) {
		scanf("%d", &A[i+1]);
		if (max < A[i]) max = A[i];
	}

	CountingSort(A, B, max);

	for (i = 0; i < n; ++i) {
		if (i != n -1 ) {
			printf("%d ", B[i+1]);
		} else {
			printf("%d\n", B[i+1]);
		}
	}
	return 0;
}

Measured memory_bytes: 24044
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double a[] = new double[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextDouble();
        }
        sc.close();

        double sum = 0;
        for (int i = 0; i < n; i++) {
            sum = sum + 1.0 / a[i];
        }

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


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int a,b;
  cin>>a>>b;
  bitset<32> bita(a),bitb(b);

  cout<<(bita&bitb)<<endl;
  cout<<(bita|bitb)<<endl;
  cout<<(bita^bitb)<<endl;


}


Measured memory_bytes: 3232
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

X = get_int

n = 0
total = 0
loop do
  n += 1
  total += X
  break if total % 360 == 0
end

puts n


Measured memory_bytes: 14500
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>

using ll = long long;

int main()
{
    int X, Y, Z, K;
    std::cin >> X >> Y >> Z >> K;
    std::vector<ll> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++)
    {
        std::cin >> A[i];
    }
    for (int i = 0; i < Y; i++)
    {
        std::cin >> B[i];
    }
    for (int i = 0; i < Z; i++)
    {
        std::cin >> C[i];
    }

    std::sort(A.begin(), A.end(), [](ll a, ll b) { return a > b; });
    std::sort(B.begin(), B.end(), [](ll a, ll b) { return a > b; });
    std::sort(C.begin(), C.end(), [](ll a, ll b) { return a > b; });
    std::vector<ll> sums;
    for (int x = 0; x < X; x++)
    {
        for (int y = 0; y < Y; y++)
        {
            for (int z = 0; z < Z; z++)
            {
                if (x * y * z > K)continue;
                sums.emplace_back(A[x] + B[y] + C[z]);
            }
        }
    }

    std::sort(sums.begin(), sums.end(), [](ll a, ll b) { return a > b; });
    for (int i = 0; i < K; i++)
    {
        std::cout << sums[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 35176
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
typedef long long int ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)

int main()
{
    int N, *d;
    cin >> N;
    d = new int[N];
    FOR(i, 1, N + 1)
    {
        cin >> d[i];
    }
    d[0] = -1;

    int count = 0;
    sort(d, d + N + 1);
    /*
    FOR(i, 0, N + 1) // 確認
    {
        printf("d[%d] = %d ", i, d[i]);
    }
    cout << endl;
    */
    FOR(i, 0, N)
    {
        if (d[i] != d[i + 1])
        {
            count++;
        }
    }

    cout << count << endl;

    delete[] d;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

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

int main()
{
    int N;
    cin >> N;
    int p[100002];
    for(int i = 1; i <= N; ++i) cin >> p[i];
    int ans = 0;
    for(int i = 1; i < N; ++i){
        if(p[i] == i)
        {
            ans++;
            swap(p[i], p[i+1]);
            if(p[i] == i){
                i++;
            }
        }
    }
    if(p[N] == N)
        ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 2000 + 100;
const int MOD = 1000000000 + 7;

int n, m, k;
int f[MAXN][MAXN];
int ans = 0;

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m >> k;
	f[0][0] = 1;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= m - 1; j++)
			if(f[i][j])
			{
				// cerr << i << ' ' << j << ' ' << f[i][j] << endl;
				for(int x = 0; x <= k - 1; x++)
				{
					int ii = i + x, jj = j + k - 1 - x;
					if(ii <= n && jj <= m - 1)
					{
						f[ii][jj] = (f[ii][jj] + f[i][j]) % MOD;
						if(x && ii % (k - 1) == n % (k - 1))
							ans = (ans + f[i][j]) % MOD;
					}
				}
			}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 16640
A = list(input())
B = list(input())
C = list(input())

player = 'a'

while True:
    if player == 'a':
        if not len(A):
            print('A')
            break
        player = A.pop(0)
    elif player == 'b':
        if not len(B):
            print('B')
            break
        player = B.pop(0)
    else:
        if not len(C):
            print('C')
            break
        player = C.pop(0)

Measured memory_bytes: 3060
#if 0
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif

using namespace std ;
typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N,  C;
	
	cin >> N >> C;

	int d[C][C];
	int c[N][N];
	int t[3][C];
	memset(t, 0, sizeof(t));

	rep(i, C)
	{
		rep(j,C)
		{
			cin >> d[i][j];
		}
	}

	rep(i, N)
	{
		rep(j, N)
		{
			cin >> c[i][j];
			t[(i+j)%3][c[i][j]-1]++;
		}
	}

	int ans = INT_MAX;

	rep(i, C)
	{
		rep(j, C)
		{
			if (i == j)
			{
				continue;
			}

			rep(k, C)
			{
				if ((i == k) || (j == k))
				{
					continue;
				}

				int tt =0;
				rep (l , C ) tt += d[l][i]* t[0][l];
				rep (l , C ) tt += d[l][j]* t[1][l];
				rep (l , C ) tt += d[l][k]* t[2][l];
				if ( tt < ans ) ans = tt ;
			}
		}
	}

	cout << ans << endl;

	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    double n;
    cin >> n;
    n = n / 3;
    printf("%.10f", n * n * n);
}

Measured memory_bytes: 3744
#include <stdio.h>
#define MAX_N 100
#define INF_COST (1 << 30)
#define NO_CONN -1
#define UNKNOWN_ID -1

typedef enum { UNEXPLORED, VISITED, COMPLETED } state_t;
typedef struct { int p, d; state_t s; } vertex_t;

static void dijkstra(int a[MAX_N][MAX_N], int size, vertex_t *v) {
  int i, u, min;

  u = 0;
  v[u].d = 0;

  while (1) {
    min = INF_COST;
    for (i = 0; i < size; ++i) {
      if (v[i].s != COMPLETED && v[i].d < min) {
        min = v[i].d;
        u = i;
      }
    }
    if (min == INF_COST) break;
    v[u].s = COMPLETED;
    for (i = 0; i < size; ++i) {
      if (v[i].s != COMPLETED && (v[u].d + a[u][i]) < v[i].d) {
        v[i].d = v[u].d + a[u][i];
        v[i].p = u;
        v[i].s = VISITED;
      }
    }
  }
}

int main(int argc, char **argv) {
  int n, m, x, y, w, i, j, a[MAX_N][MAX_N];
  vertex_t v[MAX_N];

  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    v[i].p = UNKNOWN_ID;
    v[i].d = INF_COST;
    v[i].s = UNEXPLORED;
  }
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) a[i][j] = INF_COST;
  }
  for (i = 0; i < n; ++i) {
    scanf("%d %d", &x, &m);
    for (j = 0; j < m; ++j) {
      scanf("%d %d", &y, &w);
      a[x][y] = w;
    }
  }
  dijkstra(a, n, v);
  for (i = 0; i < n; ++i) printf("%d %d\n", i, v[i].d);
}


Measured memory_bytes: 2072
#include<iostream>
#include<numeric>

using namespace std;

void change_num(int bingo[3][3], int n){
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if (bingo[i][j] == n){
                bingo[i][j] = 0;
            }
        }
    }
}

bool check_bingo(int bingo[3][3]){
    if(bingo[0][0]+bingo[1][1]+bingo[2][2] == 0)
        return true;
    else if(bingo[0][2]+bingo[1][1]+bingo[2][0] == 0)
        return true;

    if(bingo[0][0]+bingo[1][0]+bingo[2][0] == 0)
        return true;
    if(bingo[0][1]+bingo[1][1]+bingo[2][1] == 0)
        return true;
    if(bingo[0][2]+bingo[1][2]+bingo[2][2] == 0)
        return true;

    const size_t size = sizeof(bingo[0])/sizeof(bingo[0][0]);
    for(int i=0; i<3; i++){
        if(accumulate(bingo[i], bingo[i]+size, 0) == 0)
            return true;
    }
    return false;
}

int main(){

    int bingo[3][3];

    for (int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> bingo[i][j];
        }
    }

    int n;
    cin >> n;
    int b;
    for(int i=0; i<n; i++){
        cin >> b;
        change_num(bingo, b);
    }

    if(check_bingo(bingo))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

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

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

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

P dequeue(){
  P x = Q[head];
  head=(head+1)%LEN;
  return x;
}
int min(int a,int b){return a<b ? a : b;}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail=n+1;
  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t >0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    
    int answer = 0;
    int count = 0;
    for(int i = 0; i < n - 1; i++){
        if(h.at(i) >= h.at(i + 1)){
            count++;
        }else{
            if(count > answer)answer = count;
            count = 0;
        }
    }
    
    if(count > answer)answer = count;
    
    cout << answer << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N)
  {
    cin >> a[i];
  }
  int count = 0;
  int brick = 1;
  rep(i,N)
  {
    if(a[i]==brick)
    {
      brick ++;
    }
    else
    {
      count ++;
    }
    
  }
  if(count!=N)
  {
  cout << count << endl;
  }
  else
  {
    cout << -1 << endl;
  }
  
  return 0;
}


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

typedef long long ll;
typedef tuple<int,int,int,int> tp;

int main(){
	int H,W;
	cin >> H >> W;
	vector<vector<int>> F(H,vector<int>(W));
	rep(i,H)rep(j,W)cin >> F[i][j];

	vector<tp> T;
	rep(i,H)rep(j,W-1){
		if(F[i][j]%2!=0){ F[i][j]--; F[i][j+1]++; T.push_back(make_tuple(i+1,j+1,i+1,j+2)); }
	}
	rep(i,H-1){
		if(F[i][W-1]%2 != 0){ F[i][W-1]--; F[i+1][W-1]++; T.push_back(make_tuple(i+1,W,i+2,W));}
	}

	cout << T.size() << endl;
	for(tp t : T){
		printf("%d %d %d %d\n",get<0>(t),get<1>(t),get<2>(t),get<3>(t));
	}

	return 0;
}

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

int n;
int d[101];
unsigned long long int memo[101][21];

unsigned long long int solve(int i, int s){

  if(i > -1 && i < 101 && s > -1 && s < 21 && memo[i][s]) return memo[i][s];
  if(i == n-1 && s == d[n-1]) return 1;
  if(i == n-1 || s < 0 || s > 20) return 0;

  return memo[i][s] = solve(i+1, s+d[i]) + solve(i+1, s-d[i]);
}

int main(){

  cin >> n;
  for(int i=0;i<n;i++) cin >> d[i];

  cout << solve(1,d[0]) << endl;

}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

unsigned long long gcd(unsigned long long a, unsigned long long b)
{
	if (b == 0)
	{
		return a;
	}

	return gcd(b, a % b);
}

int main()
{
	int N;
	cin >> N;
	unsigned long long T[100];
	for (auto i = 0; i < N; ++i)
	{
		cin >> T[i];
	}

	sort(T, T + N);

	for (auto i = 1; i < N; ++i)
	{
		auto temp = gcd(T[i], T[i - 1]);
		T[i] = T[i] / temp * T[i - 1];
	}

	cout << T[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int L;
int R;
int D;
int main(){
  int i;
  int res = 0;
  rd(L);
  rd(R);
  rd(D);
  for(i=(L);i<(R+1);i++){
    if(i%D==0){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int L, R, D;
// {
//   int res = 0;
//   rd(L, R, D);
//   rep(i,L,R+1) if(i%D==0) res++;
//   wt(res);
// }


Measured memory_bytes: 3588
# -*- coding: utf-8 -*-


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    magic_count = 0
    slime_count = 1
    previous_slime = a[0]

    for i in range(1, n):
        if a[i] == previous_slime:
            slime_count += 1
        else:
            magic_count += slime_count // 2
            slime_count = 1

        previous_slime = a[i]

    print(magic_count + slime_count // 2)


Measured memory_bytes: 3060
import java.io.*;
import java.util.*;


public class Main {
	public static void main(String[] args) throws Exception {
		MScanner sc = new MScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n=sc.nextInt();
		int[][]mat=new int[n][n];
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				mat[i][j]=-1;
			}
		}
		for(int i=0;i<n;i++) {
			int a=sc.nextInt();
			for(int j=0;j<a;j++) {
				mat[i][sc.nextInt()-1]=sc.nextInt();
			}
		}
		int ans=0;
		for(int msk=0;msk<(1<<n);msk++) {
			int []all=new int[n];
			for(int j=0;j<n;j++) {
				if(((1<<j)&msk)!=0) {
					all[j]=1;
				}
				else {
					all[j]=0;
				}
			}
			boolean yes=true;
			for(int j=0;j<n;j++) {
				if(((1<<j)&msk)!=0) {
					for(int k=0;k<n;k++) {
						if(mat[j][k]!=-1) {
							if(mat[j][k]!=all[k]) {
								yes=false;
							}
							
						}
					}
				}
			}
			if(yes) {
				//System.out.println(msk);
				ans=Math.max(ans, Integer.bitCount(msk));
			}
		}
		pw.println(ans);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;

		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int[] takearr(int n) throws IOException {
			int[] in = new int[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public long[] takearrl(int n) throws IOException {
			long[] in = new long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

		public Integer[] takearrobj(int n) throws IOException {
			Integer[] in = new Integer[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public Long[] takearrlobj(int n) throws IOException {
			Long[] in = new Long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 24148
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b){
        printf("%d",c);
    }
    else if(b==c){
        printf("%d",a);
    }
    else {
        printf("%d",b);

    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
 
int main(){
   
  int x,i,fibonacci[44];
    scanf("%d",&x);
    for(i=0;i<=x;i++){
      if(i==0) fibonacci[i]=1;
      if(i==1) fibonacci[i]=1;
      if(i>1) fibonacci[i]=fibonacci[i-1]+fibonacci[i-2];
      if(i==x) printf("%d\n", fibonacci[i]);
    }
    return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
	ll modu = M;
	ll m = modu;
	ll a = 0, b = 1;
	if (modu == 1)
		return 0;
	while (n > 1)
	{
		ll quo = n / modu;
		ll temp = modu;
		modu = n % modu, n = temp;
		temp = a; 
		a = b - (quo * a);
		b = temp;
	}
	if (b < 0)
		b += m;
	return b;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, m;
	cin >> n >> m;
	if (n == m)
	{
		cout << "Yes";
	}
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;

int n,p[N],a[N];
multiset<int>s;
multiset<int>::iterator it[2][2];
ll ans;

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i],p[a[i]]=i;
	s.insert(0);
	s.insert(0);
	s.insert(n+1);
	s.insert(n+1);
	for(int i=n;i>=1;--i){
		int x=p[i];
		it[0][0]=it[0][1]=it[1][1]=it[1][0]=s.lower_bound(x);
		++it[1][1];
		--it[0][1];
		--it[0][0];--it[0][0];
		ans+=1ll*(*it[0][1]-*it[0][0])*(*it[1][0]-x)*i;
		ans+=1ll*(*it[1][1]-*it[1][0])*(x-*it[0][1])*i;
		s.insert(x);
	}
	cout<<ans<<endl;
}

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

int n, T;
int t[101];
int c[101];      

int main() {
    cin >> n >> T;
    for (int i = 0; i < n; ++i) cin >> c[i] >> t[i];
    int Min = 1001;

    for(int i = 0; i < n; ++i){
        if(t[i] <= T) Min = min(Min, c[i]);
    }
    if(Min == 1001) cout << "TLE" << endl;
    else cout << Min << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
const ll MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    int l[m], r[m], x[m];
    rep(i,m){
        cin >> l[i] >> r[i] >> x[i];
    }
    ll dp[n+1][n+1][n+1];
    rep(i,n+1)rep(j,n+1)rep(k,n+1)dp[i][j][k] = 0;
    dp[0][0][0] = 1;

    rep(i,n+1){
        rep(j,m){
            if(r[j] == i){
                rep(k,i+1){
                    rep(o,k+1){
                        if(k == 0){
                            if(x[j] >= 2) dp[i][k][o] = 0;
                        }else if(o == 0){
                            if(x[j] == 3){
                                dp[i][k][o] = 0;
                            }else if(k < l[j] && x[j] == 2){
                                dp[i][k][o] = 0;
                            }else if(l[j] <= k && x[j] == 1){
                                dp[i][k][o] = 0;
                            }
                        }else{
                            if(l[j] <= o && x[j] != 3){
                                dp[i][k][o] = 0;
                            }else if(o < l[j] && l[j] <= k && x[j] != 2){
                                dp[i][k][o] = 0;
                            }else if(k < l[j] && x[j] != 1){
                                dp[i][k][o] = 0;
                            }
                        }
                    }
                }
            }
        }

        if(i == n) break;

        if(i == 0){
            dp[i][0][0] %= MOD;
            dp[i+1][0][0] = dp[i][0][0] * 3;
        }else{
            rep(j,i){
                if(j == 0){
                    dp[i][0][0] %= MOD;
                    dp[i+1][0][0] += dp[i][0][0];
                    dp[i+1][i][0] += dp[i][0][0] * 2;
                }else{
                    rep(k,j){
                        dp[i][j][k] %= MOD;
                        dp[i+1][j][k] += dp[i][j][k];
                        dp[i+1][i][k] += dp[i][j][k];
                        dp[i+1][i][j] += dp[i][j][k];
                    }
                }
            }
        }
    }

    ll ans = 0;
    rep(j,n+1){
        rep(k,n+1){
            ans += dp[n][j][k];
            ans %= MOD;
        }
    }

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




Measured memory_bytes: 216668
#include<iostream>

using namespace std;

int main(){
	int x,y,a[200],sum = 0,b = 0, su = 0;
	cin>>x>>y;
	for(int i = 0; i < x; i++) cin>>a[i];

	for(int i = 1; i <= x; i++) {
		b += a[i-1];
		
		if(b > y) {
			break;
		}
		sum = i;
	}
	cout<<sum+1 << endl;
	return 	0;
}

/*
3 6
3 4 5
Sample Output 1 
Copy
2

4 9
3 3 3 3
output 
4
*/


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


pins = set()
pins_check = set()

def bfs():    
    from collections import deque
    queue = deque([(S, '', 0)])
    while queue:
        tmp_s, tmp_pin, tmp_cnt = queue.popleft()
        if tmp_cnt == 3:
            pins.add(tmp_pin)
            continue
        
        for i in range(len(tmp_s)):
            if tmp_pin+tmp_s[i] in pins_check:
                continue
            pins_check.add(tmp_pin+tmp_s[i])
            queue.append((tmp_s[i+1:], tmp_pin+tmp_s[i], tmp_cnt+1))

ans = bfs()
#print(pins)
print(len(pins))


Measured memory_bytes: 156808
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b;
	return 0;
}

Measured memory_bytes: 3624
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: u128
    }

    let mut deposit = 100;
    let mut ans = 0;

    while x > deposit {
        deposit = (deposit * 101) / 100;
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,ans = 0;
	cin >> n;
	for(int i = 1;i <= n;i++){
		if(i % 3 && i % 5) ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
	unsigned short usW_D_row;            	/* 行数格納用変数 */
	unsigned short usW_D_col;            	/* 列数格納用変数 */
	unsigned long ulW_D_sheet[101][101];	/* 表格納用配列 */
	unsigned short usW_D_i,usW_D_j;            	/* ループ変数 */
	
	/* 配列の初期化 */
	for(usW_D_i = 0;usW_D_i < 101;usW_D_i++){
		for(usW_D_j = 0;usW_D_j < 101;usW_D_j++){
			ulW_D_sheet[usW_D_i][usW_D_j] = 0;
		}
	}
	
	/* 行数、列数の入力 */
	scanf("%d %d", &usW_D_row, &usW_D_col);
	
	/* 表の要素の入力 */
	for(usW_D_i =0;usW_D_i < usW_D_row;usW_D_i++){
		for(usW_D_j = 0;usW_D_j < usW_D_col;usW_D_j++){
			/* usW_D_i行usW_D_j列の要素の入力 */
			scanf("%ld", &ulW_D_sheet[usW_D_i][usW_D_j]);
		}
	}
	
	/* 各行の要素の合計の計算 */
	for(usW_D_i =0;usW_D_i < usW_D_row;usW_D_i++){
		for(usW_D_j = 0;usW_D_j < usW_D_col;usW_D_j++){
			/* usW_D_i行usW_D_j列の要素をusW_D_i行末端に加算 */
			ulW_D_sheet[usW_D_i][usW_D_col] += ulW_D_sheet[usW_D_i][usW_D_j];
		}
	}
	
	/* 各列の要素の合計の計算 */
	for(usW_D_i =0;usW_D_i < usW_D_row;usW_D_i++){
		for(usW_D_j = 0;usW_D_j < usW_D_col;usW_D_j++){
			/* usW_D_i行usW_D_j列の要素をusW_D_j列末端に加算 */
			ulW_D_sheet[usW_D_row][usW_D_j] += ulW_D_sheet[usW_D_i][usW_D_j];
		}
	}
	
	/* 全要素の合計の計算 */
	for(usW_D_i = 0;usW_D_i < usW_D_row;usW_D_i++){
		/* 各行の合計を表の末端に加算 */
		ulW_D_sheet[usW_D_row][usW_D_col] += ulW_D_sheet[usW_D_i][usW_D_col];
	}
	
	/* 表を出力 */
	for(usW_D_i =0;usW_D_i <= usW_D_row;usW_D_i++){
		for(usW_D_j = 0;usW_D_j < usW_D_col;usW_D_j++){
			/* usW_D_i行usW_D_j列の要素の出力 */
			printf("%ld ", ulW_D_sheet[usW_D_i][usW_D_j]);
		}
		/* 末列の出力 */
		printf("%ld\n", ulW_D_sheet[usW_D_i][usW_D_col]);
	}
	return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/

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


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>h(n),dp(n,LLONG_MAX);
    rep(i,0,n){
        cin>>h[i];
    }
    dp[0]=0;
    rep(i,1,n){
        rep(j,1,k+1){
            if(i-j>=0){
                dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
            }
        }
    }
    cout<<dp[n-1]<<endl;    
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static boolean isFinished(char[] chars, char target, int length) {
		for(int i=0; i<length; i++)
			if(chars[i]!=target)
				return false;
		return true;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();

		int[] table = new int['z'-'a'+1];
		Arrays.fill(table, 0);
		for(int i=0; i<table.length; i++) {
			char c = (char)('a'+i);
			String[] tmp = str.split(c+"");
			for(String tmp2: tmp)
				if(tmp2.length()>table[i])
					table[i]=tmp2.length();
		}

//		for(int i=0; i<table.length; i++)
//			System.out.println((char)('a'+i)+" : "+table[i]);

		int min=0;
		for(int i=1; i<table.length; i++) {
			if(table[min]>table[i]) {
				min = i;
			}
		}
		char target = (char)('a'+min);
		char[] outputs = str.toCharArray();
		int length=outputs.length;

		int count = 0;
		while(!isFinished(outputs, target, length)) {
			for(int i=0; i<length-1; i++) {
				if(outputs[i] != target)
					outputs[i] = outputs[i+1];
			}
			if(outputs[length-1]!=target)
				length--;
//			for(int i=0; i<length; i++)
//				System.out.print(outputs[i]+"");
//			System.out.println();
			count++;
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <string.h>
char s[210];
int main(){
	while(scanf("%s",s),strcmp(s,"-")){
		int m;
		scanf("%d",&m);
		int c=0;
		while(m--){
			int t;
			scanf("%d",&t);
			c+=t;
		}
		c%=strlen(s);
		printf("%s",s+c);
		s[c]=0;
		puts(s);
	}
}


Measured memory_bytes: 2056
import com.sun.xml.internal.ws.api.pipe.NextAction

object Main {
  def main(args: Array[String]): Unit = {
    val in = new java.util.Scanner(System.in)
    val n = in.nextInt()
    val list = makeCardList(in,n)
    val ls = list.sorted
    for(s <- List("S","H","C","D")){
      for(i <- 1 to 13){
        if(!ls.contains((s,i))){
          println(s + " " + i)
        }
      }
    }
  }
  def makeCardList(in:java.util.Scanner,rest:Int):List[(String,Int)] ={
    val s = in.next()
    val num = in.nextInt()
    if (rest ==1){
      return List((s,num))
    }else{
      return (s, num) :: makeCardList(in, rest-1)
    }
    
  }
  def printList(ls:List[(java.lang.String,Int)]):Unit = {
    ls match{
      case List(s) => println(s);return
      case n :: ls => println(n);printList(ls)
    }
  }
}

Measured memory_bytes: 45052
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 600;
ll n;
ll comb(int a,int b) {
  ll r = 1;
  rep(i,0,b) r=r*(a-i)/(i+1);
  return r;
}
ll cof[N + 1] , c[N + 1];

int main(){
  cin >> n;
  rep(i,1,N+1) cof[i] = comb(i + 7 - 1 , 7);
  per(i,1,N+1) {
    if(cof[i] <= n) {
      c[i] = n / cof[i];
      n -= c[i] * cof[i];
    }
  }
  int end = N;
  while(!c[end]) --end;
  string ans = "";
  rep(i,1,end+1) {
    ans += "FESTIVA";
    ans += string(c[i],'L');
  }
  cout << ans << endl;
  return 0;
}


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

int G[105][105]={};
int d[105]={},f[105]={};
int N,T=0;

void Gprint(int n){
    cout<<"\\|";
    for(int i=0; i<n; i++)cout<<i+1;
    cout<<endl;
    for(int i=0; i<n+2; i++)cout<<"-";
    cout<<endl;
    for(int i=0; i<n; i++){
        cout<<i+1<<"|";
        for(int j=0; j<n; j++){
            cout<<G[i][j];
        }
        cout<<endl;
    }
}

void dfs(int n){
    if(d[n])return;
    d[n]=++T;
    for(int i=0; i<N; i++){
        if(G[n][i])dfs(i);
    }
    f[n]=++T;
}

int main(){
    int u,k,v;

    cin>>N;
    for(int i=0; i<N; i++){
        cin>>u>>k;
        for(int j=0; j<k; j++){
            cin>>v;
            G[u-1][v-1]=1;
        }
    }

//    Gprint(N);

    for(int i=0; i<N; i++)
        dfs(i);

    for(int i=0; i<N; i++){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}

Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int exercise = sc.nextInt();
		
		long power = 1;
		
		for (int i = 1; i <= exercise; i++) {
			power = (power * i) % ((long) Math.pow(10, 9) + 7);
		}
		
		System.out.println(power);
	}
}


Measured memory_bytes: 21844