akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<int,int> P;

const int MAX_H = 50;
const int MAX_W = 50;

ll w,h;
char s[MAX_H][MAX_W];
ll dist[MAX_H][MAX_W];
int dx[4] = {1,-1,0,0}, dy[4] = {0,0,-1,1};
ll white_cnt = 0;

ll bfs(){
  queue<P> que;
  cin >> h >> w;
  REP(i,h){
    REP(j,w){
      cin >> s[i][j];
      dist[i][j] = INF;
      if(s[i][j]=='.') white_cnt++;
    }
  }
  que.push(P(0,0));
  dist[0][0] = 0;
  while(que.size()){
    P p = que.front(); que.pop();
    if(p.first==h-1&&p.second==w-1) break;
    REP(i,4){
      int ny = p.first+dy[i];
      int nx = p.second+dx[i];
      if(ny>=0&&ny<h&&nx>=0&&nx<w&&s[ny][nx]!='#'&&dist[ny][nx]==INF){
        dist[ny][nx] = dist[p.first][p.second]+1;
        que.push(P(ny,nx));
      }
    }
  }
  return dist[h-1][w-1];
}

int main(){
  ll min_dist = bfs();
  if(min_dist==INF){
    cout << -1 << endl;
  }else{
    cout << white_cnt-min_dist-1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define SZ(c) int(c.size())
#define ff first
#define ss second
#define INF 1e9 + 1
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	LL c;
	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}
	return b;
}
int LCM(int a, int b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
			n /= i;
		}
	}
	if (n > 2)printf("%d ", n);
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
void dijjkstra(int src, int n) {
	list<ipair>adj[1000005];
	vector<bool>visited(1000005, false);
	vector<int>dis(1000005, 1e9);
	PQ<ipair, vector<ipair>, greater<ipair>>pq;
	pq.push(MP(0, 1));
	dis[src] = 0;
	while (!pq.empty())
	{
		int u = pq.top().ss;
		visited[u] = true;
		pq.pop();
		list<ipair>::iterator i;
		for (i = adj[u].begin(); i != adj[u].end(); i++)
		{
			int v = i->ff;
			int we = i->ss;
			if (!visited[v] && dis[v] > dis[u] + we)
			{
				dis[v] = dis[u] + we;
				pq.push(MP(dis[v], v));
			}
		}
	}
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n, m;
	cin >> n >> m;
	vector<int>a(m);
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		for (int j = 0; j < x; j++)
		{
			int v;
			cin >> v;
			a.at(v - 1)++;
		}
	}
	int  ans = 0;;
	for (int idx = 0; idx < m; idx++)
	{
		if (a.at(idx) == n)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve(int N) {
    vi S(N);
    if (N == 3) {
        S[0] = 2, S[1] = 5, S[2] = 63;
    } else if (N == 4) {
        S[0] = 2, S[1] = 5, S[2] = 20, S[3] = 63;
    } else if (N == 5) {
        S[0] = 2, S[1] = 5, S[2] = 20, S[3] = 30, S[4] = 63;
    } else {
        S.clear();
        int i;
        for (i = 1; sz(S) < N; ++i) {
            if (i % 2 == 0 || i % 3 == 0)S.push_back(i);
        }
        ll sm = accumulate(all(S), 0ll);
        if (sm % 6 == 2) {
            S.erase(S.begin());
            while (i % 6)i++;
            S.push_back(i);
        } else if (sm % 6 == 5) {
            S.erase(S.begin() + 1);
            while (i % 6 != 4)++i;
            S.push_back(i);
        } else if (sm % 6 == 3) {
            S.erase(S.begin() + 1);
            while (i % 6)i++;
            S.push_back(i);
        }
        sm = accumulate(all(S), 0ll);
        assert(sm % 6 == 0);
    }
    rep(i, N) {
        assert(S[i] <= 30000);
        cout << S[i] << (i != N - 1 ? ' ' : '\n');
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;
    solve(N);
}

Measured memory_bytes: 512
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  ll n;
  cin >> n;

  ll ans = n - 1;
  for(ll a = 2; a * a <= n; a++){
    if(n % a == 0){
      ll b = n / a;
      ans = min(ans, a + b - 2);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<queue>
#include<algorithm>
#define INF 99999999
using namespace std;
queue <int> qy,qx,qcnt;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m,x,y,cnt,nx,ny,mini,ansx,ansy;
int t[20][20],sx,sy,tx,ty,vd[20][20];
string in;
int main(){
  while(cin>>n>>m&&n){
    for(int i=0;i<n;i++){
      cin>>in;
      for(int j=0;j<(int)in.size();j++){
	if(in[j]=='A')sx=j,sy=i;
	else if(in[j]=='B')tx=j,ty=i;
	t[i][j]=(in[j]=='#');
      }
    }
    
    for(int i=0;i<20;i++)for(int j=0;j<20;j++)vd[i][j]=INF;
    vd[sy][sx]=1;
    qx.push(sx);
    qy.push(sy);
    qcnt.push(1);
    while(!qx.empty()){
      x=qx.front();qx.pop();
      y=qy.front();qy.pop();
      cnt=qcnt.front();qcnt.pop();
      for(int i=0;i<4;i++){
	nx=x+dx[i];ny=y+dy[i];
	if(!(0<=nx&&nx<m&&0<=ny&&ny<n))continue;
	if(vd[ny][nx]!=INF||t[ny][nx]==1)continue;
	vd[ny][nx]=cnt+1;
	qx.push(nx);
	qy.push(ny);
	qcnt.push(cnt+1);
      }
    }
    
    cin>>in;
    cnt=0;
    mini=INF;

    for(int I=0;I<n*m;I++){
      for(int i=0;i<(int)in.size();i++){
	cnt++;
	if(cnt>=vd[ty][tx]){
	  if(mini>cnt){
	    mini=cnt;
	    ansy=ty;
	    ansx=tx;
	  }
	}
	if(in[i]=='5')continue;
	else if(in[i]=='8'){
	  if(ty==0)continue;
	  ty--;
	}else if(in[i]=='6'){
	  if(tx==m-1)continue;
	  tx++;
	}else if(in[i]=='4'){
	  if(tx==0)continue;
	  tx--;
	}else{
	  if(ty==n-1)continue;
	  ty++;
	}
      }//for
    }//while
    if(mini==INF)cout<<"impossible"<<endl;
    else cout<<mini-1<<' '<<ansy<<' '<<ansx<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    vector<vector<int>> sums(N);
    for (int j = 1; j < N; j++) {
        for (int i = 0; (i < j && L[i] != L[j]); i++) {
            sums[j].push_back(L[i] + L[j]);
        }
    }
    int result = 0;
    for (int k = 2; k < N; k++) {
        for (int j = 1; (j < k && L[j] != L[k]); j++) {
            result += (sums[j].end() - upper_bound(sums[j].begin(), sums[j].end(), L[k]));
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC333
{
    public class Program
    {
        public static void Main()
        {
                string[] AB = Console.ReadLine().Split(' ');
                int A = int.Parse(AB[0]);
                int B = int.Parse(AB[1]);

                if(A%2==1&&B%2==1)
                {
                 	Console.WriteLine("Yes"); 
                }
                else
                {
                 	Console.WriteLine("No"); 
                }
        }
    }
}

Measured memory_bytes: 11092
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

long solve(long[] a) {
    long[] b;
    foreach(i; iota(a.length-1)) {
        b ~= a[i+1]-a[i];
    }
    long ret;
    foreach(i; iota(b.length)) {
        ret += ((((i+1) * (b.length-i)) % p) * b[i]) % p;
        ret %= p;
    }
    return ret;
}

void main(){
    long n, m;
    readlnTo(n, m);
    auto x = readLongs();
    auto y = readLongs();

    writeln((solve(x) * solve(y)) % p);
}



Measured memory_bytes: 11532
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define ull long long
using namespace std;

const int nmax = 100100;
ull N, K;

void read(){
    cin >> N >> K;
}
ull max(ull x, ull y)
{
    return x < y ? y : x;
}
void solve(){
    if ( K == 0)
    {
        cout << N * N << endl;
        return;
    }
    ull ans = 0;
    for(ull b = K+1; b<=N; ++b)
    {
        ull x = N/b;
        ull y = N%b;
        ans += x * (b-K); 
        if(y != 0){
           ans += max(0ULL, y - K + 1);
        }

    //cout << b << ' ' << ans << endl;
    }
    cout << ans << endl;
}

int main(){
    read();
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 4010
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-15)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

struct edge{ int to,cap,cost,rev; };
 
int v;
vector<edge> e[MAX];
int h[MAX];
int dist[MAX];
int prevv[MAX],preve[MAX];
int n;
int a[MAX],b[MAX];
vector<int> ab;
 
void add_edge(int from,int to,int cap,int cost){
  e[from].push_back((edge){to,cap,cost,(int)e[to].size()});
  e[to].push_back((edge){from,0,-cost,(int)e[from].size()-1});
}
 
int min_cost_flow(int s,int t,int f){
  int res=0;
  fill(h,h+v,0);
  fill(prevv,prevv+MAX,0);
  fill(preve,preve+MAX,0);
  while(f>0){
    priority_queue<pii,vector<pii>,greater<pii> > pq;
    fill(dist,dist+v,inf);
    dist[s]=0;
    pq.push(pii(0,s));
    while(pq.size()){
      pii p=pq.top();
      pq.pop();
      int u=p.second;
      if(dist[u]<p.first)continue;
      for(int i=0;i<e[u].size();i++){
        edge &E=e[u][i];
        if(E.cap>0 && dist[E.to]>dist[u]+E.cost+h[u]-h[E.to]){
          dist[E.to]=dist[u]+E.cost+h[u]-h[E.to];
          prevv[E.to]=u;
          preve[E.to]=i;
          pq.push(pii(dist[E.to],E.to));
        }
      }
    }
    if(dist[t]==inf)return -1;
    for(int i=0;i<v;i++)h[i]+=dist[i];
 
    int d=f;
    for(int u=t;u!=s;u=prevv[u]){
      d=min(d,e[prevv[u]][preve[u]].cap);
    }
    f-=d;
    res+=d*h[t];
    for(int u=t;u!=s;u=prevv[u]){
      edge &E=e[prevv[u]][preve[u]];
      E.cap-=d;
      e[u][E.rev].cap+=d;
    }
  }
  return res;
}

ll solve(){
  FOR(i,0,n){ ab.pb(a[i]);ab.pb(b[i]); }
  sort(all(ab));
  Unique(ab);
  FOR(i,0,ab.size()){
    FOR(j,0,n){
      if(ab[i]==a[j])add_edge(i,j+ab.size(),1,-b[j]);
      if(ab[i]==b[j])add_edge(i,j+ab.size(),1,-a[j]);
    }
  }
  int s=ab.size()+n,t=s+1,u=t+1;
  v=t+2;
  FOR(i,0,ab.size())add_edge(s,i,1,0);
  FOR(i,0,n)add_edge(i+ab.size(),t,1,0);
  add_edge(s,u,inf,0);
  add_edge(u,t,inf,0);
  return -min_cost_flow(s,t,inf);
}

int main()
{
  cin>>n;
  FOR(i,0,n)cin>>a[i]>>b[i];
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 3576
a, b, c = map(int, input().split())
li = []
i = 1
while i >= 0:
    ans = (a*i) % b
    if ans == c:
        print("YES")
        break
    else:
        al = ans in li
        if al == True:
            print("NO")
            break
        else:
            li.append(ans)
    i += 1


Measured memory_bytes: 2940
#include <iostream>
#include <vector>

using namespace std;

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n + m == 0) {
      break;
    }
    vector<vector<int>> pc(n);
    for (int i = 0; i < n; i++) {
      pc[i] = vector<int>(1261);
    }
    int r;
    cin >> r;
    for (int i = 0; i < r; i++) {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      b--;
      if (d) {
        pc[b][a] = c;
      } else {
        pc[b][a] = -c;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int t = 1; t < 1261; t++) {
        pc[i][t] += pc[i][t - 1];
      }
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
      int ts, te, tm;
      cin >> ts >> te >> tm;
     
      int ans = 0;
      for (int t = ts; t < te; t++) {
        for (int j = 0; j < n; j++) {
          if (pc[j][t] == tm) {
            ans++;
            break;
          }
        }
      }
      cout << ans << endl;
    }
  }
  return 0;
}

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

using namespace std;

#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define re return
#define endl '\n'

using ll = long long;
using ull = unsigned long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using ld = long double;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }

const ld pi = 4 * atan(1.);
const int mod = 1e9 + 7; 
const int N = 3e5 + 17;

int n, m, k;
ll f[N], inv[N];

ll power(ll x, ll y = mod - 2) {
    ll ans = 1;
    while (y) {
        if (y & 1) ans = ans * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    re ans;
}

ll cnk(int n, int k) {
    re f[n] * (inv[k] * inv[n - k] % mod) % mod;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a, b, c;
    cin >> n >> a >> b >> c;
    if (b & 1) { cout << 0; re 0; }
    ll ans = 0;
    f[0] = inv[0] = 1;
    for (int i = 1; i < N; i++) {
        f[i] = f[i - 1] * i % mod;
        inv[i] = power(f[i]);
    }
    for (int i = 0; i <= a; i++)
        for (int j = 0; 3 * j + i <= c; j++) { 
                int k = c - (3 * j + i);
                if (!b && k) continue;
                ll cur = f[a + j + b / 2] * inv[a - i] % mod;
                cur = cur * inv[i] % mod; 
                cur = cur * inv[j] % mod; 
                cur = cur * inv[b / 2] % mod;
                if (b || k)
                    cur = cur * cnk(b / 2 - 1 + k, k) % mod;
                ans = (cur + ans) % mod;
            }
    cout << ans;
}


Measured memory_bytes: 8304
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    double T, X;
    cin >> T >> X;
    cout << fixed << setprecision(10) << double(T/X) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int N, C, K;
  cin >> N >> C >> K;
  vi t(N);
  rep(i, N) cin >> t[i];
  sort(all(t));

  int res = 1;
  int s = t[0];
  int n = 0;
  rep(i, N) {
    while (i < N && n < C && t[i] - s <= K) n++, i++;
    if (i >= N) break;
    s = t[i], n = 1;
    res++;
  }

  cout << res << endl;
}

Measured memory_bytes: 640
s = [list(map(int, s.split())) for s in open(0)][0][0]
cnt = 0 
num_mon = 1
while True:
    if s > 1:
        cnt += num_mon
        s = s // 2
        num_mon += num_mon * 2 - num_mon
    else:
        break 
print(cnt + num_mon)

Measured memory_bytes: 3060
def main():
    nvertices, nedges = map(int, input().split())
    adj = [[0] * nvertices for j in range(nvertices)]
    for i in range(nedges):
        u, v, c = map(int, input().split())
        adj[u][v] = c

    INF = float('inf')
    ans = 0
    while True:
        parents = bfs(0, nvertices - 1, adj)
        if parents is None:
            break
        v = nvertices - 1
        f = INF
        while parents[v] != -1:
            f = min(f, adj[parents[v]][v])
            v = parents[v]

        ans += f
        v = nvertices - 1
        while v != 0:
            u = parents[v]
            adj[u][v] -= f
            adj[v][u] += f
            v = u

    print(ans)


def bfs(s, t, adj):
    nvertices = len(adj)
    visited = [False] * nvertices
    visited[0] = True
    que = [s]
    parents = [-1] * nvertices
    while que:
        u = que.pop(0)
        if u == t:
            return parents

        for v in range(len(adj)):
            if not visited[v] and adj[u][v] > 0:
                parents[v] = u
                visited[v] = True
                que.append(v)

    return None


main()

Measured memory_bytes: 7800
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;



int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll min=1e8;
    ll cnt=0;
    rep(i,n){
      if(min>a[i]) {cnt++; min=a[i];}
    }
  cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 2560
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp;
    auto T = readln.chomp;

    int[26] cs, ds;
    foreach (i; 0..S.length) {
        auto s = S[i] - 'a';
        auto t = T[i] - 'a';
        if (cs[s] == 0 && ds[t] == 0) {
            cs[s] = t+1;
            ds[t] = s+1;
        } else if (cs[s] != t+1 || ds[t] != s+1) {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}

Measured memory_bytes: 2744
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    long nums[max(N + 1, 2)];
    nums[0] = 2;
    nums[1] = 1;
    for(int i = 2; i <= N; i++){
        nums[i] = nums[i - 2] + nums[i - 1];
    }
    cout << nums[N] << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const int inf = 1e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

vector<pii> dist[100000];
bool visited[100000];
ll memo[100000];

bool check(int i, ll d) {
	if (visited[i])	return memo[i] == d;
	memo[i] = d;
	visited[i] = true;
	rep(j, dist[i].size()) {
		int to = dist[i][j].first;
		ll add = dist[i][j].second;
		if (!check(to, d + add))	return false;
	}
	return true;
}

int main() {
	int n, m;	cin >> n >> m;
	rep(i, m) {
		int l, r, d;	cin >> l >> r >> d;
		l--;	r--;
		dist[l].push_back(mp(r, d));
		dist[r].push_back(mp(l, -d));
	}
	rep(i, n) {
		if (!visited[i]) {
			if (!check(i, 0)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 12416
def warshall_floyd(dist_matrix)
	dist = dist_matrix
	n = dist.size
	raise "dist_matrix is not square" if dist.any?{|row| row.size != n}

	next_dist = (1..n).map{ Array.new(n) }	
	(0..n-1).each{|k|
		dist_k = dist[k]
		(0..n-1).each{|i|
			dist_i = dist[i]
			next_dist_i = next_dist[i]
			(0..n-1).each{|j|
				x = dist_i[j]
				y = dist_i[k] + dist_k[j]
				next_dist_i[j] = (x < y ? x : y)
			}
		}
		dist = next_dist
	}
	dist
end

loop do
	n, m = gets.split.map &:to_i
	break if n == 0 
	c_mat = (1..m).map{[Float::INFINITY] * m}
	t_mat = (1..m).map{[Float::INFINITY] * m}
	(0..m-1).each do |i|
		c_mat[i][i] = t_mat[i][i] = 0
	end
	
	n.times do
		i, j, c, t = gets.split.map &:to_i	
		i -= 1
		j -= 1
		c_mat[i][j] = c_mat[j][i] = c
		t_mat[i][j] = t_mat[j][i] = t
	end
	
	c_mat = warshall_floyd(c_mat)
	t_mat = warshall_floyd(t_mat)
	
	q = gets.to_i
	q.times do
		i, j, k = gets.split.map &:to_i
		i -= 1
		j -= 1
		puts k == 0 ? c_mat[i][j] : t_mat[i][j]
	end
end

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

int main(){
    int n;
    while(cin >> n, n != 0){
        set<int> info[102];
        for(int i=0;i<n;++i){
            int m;
            cin >> m;
            for(int j=0;j<m;++j){
                int p;
                cin >> p;
                info[i].insert(p);
            }
        }
        int k;
        cin >> k;
        vector<int> leaked;
        for(int i=0;i<k;++i){
            int l;
            cin >> l;
            leaked.push_back(l);
        }
        int cnt = 0, idx = -1;
        for(int i=0;i<n;++i){
            bool flag = true;
            for(int e : leaked){
                if(info[i].count(e) == 0)flag = false;
            }
            if(flag){
                cnt++;
                idx = i;
            }
        }
        if(cnt != 1 || idx == -1)cout << -1 << endl;
        else cout << idx + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 3568
def main():
    n = int(input())
    s = ["".join(sorted(input())) for i in range(n)]
    
    from collections import Counter
    c = Counter(s)
    res = 0
    for i in c.values():
        if i < 2:
            continue
        else:
            res += i * (i-1) // 2
    print(res)
    
if __name__ == '__main__':
    main()
                

Measured memory_bytes: 68312
#include<cstdio>
int main()
{
	int n,pre,x,ans=0;scanf("%d%d",&n,&pre);
	for(int i=1;i<n;i++)
	{
		scanf("%d",&x);
		if(x==pre) ans++,x=0;
		pre=x;
	}
	printf("%d\n",ans); 
	return 0; 
} 

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

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const LL mod=1000000007;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=100005;

char str[maxn];

int main()
{
    int a,b,c;
    while(~scanf("%s", &str)){
        int len=strlen(str), ans=0;
        for(int i=len-1;i>1;i--){
            if(i%2==0){
                for(int j=0;j+i-1<len;j++){
                    int l=j;
                    while(l<i/2&&str[l]==str[l+i/2])l++;
                    if(l+i/2-j+1==i){
                        ans=i;
                        break;
                    }
                }
            }
            if(ans)break;
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
Y,X=map(int,input().split())
info=[]
for i in range(Y):
    s=list(input())
    info.append(s)
#print(info)

def search(y,x):
    a=0
    if 0<=y<=Y-1 and 0<=x<=X-1:
        if info[y][x]=="#":
            a+=1
    return a
            
def count(y,x):
    num=0
    num+=search(y-1,x-1)
    num+=search(y-1,x)
    num+=search(y-1,x+1)
    num+=search(y,x-1)
    num+=search(y,x+1)
    num+=search(y+1,x-1)
    num+=search(y+1,x)
    num+=search(y+1,x+1)
    return num

for i in range(Y):
    for j in range(X):
        if info[i][j]!="#":
            info[i][j]=str(count(i,j))
for i in range(Y):
    for j in range(X):
        print(info[i][j],end="")
    print()

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

int main(void)
{
    char X, Y;
    cin >> X >> Y;

    if (X > Y)
    {
        cout << ">" << endl;
    }
    else if (X < Y)
    {
        cout << "<" << endl;
    }
    else
    {
        cout << "=" << endl;
    }

    return (0);
}

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

int main()
{
    
    long double a,b,x;
    long double ans;
    const long double PI = (acos(-1));

    cin >> a >> b >> x;

    if(x <= a*a*b/2){
        ans = atan2( (a*b*b), (2*x)  );
    }else{
        ans = atan2( (2*(a*a*b-x)) ,(a*a*a));
    }

    cout << fixed << setprecision(10) << (ans  * 180.0 / PI) << "\n";

}

Measured memory_bytes: 256
#  deque

import collections
import sys
deque = collections.deque([])

n = int(input())
for i in range(n):
    query = sys.stdin.readline().split()
    if query[0] == "insert":
        deque.appendleft(int(query[1]))
    elif query[0] == "deleteFirst":
        deque.popleft()
    elif query[0] == "deleteLast":
        deque.pop()
    elif query[0] == "delete":
        try:
            deque.index(int(query[1]))
        except:
            pass
        else:
            deque.remove(int(query[1]))

print(*deque)


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string s; cin >> s;
    int N = s.size();
    if(s[0] == s[N-1] && N%2==0) cout << "First" << endl;
    else if(s[0] == s[N-1] && N%2==1) cout << "Second" << endl;
    else if(s[0] != s[N-1] && N%2==0) cout << "Second" << endl;
    else if(s[0] != s[N-1] && N%2==1) cout << "First" << endl;
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    int n,k;
    string s;

    cin>>n>>s>>k;
    for(int i=0;i<n;i++){
        if(s[i]!=s[k-1]) s[i]='*';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
long long int a,b,k;

scanf("%lld",&a);
scanf("%lld",&b);

k = (a*a-b*b)/(2*a-2*b);
if((a*a-b*b)%(2*a-2*b)!=0)
        printf("IMPOSSIBLE\n");
else    printf("%lld\n",k);
return 0;
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int a5, b7, c5;

  if (a == 7)
  {
    b7 = a;
    a5 = b;
    c5 = c;
  }
  else if (b == 7)
  {
    b7 = b;
    a5 = a;
    c5 = c;
  }
  else if (c == 7)
  {
    b7 = c;
    a5 = a;
    c5 = b;
  }
  else
  {
    cout << "NO" << endl;
    return 0;
  }

  if (a5 == 5 && c5 == 5)
  {
    cout << "YES" << endl;
    return 0;
  }
  else
  {
    cout << "NO" << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

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

  bool flag = false;

  for (int ii=1; !flag && ii<=9; ++ii) {
    if (N%ii==0 && N/ii < 10)
      flag = true;
  }

  cout << (flag ? "Yes" : "No") << endl;

  return 0;
}


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

using namespace std;

#define MOD 1000000007
#define N 3003
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

ll dp[N][N], a[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, l, r, i;
    cin>>n;
    for(i=0; i<n; i++){
        cin>>a[i];
    }
    for(l=n-1; l>=0; l--){
        for(r=l; r<n; r++){
            if(l == r) dp[l][r] = a[l];
            else{
                dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
            }
        }
    }
    cout<<dp[0][n-1];
    return 0;
}

Measured memory_bytes: 70016
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)
int main(){
  char s[100];
  scanf("%s",s);
  int len = strlen(s);
  printf("%c%d%c\n",s[0],len-2,s[len-1]);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "no" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    map<char, ll> cnt;
    rep(i, s.size()) cnt[s[i]]++;

    bool chk = true;
    for(auto p: cnt) if(p.second >= 2) chk = false;
    (chk) ? Yes() : No();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int w[30][100020];
int x[100010];

int main(){
  int n,C;
  cin >> n >> C;
  rep(i,n){
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--,z--;
    w[z][x]--;
    w[z][y]++;
  }
  vector<pint> v[30];
  rep(i,30){
    rep(j,100010){
      if(w[i][j]==-1){
        int temp=j+1;
        while(temp<100010 && w[i][temp]!=1){
          temp++;
        }
        if(w[i][temp]==1){
          v[i].push_back({j,temp});
          x[j]++;
          x[temp+1]--;
        }
      }
    }
  }
  int ans=0;
  int temp=0;
  rep(i,100005){
    temp+=x[i];
    ans=max(ans,temp);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int r, n=0;
    bool flg = true;
    string str;

    cin >> r;
    cin >> str;
	
    if ( r % 2 == 0 ) {
      n = r/2;
    }
    else {
      flg = false;
    }
  
    for( int i=0; i<n; i++ ) {
        if ( str.at(i) != str.at(i+n) ) {
            flg = false;
            break;
        }
    }
    if (flg) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,x,y,flg;
	scanf("%d",&n);
	flg=0;
	x=0;
	while(y>=0){
		y=n-x;
		if(y==0){
			flg=1;
			break;
		}
		else if(y%7==0){
			flg=1;
			break;
		}
		x=x+4;
	}
	if(flg==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}	

Measured memory_bytes: 128
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

int N;
map< string, int > label_id;

int dist[110][110];

void solve() {
	for_(i,0,110) for_(j,0,110) dist[i][j] = iINF / 2;
	
	vector< pair< string, int > > vpsi;
	
	for_(i,0,N) {
		string s; cin >> s;
		
		if (s == "goto") {
			string ss; cin >> ss;
			ss = ss.substr(0, size_of(ss) - 1);
			vpsi.push_back( make_pair(ss, i) );
		} else {
			s = s.substr(0, size_of(s) - 1);
			label_id[s] = i;
		}
		
		if (i > 0) dist[i - 1][i] = 0;
	}
	dist[N - 1][N] = 0;
	
	int v_size = size_of(vpsi);
	for_(i,0,v_size) {
		pair< string, int > psi = vpsi[i];
		int id = label_id[psi.first];
		dist[psi.second][psi.second + 1] = 1;
		dist[psi.second][id] = 0;
	}
	
	for_(k,0,N+1) for_(i,0,N+1) for_(j,0,N+1) {
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	}
	
	cout << dist[0][N] << endl;
}

int main() {
	cin >> N;
	solve();
	return 0;
}

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

int main()
{
  int left[4]  = { 0, 0, 0, 0, };
  int right[4] = { 0, 0, 0, 0, };   //人数

  while (true)
  {
    double l_eye, r_eye;
    cin >> l_eye >> r_eye;
    if ( cin.eof() ) break;
    if ( 1.1 <= l_eye )       // left
    {
      left[0]++;
    }
    else if ( 0.6 <= l_eye )
    {
      left[1]++;
    }
    else if ( 0.2 <= l_eye )
    {
      left[2]++;
    }
    else
    {
      left[3]++;
    }

    if ( 1.1 <= r_eye )       // right
    {
      right[0]++;
    }
    else if ( 0.6 <= r_eye )
    {
      right[1]++;
    }
    else if ( 0.2 <= r_eye )
    {
      right[2]++;
    }
    else
    {
      right[3]++;
    }
  }
  for (int i=0; i<4; i++)
  {
    cout << left[i] << ' ' << right[i] << endl;
  }
}

Measured memory_bytes: 1224
#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))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
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() {
  string s;
  cin >> s;
  rep(i,sz(s)) {
    if(s[i]==',') {
      s[i]=' ';
    }
  }
  cout << s << endl;
  return 0;
}

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

int main(){

    int S;
    cin >> S;

    int front, rear;
    front = S/100;
    rear = S%100;
    
    bool thr1, thr2;

    thr1 = (front>0) && (front<13);
    thr2 = (rear>0) && (rear<13);

    if(!thr1 && thr2)
        cout << "YYMM" << endl;
    else if(thr1 && !thr2)
        cout << "MMYY" << endl;
    else if(thr1 && thr2)
        cout << "AMBIGUOUS" << endl;
    else
        cout << "NA" << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define lowbit(x) (x&(-x))
using namespace std;

const int maxn=105;
int n,a[maxn],t[maxn],tl[maxn];
int q[maxn];
vector<int>g[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

inline void update(int pos,int ad){
	for(rg int i=pos;i<=n;i+=lowbit(i)) t[i]+=ad;
}

inline int get(int pos){
	int ss=0; for(rg int i=pos;i>0;i-=lowbit(i)) ss+=t[i];
	return ss;
}

int main(){
	#ifndef ONLINE_JUDGE
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	#endif
	n=rd(); int fl=0;
	go(i,n+1,1){
		a[i]=rd();
		if(a[i] > i){ fl=1; break; }
	}
	if(fl){ puts("-1"); return 0; }
	for(rg int i=n;i>=1;i--){
		g[a[i]].push_back(get(a[i]));
		update(a[i],1);
		//g[a[i]].push_back(n-i);
	}
	int now=0;
	memset(t,0,sizeof(t));
	while(now < n){
		for(rg int i=n;i>=1;i--){
			if(tl[i] >= g[i].size() || now < i-1) continue ;
			int ss=0;
			go(j,now+1,i) if(q[j] <= i) ss++;
			if(ss == g[i][tl[i]]){
				printf("%d\n",i);
				for(rg int j=now+1;j>i;j--) q[j]=q[j-1];
				q[i]=i; now++; tl[i]++;
				break;
			}
		}
	}
	return 0;
}//Faze


Measured memory_bytes: 256
# https://www.youtube.com/watch?v=ENSOy8u9K9I&feature=youtu.be
# https://twitter.com/tempura_cpp/status/1259483252919635969

n, k = gets.to_s.split.map{|e|e.to_i}
a = [0].concat gets.to_s.split.map{|e|e.to_i}

cur = 1
while k > 0

  cur = a[cur] if k[0] == 1
  
  a = Array.new(n+1){ |i| a[a[i]] }
  
  k >>= 1
end

puts cur

Measured memory_bytes: 81692
#include<stdio.h>
#include<map>
#include<string>
#include<string.h>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#include<math.h>
#include<stack>
#include<set>
#define INF 2147483647
#define n 300000
#define loop(i, a, b) for(int i=a; i<=b; i++)
#define mem(arr) memset(arr, 0, sizeof(arr));
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
struct edge{
	int to, weight;
};
void solve();
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 1, times)
	{
		solve();
		cout << '\n';
	}
	return 0;
}
vector<edge> V[n + 50];
int a, b, c, d, e, f;
int arr[n + 50], arr1[n + 50], arr2[n + 50];
string str, str1, str2;

void solve()
{
	cin >> str;
	int cnt = 0;
	for(int i=0, j = str.size() - 1; i < j; i++, j--)
	{
		if(str[i] != str[j]) cnt ++;
	}
	cout << cnt << '\n'; 
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, A, B;

	cin >> N >> A >> B;
	cout << min(N*A, B) << endl;

	return 0;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {
  ll n, d;
  cin >> n >> d;

  int ans = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    ll dist = (x * x) + (y * y);
    ll t = d * d;
    if (dist <= t) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628