akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    vector<int> P(n);
    REP(i,n) {
        int a;
        cin >> a;
        a--;
        P[a]=i;
    }

    REP(i,n) cout << (i!=0?" ":"") << 30000*(i+1);
    cout << endl;

    REP(i,n) cout << (i!=0?" ":"") << 30000*(n-i)+P[i];
    cout << endl;

	return 0;
}


Measured memory_bytes: 768
///
// File:  0008.cpp
// Author: ymiyamoto
//
// Created on Wed Nov  8 22:24:12 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t n;
    cin >> n;
    if (cin.eof()) break;
    uint32_t count = 0;
    for (uint32_t a = 0; a < 10; a++) {
      for (uint32_t b = 0; b < 10; b++) {
        for (uint32_t c = 0; c < 10; c++) {
          for (uint32_t d = 0; d < 10; d++) {
            if (a + b + c + d == n) {
              count++;
            }
          }
        }
      }
    }
    cout << count << endl;
  }

  return 0;
}

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

int main()
{
	int val;
	int cnt[101] = {};
	while (cin >> val) {
		cnt[val]++;
	}
	vector<int> v;
	int ma = 0;
	for (int i = 1; i <= 100; i++) {
		if (cnt[i] > ma) {
			ma = cnt[i];
			v.clear();
			v.push_back(i);
		}
		else if (cnt[i] == ma) {
			v.push_back(i);
		}
	}
	for (auto va : v) {
		cout << va << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) (a).size())

const int N = (int) 1e6 + 10;
int x[N], p[N], bad[N], sum_bad, n, m, good, last = -1;
int64 sum[N];

int getp(int v) {
	return (v == p[v]) ? v : (p[v] = getp(p[v]));
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &x[i]);
		p[i] = i;
		sum[i] = x[i];
	}
	vector< pair< int, pair<int, int> > > e(m);
	for (int i = 0; i < m; ++i) {
		scanf("%d%d%d", &e[i].sc.fs, &e[i].sc.sc, &e[i].fs);
		--e[i].sc.fs, --e[i].sc.sc;
	}
	sort(e.begin(), e.end());
	for (int i = 0; i < m; ++i) {
		int u = getp(e[i].sc.fs), v = getp(e[i].sc.sc), w = e[i].fs;
		if (u != v) {
			sum[u] += sum[v], p[v] = u, bad[u] += bad[v];
			if (w <= sum[u]) {
				sum_bad -= bad[u];
				bad[u] = 0;
			} else {
				bad[u]++;
				sum_bad++;
			}
		} else {
			if (w > sum[u]) {
				bad[u]++;
				sum_bad++;
			}
		}
	}
	printf("%d\n", sum_bad);
	return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n;cin >> n;
vector<int>a(n);
for(int i = 0;i<n;i++) cin >> a[i];
vector<int>dp(n);
dp[1] = abs(a[1]-a[0]);
for(int i = 2;i<n;i++){
    dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
}
cout << dp[n-1];
return 0;
}

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

using namespace std;

const int N = 55;
const int INF = 0x3f3f3f3f;

int n, X, D;
int sz[N], p[N];
int f[N][N * N * N];
long long m[N];
vector<int> G[N];

void dfs(int u) {
	sz[u] = 1; 
	for (auto v : G[u]) {
		dfs(v), m[u] += m[v], sz[u] += sz[v];
	}
}

void upd(int &x, int y) { x = max(x, y); }

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> X >> D;
	cin >> m[1];
	for (int i = 2; i <= n; ++i) {
		int x; cin >> m[i] >> x;
		G[x].push_back(i);
	}
	dfs(1);
	for (int i = 1; i <= n; ++i) p[i] = i;
	sort(p + 1, p + 1 + n, [&] (int x, int y) {
		return sz[x] * m[y] > sz[y] * m[x];
	});
	memset(f, -INF, sizeof f);
	f[0][0] = X;
	int lim = 0;
	for (int i = 0; i < n; ++i) {
		int tmp = 50;
		if (p[i + 1] != 1) tmp = min(tmp, D);
		for (int j = 0; j <= lim; ++j) {
			for (int k = 0; k <= tmp; ++k) {
				if (f[i][j] < k * m[p[i + 1]]) break;
				upd(f[i + 1][j + k * sz[p[i + 1]]], f[i][j] - k * m[p[i + 1]]);
			}
		}
		lim += tmp * sz[p[i + 1]];
	}	
	int res = 0;
	for (int i = 0; i <= lim; ++i) {
		int cur = f[n][i];
		if (cur < 0) continue;
		int sum = i;
		for (int j = 1; j <= n; ++j) {
			int tmp;
			if (p[j] == 1) tmp = INF;
			else tmp = max(0, D - 50);
			tmp = min(0LL + tmp, cur / m[p[j]]);
			sum += tmp * sz[p[j]];
			cur -= tmp * m[p[j]];
		}
		res = max(res, sum);
	}
	cout << res;
}

Measured memory_bytes: 35968
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

struct node
{
	int l,r;
	pair<LL,int>mx;
}seg[300111];
#define lson (t<<1)
#define rson ((t<<1)|1)
void build(int l,int r,int t=1)
{
	seg[t].l=l;seg[t].r=r;seg[t].mx=mp(0,0);
	if(l==r)return;
	int mid=(l+r)>>1;
	build(l,mid,lson);
	build(mid+1,r,rson);
}
void modify(int p,LL v,int t=1)
{
	if(seg[t].l==seg[t].r){seg[t].mx=mp(v,p);return;}
	int mid=(seg[t].l+seg[t].r)>>1;
	if(p<=mid)modify(p,v,lson);
	else modify(p,v,rson);
	seg[t].mx=max(seg[lson].mx,seg[rson].mx);
}
pair<LL,int> query(int l,int r,int t=1)
{
	if(seg[t].l==l&&seg[t].r==r)return seg[t].mx;
	int mid=(seg[t].l+seg[t].r)>>1;
	if(r<=mid)return query(l,r,lson);
	else if(l>mid)return query(l,r,rson);
	else return max(query(l,mid,lson),query(mid+1,r,rson));
}

int n,q,a[100111];
LL cnt[100111],ans[100111],b[100111];
int main()
{
	get2(n,q);q++;b[1]=n;
	for(int i=2;i<=q;i++)get1(b[i]);
	build(1,q+1);modify(1,b[q]);cnt[1]=1;
	for(int i=q-1;i>=1;i--)
	{
		pair<LL,int> tmp;
		LL sum=0;
		while((tmp=query(1,q-i)).ff>=b[i])
		{
			sum+=cnt[tmp.ss]*(tmp.ff/b[i]);
			modify(tmp.ss,tmp.ff%b[i]);
		}
		modify(q-i+1,b[i]);cnt[q-i+1]=sum;
	}
	for(int i=1;i<=q;i++)
	{
		pair<LL,int>tmp=query(i,i);
		ans[0]+=cnt[tmp.ss];ans[tmp.ff]-=cnt[tmp.ss];
	}
	for(int i=1;i<n;i++)ans[i]+=ans[i-1];
	for(int i=0;i<n;i++)printendl(ans[i]);
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a,min=0,count=0;
  cin>>N;
  vector<int> M(9,0);
  for(int i=0;i<9;i++)M[i]=0;
  for(int i=0;i<N;i++){
    cin>>a;
    if(a>=3200){a=3200;}
    M[a/400]++;
  }
  for(int i=0;i<8;i++){if(M[i]!=0)min++;}
  
  min!=0?cout<<min<<" ":cout<<"1 ";
  cout<<min+M[8]<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, Q;

struct Query {
    int l, r, i;

    bool operator<(const Query &o) const {
	return r < o.r;
    }
};

const int MAXN = 500011;
const int MAGIC = 700;
const int SIZE = MAXN / MAGIC;
vector<Query> B[SIZE], P;

int C[MAXN];

int cnt;
int mem[MAXN];
int ans[MAXN];


void MAIN() {
    scanf("%d%d", &N, &Q);
    REP (i, N) scanf("%d", C+i);
    REP (i, Q) {
	int l, r;
	scanf("%d%d", &l, &r);
	l--;
	if (l / MAGIC == r / MAGIC) {
	    P.push_back((Query){l, r, i});
	} else {
	    B[l/MAGIC].push_back((Query){l, r, i});
	}
    }

    REP (k, SIZE) if (B[k].size()) {
	int sep = min(N, k * MAGIC + MAGIC);
	int R = sep;
	sort(B[k].begin(), B[k].end());

	cnt = 0;
	memset(mem, 0, sizeof mem);

	EACH (e, B[k]) {
	    while (R < N && R < e->r) {
		if (mem[C[R]] == 0) cnt++;
		mem[C[R]]++;
		R++;
	    }

	    for (int i=e->l; i<sep; i++) {
		if (mem[C[i]] == 0) cnt++;
		mem[C[i]]++;
	    }

	    ans[e->i] = cnt;

	    for (int i=e->l; i<sep; i++) {
		mem[C[i]]--;
		if (mem[C[i]] == 0) cnt--;
	    }
	}
    }

    cnt = 0;
    memset(mem, 0, sizeof mem);

    EACH (e, P) {
	for (int i=e->l; i<e->r; i++) {
	    if (mem[C[i]] == 0) cnt++;
	    mem[C[i]]++;
	}

	ans[e->i] = cnt;

	for (int i=e->l; i<e->r; i++) {
	    mem[C[i]]--;
	    if (mem[C[i]] == 0) cnt--;
	}

    }

    REP (i, Q) printf("%d\n", ans[i]);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 18892
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <list>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

ll fact_under(ll a, ll x){
    if(a < 0){
        return 0;
    }else{
        return a / x + 1;
    }
}

ll solve(ll a, ll b, ll x){
    return fact_under(b, x) - fact_under(a - 1, x);
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b, x;
    cin >> a >> b >> x;

    cout << solve(a, b, x) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        String s = num2alphabet(N);
        System.out.println(s);
    }

    public static String num2alphabet(long num) {

        long firstIndexAlpha = (int)'a'; 
        long sizeAlpha = 26; 

        if (num <= 0) {
            
            return "";

        } else if (num <= sizeAlpha) {
            
            return String.valueOf((char)(firstIndexAlpha + num - 1));

        } else {

            long offset = num -1;
            long tmp = offset;
            String str = "";
            while(true) {
                long div = tmp / sizeAlpha; 
                long mod = tmp % sizeAlpha; 

                str = num2alphabet(mod + 1) + str;

                if (div <= 0) {
                    break;
                }

                tmp = (div -1);
            };
            return str;
        }
    }
}


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

const ll INF = 1e18;

int main() {
    int h,w,k,x,y,nx,ny,K;
    cin >> h >> w >> k;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;b--;c--;d--;
    vector<string> g(h);
    rep(i,h) cin >> g[i];
    vector<int> dx = {1,-1,0,0};
    vector<int> dy = {0,0,1,-1};
    vector<vector<ll>> depth(h,vector<ll>(w,INF));
    queue<P> q;
    q.push(make_pair(b,a));
    depth[a][b] = 0;
    while (!q.empty()){
        x = q.front().first;
        y = q.front().second;
        q.pop();
        if (x==d and y==c) break;
        rep(i,4){
            nx = x;
            ny = y;
            K = k;
            while (K--){
                nx += dx[i];
                ny += dy[i];
                if (0<=nx and nx<w and 0<=ny and ny<h and g[ny][nx] != '@'
                and depth[ny][nx] > depth[y][x]){
                    if (depth[ny][nx] != depth[y][x] + 1){
                        depth[ny][nx] = depth[y][x] + 1;
                        q.push(make_pair(nx,ny));
                    } 
                }
                else break;
            }
        }
    }
    if (depth[c][d] == INF) cout << -1 << endl;
    else cout << depth[c][d] << endl;
}

Measured memory_bytes: 19944
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0

for i in range(n):
    ans += b[a[i]-1]
    if i>0 and a[i] == a[i-1]+1:
        ans += c[a[i-1]-1]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, L, a;
  cin >> N >> L;
  if (L > 0) {
    a = L;
  }
  else if (L + N - 1 < 0) {
    a = L + N - 1;
  }
  else {
    a = 0;
  }
  cout << N * (L + (L + N - 1)) / 2 - a << endl;
}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let mut bng = vec![];
    for _ in 0..3 {
      let l: Vec<usize> = read_vec();
      bng.push(l);
    }
    let n: usize = read();
    let mut nums = vec![];
    for _ in 0..n {
      let t: usize = read();
      nums.push(t);
    }

    let mut check_table = vec![vec![false; 3]; 3];

    for b in nums {
      for i in 0..3 {
        for j in 0..3 {
          if bng[i][j] == b {
             check_table[i][j] = true;
          }
        }
      }

      if check(&check_table) {
        println!("Yes");
        return
      }
    }

    println!("No");
}


fn check(bng: &Vec<Vec<bool>>) -> bool {
  // ->
  let mut ok = false;
  for i in 0..3 {
    let mut tmp = true;
    for j in 0..3 {
      tmp = tmp && bng[i][j];
    }
    ok = ok || tmp;
  }

  // |
  for i in 0..3 {
    let mut tmp = true;
    for j in 0..3 {
      tmp = tmp && bng[j][i];
    }
    ok = ok || tmp;
  }

  // \
  let mut tmp = true;
  for i in 0..3 {
    tmp = tmp && bng[i][i];
  }
  ok = ok || tmp;

  tmp = true;
  for i in 0..3 {
    tmp = tmp && bng[2-i][i];
  }

  ok = ok || tmp;

  ok
}

Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

ll N, M, X;
ll C[13], A[13][13];
ll s[13];

ll mcost(ll, int);

int main()
{
  ll ans;
  int i, j;

  cin >> N >> M >> X;
  for (i=1; i<=N; i++) {
    cin >> C[i];
    for (j=1; j<=M; j++) {
      cin >> A[i][j];
    }
  }
  for (j=1; j<=M; j++) s[j] = 0;
  ans = mcost(0, 1);

  cout << ans << endl;

  return 0;
}

ll mcost(ll cc, int d) {
  int j;
  ll tc1, tc2;

  if (d>N) {
//printf("%lld:", cc);
    for (j=1; j<=M; j++) {
//printf(" %lld", s[j]);
      if (s[j] < X) {
//printf("\n");
        return -1;
      }
    }
//printf("\n");
    return cc;
  }
  tc1 = mcost(cc, d+1);
  for (j=1; j<=M; j++) {
    s[j] += A[d][j];
  }
  tc2 = mcost(cc + C[d], d+1);
  for (j=1; j<=M; j++) {
    s[j] -= A[d][j];
  }
//printf("mcost(%lld, %d) tc1=%lld, tc2=%lld\n", cc, d, tc1, tc2);
  if (tc1<0) return tc2;
  if (tc2<0) return tc1;
  if (tc1<tc2) return tc1;
  return tc2;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    vector<vector<int>> c(10, vector<int>(10, 0));
    FOR(i, 1, n + 1) {
        vector<int> d;
        int nn = i;
        while(nn) {
            d.push_back(nn % 10);
            nn /= 10;
        }
        int a = d[0], b = d.back();
        c[a][b]++;
    }
    int ans = 0;
    FOR (i, 1, 10) {
        FOR (k, 1, 10) {
            ans += c[i][k] * c[k][i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

vector<int> z_algorithm(string s){
    int n = s.size();
    vector<int> ret(n);
    ret[0] = n;
    int i = 1, j = 0;
    while(i < n){
        while(i+j < n && s[j] == s[i+j]) j++;
        ret[i] = j;
        if(j == 0) {i++; continue;}
        int k = 1;
        while(i+k < n && k+ret[k] < j) {ret[i+k] = ret[k], k++;}
        i += k, j -= k; 
    }
    return ret;
}

int main(){
    int N;
    string S, now = "";
    cin >> N >> S;
    int ans = 0;
    rep3(i, N-1, 0){
        now = S[i]+now;
        vector<int> res = z_algorithm(now);
        rep(i, res.size()){
            ans = max(ans, min(i, res[i]));
        }
    }
    cout << ans << endl;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

struct Point {
    double x, y;
    Point(double x = 0, double y = 0) : x(x), y(y) {}
    Point(const Point& p) : x(p.x), y(p.y) {}

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

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

    static double norm(const Point& p) { return sqrt(p.x * p.x + p.y * p.y); }
    static double dot(const Point& p1, const Point& p2) { return p1.x * p2.x + p1.y * p2.y; }
    static double cross(const Point& p1, const Point& p2) { return p1.x * p2.y - p1.y * p2.x; }
};
typedef Point Vector;

Point projection(const Point& p1, const Point& p2, const Point& p) {
    double dot = Vector::dot(p2 - p1, p - p1);
    double norm = Vector::norm(p2 - p1);
    return Point(p2 - p1) * dot / (norm * norm) + p1;
}

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

    Point p1, p2;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;

    int q;
    cin >> q;

    rep(i, 0, q) {
        Point p;
        cin >> p.x >> p.y;
        Point ans = projection(p1, p2, p);
        printf("%.10f %.10f\n", ans.x, ans.y);
    }

    return 0;
}


Measured memory_bytes: 3320
#include<stdio.h>
#include<string.h>
int main()
{
	char a[10], b[10], c[10];
	scanf("%s %s %s", &a, &b, &c);
	
	int lenA = strlen(a);
	int lenB = strlen(b);
	
	if (a[lenA-1] == b[0] && b[lenB-1] == c[0]){
		printf("YES\n");
	}
	else printf("NO\n");
	
	
	
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int c1=0,c2=0,c3=0,c4=0;
  while(n--){
    string s;
    cin >> s;
    if(s=="AC")
      c1++;
    else if(s=="WA")
      c2++;
    else if(s=="TLE")
      c3++;
    else
      c4++;
  }

  cout << "AC x " << c1 << endl;
  cout << "WA x " << c2 << endl;
  cout << "TLE x " << c3 << endl;
  cout << "RE x " << c4 << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec(3);
    for (int i = 0; i < 3; ++i)
        cin >> vec[i];

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

    cout << vec[0];
    for (int i = 1; i < 3; ++i)
        cout << ' ' << vec[i];
    cout << '\n';
}



Measured memory_bytes: 3080
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N=int(input())
A=list(map(int,input().split()))

SUM=[0]*(N+1)
for i in range(N-1,-1,-1):
    SUM[i]=SUM[i+1]

    if (N-i)%2==1:
        SUM[i]+=A[i]

#print(SUM)
        
from functools import lru_cache
@lru_cache(maxsize=None)
def calc(i,select):
    rest=N-i

    if rest==0 or select==0:
        return 0

    if rest%2==1 and rest//2+1==select:
        return SUM[i]
    
    elif rest%2==0 and rest//2==select:
        return max(calc(i+1,select),A[i]+calc(i+2,select-1))

    elif rest%2==1 and rest//2==select:
        return max(calc(i+1,select),A[i]+calc(i+2,select-1))

print(calc(0,N//2))

    


Measured memory_bytes: 188528
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
    int n,k;string s;cin>>n>>s>>k;
    char x=s[k-1];
    for(int i=0;i<n;i++){
        if(s[i]!=x)cout<<"*";
        else cout<<x;
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

// 各ノードの座標と深さを保持するための構造体
struct Node{
    int y;
    int x;
    int depth;
};

int main() {
    // 標準入力
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i=0; i<H; i++) {
        cin >> s[i];
    }
    
    int num_black=0;
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (s[i][j]=='#') {
                num_black++;
            }
        }
    }
    
    
    vector<int> y_vec = {0,0,-1,+1}; // 進む方向の簡便化
    vector<int> x_vec = {-1,+1,0,0}; // ループで回すことで上下左右に移動出来る。
    
    
    queue<Node> q;
    // 初期位置をキューに格納
    Node start = {0, 0, 0}; //初期位置の深さは0
    q.emplace(start);
    
    
    int ans=-1;
    
    // 幅優先探索
    while (!q.empty() && ans==-1) {
        Node now = q.front(); q.pop(); // キューの先頭を取り出し、nowとする
        
        // 上下左右４方向を探索。進むことができればキューに格納。
        for (int i=0; i<4; i++) {
            // 上下左右４方向に進む
            Node next = {now.y+y_vec[i], now.x+x_vec[i], now.depth+1};
            // 進む事ができれば（＝未探索Nodeかつ壁でなければ）キューに格納
            if (0<=next.y && next.y<H && 0<=next.x && next.x<W && //そこにNodeがあること
                s[next.y][next.x]=='.') { // 未探索でかつ壁マスでないこと
                s[next.y][next.x]='x'; // 探索済みの印を付ける
                q.push(next); // キューの後ろに追加する
                
                if (next.y==H-1 && next.x==W-1) {
                    ans=(H*W)-(num_black+next.depth+1);
                    break;
                }
            }
        }
    }
    
    // 解
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 200001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, m;

signed main(){
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  for (int i = k; i < n; i++) {
    if (a.at(i - k) < a.at(i))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 4312
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        /*
         * 部分文字列を全探索
         * ATCG文字列であるかを判定する
         * */

        String S = sc.next();
        String sub;
        int cnt = 0;
        int ans = 0;

        for (int i = 0; i < S.length() + 1; i++) {
            for (int j = i + 1; j < S.length() + 1; j++) {
                sub = S.substring(i, j);
                cnt = 0;
                for (int k = 0; k < sub.length(); k++) {
                    if (sub.charAt(k) == 'A' || sub.charAt(k) == 'T' || sub.charAt(k) == 'C' || sub.charAt(k) == 'G') {
                        cnt++;
                    } else {
                        break;
                    }
                }
            }
            ans = Math.max(ans, cnt);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string a="";
	string b="";
	string aa="..##";
	string bb=".#.#";
	int n;
	cin>>n;
	while(1){
		bool ok = false;
		rep(i,4){
			string na = a + aa[i];
			string nb = b + bb[i];
			cout<<na<<endl<<nb<<endl;
			string t;
			cin>>t;
			if(t=="end") return;
			if(t=="T"){
				ok=true;
				a=na;
				b=nb;
				break;
			}
		}
		if(!ok) break;
	}
	while(1){
		bool ok = false;
		rep(i,4){
			string na = aa[i] + a;
			string nb = bb[i] + b;
			cout<<na<<endl<<nb<<endl;
			string t;
			cin>>t;
			if(t=="end") return;
			if(t=="T"){
				ok=true;
				a=na;
				b=nb;
				break;
			}
		}
		if(!ok) break;
	}
}


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

Measured memory_bytes: 596
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if(a+b<2*c) cout << a*x+b*y;
  else if(a<2*c&&b<2*c) cout << min(x, y)*2*c+(x-min(x, y))*a+(y-min(x, y))*b;
  else if(2*c<=a&&b<2*c) cout << x*2*c+max(y-x, 0)*b;
  else if(a<2*c&&2*c<b) cout<< y*2*c+max(x-y, 0)*a;
  else cout << max(x, y)*2*c;
  return 0;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
a = [int(input()) for i in range(M)]
a_complement = list((set(list(range(N+1))) ^ set(a)))
cnt = {s: 0 for s in range(-2,N+1)}
cnt[0] = 1

for i in a_complement:
  cnt[i] += cnt[i-1] + cnt[i-2]

print(cnt[N] % 1000000007)

Measured memory_bytes: 480076
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N, A, B;
  get(N, A, B);
  print(min(N * A, B));
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::BinaryHeap;

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

type Graph = Vec<Vec<(usize,usize)>>;

fn dijkstra(s:usize,g:Graph){
    let mut d = vec![isize::max_value();g.len()];
    let mut bh = BinaryHeap::new();
    // white=-1, gray=0, black=1 whiteで初期化
    let mut color:Vec<isize> = vec![-1;g.len()];

    d[s] = 0;
    //(距離,頂点)
    bh.push((0,s));
    color[s] = 0;

    while !bh.is_empty() {
        let f = bh.pop().unwrap();
        //最小距離の隣接頂点
        let u = f.1;
        color[u] = 1;
        //最小距離でなければ無視
        if d[u] < f.0 * (-1) {
            continue;
        }

        //v(頂点,距離)
        for v in g[u].iter() {
            //未確定頂点か判定
            if color[v.0] != 1 {
                if d[v.0] > d[u] + v.1 as isize {
                    d[v.0] = d[u] + v.1 as isize;
                    bh.push( (d[v.0] * (-1), v.0) );
                    color[v.0] = 0;
                }
            }
        }
    }

    for (i,e) in d.iter().enumerate(){
        println!("{} {}",i,e);
    }
}

fn main() {
    
    let n: usize = read();
    let mut G: Graph = vec![Vec::new(); n];
    for _i in 0..n {
        let u: usize = read();
        let k: usize = read();
        for _j in 0..k {
            let v: usize = read();
            let c: usize = read();
            G[u].push((v,c));
        }
    }

    dijkstra(0,G);    
    
}


Measured memory_bytes: 15268
#include <algorithm>
#include <cstdio>
#include <cstring>

const int MaxN = 100000 + 5;

int N, M;
char S[MaxN];
int F[MaxN], Nxt[MaxN];

void init() {
  scanf("%d %d", &N, &M);
  scanf("%s", S);
  std::reverse(S, S + N + 1);
}

void solve() {
  F[0] = 0;
  static int que[MaxN];
  int head = 1, tail = 0;
  que[++tail] = 0;
  for (int i = 1; i <= N; ++i) {
    if (S[i] == '1') {
      F[i] = -1;
      continue;
    }
    while (head <= tail && que[head] + M < i) head++;
    if (head > tail) {
      F[i] = -1;
      continue;
    }
    int j = que[head];
    F[i] = F[j] + 1;
    Nxt[i] = j;
    while (head <= tail && F[que[tail]] >= F[i]) tail--;
    que[++tail] = i;
  }
  if (F[N] == -1) {
    printf("%d\n", F[N]);
    return;
  }
  for (int i = N; i; i = Nxt[i])
    printf("%d ", i - Nxt[i]);
  putchar('\n');
}

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

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int sum;
  sum = 0;
  cin >> N;
  for (int i = 0; i < 9; i++) {
    int a,b,c;
    a = 1;
    for(int j = 0; j < i; j++){
    a *= 10;
    }
    b = N % a;
    if(b == N){
      break;
    }
    c = ( (N - b) / a ) % 10;
    sum += c;
  }
  if(N % sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 }

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

#define ll long long int
ll mod=1e9+7;

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j;
        double d;
        cin >> n >> d;
        // ll arr[n];
        pair<ll,ll> pr[n];
        ll ans = 0;
        for(i=0;i<n;i++)
        {
            cin >> pr[i].first >> pr[i].second;

            double x = (double) pr[i].first;
            double y = (double) pr[i].second;

            double sq = pow(x,2) + pow(y,2);
            double dist = sqrt(sq);
            if(dist <= d)
            {
                ans++;
            }

        }

        cout << ans << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 6824
#include <bits/stdc++.h>
using namespace std;
template <typename node> void chkmax(node &x, node y) {x = max(x, y);}
template <typename node> void chkmin(node &x, node y) {x = min(x, y);}
template <typename node> void read(node &x) {
	x = 0; int f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) x = x * 10 + c - '0', c = getchar(); x *= f;
}
int main() {
	int n, ans = 0; read(n);
	for (int i = 2; i <= n; i += 2)
		for (int j = 1; j <= n; j += 2)
			ans++;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int N, M, a = 0;
  scanf("%d", &N);
  scanf("%d", &M);
  int A[M];
  for (int i = 0; i < M; i++){
    scanf("%d", &A[i]);
    a += A[i];
  }
  if(N >= a) printf("%d", N - a);
  else printf("-1");
  return 0;
}   

Measured memory_bytes: 1768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int dc=100000;
#define MAX 100010


int main(){
  if(df)printf("*** debug mode ***\n");
  int n;
  scanf("%d",&n);
  int i,h,temp=0,flag=1;
  for(i=0;i<n;i++){
    scanf("%d",&h);
    if(temp<h)temp=h-1;
    if(temp>h)flag=0;
  }

  printf("%s",flag?"Yes":"No");
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 128
d = int(input())
clst = list(map(int, input().split()))
slst = []
lastday = [0] * 26
for i in range(d):
  slst.append(list(map(int, input().split())))
for i in range(1, d + 1): # iは日
  resmax = 0
  best = 1
  for j in range(26): # jはタイプの候補
    res = 0
    oldlast = lastday[j]
    lastday[j] = i
    res += slst[i - 1][j]
    c = 0
    for k in range(26):
      c += clst[k] * (i - lastday[k])
    res -= c
    if res > resmax:
      resmax = res
      best = j
    lastday[j] = oldlast
  lastday[best] = i
  print(best + 1)

Measured memory_bytes: 9420
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;


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

vector< int > divisor(int n)
{
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return(ret);
}

int N;

signed main(){

    in(N);

    map<int,int> p=prime_factor(N);
    vector<int> d=divisor(N);     
    out(p.size(),d.size()-1);

    return 0;
}



Measured memory_bytes: 3216
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;

int main(){
    int n; cin>>n;
    map<string,long long> m;
    for(int i=0;i<n;i++){
        string s; cin>>s;
        sort(s.begin(),s.end());
        m[s]++;
    }

    long long ans=0;
    for(auto p:m){
        ans+=p.second*(p.second-1)/2;
    }
    cout<<ans<<endl;
}

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


int main() {
    int N;
    cin >> N;
    int max_count = 0;
    map<string, int> S;
    rep(i, N){
        string si;
        cin >> si;
        S[si]++;
        if(max_count < S[si]){
            max_count = S[si];
        }
    }

    for(auto i = S.begin(); i != S.end(); i++){
        if(i->second == max_count){
            cout << i->first << endl;
        }
    }
}

Measured memory_bytes: 26624
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		String str = sc.next();
		String ret = "";
		while(!str.isEmpty()){
			ret += str.charAt((str.length()-1));
			str = str.substring(0,str.length()-1);
		}
		System.out.println(ret);
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
		
	}
}

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

string to_string(string s) { return '"' + s + '"'; }
string to_string(char c) { string s = "'"; s += c; return s + "'"; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
    cerr << *it << " = " << to_string(H);
    if(++it != eos) cerr << ", ";
    dbg_out(it, T...);
}
#ifdef LOCAL
    #define dbg(...) { string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); dbg_out(_it, __VA_ARGS__); }
#else
    #define dbg(...)
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int n, k;
    cin >> n >> k;
    int ans = 0;

    for(int i = k; i <= n+1; i++) {
        int min_sum = (i - 1) * i / 2;                                   // 0..(i-1)   => i elements
        int max_sum = n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2;      // (n-i+1)...n => i elements

        int can_get = max_sum - min_sum + 1;
        ans = (ans + can_get) % mod;
    }
    cout << ans << '\n';
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int N, S[3];
	cin >> N;
	while(N-- > 0) {
		for(int i = 0; i < 3; i++)
			cin >> S[i];
		sort(S, S + 3);
		cout << (S[0] * S[0] + S[1] * S[1] == S[2] * S[2] ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 0
def fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))

n, = I()
l = I()
ans = [0]*(n + 10)
ans[1] = abs(l[1] - l[0])
for i in range(2, n):
    ans[i] = min(ans[i-1] + abs(l[i] - l[i-1]), ans[i-2] + abs(l[i] - l[i-2]))
print(ans[n-1])

Measured memory_bytes: 16068
#include<stdio.h>
int main(void)
{
	int m,f,b,x,n;
	scanf("%d",&m);
	scanf("%d",&f);
	scanf("%d",&b);
	x=m-b;
	if(x<0 && f+x<0){
		printf("NA\n");
	}
	else if(x<0 && f+x>=0){
		n=-x;
		printf("%d\n",n);
	}
	else{
		printf("%d\n",0);
	}
	
	return 0;
}



Measured memory_bytes: 2764
#include <stdio.h>

int main(){

  int i,n,A[45];

  scanf("%d",&n);
  A[0]=1;
  A[1]=1;

  for(i=2;i<=n;i++) A[i]=A[i-1]+A[i-2];

  printf("%d\n",A[n]);

  return 0;
}



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

int main()
{
    int n; cin>>n;
    int a[n],tmp=0,ans=0;
    
    for(int i=0;i<n;++i){
        cin>>a[i];
        if(a[i]==tmp+1)tmp+=1;
        else ans+=1;
    }
    if(tmp==0)ans=-1;
	cout<<ans<<endl;
}

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

int main(){

  long long n, p[100000], cnt=0;

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

  for(int i=0;i<n;i++){
    if(i+1==p[i]){
      if(i==n-1) cnt++;
      else{
      swap(p[i], p[i+1]);
      cnt++;
      }
    }
  }

  cout<<cnt<<endl;

  return 0;
}


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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;

  if ((B - A) % 2 == 0) {
    cout << (B - A) / 2 << "\n";
    return 0;
  }

  long long X = min(A - 1, N - B);
  cout << (B - A + 1) / 2 + X << "\n";
}

Measured memory_bytes: 256