akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define REP(i, k, n) for(int i=(int)(k); i<(int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int num[500000];

int main(){
	int N; cin >> N;
	int a[N];
	vector<P> p;
	rep(i, N){
		cin >> a[i];
		if(a[i] <= 200000) p.push_back(P(i, a[i]));
	}
	rep(i, p.size()){
		if(p[i].first - p[i].second >= 0 && p[i].first - p[i].second < 500000){
			num[p[i].first - p[i].second]++;
		}
	}
	ll ans = 0; 
	rep(i, p.size()){
		if(p[i].first - p[i].second >= 0 && p[i].first - p[i].second < 500000){
			num[p[i].first - p[i].second]--;
		}
		if(p[i].first + p[i].second < 500000){
			ans += num[p[i].first + p[i].second];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8160
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int lim=100005;
const int mod=1000000007;

ll t[1003][1003];

int n,m;

char a;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m;
	
	cin>>a;
	t[1][1]=1;	
	for(int i=2;i<=m;i++){
		cin>>a;
		if(a=='.'){
			t[1][i]=t[1][i-1];
		}
	}
	
	for(int i=2;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a;
			if(a=='.'){
				t[i][j]=t[i][j-1]+t[i-1][j];
				if(t[i][j]>mod) t[i][j]-=mod;
			}
		}
	}
	cout<<t[n][m];
	return 0;
}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String nStr0 = sc.next();
		String nStr1 = sc.next();
		String nStr2 = sc.next();
		int n0 = Integer.parseInt(nStr0);
		int n1 = Integer.parseInt(nStr1);
		int n2 = Integer.parseInt(nStr2);

		int flg = 1;
		while (flg == 1) {
			flg = 0;
			if (n1 > n2) {
				int tmp = n1;
				n1 = n2;
				n2 = tmp;
				flg = 1;
			}
			if (n0 > n1) {
				int tmp = n0;
				n0 = n1;
				n1 = tmp;
				flg = 1;
			} 
		}
		System.out.println(n0 + " " + n1 + " " + n2);
		sc.close();
	}
}

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

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int dp[n + 1][2][2][2][2][2][2]{}; //番目、張り付き、0以外、753以外、7、5、3
	dp[0][1][0][0][0][0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < 2; k++)
			{
				for (int l = 0; l < 2; l++)
				{
					for (int m = 0; m < 2; m++)
					{
						for (int o = 0; o < 2; o++)
						{
							for (int p = 0; p < 2; p++)
							{
								int lim = j ? (s[i] - '0') : 9;
								for (int d = 0; d <= lim; d++)
								{
									dp[i + 1][j && (d == lim)][k || d][l || ((k || d) && !(d == 7 || d == 5 || d == 3))][m || (d == 7)][o || (d == 5)][p || (d == 3)] += dp[i][j][k][l][m][o][p];
								}
							}
						}
					}
				}
			}
		}
	}
	cout << dp[n][0][1][0][1][1][1] + dp[n][1][1][0][1][1][1] << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::*;

fn main() {
    input!{
        l: usize,
        r: usize,
        d: usize,
    }

    let mut ans = 0;
    for i in l..=r {
        ans += if i % d == 0 { 1 } else { 0 };
    }

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


Measured memory_bytes: 2096
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<char,int>;

const ll MOD = INF + 7;
bool seen[401][401];
vector<string> s(400);
int cntb, cntw;
int h, w;
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};
void dfs(int y, int x, char c){
   seen[y][x] = true;
   if(s[y][x] == '#')cntb++;
   if(s[y][x] == '.')cntw++;

   rep(i, 4){
      int ny = y + dy[i], nx = x + dx[i];

      if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
      if(c == s[ny][nx])continue;
      if(seen[ny][nx])continue;

      dfs(ny, nx, s[ny][nx]);
      
   }
}

int main(){
   cin >> h >> w;
   rep(i, h)cin >> s[i];

   ll res = 0;
   rep(i, h){
      rep(j, w){
         if(seen[i][j])continue;
         cntw = 0, cntb = 0;
         dfs(i, j, s[i][j]);
         res += (cntb * cntw);
      }
   }
   cout << res << endl;
}

Measured memory_bytes: 10988
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll mod = 1000000007;
string s;
ll N;
ll A[200000];
ll a[200000];
bool is_right[200000];
ll ans;
ll kaijo[200001];
bool flag = false;

bool ok(){
    ll right = 0;
    ll right_cnt = 0;
    rep(i, 2*N){
        if(flag) A[i] = 1-A[i];
        if(i == 0 || A[i] != A[i-1]){
            right += 1;
            right_cnt += 1;
            flag = !flag;
            is_right[i] = true;
            if(right_cnt>N) return false;
        }
        else{
            right -= 1;
            is_right[i] = false;
            if(right<0){
                return false;
            }
        }
        A[i] = 1-A[i];
    }
    if(A[2*N-1] == 0) return true;
    else return false;
}

int main()
{
    cin>>N;
    cin>>s;
    rep(i, 2*N){
        if(s[i] == 'W'){
            A[i] = 0;
        }
        else A[i] = 1;
        if(N % 2 == 1) A[i] = 1-A[i];
    }
    kaijo[0] = 1;
    rep1(i, 2*N){
        kaijo[i] = (kaijo[i-1] * i) % mod;
    }
    ans = 0;
    if(ok()){
        ans = 1;
        ll right_num = 0;
        rep(i, 2*N){
            if(is_right[i]) right_num+=1;
            else{
                ans = (ans * right_num) % mod;
                right_num -= 1;
            }
        }
        ans *= kaijo[N];
        ans %= mod;
    }
    cout<<ans%mod<<endl;
}

Measured memory_bytes: 5124
#include <algorithm>
#include <climits>
#include <cstring>
#include <inttypes.h>
#include <iostream>
#include <iterator>
#include <map>
#include <utility>
#include <vector>

using namespace std;

const int cap = 100;
int N, W;
pair<int, int> I[cap];

int main() {
    scanf("%d %d", &N, &W);
    for (int i = 0; i < N; ++i)
        scanf(" %d %d", &I[i].first, &I[i].second);
    sort(I, I + N);

    map<int, int64_t> dp = {{0, 0}};
    for (int i = N - 1; i >= 0; --i) {
        map<int, int64_t> tmp = dp;
        for (auto it = tmp.begin(); it != tmp.end() && it->first + I[i].first <= W; ++it) {
            int k = it->first + I[i].first;
            int64_t v = it->second + I[i].second;
            auto upper = dp.upper_bound(k);
            if (upper != dp.begin()) {
                auto low = prev(upper);
                if (low->second >= v)
                    continue;
            }
            vector<int> to_remove;
            for (; upper != dp.end(); ++upper)
                if (upper->second <= v)
                    to_remove.push_back(upper->first);
            for (int x : to_remove)
                dp.erase(x);
            dp[k] = v;
        }
    }
    printf("%" PRId64 "\n", dp.rbegin()->second);
}


Measured memory_bytes: 384
let calc a b c = List.fold_left2 (fun x y z -> x + y * z) c a b
let () =
  try
    let (n, m, c) = Scanf.scanf "%d %d %d\n" (fun a b c -> (a, b, c)) in
    let b = Array.to_list
        (Array.init m (fun _ -> Scanf.scanf "%d " (fun x -> x))) in
    let a = Array.to_list
        (Array.init (n) (fun _ -> Array.to_list (Array.init m (fun _ -> Scanf.scanf "%d " (fun x -> x))))) in
    List.length (List.filter (fun lst -> calc lst b c > 0) a) |> print_int
  with
    End_of_file -> ()

Measured memory_bytes: 2432
#include <stdio.h>
 
int parentNode(int index);
int leftChild(int index);
int rightChild(int index);
 
int nodes[251];
 
main(){
 
    int i, n;
 
    scanf("%d", &n);
 
    for(i=1; i<=n; i++){
        scanf("%d", &nodes[i]);
    }
     
    for(i=1; i<=n; i++){
        printf("node %d: ", i);
        printf("key = %d, ", nodes[i]);
        if(parentNode(i-i%2) > 0)
            printf("parent key = %d, ", nodes[parentNode(i-i%2)]);
        if(leftChild(i) <= n)
            printf("left key = %d, ", nodes[leftChild(i)]);
        if(rightChild(i) <= n)
            printf("right key = %d, ", nodes[rightChild(i)]);
        printf("\n");
    }
     
    return 0;
     
}
 
int parentNode(int i){
    return (int)i/2;
}
 
int leftChild(int i){
    return 2*i;
}
 
int rightChild(int i){
    return 2*i+1;
}

Measured memory_bytes: 600
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


// booooooooooooost
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)


signed main() {

	int K;
	cin >> K;

	int N = 50;
	int modK = K % N, divK = K / N;
	vector<int> ans(N, N - 2 + divK); ++ans.back();
	for (int i = 0; i < modK; ++i) {
		sort(ans.begin(), ans.end());
		ans[0] += N;
		for (int j = 1; j < N; ++j) {
			--ans[j];
		}
	}

	cout << N << endl;
	for (int i = 0; i < N; ++i) {
		cout << ans[i];
		if (i != N - 1) cout << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 2005;
int n;
char tmp[maxn];
string s;
vector<int> g[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  scanf("%s", tmp);
  s = tmp;
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  return true;
}

int sum[maxn], cnt[maxn], dp[maxn];

void dfs(int v, int p) {
  sum[v] = 0;
  cnt[v] = (s[v] == '1');
  int maxu = -1;
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i];
    if (u == p) {
      continue;
    }
    dfs(u, v);
    sum[v] += sum[u] + cnt[u];
    cnt[v] += cnt[u];
    if (maxu == -1 || sum[u] + cnt[u] > sum[maxu] + cnt[maxu]) {
      maxu = u;
    }
  }
  if (maxu == -1) {
    dp[v] = sum[v];
    return;
  }
  int x = sum[maxu] + cnt[maxu];
  int y = dp[maxu] + cnt[maxu];
  if (2 * x <= sum[v]) {
    dp[v] = (sum[v] & 1);
    return;
  }
  if (2 * y <= sum[v] - (x - y)) {
    dp[v] = (sum[v] & 1);
    return;
  }
  int z = sum[v] - (x - y) - y;
  dp[v] = y - z;
}

void solve() {
  int res = inf;
  for (int s = 0; s < n; s++) {
    dfs(s, -1);
    if (dp[s] == 0) {
      res = min(res, sum[s] / 2);
    }
  }
  if (res >= inf) {
    res = -1;
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 512
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 200005;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int X = 200005;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    for (int zz = 0; zz < t; zz++)
    {
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    int n,k;
    cin>>n>>k;
    int p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p,p+n);
    ll sum=0;
    for(int i=0;i<k;i++){
        sum+=p[i];
    }
    cout<<sum;
    return;
}



Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }

    public void solve() throws Exception {
        //Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        FastScan scan = new FastScan(System.in);
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        Arrays.sort(A);
        int max = A[N-1];
        boolean[] dp = new boolean[max+1];
        Arrays.fill(dp, true);
        for (int i = 0; i < N; i++) {
            if (dp[A[i]] == false) {
                continue;
            }
            for (int j = 2; A[i] * j <= max; j++) {
                dp[A[i]*j] = false;
            }
        }
        for (int i = 1; i < N; i++) {
            if (A[i-1] == A[i]) {
                dp[A[i]] = false;
            }
        }
        int a = 0;
        for (int i = 0; i < N; i++) {
            if (dp[A[i]]) {
                a += 1;
            }
        }
        System.out.println(a);
    }
    class FastScan {
        BufferedReader br;
        StringTokenizer st;
        FastScan(InputStream is) {
            InputStreamReader isr = new InputStreamReader(is);
            this.br = new BufferedReader(isr);
        }
        String next() throws IOException {
            while (this.st == null || !this.st.hasMoreTokens()) {
                this.st = new StringTokenizer(br.readLine().trim());
            }
            return st.nextToken();
        }
        int nextInt() throws IOException {
            return Integer.parseInt(this.next());
        }
        String nextLine() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 55064
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin >> s;
    char ans='!';

    for(char c = 'a'; c<='z'; c++){
        bool jud = false;

        rep(i,s.size()){

        if(s[i] == c) jud = true;
        }

        if(!jud){
            ans = c;
            break;
        }

    }

    if(ans == '!'){
        cout << "None" << endl;
        return 0;
    }

    cout  << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        sc.nextLine();

        int pointA = 0;
        int pointB = 0;

        for(int i=0;i<n;i++){
            String strA = sc.next();
            String strB = sc.next();
            sc.nextLine();

            switch (compString(strA, strB)){
                case 1:
                    pointA += 3;
                    break;
                case -1:
                    pointB +=3;
                    break;
                case 0:
                    pointA++;
                    pointB++;
                    break;
            }
        }
        System.out.printf("%d %d\n", pointA, pointB);
        sc.close();
    }
    static int compString(String a, String b){
        if(a.equals(b)){
            return 0;
        }
        
        int len = a.length() < b.length() ? a.length() : b.length();
        for(int i=0;i<len;i++){
            if(a.charAt(i)>b.charAt(i)){
                return 1;
            }else if(a.charAt(i)<b.charAt(i)){
                return -1;
            }
        }

        if(a.length()>b.length()){
            return 1;
        }else{
            return -1;
        }
    }
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N, L[2500];

void input() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> L[i];
}
 
void solve() {
    input();
    vector<ll> v(N);
    for(int i = 0; i < N; i++) v[i] = L[i+1];
    sort(v.begin(), v.end());
    ll ans = 0;
    for(ll mid = N - 1; mid >= 0; mid--) {
        for(ll low = mid - 1; low >= 0; low--) {
            auto itr = lower_bound(v.begin(), v.end(), v[mid] + v[low]);
            ll ng = distance(itr, v.end());
            ans += (N - 1 - mid) - ng;
            //cerr << v[mid] + v[low] << " " << ng << " " << (N-1-mid)-ng << endl;
        }
    }
    cout << ans << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int N;
    cin >> N;
    int res[N+1]={};
    rep1(i,N){
        int tmp = i;
        while(tmp<=N){
            res[tmp]++;
            tmp+=i;
        }
    }
    int out=0;
    rep1(i,N){
        if(i%2==1&&res[i]==8){
            out++;
        }
    }
    cout << out << endl;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int get_int(char *line, int size) {
  if(!fgets(line, size, stdin)) return 0;
  int num;
  sscanf(line, "%d", &num);
  return num;
}
#define BUF_SIZE 6
#define NUM_MAX 200

int table[NUM_MAX+1] = {
  [3*5*7] = 1,
  [3*3*3*5] = 1,
  [3*3*3*7] = 1,
  [3*5*11] = 1,
  [3*5*13] = 1,
};

int main(void) {
  char line[BUF_SIZE];
  int num = get_int(line, BUF_SIZE);
  int ans = 0;
  int i;
  for(i = 1; i <= num; i+=2) {
    ans += table[i];
  }

  printf("%d\n", ans);
  return 0;
}


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

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

  int s_len = (int) s.size();
  if (s_len <= k) {
    cout << s << endl;
  } else {
    string s2 = s.substr(0, k);
    cout << s2 << "..." << endl;
  }

  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
char a[105];
int n;
int main()
{
	cin>>a;
	n=strlen(a);
	for(int i=0;i<n;i++)
	{
		if(a[i]=='C')
		{
			for(int j=i+1;j<n;j++)
			{
				if(a[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
int main(void){
        int c[6]={}, money=0, i;
        for(i=0;i<6;i++){
                scanf("%d", &c[i]);
        }
        if(c[0], c[1], c[2], c[3], c[4], c[5] >=0 && c[0], c[1], c[2], c[3], c[4], c[5] <=50){
                c[1]*=5;
                c[2]*=10;
                c[3]*=50;
                c[4]*=100;
                c[5]*=500;
                for(i=0;i<6;i++){
                        money+=c[i];
                }
                if(money>=1000)
                        puts("1");
                else
                        puts("0");
        }
        return 0;
}

Measured memory_bytes: 1808
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    l = set([])
    
    for i in range(1, 10):
        for j in range(1, 10):
            l.add(i*j)
    
    print(YES if N in l else NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(solve(s[0], s[1]));
    }
    static int solve(int n, int k) {
        int ans = (n-2+k-1)/(k-1);
        return ans;
    }
}

Measured memory_bytes: 20064
x,y=list(map(int, input().split()))

if y>x+2020:
	y=x+2020

ans=2019
for i in range (x,y+1):
	for j in range (i+1,y+1):
		if (i*j)%2019<ans:
			ans=(i*j)%2019
print(ans)

Measured memory_bytes: 3060
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)

max_a = a.max
a.delete(max_a)
closest_half_max_a = a.min_by{ |elem| (elem - max_a / 2).abs }
puts "#{max_a} #{closest_half_max_a}"


Measured memory_bytes: 10372
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		int[] heap = new int[n+1];
		String[] tmpArray = br.readLine().split(" ");
		for(int i = 1; i <= n ;i++){
			//heap[i] = new Node(Integer.parseInt(tmpArray[i - 1]));
			heap[i] = Integer.parseInt(tmpArray[i - 1]);
		}
		
		buildMaxHeap(heap);
		
		for(int i = 1; i < heap.length ; i++){
			System.out.print(" "+heap[i]);
		}
		System.out.println();
		
	}
	
	static void maxHeapify(int[] nodes, int i){
		int l = left(i);
		int r = right(i);
		
		int largest;
		if (l <= nodes.length - 1 && nodes[l] > nodes[i]){
			largest = l;
		}
		else {
			largest = i;
		}
		if( r <= nodes.length - 1 && nodes[r] > nodes[largest]){
			largest = r;
		}
		
		if (largest != i){
			int tmp = nodes[i];
			nodes[i] = nodes[largest];
			nodes[largest] = tmp;
			maxHeapify(nodes, largest);
		}
	}
	
	static void buildMaxHeap(int[] a){
		for(int i = a.length/2 ; i >= 1 ;i--){
			maxHeapify(a, i);
		}
	}
	
	static int left(int i){
		return i*2;
	}
	
	static int right(int i){
		return i*2 + 1;
	}
	
	static int parent(int i){
		return i/2;
	}

}

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

sa = list(input())
sb = list(input())
sc = list(input())
now = "a"
while True:
    if now == "a":
        if len(sa) == 0:
            print("A")
            sys.exit()
        else:
            now = sa[0]
            sa.pop(0)
    elif now == "b":
        if len(sb) == 0:
            print("B")
            sys.exit()
        else:
            now = sb[0]
            sb.pop(0)
    else:
        if len(sc) == 0:
            print("C")
            sys.exit()
        else:
            now = sc[0]
            sc.pop(0)
    

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

int main()
{
	int N, M;
	cin >> N >> M;
	int res = 1;
	for (int i = 1; i * i <= M; i++) if (M % i == 0) {
		if (N <= i) {
			res = max(res, M / i);
		}
		if (N <= M / i) {
			res = max(res, i);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ostream>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

const int INF = 1000000;

int main() {
	ll n;
	vector<ll>a(5);
	cin >> n;
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll res;
	if(n%a[0]==0)res= n / a[0] + 4;
	else 	res=n / a[0] + 5;
	cout << res  << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

s = S()
ans = INF
for i in range(len(s)-2):
    ans = min(ans, abs(int(s[i:i+3])-753))
print(ans)


Measured memory_bytes: 63212
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int n;
    int k;
    cin>>n;
    cin>>k;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    vector<int> mintemp(n,0);
    
    for(int i=n-2;i>=0;i--){
        int j = i+1;
        int minval = INT_MAX;
        while((j<=n-1)&&(j<=i+k)){
            minval = min(minval,abs(A[i]-A[j])+mintemp[j]);
            j++;
        }
       // cout<<minval<<" ";
        mintemp[i] = minval;
    }
    cout<<mintemp[0]<<endl;
    
    
}

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

int main(){
  int n,ans=0;
  cin >>n;
  vector<int>flag(n);
  vector<int>a(n);
  for(int i=0;i<n;i++)
    cin >>a.at(i);
  int tmp=1;
  while(1){
    ans++;
    if(a.at(tmp-1)==2){
      cout <<ans<<endl;
      return 0;
    }
    if(flag.at(tmp-1)==1){
      cout <<-1<<endl;
      return 0;
    }
    flag.at(tmp-1)=1;
    tmp=a.at(tmp-1);
  }
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{

    public static List<Integer> P;
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        char [] cha = S.toCharArray();

        int countFrom1 = 0;
        int countFrom0 = 0;
        for(int i=0; i<S.length(); i++){
            if(i%2==0 && cha[i]=='1'){
                countFrom0++;
            }
            if(i%2==1 && cha[i]=='0'){
                countFrom0++;
            }
            if(i%2==0 && cha[i]=='0'){
                countFrom1++;
            }
            if(i%2==1 && cha[i]=='1'){
                countFrom1++;
            }
        }
        System.out.println(Math.min(countFrom0, countFrom1));
    }
}

Measured memory_bytes: 26548
def bubblesort(a,n):
    flag=1
    while flag:
        flag=0
        for j in range(n-1,0,-1):
            if int(a[j][1])<int(a[j-1][1]):
                m=a[j]
                a[j]=a[j-1]
                a[j-1]=m
                flag=1
    return a

def selectionsort(a,n):
    for i in range(n):
        minj=i
        for j in range(i,n):
            if a[j][1]<a[minj][1]:
                minj=j
        if i!=minj:
            m=a[i]
            a[i]=a[minj]
            a[minj]=m
    return a

n=int(input())
a=list(input().split( ))
b=[a[i] for i in range(n)]
a1=bubblesort(a,n)
print(" ".join(a1))
print("Stable")
a2=selectionsort(b,n)
print(" ".join(a2))
if a1==a2:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)

int main()
{
  int N;
  cin >> N;
  vector<ll> B(N+1,0);
  vector<ll> v(N);
  rep(i,N){
    cin >> v[i];
    B[i+1]=B[i]+v[i];
  }
  int MOD=1000000007;
  ll ans=0;
  for(int i=0;i<N;i++){
    ll sum=(B[N]-B[i+1])%MOD;
    ans+=(v[i]*sum)%MOD;
    ans%=MOD;
  }
	cout<<ans<< endl;
}


Measured memory_bytes: 6272
n ,m = map(int, input().split())
a = list(map(int, input().split()))

a_sum = sum(a)
if a_sum % (4 * m) != 0:
    a_border = (a_sum // (4 * m)) + 1
else:
    a_border = a_sum // (4 * m)

count = 0
for a_one in a:
    if a_one >= a_border:
        count += 1

if count >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	int now = 1;
	while (cnt < n) {
		if (2 * now < now + k) {
			now *= 2;
		}
		else {
			now += k;
		}
		cnt++;
	}
	cout << now << endl;
}

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

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

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

int main(void) {
    int n;
    long long ans = 1LL;
    cin >> n;
    for (int i = 0; i < n; i++) {
        long long t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
}


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

int main(){
	ll count = 0;
	string s;
	cin >> s;
	vector<ll> v(s.size(), 0);
	
	for(int i = s.size()-1; i > 0; i--){
		if(i != s.size()-1) v.at(i) = v.at(i+1);
		if(s[i] == 'W')v.at(i)++;
	}
	
	rep(i, s.size()-1){
		if(s[i] == 'B') count += v.at(i+1);
	}
	
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 2180
//https://atcoder.jp/contests/dp/tasks/dp_f
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int dp[3123][3123];
int main(){
    string s,t;
    cin>>s>>t;
    int A=s.size();
    int B=t.size();
    for(int i:range(A+10))for(int j:range(B+10))dp[i][j]=-1000000;
    dp[0][0]=0;
    for(int i:range(3123))dp[i][0]=dp[0][i]=0;
    for(int i:range(A)){
        for(int j:range(B)){
            dp[i+1][j+1]=dp[i][j];
            if(s[i]==t[j])dp[i+1][j+1]++;
            chmax(dp[i+1][j+1],dp[i+1][j]);
            chmax(dp[i+1][j+1],dp[i][j+1]);
        }
    }
    stack<char> st;
    int p=A,q=B;
    while(p>0&&q>0){
        if(s[p-1]==t[q-1]){
            st.push(s[p-1]);
            p--;q--;
        }
        else{
            if(dp[p][q]==dp[p-1][q]){
                p--;
            }
            else if(dp[p][q]==dp[p][q-1]){
                q--;
            }
            else{
                p--;q--;
            }
        }
    }
    while(st.size()){
        cout<<st.top();st.pop();
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 37504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int N,M,H[100010];
bool ans[100010];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>M;
    for(int i=1;i<=N;i++) cin>>H[i];
    memset(ans,1,sizeof(ans));
    while(M--){
        int u,v; cin>>u>>v;
        ans[u]&=H[u]>H[v];
        ans[v]&=H[v]>H[u];
    }
    int res=0;
    for(int i=1;i<=N;i++) res+=ans[i];
    cout<<res;
    return 0;
}

Measured memory_bytes: 4128
l=[int(input()) for i in range(5)]
def A(i):
    return 10-(i-1)%10
l.sort(key=A)
t=0
for i in range(4):
    if l[i]%10==0:
        t+=l[i]
    else:
        t+=l[i]//10*10+10
print(t+l[4])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}


int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	  ll n,m,x; 
	  cin>>n>>m>>x;
	  ll a[n][m+1];
	  
	  for(int i=0;i<n;i++)
	  {
	      for(int j=0;j<=m;j++) cin>>a[i][j];
	  }
	  
	  ll cc = 1e18;
	  for(ll i=1;i<(1LL<<n);i++)
	  {
	      ll vv[m+1] = {0}; ll g=0;
	      bitset <12> b(i);
	      //for(int j=0;j<n;j++) cout<<b[j]; cout<<endl;
	      for(int j=0;j<n;j++)
	      {
	          
	          if( b[j] )
	          {
	              for(int k=1;k<=m;k++)
	              {
	                  vv[k] += a[j][k];
	              }
	              g += a[j][0];
	              
	          }
	      }
	      if(g<cc)
	      {
	          bool ok=1;
	          for(int j=1;j<=m;j++)
	          {
	              if( vv[j] < x )
	              {
	                  ok=0; 
	                  break;
	              }
	            
	          }
	          if(ok) cc = g;
	      
	      }
	   //   for(int j=1;j<=m;j++) cout<<vv[j]<<' '; cout<<endl;
	   //   cout<<cc<<endl;
	  }
	  if( cc < 1e18 )
	    cout<<cc<<'\n';
	  else
	  cout<<-1<<'\n';
	
	return 0;
}


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

int main(){
  char a[106];
  char b[106];
  int na,nb;

  scanf("%s %s", a, b);

  na = strlen(a);
  nb = strlen(b);

  if(na > nb) printf("GREATER\n");

  else if(nb > na) printf("LESS\n");

  else {
    int i;
    int f = 0;
    for(i = 0;i < na;i++){
      if(a[i] > b[i]){
        f = 1;
        printf("GREATER\n");
        break;
      }

      else if(a[i] < b[i]){
        f = 1;
        printf("LESS\n");
        break;
      }
    }

    if(f == 0) printf("EQUAL\n");
  }

  return 0;
}

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

UL N,M;
struct Pic{ UL S,V; };
bool prioriCmp(const Pic& l, const Pic& r){
 if(l.V != r.V) return l.V > r.V;
 return l.S > r.S;
}
UL C[100000];
Pic A[100000];

int main(){
 scanf("%u%u",&N,&M);
 rep(i,N) scanf("%u%u",&A[i].S,&A[i].V);
 rep(i,M) scanf("%u",&C[i]);
 sort(C,C+M); reverse(C,C+M);
 sort(A,A+N,prioriCmp);

 UL ans=0;
 rep(i,N){
  if(ans==M) break;
  if(C[ans] >= A[i].S) ans++;
 }

 printf("%u\n",ans);

 return 0;
}



Measured memory_bytes: 4452
program ABCSwap;
var
	A, B, C, temp : integer;
begin
	readln(A, B, C);
	
	temp:= A; 
	A := B;
	B:= temp;
	
	temp:= A; 
	A := C;
	C:= temp;
	
	writeln(A, ' ', B, ' ', C);
end.

Measured memory_bytes: 1384
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


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

  Int N;
  cin>>N;
  vector<Int> A(N);
  cin>>A;

  Int sum = 0;
  for(Int i=0;i<N;i++) sum += A[i];
  Int k = sum / (N * (N + 1) / 2);
  vector<Int> d(N);
  for(Int i=0;i<N;i++) d[i] = A[(i + 1)%N] - A[i];
  for(Int i=0;i<N;i++) d[i] -= k;

  Int ans = 1;
  if(sum % (N * (N + 1) / 2) != 0) ans = 0;
  for(Int i=0;i<N;i++){
    if(d[i] > 0) ans = 0;
    if(abs(d[i]) % N != 0) ans = 0;
    k -= abs(d[i]) / N;
  }

  ans &= k == 0;
  cout<<(ans? "YES":"NO")<<endl;

  return 0;
}


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

int main() {
    long long x; cin >> x;
    for (int i=-200; i<=200; ++i) {
        for (int j=-200; j<=200; ++j) {
            if ((long long)i*i*i*i*i - (long long)j*j*j*j*j == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)

const int N_MAX = 2000;
const int INF = 1e9;

int N, K, Q;
int A[N_MAX];

pair<int, int> ps[N_MAX];
map<int, int> ss;
vector<int> vs;
vector<int> ws;

void solve() {
  REP(i, N) ps[i] = make_pair(A[i], i);
  sort(ps, ps + N);
  ss[N] = 0;
  int ans = INF;
  int i = 0;
  while (i < N) {
    // printf("i: %d\n", i);
    vs.clear();
    ITR(ss, it) {
      int l = it->second;
      int r = it->first;
      int w = r - l;
      // printf(" l: %d, r: %d, w: %d", l, r, w);
      if (w >= K) {
        ws.clear();
        ws.insert(ws.end(), A + l, A + r);
        sort(ws.begin(), ws.end());
        vs.insert(vs.end(), ws.begin(), ws.begin() + w - K + 1);
        // printf(" : add %d items", w - K + 1);
      }
      // puts("");
    }
    // printf(" vs.size(): %d\n", vs.size());
    if (vs.size() < Q) break;
    sort(vs.begin(), vs.end());
    // printf(" vs[0]: %d, vs[%d]: %d\n", vs[0], Q - 1, vs[Q - 1]);
    ans = min(ans, vs[Q - 1] - vs[0]);
    int ai = ps[i].first;
    while (ps[i].first == ai) {
      int ap = ps[i].second;
      auto it2 = ss.lower_bound(ap);
      int l = it2->second;
      int r = it2->first;
      // printf(" x: %d, l: %d, r: %d\n", x, l, r);
      ss.erase(r);
      if (ap > l) ss[ap] = l;
      if (ap + 1 < r) ss[r] = ap + 1;
      i++;
    }
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d%d", &N, &K, &Q);
  REP(i, N) scanf("%d", A + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int A,B;
  cin >> A >> B;
  if(A>8 || B>8) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
char v1[100001];
int v[100001];
int main() {
    int i,n,l,c,a,b,op,j,ok;
    c=0;
    ok=0;
    cin>>n>>l>>a;
    for(i = 2; i<=n; i++) {
        cin>>b;
        v1[i-1]=((a+b)>=l);
        a=b;
    }

    for(i=1; i<=n-1; i++) {
        if(v1[i]) {
            op=n;
            for(j=i+1; j<=n-1; j++) {
                if(v1[j]==1) {
                    op=j;
                    break;
                }
            }
            if(op!=n) {
                for(j=i+1; j<=op-1; j++) {
                    v[++c]=j;
                }
            } else {
                for(int j = n-1; j>=i+1; j--)
                    v[++c]=j;
            }
            i=op-1;
        } else {
            ok=0;
            for(j = i; j<=n-1; j++, i++) {
                if(v1[j]==1) {
                    ok=1;
                    break;
                }
                v[++c]=j;
            }
            i--;
            if(!ok) {
                cout<<"Impossible";
                return 0;
            }
        }
    }
    for(i=1; i<=n-1; i++) {
        if(v1[i]==1)
            v[++c]=i;
    }
    if(c==n-1) {
        cout<<"Possible\n";
        for(i=1; i<=n-1; i++) {
            cout<<v[i]<<'\n';
        }
    }
    return 0;
}


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

int main(){
	int n;
  	string s;
  	cin >> n >> s;
  
  	int ans = 0;
  	rep(i, n - 2){
    	if(s.substr(i, 3) == "ABC") ans++;
    }
  	cout << ans << endl;
}

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

int main(){
  int N,ans = 0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
    if (i % 2 == 0 && a.at(i) % 2 != 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
s=input()
n=len(s)
a=[]
for i in range(len(s)):
    a.append(s[i])
b=list(reversed(a))
cn=a[:((n-1)//2)]
c=list(reversed(a[:((n-1)//2)]))
d=list(reversed(a[(n+3)//2-1:]))
dn=a[(n+3)//2-1:]
if a==b and c==cn and d==dn:
    print('Yes')
else:
    print('No')

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    int EnjoyDay = N;
    rep(i,M){
        cin >> A.at(i);
        EnjoyDay -= A.at(i);
    }
    if(EnjoyDay < 0) cout << -1 << endl;
    else cout << EnjoyDay << endl;
}

Measured memory_bytes: 3664
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		while(sc.hasNext()){
			String str = sc.nextLine();
			int i = 0;
			int tmp = 0;
			while(i<str.length()){
				char ch = str.charAt(i++);
				if( '0' <= ch && ch <= '9' )
					tmp = tmp * 10 + Integer.parseInt(""+ch);
				else {
					sum += tmp;
					tmp = 0;
				}
			}
			sum += tmp;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 12000
N, M = map(int, input().split())
br = []
for i in range(M):
    a, b = map(int, input().split())
    br.append([a, b])
br.sort()


br_ = []
q = 0

for i in br:
    a = i[0]
    if q == a:
        continue
    else:
        br_.append(i)
    q = a

ans = []
w = br_[0]
for i in br_[1:]:
    if i[0] < w[1]:
        w = [i[0], min(i[1], w[1])]
    else:
        ans.append(w)
        w = i

print(len(ans)+1)

Measured memory_bytes: 22828