akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

std::random_device seed_gen;
std::mt19937 engine(seed_gen());
constexpr int prob = 26;
const double TL = 1.970;
// const double TL = 0.100;

vector<ll> c,l;
vector<vector<int>> s;
int d;

ll score(vector<int> &t) {
    ll sat = 0;
    rep (i, prob) l[i] = -1;
    rep (dy, d) {
        int k = t[dy];
        sat += s[dy][k];
        l[k] = dy;
        rep (i, 26) sat -= c[i] * (dy - l[i]);
    }
    return sat;
    // return (ll)-1e18 - 1;
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    clock_t start = clock(), end;
    cin >> d;
    c.resize(prob); l.resize(prob);
    s.resize(d); rep (i, s.size()) s[i].resize(prob);
    rep (i, c.size()) cin >> c[i];
    rep (i, s.size()) { rep (j, s[0].size()) { cin >> s[i][j]; }}

    vector<int> t(d), tmp;
    vector<int> sum(prob + 1);
    rep (i, prob) sum[i + 1] = sum[i] + c[i];
    rep (i, prob) l[i] = -1;
    rep (i, d) {
        int k = -1, x = -1;
        rep (j, prob) if (chmax(x, (int)c[j] * (i - (int)l[j]))) k = j;
        t[i] = k;
        l[k] = i;
    }
    tmp = t;
    ll max_score = -(ll)1e18;
    int count = 1, k;
    while (true) {
        // write here
        
        do {
            k = engine() % d;
            tmp[k] = engine() % prob;
        } while (tmp[k] == t[k]);
        if (chmax(max_score, score(tmp))) t = tmp;

        if (count % 100 == 0) {
            end = clock();
            if (static_cast<double>(end - start) / CLOCKS_PER_SEC > TL) break;
        }
        count++;
    }
    
    rep (i, d) cout << t[i] + 1 << "\n";
    eprintf("count: %d\n", count);
    return 0;
}

Measured memory_bytes: 3748
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#include <unordered_map>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.0000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007 
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
using namespace std;
int main() {
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int failed = 1;
	vector<long long> geko;
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		long long a, b;
		cin >> a >> b;
		if (a != b) failed = 0;
		else ans += a;
		if (a < b) ans += b;
		else if (a != b) geko.push_back(b);
	}
	sort(geko.begin(), geko.end(),greater<long long>());
	if (failed == 1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < geko.size() - 1; ++i) {
		ans += geko[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int W, H, x, y, r;
cin >> W >> H >> x >> y >> r;
if(W < x+r || 0 > x-r || H < y+r || 0 > y-r){
cout << "No" << endl;
}
else{
cout << "Yes" << endl;
}
}


Measured memory_bytes: 3116
export class Main {
  static main(input): string {
    const s: string[] = input.split("\n")[0].split("");
    let result: number = 0;
    let aCount: number = 0;
    for (let i = 0, len = s.length; i < len; ++i) {
      if (s[i] == "A") {
        while (s[i] == "A") {
          ++aCount;
          ++i;
        }
      }
      // s[i] != "a"
      if (aCount == 0) {
        continue;
      }
      if (s[i] == "B" && s[i + 1] && s[i + 1] == "C") {
        ++i;
        result += aCount;
      } else {
        aCount = 0;
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 9548
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
// #define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;
 
int arr[N];
 
void solve()
{
	int k, x;
	cin >> k >> x;
	if(500 * k >= x)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	// #ifndef ONLINE_JUDGE
	//      freopen("input.txt", "r", stdin);
	//      freopen("output.txt", "w", stdout);
	// #endif
	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
        printf("a > b\n");
    else if(a<b)
        printf("a < b\n");
    else
        printf("a == b\n");

    return 0;
}



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

using namespace std;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000000000
int main(){
    int x,y; 
    cin >> x >> y;
    
   for(int i = 0; i <= x; i++){
   		if(i*2 + (x-i)*4 == y){
   			cout << "Yes" << endl;
   			return 0;
   		}
   }
   
   cout << "No" << endl;
    
    return 0;	
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long n,i,ans;
	i=0;
	ans=0;
	string s;
	cin>>n;
	cin>>s;
	s=s+"   ";
	while (i<n)
	{
		if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
		{
			ans++;
			i=i+3;
		}
		else
		{
			i++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    numbers=[]
    dp=[]
    n = int(input())
    numbers=np.array(list(map(int,input().split())),dtype=int)
    numbers.sort()
    print(numbers[n::2].sum())

if __name__=="__main__":
    main()

Measured memory_bytes: 60500
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int n;

int ccw(P p0,P p1,P p2)
{
	P a = P(p1.first - p0.first,p1.second - p0.second);
	P b = P(p2.first - p0.first,p2.second - p0.second);
	ll dot = (ll)a.first*b.first + (ll)a.second*b.second;
	ll cross = (ll)a.first*b.second - (ll)a.second*b.first;
	ll na = (ll)a.first*a.first + (ll)a.second*a.second;
	ll nb = (ll)b.first*b.first + (ll)b.second*b.second;
	if(cross > EPS){
		return 1;
	}else if(cross < -EPS){
		return -1;
	}else if(dot < -EPS){
		return 2;
	}else if(na < nb){
		return -2;
	}else{
		return 0;
	}
}

bool isIntersection(P p0,P p1,P p2,P p3)
{
	return ccw(p0,p1,p2)*ccw(p0,p1,p3) <= 0 && ccw(p2,p3,p0)*ccw(p2,p3,p1) <= 0;
}

int main()
{
	scanf("%d",&n);
	rep(i,n){
		int a[8];
		rep(j,8){
			scanf("%d",&a[j]);
		}
		printf("%d\n",isIntersection(P(a[0],a[1]),P(a[2],a[3]),P(a[4],a[5]),P(a[6],a[7])));
	}
	return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
#define SORT(a) sort(a.begin(), a.end())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;


ll com[51][51];
int main() {
    //パスカルの三角形
    com[0][0] = 1;
    for (int i = 1; i < 51; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];        
        }
    }

    int N, A, B; cin >> N >> A >> B;
    vector<ll> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i];
    sort(v.begin(), v.end(), greater<ll>());

    // 最大値
    ll sum = 0;
    for (int i = 0; i < A; ++i) sum += v[i];
    double ave = (double)(sum) / A;

    // 小さいやつの個数
    ll res = 0;
    int num = 0;
    for (int i = 0; i < N; ++i) if (v[i] == v[A-1]) ++num;
    if (v[0] == v[A-1]) {
        for (int j = A; j <= B; ++j) {
            res += com[num][j];
        }
    }
    else {
        int a = 0;
        for (int i = 0; i < A; ++i) if (v[i] == v[A-1]) ++a;
        res = com[num][a];
    }
    cout << fixed << setprecision(10) << ave << endl;
    cout << res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define int long long
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N;
  cin>>N;
  cout<<(N/500)*1000+((N%500)/5)*5<<endl;
}

Measured memory_bytes: 3636
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N;
    R(N);
    int an=0;
    FOR(i,1,N){
        char s[12];
        sprintf(s,"%d",i);
        if(strlen(s)%2)an++;
    }
    W(an);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k <= a){
        cout<<k<<"\n";
    }
    else if(a + b >= k){
        cout<<a<<"\n";
    }
    else{
        int remaining = k - a - b;
        cout<< a - remaining;
    }
    return 0;
} 

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main(){
    int N,X;
    int min_m=1e9,ans=0;
    cin >> N >> X;
    vector<int> m(N);
    for(int i = 0; i < N; i++){
        cin >> m[i];
        X -= m[i];
        min_m = min(min_m,m[i]);
    }
    int tmp = X / min_m;
    ans = N + tmp;

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vec<int> H(2),M(2);
    cin >> H[0] >> M[0];
    cin >> H[1] >> M[1];
    int K;
    cin >> K;
    int t0 = 60*H[0]+M[0],t1 = 60*H[1]+M[1];
    if(t0+K>t1) cout << 0 << "\n";
    else cout << t1-(t0+K) << "\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define mdsaqib std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

int mod=1e9+7;

signed main(){
    mdsaqib;
    int n;
    cin >> n;
    vector <int> A(n),P(n);
    int sum=0;
    for(int i=0;i<n;i++){
        P[i]=sum;
        cin >> A[i];
        sum+=A[i];
        sum%=mod;
    }
    int ans=0;
    for(int i=1;i<n;i++){
        ans+=P[i]*A[i];
        ans%=mod;
    }
    cout << ans;
}

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

int main()
{
  int n;
  cin >> n;
  int d[101];
  int num[101] = {0};

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

  int count = 0;

  for(int i = 1;i <= 100;++i){
    if(num[i] > 0) ++count;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char
import Control.Monad

dist :: VU.Vector Int -> Int
dist xs
    | VU.length xs == 1 = 0
    | otherwise = (abs $ f - s) + dist (VU.tail xs)
    where
        f = VU.head xs
        s = xs VU.! 1

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace)  <$> B.getLine
    let xs' = VU.cons 0 $ VU.snoc xs 0
    let d = dist xs'
    forM_ [1..n] $ \i -> do
        let curr = xs' VU.! i
        let prev = xs' VU.! (i - 1)
        let next = xs' VU.! (i + 1)
        let ans = (abs $ next - prev) - ((abs $ prev - curr) + (abs $ curr - next))
        print $ d + ans

Measured memory_bytes: 5500
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        List<int> a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToList();

        a.Sort();
        int alice = 0;
        int bob = 0;

        for (int i = 0; i < a.Count; i++)
        {
            if (i % 2 == 0) alice += a[i];
            else bob += a[i];
        }
        Console.WriteLine(Math.Abs(alice - bob));
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color; vll path; ll start = 0;
//***********//
int main() {
	cin >> N;
	for (i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstring>
#define N 1200
using namespace std;

int main() {
	char ch;
	int count[N];

	for (int i = 0; i < 26; i++) {
		count[i] = 0;
	}

	while (cin >> ch) {
		//cin >> ch;
		ch = tolower(ch);
		//if (ch == '.') break;
		if (ch == 'a') count[0] += 1;
		else if (ch == 'b') count[1] += 1;
		else if (ch == 'c') count[2] += 1;
		else if (ch == 'd') count[3] += 1;
		else if (ch == 'e') count[4] += 1;
		else if (ch == 'f') count[5] += 1;
		else if (ch == 'g') count[6] += 1;
		else if (ch == 'h') count[7] += 1;
		else if (ch == 'i') count[8] += 1;
		else if (ch == 'j') count[9] += 1;
		else if (ch == 'k') count[10] += 1;
		else if (ch == 'l') count[11] += 1;
		else if (ch == 'm') count[12] += 1;
		else if (ch == 'n') count[13] += 1;
		else if (ch == 'o') count[14] += 1;
		else if (ch == 'p') count[15] += 1;
		else if (ch == 'q') count[16] += 1;
		else if (ch == 'r') count[17] += 1;
		else if (ch == 's') count[18] += 1;
		else if (ch == 't') count[19] += 1;
		else if (ch == 'u') count[20] += 1;
		else if (ch == 'v') count[21] += 1;
		else if (ch == 'w') count[22] += 1;
		else if (ch == 'x') count[23] += 1;
		else if (ch == 'y') count[24] += 1;
		else if (ch == 'z') count[25] += 1;
	}

	cout << "a : " << count[0] << endl;
	cout << "b : " << count[1] << endl;
	cout << "c : " << count[2] << endl;
	cout << "d : " << count[3] << endl;
	cout << "e : " << count[4] << endl;
	cout << "f : " << count[5] << endl;
	cout << "g : " << count[6] << endl;
	cout << "h : " << count[7] << endl;
	cout << "i : " << count[8] << endl;
	cout << "j : " << count[9] << endl;
	cout << "k : " << count[10] << endl;
	cout << "l : " << count[11] << endl;
	cout << "m : " << count[12] << endl;
	cout << "n : " << count[13] << endl;
	cout << "o : " << count[14] << endl;
	cout << "p : " << count[15] << endl;
	cout << "q : " << count[16] << endl;
	cout << "r : " << count[17] << endl;
	cout << "s : " << count[18] << endl;
	cout << "t : " << count[19] << endl;
	cout << "u : " << count[20] << endl;
	cout << "v : " << count[21] << endl;
	cout << "w : " << count[22] << endl;
	cout << "x : " << count[23] << endl;
	cout << "y : " << count[24] << endl;
	cout << "z : " << count[25] << endl;

	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cmath>
#define absolute(x) x > 0 ? x : -x
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		double xa, ya, ra, xb, yb, rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		int result;
		double d = sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
		if (d+rb < ra) result = 2;
		else if (d+ra < rb) result = -2;
		else if (d <= ra+rb) result = 1;
		else result = 0;
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];
        var p = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(v => v).ToArray();

        var min = p.Take(K).Sum();
        Console.WriteLine(min);
    }
}

Measured memory_bytes: 28432
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))


N,M = two_int()

from collections import defaultdict
start_dicts =defaultdict(list)
end_dicts = defaultdict(list)
for i in range(M):
    a,b = two_int()

    if a in start_dicts:
        start_dicts[a].append(b)
    else:
        start_dicts[a] =[b]

        
    if b in end_dicts:
        end_dicts[b].append(a)
    else:
        end_dicts[b] =[a]


if len(set(start_dicts[1]) & set(end_dicts[N]))>0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main() {
    //
    long long num;
    long long kekka = 0;
    vector<long long> vec;

    cin >> num;

    if (num == 1) {
        cout << 1;
        return 0;
    }else if(num == 2){
        cout << 2;
        return 0;
    }

    for (int i = 1; i < num; i++) {
        kekka += i;
        vec.push_back(i);

        if (kekka == num) break;
        if (kekka > num) {
            vec.erase(vec.begin() + (kekka - num - 1));
            break;
        }
    }

    for (int i = 0; i < vec.size(); i++) { cout << vec.at(i) << endl; }
    //
}


Measured memory_bytes: 3652
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

L = [i + 1 for i in xrange(int(stdin.readline()))]
for _, line in zip(xrange(int(stdin.readline())), stdin):
    a, b = (int(t) - 1 for t in line.split(','))
    L[a], L[b] = L[b], L[a]
for i in L:
    print(i)

Measured memory_bytes: 4268
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace AtTest.ABC_117
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            long[] nk = ReadLongs();
            var array = ReadLongs();
            Array.Sort(array);
            long n = nk[0];
            long k = nk[1];
            int aDigit = 0;
            long aa = array[n - 1];
            while (aa > 1)
            {
                aDigit++;
                aa /= 2;
            }
            int kDigit = 0;
            long kk = k;
            while (kk > 1)
            {
                kDigit++;
                kk /= 2;
            }
            long res = 0;
            for(int i = kDigit+1; i >= 0; i--)
            {
                long val = 0;
                bool down = (k & (long)Math.Pow(2, i)) > 0;
                for (int j = Math.Max(aDigit,kDigit); j >= 0; j--)
                {
                    long div = (long)Math.Pow(2, j);
                    long cnt = 0;
                    for (int l = 0; l < n; l++)
                    {
                        if ((array[l] & div) > 0) cnt++;
                    }
                    if (cnt >= n - cnt)
                    {
                        val += div * cnt;
                    }
                    else
                    {
                        if (down)
                        {
                            if (j == i || (j > i && (k & div) == 0))
                                val += div * cnt;
                            else val += div * (n - cnt);
                        }
                        else
                        {
                            if ((k & div) == 0) val += div * cnt;
                            else val += div * (n - cnt);
                        }
                    }
                    //Console.WriteLine(cnt+" "+val);
                }
                res = Math.Max(res, val);
            }
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

#define INF (1<<29)

struct State{
    int s,t;
    State(){}
    State(int s,int t) : s(s),t(t) {}
};

int getMin(int h,int m){
    return h*60+m;
}

bool check(State &s1,State &s2){
    return (s2.s <= s1.s && s1.t <= s2.t);
}

int main(){
    int V,N,M,h1,m1,h2,m2,K;
    cin >> V;
    vector<State> v(V);
    vector<int> cnt(V, 0),cnt2(V, 0);
    for(int i = 0 ; i < V ; i++){
        scanf("%d:%d-%d:%d",&h1,&m1,&h2,&m2);
        v[i] = State(getMin(h1,m1),getMin(h2,m2));
    }
    cin >> N;
    for(int i = 0 ; i < N ; i++){
        cin >> K;
        for(int j = 0 ; j < K ; j++){
            scanf("%d:%d-%d:%d",&h1,&m1,&h2,&m2);
            State s = State(getMin(h1,m1),getMin(h2,m2));
            for(int k = 0 ; k < V ; k++){
                if(check(v[k],s)) cnt[k]++;
            }
        }
    }
    cin >> M;
    for(int i = 0 ; i < M ; i++){
        cin >> K;
        for(int j = 0 ; j < K ; j++){
            scanf("%d:%d-%d:%d",&h1,&m1,&h2,&m2);
            State s = State(getMin(h1,m1),getMin(h2,m2));
            for(int k = 0 ; k < V ; k++){
                if(check(v[k],s)) cnt2[k]++;
            }
        }
    }
    int res = 0;
    for(int i = 0 ; i < V ; i++){
        res += min(cnt[i], cnt2[i]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1240
program ec12;
var 
	head,last,next,side:array[1..400002] of longint;
	n,m,i,j,p,q,tot,x,y:longint;
procedure add(x,y:longint);
begin 
	inc(tot);
	if head[x]=-1 then 
	begin 
		last[x]:=tot;
		next[tot]:=-1;
		side[tot]:=y;
		head[x]:=tot;
	end
	else
	begin 
		next[last[x]]:=tot;
		next[tot]:=-1;
		side[tot]:=y;
		last[x]:=tot;
	end;
end;
begin
	readln(n,m);
	for i:=1 to n do 
	head[i]:=-1;
	tot:=0;
	for i:=1 to m do 
	begin 
		readln(x,y);
		add(x,y);
	end;
	p:=head[1];
	while p>0 do 
	begin 
		q:=head[side[p]];
		while q>0 do 
		begin 
			if side[q]=n then 
			begin 
				writeln('POSSIBLE');
				halt;
			end;
			q:=next[q];
		end;
		p:=next[p];
	end;
	writeln('IMPOSSIBLE');
end. 

Measured memory_bytes: 5248
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			ArrayList<PriorityQueue<Integer>> PQ = new ArrayList<>();
			int n = sc.nextInt();
			for(int i = 0; i < n; i++) {
				// 大きい順は natural ordering の逆
				PQ.add(new PriorityQueue<Integer>(Collections.reverseOrder()));
			}
			int qn = sc.nextInt();
			for(int i = 0; i < qn; i++) {
				int q = sc.nextInt();
				switch(q) {  // 文字列に対し switch を使って良い
				case 0 /* insert(t)*/: {
					int t = sc.nextInt();
					int x = sc.nextInt();
					PQ.get(t).add(x);
					break;  /* break を忘れない */
				}
				case 1 /* getMax(t) */: {
					int t = sc.nextInt();
					if(!PQ.get(t).isEmpty()) {
						System.out.println(PQ.get(t).peek());
					}
					break;  /* break を忘れない */
				}
				case 2: /* deleteMax(t) */ {
					int t = sc.nextInt();
					if(!PQ.get(t).isEmpty()) {
						PQ.get(t).remove();
					}
					break;  /* break を忘れない */
				}
				}
			}
		}
	}
}



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

int main() {
    int N, d[60];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];

    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io;

#[allow(dead_code)]
fn gcd(x: u32, y:u32) -> u32 {
    let _x = if x >= y { x } else { y };
    let _y = if x >= y { y } else { x };

    if _y == 1 {
        return 1;
    }
    else if _y == 0 {
        return _x;
    } else {
        return gcd(_y, _x%_y);
    }
}

fn gcd_rev(x: u32, y:u32) -> u32 {
    let mut _x = if x >= y { x } else { y };
    let mut _y = if x >= y { y } else { x };

    while _y > 0 {
        let r = _x % _y;
        _x = _y;
        _y = r;
    }
    _x
}

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let mut ws = buf.split_whitespace();
    let x: u32 = ws.next().unwrap().parse().unwrap();
    let y: u32 = ws.next().unwrap().parse().unwrap();

    // println!("{}", gcd(x,y));
    println!("{}", gcd_rev(x,y));
}



Measured memory_bytes: 5016
// 物极必反

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 5e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 998244353;
const long long INF = 1e18 + 9;
const int SM = 3e3 + 5;
const int logN = 22, BL = 400;
const long double EPS = 1e-14;
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main(){
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n; cin >> n;

    vector<long long> a(n);

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

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

    cout << a[n / 2] - a[n / 2 - 1];

    return 0;
}


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

int main()
{
    int n,x,ans=1,mn;
    cin>>n;
    cin>>mn;
    for(int i=1;i<n;i++)
    {
        cin>>x;
        if(x<=mn)
            {
                ++ans;
                mn = x;
            }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3620
from scipy.sparse.csgraph import dijkstra
N, M = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(M)]

# 隣接行列
graph = [[0] * (N + 1) for _ in range(N + 1)]

for i, j in edge:
  graph[i][j] = 1
  
ans = 0
INF = 10 ** 9
for a, b in edge:
  # 辺を取り除く-> INF
  graph[a][b] = INF
  dist = dijkstra(graph, indices=a, directed=False) # directed=False -> 無効グラフ用
  if dist[b] >= INF:
    ans += 1
  # 元に戻す -> 1
  graph[a][b] = 1

print(ans)

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

string vow = "aeiou";

void solve ( int test_case )
{
	ll n ; 
  cin >> n ; 
  
  n *= ( n + 1 ) ; 
  n/= 2 ; 
  cout << n ; 
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
function main(input){
  const a = input.trim().split('');
  let count = 0;
  for(let i=0; i<3; i++){
    if(a[i]=='o'){
      count+=100;
    }
  }
  //let cnt = parseInt(count, 10);
  console.log(700+count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29512
#include<iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    int ans1=0,ans2=0;
    bool flag = false;
    for(int i=0;i<s.size();i++){
        if(flag){
            if(s.substr(i,1) == "1"){
                ans1 ++;
            }
        }
        else{
            if(s.substr(i,1) == "0"){
                ans1 ++;
            }
        }
        if(flag){
            flag = false;
        }
        else{
            flag = true;
        }
    }

    flag = false;
    for(int i=0;i<s.size();i++){
        if(flag){
            if(s.substr(i,1) == "0"){
                ans2 ++;
            }
        }
        else{
            if(s.substr(i,1) == "1"){
                ans2 ++;
            }
        }
        
        if(flag){
            flag = false;
        }
        else{
            flag = true;
        }
    }
    cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 512
n, k = map(int, input().split())
a = list(map(int, input().split()))

history = []
is_visited = [False] * n

index = 0
cnt = 0
loop_start_city_index = 0
for i in range(k+1):
    if i == k:
        print(index+1)
        exit()

    if is_visited[index]:    # すでに訪れた街にきた
        loop_start_city_index = index
        break
    
    is_visited[index] = True
    history.append(index)
    index = a[index] - 1
    cnt += 1

from_start_to_loop_start = history.index(loop_start_city_index)
loop_length = len(history) - from_start_to_loop_start

print(history[from_start_to_loop_start + (k-from_start_to_loop_start)%loop_length] + 1)

Measured memory_bytes: 94016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

int main() {
    ll n;
    cin >> n;
    auto mp = factorize(n);
    int ans = 0;
    for (auto &i : mp) {
        int cnt = 1;
        while (1) {
            if (i.second - cnt >= 0) {
                i.second -= cnt;
                cnt++;
                ans++;
            } else {
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>//for the sake of memset
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
int rabbit[100001];
int N;

int main(){
	cin >> N;
	for(int i = 1;i <= N;i++){
		cin >> rabbit[i];
	}

	int cnt = 0;
	for(int i = 1;i<=N;i++){
		if(rabbit[rabbit[i]] == i){
			cnt++;
			rabbit[rabbit[i]] = 0;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main() {
	string s,t;
	cin >> s;
	int n,a,b;
	cin >> n;
	for (int j = 0; j < n; j++) {
		cin >> t >> a >> b;
		if (t == "replace") {
			string r;
			cin >> r;
			s.erase(a, b - a + 1);
			s.insert(a, r);
		}
		if (t == "reverse") {
			for (int i = 0; i <= (a + b) / 2-a; i++) {
				char temp = '0';
				temp = s[a + i];
				s[a + i] = s[b - i];
				s[b - i] = temp;
			}
		}
		if (t == "print") {
			for (int i = a; i <= b; i++) {
				cout << s[i];
			}
			cout << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3204
#include<stdio.h>
#define MAX 100000
int A[MAX],n;
int partition(int p,int r)
{
	int x,i,j,t;
	x=A[r];
	i=p-1;
	for(j=p;j<r;j++)
	{
		if(A[j]<=x)
		{
			i++;
			t=A[i];
			A[i]=A[j];
			A[j]=t;
		}
	}
	t=A[i+1];A[i+1]=A[r];
	A[r]=t;
	return i+1;
}

int main()
{
	int i,q;
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	q=partition(0,n-1);
	for(i=0;i<n;i++)
	{
		if(i)printf(" ");
		if(i==q)printf("[");
		printf("%d",A[i]);
		if(i==q)printf("]");
	}
	printf("\n");
	return 0;

}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int w, h, n, s = 0, t = 0;
  cin >> w >> h >> n;
  for (int i = 0; i < n; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    switch (a) {
    case 1: s = max(s, x); break;
    case 2: w = min(w, x); break;
    case 3: t = max(t, y); break;
    case 4: h = min(h, y); break;
    }
  }
  cout << max(w - s, 0) * max(h - t, 0) << endl;
}


Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

const ll MAX = 1LL<<60;

int main() {
    int N; cin >> N;
    vector<ll> a(N),s(N+1);
    REP(i,N) cin >> a[i];
    REP(i,N) s[i+1] = s[i] + a[i];
    map<ll,ll> res;
    REP(i,N+1) 
        if(res.count(s[i])) res[s[i]]++;
        else res[s[i]] = 1;
    ll ans = 0;
    for(auto x:res) {
        //cout << x.first << " " << x.second << endl;
        ans += x.second * (x.second - 1) / 2;
    }
    cout << ans << endl;
}

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

int main() {
  string S;
  int i = 0;
  
  cin >> S; 
  std::string str = S;
  std::size_t n = str.size();
 //cout << n << endl;
  while( i<n ){
    if( ((i%2) == 0) && (S[i] == 'L') ){
      cout << "No" << endl;
      break;
    }
    else if( ((i%2) != 0) && (S[i] == 'R') ){
      cout << "No" << endl;
      break;
    }
    i++;
  }
  if( i == n ){
  cout << "Yes" << endl;
  }
}


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

using namespace std;

int main(int argc, char *argv[]) {
  vector<string> result;
  int time;
  double x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> time;
  for (int i = 0; i < time; i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

    double ab, cd;
    ab = (y1 - y2) / (x1 - x2);
    cd = (y3 - y4) / (x3 - x4);
    if (ab == cd)
      result.push_back("YES");
    else
      result.push_back("NO");
  }

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

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename T>string join(V<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2)return 0;if(!(n%2))return !(n-2);lll d=n-1,t,y;while(!(d%2))d>>=1;V<ll> al={2,325,9375,28178,450775,9780504,1795265022};for(ll a:al){if(n<=a)break;t=d,y=modpow(a,t,n);while(t!=n-1&&y!=1&&y!=n-1)y=y*y%n,t<<=1;if(y!=n-1&&!(t%2))return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
mt19937 rnd; void set_rnd(){random_device r;rnd=mt19937(r());}
V<ll> fact, rfact; void set_fact(int n, ll m){fact.pb(1);rfact.pb(1);FOR(i,1,n+1)fact.pb(fact[i-1]*i%m),rfact.pb(modpow(fact[i],m,m-2));}
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 2e5+5;
void init(){
  set_rnd();
//  set_fact(N);
}
int n;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  init();
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    if(a%2){
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
#define pc putchar
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=100005;
int n,a[N];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
signed main(){
	n=read();
	int mx=0,mn=1e9;
	for(int i=1;i<=n;i++){
		a[i]=read();
		mx=max(mx,a[i]);
		mn=min(mn,a[i]);
	}
	if(mx-mn>1) puts("No");
	else if(mx==mn){
		if(mx<=n/2||mx==n-1) puts("Yes");
		else puts("No");
	}
	else{
		int c1=0,c2=0;
		for(int i=1;i<=n;i++){
			c1+=(a[i]==mn);
			c2+=(a[i]==mx);
		}
		if(mx-c1>=1&&mx-c1<=c2/2) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 1024
import math
n,m = map(int,input().split())
num = abs(n-m)
if num > 1:
    print(0)
else:
    dum1 = math.factorial(n)
    dum2 = math.factorial(m)
    if num == 1:
        print((dum1*dum2)%(10**9+7))
    else:
        print(((dum1 * dum2))*2 % (10 ** 9 + 7))

Measured memory_bytes: 5184
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    char c;
    cin >> c;
    printf("%c\n",c+1);

    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int k;
  cin>>k;
  deque<P> q;
  int used[100001]={};
  q.push_back(P(1,1));
  while(!q.empty()){
    int to=q.front().first;
    int co=q.front().second;
    if(!to){
      cout<<co<<endl;
      return 0;
    }
    q.pop_front();
    if(!used[to]){
      used[to]=1;
      q.push_front(P((to*10)%k,co));
      q.push_back(P(to+1,co+1));
    }
  }
  return 0;
}


Measured memory_bytes: 1408