akhauriyash/Code-Regression huggingface dataset:
#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 ans = 0;
  rep(i, n+1) {
    if (i==0) continue;
    int cnt = 0;
    rep(j, n+1) {
      if (j==0) continue;
      if (i%j==0) cnt++;
    }
    if (cnt==8&&i%2==1) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
N,M=map(int,input().split())

def find_negative_loop(n,w,es):
  dist=[float("inf")]*n
  #この始点はどこでもよい
  dist[1]=0
  
  for i in range(n):
    for j in range(w):
      e=es[j]
      if dist[e[1]]>dist[e[0]]+e[2]:
        dist[e[1]]=dist[e[0]]+e[2]
        if i==n-1:
          return True
  return False

def shortest_path(s,n,w,es):
  #s→iの最短距離
  #s:始点, n:頂点数, w:辺の数, es[i]:[辺の始点,辺の終点,辺のコスト]
  dist=[float("inf")]*n
  #d[i]: s→iの最短距離
  dist[s]=0

  while True:
    update=False
    for p,q,r in es:
      # e: 辺iについて [from,to,cost]
      if dist[p]!=float("inf") and dist[q]>dist[p]+r:
        dist[q]=dist[p]+r
        update=True
    if not update:
      break
      
  return dist

graph=[[] for _ in range(N+1)]
elist=[]
for _ in range(M):
  a,b,c=map(int,input().split())
  graph[a].append(b)
  elist.append((a,b,-c))
  
#remove unnecessary vertex and edge
visited=[None]*(N+1)
def check_reachable(s,u):
  if u==N:
    reachable_list[s]=True
    return True
  
  visited[u]=True
  for v in graph[u]:
    if not visited[v]:
      check_reachable(s,v)    
  return False

reachable_list=[False]*(N+1)
for i in range(1,N+1):
  visited=[False]*(N+1)
  check_reachable(i,i)
#print(reachable_list)
  
elist2=[]
for a,b,nc in elist:
  if reachable_list[b]:
    elist2.append((a,b,nc))
  
M2=len(elist2)
res1=find_negative_loop(N+1,M2,elist2)

if res1:
  print("inf")
else:
  res2=shortest_path(1,N+1,M2,elist2)
  print(-res2[N])

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

struct UnionFind {
private:
    vector<int> par,depth;
public:
    UnionFind (int n) {
        par.resize(n);
        depth = vector<int>(n,0);
        for (int i = 0;i < n;++i) par[i] = i;
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (depth[x] < depth[y]) par[x] = y;
        else {
            par[y] = x;
            if (depth[x] == depth[y]) depth[x]++;
        }
    }

    bool same(int x,int y) {
        return find(x) == find(y);
    }
};

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> p(n);
    for (int i = 0;i < n;++i) cin >> p[i];
    UnionFind uf(n);
    for (int i = 0;i < m;++i) {
        int x,y;
        cin >> x >> y;
        uf.unite(x-1,y-1);
    }
    int ans = 0;
    for (int i = 0;i < n;++i) {
        if (uf.same(i,p[i]-1)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
n, m = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(m)]
A.sort(key=lambda x: x[1])

posi = A[0][1]
count = 1
for i in range(m):
    if posi <= A[i][0]:
        count += 1
        posi = A[i][1]
        
print(count)

Measured memory_bytes: 22816
#include <iostream>
#include <string>

int main(){
	std::string num,s;
	int a,b,c=0;
	std::cin>>a>>b;
	for(int x=a;x<=b;x++){
		s=std::to_string(x);
		if(s[0]==s[4]&&s[1]==s[3])
			c++;
	}
	std::cout<<c<<std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[101],b[101];
    int n,len1,len2,x,i;
    scanf("%s %s",a,b);
    len1=strlen(a);
    len2=strlen(b);
    n=0;
    for(i=0;i<len1;i++)
    {
        n*=10;
        x=a[i]-'0';
        n+=x;
    }
    for(i=0;i<len2;i++)
    {
        n*=10;
        x=b[i]-'0';
        n+=x;
    }
    //printf("%d\n",n);
    int root=sqrt(n);
    if(root*root==n)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;

}


Measured memory_bytes: 256
function Main(input){
  
  var str = input.split("\n");
  var n = str[0];
  //var tmph = str[1];
  var h = str[1].split(" ");
  
  //console.log("str[1]:"+str[1]);
  h.map(Number);
    //console.log("h:"+h);
  var kekka = 0;
  //var kekka = 0;
  //arr.indexOf(Math.max.apply(null,arr) 
  
  var highest = 0;
  
  for(i=0;i<n;i++){
    if(highest-h[i]<=0){
      highest = h[i];
      //console.log("h:"+h[i]);
      //console.log("high:"+highest);
      kekka++;
    }//if end
    
  }//for end
  
    
   console.log(kekka);
}//function end
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

struct UnionFind {
	vector<int> par, rank;
	
	UnionFind(int n) {
		par.resize(n);
		rank.resize(n);
		REP(i, n) {
		 par[i] = i;
		 rank[i] = 0;
		}
	}
	
	int operator[] (int x) {
		return find(x);
	}
	
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		
		if (rank[x] < rank[y]) swap(x, y);
		
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
	
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	
};

template <typename T>
struct SegTree {
	T init_val;
	int n;
	vector<T> dat;
	
	SegTree(int _n, T init_val) : init_val(init_val) {
		n = 1;
		while (n < _n) n *= 2;
		dat.resize(n * 2 - 1, init_val);
	}
	
	void update(int i, T x) {
		i += n - 1;
		dat[i] = min(dat[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}
	
	void set(int i, T x) {
		dat[i + n - 1] = x;
		update(i, x);
	}
	
	// 探索範囲[a,b), 現在見ているkノード[l,r)
	T query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		
		if (r <= a || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k];
		return min( query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r) );
	}
};

using pll = pair<ll, ll>;
int N, D;
vector<int> A;

int main() {
	cin >> N >> D;
	A.resize(N);
	REP(i, N) scanf("%d", &A[i]);
	
	vector<int> ord(N);
	iota(ALL(ord), 0);
	
	sort(ALL(ord), [&](int x, int y) {
		return A[x] > A[y];
	});
	
	vector<pair<ll, pii> > edge;
	
	SegTree<pll> lseg(N, pll(longINF, -1));
	SegTree<pll> rseg(N, pll(longINF, -1));
	
	REP(i, N) lseg.update(i, pll(A[i] + (ll)i * D, i));
	REP(i, N) rseg.update(i, pll(A[i] - (ll)i * D, i));
	
	for (int idx : ord) {
		pll cur = lseg.query(idx + 1, N);
		if (~cur.se) edge.emplace_back(A[idx] - (ll)idx * D + cur.fi, pii(idx, cur.se));
		cur = rseg.query(0, idx);
		if (~cur.se) edge.emplace_back(A[idx] + (ll)idx * D + cur.fi, pii(idx, cur.se));
		lseg.set(idx, pll(longINF, -1));
		rseg.set(idx, pll(longINF, -1));
	}
	
	sort(ALL(edge));
	
	UnionFind uf(N);
	ll ans = 0;
	for (auto cur : edge) {
		ll cost = cur.fi;
		int x = cur.se.fi, y = cur.se.se;
		if (uf.same(x, y)) continue;
		uf.unite(x, y);
		ans += cost;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 28524
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string s; cin>>s;
	if(s=="RRR") cout<<3<<endl;
	else if(s=="SRR" || s=="RRS") cout<<2<<endl;
	else if(s=="SSS") cout<<0<<endl;
	else cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 3536
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)2000 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)998244353;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

void add(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}
int sum(int x, int y) {
	add(x, y);
	return x;
}
int mult(int x, int y) {
	return x * 1ll * y % mod;
}

int bp(int x, int y) {
	if (x < 0) return 0;
	int res = 1;
	while (y) { 
		if (y & 1) res = res * 1ll * x;
		x = x * 1ll * x % mod, y >>= 1;
	}
	return res;
}

int n, k;

int dp[N][N][2];
int calc(int ost, int prs, int f) {
	if (ost < 0) return 0;
	if (!ost) return 1;
	if (~dp[ost][prs][f]) return dp[ost][prs][f];
	int res = 0;
	if (prs) add(res, calc(ost, prs - 1, 1));
	if (f) {
		if (prs) add(res, calc(ost - 1, prs, 0) * 2ll % mod);
	} else {
		add(res, calc(ost - 1, prs, 0));
	}
	return dp[ost][prs][f] = res;
}
int dp1[N][N];
int calc1(int ost, int cnt) {
	if (ost < 0) return 0;
	if (!ost || cnt <= 0) return !ost;
	if (~dp1[ost][cnt]) return dp1[ost][cnt];
	int res = calc1(ost, cnt - 1);
	if (cnt) add(res, calc1(ost - 1, cnt));
	return dp1[ost][cnt] = res;
}
int total(int K) {
	int prs = 0;
	rep(i, 1, K) {
		prs += (K - i <= k && i < K - i);
	}	
	int res = 0;
	rep(i, 0, n) {
		int cnt1 = sum(calc(i, prs, 1), calc(i - 1, prs, 1) * (K % 2 == 0 && K / 2 <= k));
		/* cout << calc(i, prs, (K % 2 == 0 && K / 2 <= n), 1) << nl;
		cout << calc1(n - i, k - 2 * prs - (K % 2 == 0 && K / 2 <= n)) << nl;
		cout << nl; */
		add(res, mult(cnt1, calc1(n - i, k - 2 * prs - (K % 2 == 0 && K / 2 <= k))));
	}
	return res;
}
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	cin >> k >> n;
	memset(dp, -1, sizeof(dp));
	memset(dp1, -1, sizeof(dp1));
	rep(i, 2, 2 * k) {
		cout << total(i) << nl;
	}
	ioi
}



Measured memory_bytes: 47616
/*
Author : N_o_o_B
Created : March 14 2020 17:33:15 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll n,m;
    
    cin >> n >> m;

    if(n==1 or m==1){
        cout << 1 << endl;
        return 0;
    }

    ll ans = ((n+1)/2)*((m+1)/2) ;
   
    ans += (n/2)*(m/2);

    cout << ans << endl; 


    time_taken();
    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int main() {
    double pi = 3.14159265;
    double N;cin >> N;
    cout << N*2*pi << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

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

  vector<int> A(N);
  map<int, int> count;
  Rep(n, N) {
    cin >> A[n];
    count[A[n]]++;
  }

  int answer = N;
  Rep(i, N) {
    int a = A[i];
    if (count[a] > 1 || (a != 1 && count[1] > 0)) {
      answer--;
      continue;
    }

    int bound = sqrt(a) + 1;
    For(j, 2, bound) {
      if (a % j == 0 && (count[j] > 0 || count[a / j] > 0)) {
        answer--;
        break;
      }
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 32660
#include<cstdio>
#include<cstdlib>
const int MAXN=100005;

int l[MAXN],r[MAXN];
int A[MAXN];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",A+i);
	for(int i=1;i<=n;i++)
		l[i]=l[i-1]+abs(A[i]-A[i-1]);
	for(int i=n;i>0;i--)
		r[i]=r[i+1]+abs(A[i]-A[i+1]);
	for(int i=1;i<=n;i++)
		printf("%d\n",l[i-1]+abs(A[i+1]-A[i-1])+r[i+1]);
	return 0;
}


Measured memory_bytes: 2304
#include<cstdio>
#include<algorithm>
char buf[1000010];
int main() {
  scanf("%s", buf);
  int a0 = 0, a1 = 1, b0 = 0, b1 = -1;
  int c0 = a0-b0, c1 = a0-b1, c2 = a1-b0, c3 = a1-b1;
  for(char *p = buf; *p; p++) {
    if(*p=='0')      { --a0; --a1; --b0; --b1; }
    else if(*p=='1') { ++a0; ++a1; ++b0; ++b1; }
    else             { --a0; --a1; ++b0; ++b1; }
    if(a0 < 0) a0 += 2;
    if(a1 < 0) a1 += 2;
    if(b0 > 0) b0 -= 2;
    if(b1 > 0) b1 -= 2;
    c0 = std::max(c0, a0-b0);
    c1 = std::max(c1, a0-b1);
    c2 = std::max(c2, a1-b0);
    c3 = std::max(c3, a1-b1);
  }
  printf("%d\n", std::min(std::min(c0, c1), std::min(c2, c3)));
  return 0;
}

Measured memory_bytes: 2712
import numpy as np

W, H, N = map(int, input().split())


BW = np.zeros([H,W])

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        BW[:, :x] = 1
    elif a == 2:
        BW[:, x:] = 1
    elif a == 3:
        BW[H-y:, :] = 1
    elif a == 4:
        BW[:H-y, :] = 1
print(np.count_nonzero(BW-1))

Measured memory_bytes: 12508
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int x[3], i;
	rep(i, 3) cin >> x[i];
	sort(x, x + 3, greater<int>());
	cout << x[0] * 10 + x[1] + x[2] << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"


func main() {
	var n, k, ans int
	fmt.Scan(&n, &k)
	max := func (x, y int) int {
		if x < y {
			return y
		} else {
			return x
		}
	}
	for b := 1; b <= n; b++ {
		p := n / b
		r := n % b
		ans += max(0, b-k)*p + max(0, r-k+1)
	}
	if k == 0 {
		ans -= n
	}
	fmt.Println(ans)
}
//func main() {
//	var n, k, ans int
//	fmt.Scan(&n, &k)
//	for i := 1; i <= n; i++ {
//		for j := 1; j <= n; j++ {
//			if i % j >= k {
//				ans++
//			}
//		}
//	}
//
//	fmt.Println(ans)
//}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2]) cout<<"Yes";
    else if(s[1]==s[2] && s[2]==s[3]) cout<<"Yes";
    else cout<<"No";
}


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

using namespace std;

int main() {
    long long int N, M;
    cin >> N >> M;
    
    if(N==1 || M==1) {
        if(N==M) {
            cout << 1 << endl;
        } else {
            cout << max(N, M)-2 << endl;
        }
    } else {
        cout << (N-2)*(M-2) << endl;
    }


    return 0;
    
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    char c; cin >> c;
    if (c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    Arrays.sort(str);
    System.out.println(str[0].equals("5") && str[1].equals("5") && str[2].equals("7")?"YES":"NO");
  }
}

Measured memory_bytes: 32652
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
const ll inf=1LL<<61;
int main(){
  ll n;cin>>n;
  ll ans=0;
  ll res=0;
  ans=(n+999)/1000;
  res=ans*1000-n;
  cout << res << endl;

}

Measured memory_bytes: 3636
// エラトステネスの篩, フェルマーの小定理
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	m = 1000000007
)

func mpow(x int, n int) int {
	result := 1
	for n != 0 {
		if n&1 == 1 {
			result *= x
			result %= m
		}
		x *= x
		x %= m
		n >>= 1
	}
	return result
}

func main() {
	maxA := 1000000

	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	sieve := make([]int, maxA+1)
	sieve[0] = -1
	sieve[1] = -1
	for i := 2; i <= maxA; i++ {
		if sieve[i] != 0 {
			continue
		}
		sieve[i] = i
		for j := i * i; j <= maxA; j += i {
			if sieve[j] == 0 {
				sieve[j] = i
			}
		}
	}

	lcmFactors := map[int]int{}
	for i := 0; i < N; i++ {
		t := map[int]int{}
		a := A[i]
		for a != 1 {
			t[sieve[a]]++
			a /= sieve[a]
		}
		for k, v := range t {
			if lcmFactors[k] < v {
				lcmFactors[k] = v
			}
		}
	}

	lcm := 1
	for k, v := range lcmFactors {
		for i := 0; i < v; i++ {
			lcm *= k
			lcm %= m
		}
	}

	result := 0
	for i := 0; i < N; i++ {
		result += lcm * mpow(A[i], m-2)
		result %= m
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


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

int main() {
	string S;
	cin >> S;

	if (S[5] == '1') {
		cout << "TBD" << endl;
	}
	else if (S[6] < '5') {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
 }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int n,h,w;cin>>n>>h>>w;
    int cnt=0;
    rep(i,n){
        int a,b;cin>>a>>b;
        
        if(a>=h && b>=w)cnt++;
    }
    cout<<cnt<<endl;
    
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  ll N;
  ll A;
   ll B;
   ll C;
   ll D;
   ll E;
  cin >>N>>A>>B>>C>>D>>E;
  ll x=min(A,B);
  ll y=min(min(C,D),E);
  ll z=min(x,y);
  
  long double d=(double)N/(double)z;
  ll e=ceil(d);
  ll f=e+4;
  cout<<f<<endl;
}
  

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

using namespace std;

#define ll long long
#define P pair<int, int>
#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 GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { 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...);
}

int main() {
  GI(N);
  vector<vector<int>> G(N);
  int maxdeg = 0, maxi;
  FOR(i, N - 1) {
    GI2(a, b);
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  GVI(c, N);
  sort(ALL(c), greater<int>());
  FOR(i, N) {
    if (G[i].size() > maxdeg) {
      maxdeg = G[i].size();
      maxi = i;
    }
  }
  priority_queue<P, vector<P>, greater<P>> q;
  q.push(P(maxi, maxdeg));
  vector<bool> visited(N);
  int next = 0;
  vector<int> ans(N);
  while (!q.empty()) {
    int i = q.top().first, deg = q.top().second;
    q.pop();
    visited[i] = 1;
    ans[i] = c[next++];
    for (int v : G[i]) {
      if (!visited[v]) {
        q.push(P(v, G[v].size()));
      }
    }
  }
  ll sum = 0;
  FOR(i, N) {
    for (int v : G[i]) {
      if (i < v)
        sum += min(ans[i], ans[v]);
    }
  }
  print(sum);
  FOR(i, N - 1) cout << ans[i] << " ";
  cout << ans[N - 1] << endl;
  return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

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

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto it = begin(v); it != end(v); ++it) {
    if (it != begin(v)) os << " ";
    os << *it;
  }
  return os;
}

const string ln = "\n";
template <class T>
ostream &operator,(ostream &os, const T &v) { return os << " " << v; }
ostream &operator,(ostream &os, const string &s) {
  return (s == ln ? os << endl : os << " " << s);
}

// =============================================================================

int solve() {
  int a, b;
  cin >> a >> b;
  if (a > 0) return 1;
  if (b < 0) {
    if ((b - a) % 2) return 1;
    return -1;
  }
  return 0;
}

int main() {
  cout << setprecision(12) << fixed << boolalpha;
  const string res[3] = {"Negative", "Zero", "Positive"};
  cout << res[solve() + 1] << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

int main() {
    int n;
    cin >> n;
    int a, b, c;
    if(n == 2) {
        cin >> a >> b;
        c = 0;
    }else cin >> a >> b >> c;
    int g = gcd(a, gcd(b, c));

    int root = 1;
    while((root + 1) * (root + 1) <= g) root++;
    deque<int> ans;
    if(root * root == g) {
        ans.push_back(root);
        root--;
    }
    for(int i = root; i >= 1; i--) {
        if(g % i == 0) {
            ans.push_front(i);
            ans.push_back(g / i);
        }
    }

    while(!ans.empty()) {
        cout << ans.front() << endl;
        ans.pop_front();
    }
}



Measured memory_bytes: 3108
#include<iostream>
//#include<bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define  si(a)       scanf("%d",&a);
#define  sl(a)       scanf("%lld",&a);
#define  sii(a,b)    scanf("%d%d",&a,&b);
#define  sll(a,b)    scanf("%lld%lld",&a,&b);
#define  queues      priority_queue
#define mod 1000000007
#define mem(a)  memset(a,0,sizeof(a));
typedef long long ll;
const int INF=0x3f3f3f3f;
//queues<int,vector<int >,greater<int > >q;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
ll ks(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
  ll n;
  cin>>n;
  ll s[13];
  ll ss[13];
  for(ll i=1;i<=n;i++)
    cin>>s[i];
  ss[1]=s[1]*s[2]/gcd(s[1],s[2]);
  for(ll i=3;i<=n;i++)
    ss[i-1]=ss[i-2]*s[i]/(gcd(ss[i-2],s[i]));
    //for(int i=1;i<=n-1;i++)
  cout<<ss[n-1]<<endl;
}


/******************************************
**        **             ********       **
**       ** **           **             **
**      **   **          **             **
**     **     **         **             **
**    ***********        **             **
**   **         **       ********       **
******************************************/



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
const long long M=998244353;
const long long iv2=499122177;
int n,t,a,b,v,w;
int main()
{
	scanf("%d %d",&a,&v);
	scanf("%d %d",&b,&w);
	scanf("%d",&t);
	puts((1ll*t*(v-w)>=abs(a-b)||a==b)?"YES":"NO");
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = (int) s.size();
	stack<int> st;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(st.size() && st.top() != s[i]) {
			st.pop();
			ans++;
		} else {
			st.push(s[i]);
		}
	}
	cout << ans * 2 << endl;
}

Measured memory_bytes: 3880
N,Q = map(int,input().split())
S = input()
LR = [tuple(map(int,input().split())) for i in range(Q)]

cums = [0]
for i in range(N-1):
    cums.append(cums[-1] + (S[i:i+2]=='AC'))

ans = []
for l,r in LR:
    l,r = l-1,r-1
    ans.append(cums[r] - cums[l])
print(*ans,sep='\n')

Measured memory_bytes: 26772
#include"bits/stdc++.h"
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size())
		cout<<"GREATER";
	else if(a.size()<b.size())
		cout<<"LESS";
	else{
	if(a>b)
		cout<<"GREATER";
	else if(a<b)
		cout<<"LESS";
	else
		cout<<"EQUAL";
}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,m,n;
	scanf("%d %d",&m,&n);
	while(m!=0 && n!=0) {
		for(i=1;i<=m;i++) {
			for(j=1;j<=n;j++) {
				if((i+j)%2==0) {
						printf("#");
					}
				else {
						printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	scanf("%d %d",&m,&n);
	}
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long long h, w;
  cin >> h >> w;
  
  long long a, b, c, ans = 1e15;
  
  for(int i = 1; i < h; i++){
    a = i * w;
    b = (w / 2) * (h - i);
    c = h * w - a - b;
    ans = min(ans, max({a, b, c}) - min({a, b, c}));
    
    b = ((h - i) / 2) * w;
    c = h * w - a - b;
    ans = min(ans, max({a, b, c}) - min({a, b, c}));
  }
  
  for(int i = 1; i < w; i++){
    a = i * h;
    b = (h / 2) * (w - i);
    c = h * w - a - b;
    ans = min(ans, max({a, b, c}) - min({a, b, c}));
    
    b = ((w - i) / 2) * h;
    c = h * w - a - b;
    ans = min(ans, max({a, b, c}) - min({a, b, c}));
  }
  
  cout << ans << "\n";
}

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

int main() {
	string abc = "ABC";
	string arc = "ARC";
	string input;
	cin >> input;
	if (input == abc) {
		cout << arc << endl;
	}
	else {
		cout << abc << endl;
	}

	return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    if(s.size()<5){
        cout << "NO" << endl;
        return 0;
    }

    string ans="NO";
    int checked;
    for(checked=0;checked<=s.size();){
        if(s.size()-checked<5){
            ans="NO";
            break;
        }
        if(s.substr(checked,5)=="dream"){
            checked+=5;
            if(checked==s.size()){
                ans="YES";
                break;
            }
            if(s.substr(checked,2)=="er"){
                if(checked+2==s.size()){
                    ans="YES";
                    break;
                }else{
                    if(s.at(checked+2)=='e' || s.at(checked+2)=='d'){
                        checked+=2;
                        continue;
                    }else if(s.at(checked+2)=='a'){
                        continue;
                    }else{
                        ans="NO";
                        break;
                    }
                }
            }
        }else if(s.substr(checked,5)=="erase"){
            checked+=5;
            if(checked==s.size()){
                ans="YES";
                break;
            }
            if(s.substr(checked,1)=="r"){
                if(checked+1==s.size()){
                    ans="YES";
                    break;
                }else{
                    if(s.at(checked+1)=='e' || s.at(checked+1)=='d'){
                        checked+=1;
                        continue;
                    }else if(s.at(checked+1)=='a'){
                        continue;
                    }else{
                        ans="NO";
                        break;
                    }
                }   
            }
        }else{
            ans="NO";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3728
import sys
def input():
	return sys.stdin.readline()[:-1]

def Z_algorithm(s):
	l = len(s)
	res = [-1 for _ in range(l)]
	res[0] = l
	i, j = 1, 0
	while i < l:
		while i+j < l and s[j] == s[i+j]:
			j += 1
		res[i] = j

		if j == 0:
			i += 1
			continue
		else:
			k = 1
			while i+k < l and k + res[k] < j:
				res[i+k] = res[k]
				k += 1

			i += k
			j -= k

	return res

s = input()
s_concat = s
t = input()
ns, nt = len(s), len(t)

if ns == 1:
	if {s} == set(list(t)):
		print(-1)
	else:
		print(0)
	sys.exit()

while len(s_concat) < ns + nt - 1:
	s_concat += s
ts_concat = t + " " + s_concat
z = Z_algorithm(ts_concat)

adj = [-1 for _ in range(ns)]

for i in range(1, len(z)):
	if i-nt-1 >= ns:
		break
	if z[i] == nt:
		j = i-nt-1
		if j == (j+nt)%ns:
			print(-1)
			sys.exit()
		adj[j] = (j+nt)%ns

visited = [False for _ in range(ns)]
path_len = [0 for _ in range(ns)]

def dfs(x):
	cur = x
	res = 0
	while adj[cur] >= 0:
		visited[cur] = True
		if adj[cur] == x:
			print(-1)
			sys.exit()
		res += 1
		if path_len[adj[cur]] > 0:
			path_len[x] = path_len[adj[cur]] + res
			return path_len[adj[cur]] + res
		cur = adj[cur]
	path_len[x] = res
	return res

ans = 0
for i in range(ns):
	if not visited[i]:
		d = dfs(i)
		ans = max(ans, d)

if ans == ns:
	print(-1)
else:
	print(ans)

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	string s;

	cin >> s;

	REP(i, s.size()) {
		if (s[i] == ',') {
			cout << " ";
		}
		else {
			cout << s[i];
		}
	}

	cout << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s; std::cin >> s;
    int ans = 0;
    srep(i, 1, s.size()) {
        bool ok = true;
        int slen = s.size() - i;
        if (slen & 1) continue;
        string s1 = s.substr(0, slen/2);
        string s2 = s.substr(slen/2, slen/2);
        if (s1 == s2) chmax(ans, slen);
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
 
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    rep(i,m) cin >> l[i] >> r[i];
    int mx = 1;
    int mn = 1e5;
    rep(i,m){
        mn = min(r[i],mn);
        mx = max(l[i],mx);
    }
    int ans = max(mn - mx + 1, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=4e5+7;

ll a[N],sum[N];
int n,k;

il ll solve(int l,int r){
	if(l==r) return 0;
	int mid=l+r>>1;
	ll ans=solve(l,mid)+solve(mid+1,r);
	int i=l-1,j;
	for(j=mid+1;j<=r;++j){
		while(i+1<=mid&&sum[i+1]<=sum[j]) ++i;
		ans+=i-l+1;
	}
	sort(sum+l,sum+r+1);
	return ans;
}

int main(){
	scanf("%d%d",&n,&k);
	rep(i,1,n) scanf("%lld",a+i),a[i]-=k;
	rep(i,1,n) sum[i+1]=sum[i]+a[i];
	printf("%lld\n",solve(1,n+1));
	return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<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); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 998244353;

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

    ll n;
    cin >> n;
    vector<ll> h(n);
    REP(i, n) cin >> h[i];

    const ll lim = 400;
    vector<vector<double>> dp(200, vector<double>(lim, 1e10));
    dp[0][1] = 0;
    FOR(i, 1, n+1) FOR(j, 1, lim) {
        FOR(k, 1, lim) {
            double ad = abs(j - h[i-1]), be = abs(k - h[i-1]);
            bool jupper = j > h[i-1], kupper = k > h[i-1];
            double area = 0;
            if(jupper ^ kupper) {
                double gp = ad / (ad + be), gc = be / (ad + be);
                area = ad * gp / 2.0 + be * gc / 2.0;
            } else {
                area = (ad + be) / 2.0;
            }
            chmin(dp[i][k], dp[i-1][j] + area);
        }
    }

    double ret = 1e10;
    FOR(i, 1, lim) chmin(ret, dp[n][i]);
    cout << fixed << setprecision(9) << ret << endl;

    return 0;
}



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

int main() {

  int n;
  cin >> n;

  
  int x[6];
  int i= n;
  int ans[2]={};
  while(1){
    int a = i,c=0;
    while(a !=0) {
      x[c] = a%10;
      a/=10;
      c++;
    }
    
    int flg = 0;
    for(int j=0;j<c;j++){
      if(x[j] != x[c-1-j]) break;
      if(c == c-1-j || j == c-1) flg = 1;
    }
    if(flg == 1) {
      ans[0] = i;
      break;
    }
    i++;
  }
  
  i = n;

  while(1){
    int a = i,c=0;
    while(a !=0) {
      x[c] = a%10;
      a/=10;
      c++;
    }
    
    int flg = 0;
    for(int j=0;j<c;j++){
      if(x[j] != x[c-1-j]) break;
      if(c == c-1-j || j == c -1) flg = 1;
    }
    if(flg == 1) {
      ans[1] = i;
      break;
    }
    i--;
  }
  
  if(ans[0]-n >= n-ans[1]) cout << ans[1] <<endl;
  else cout << ans[0] <<endl;

  return 0;
}

Measured memory_bytes: 1164
import itertools


def get_num_1group(input_list):
    num_group = 0
    for key, elems in itertools.groupby(input_list):
        if key == 1:
            num_group += 1
    return num_group


N = int(input())
H = list(map(int, input().split()))
maxH = max(H)
hist = [[0 for _ in range(N)] for _ in range(maxH)]
for idx, h in enumerate(H):
    for num in range(h):
        hist[num][idx] = 1

print(sum([get_num_1group(hist[num]) for num in range(maxH)]))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
#include <queue>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007

/*
int median(int a, int b, int c){
	vector<int> v{ a, b, c };
	sort(v.begin(), v.end());
	return v[1];
}*/


signed main(){

	int N, A, B;
	cin >> N >> A >> B;
	int X[123456];
	for (int i = 0; i < N; i++)
		cin >> X[i];

	int ans = 0;
	for (int i = 0; i < N-1; i++){
		ans += min(B, (X[i + 1] - X[i])*A);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
/*************************************************************************
    > File Name: aoj0118.cpp
    > Author:    WArobot 
    > Blog:      http://www.cnblogs.com/WArobot/ 
    > Created Time: 2017??´06???21??\ ????????? 19??¶09???51?§?
 ************************************************************************/

#include<bits/stdc++.h>
using namespace std;

const int MAX_N = 110;

char M[MAX_N][MAX_N];
int  vis[MAX_N][MAX_N];
int  dx[4] = { 0 , 0 , 1 , -1 } , dy[4] = { -1 , 1 , 0 , 0 };
int  n , m , cnt;

void DFS(int x,int y,char c){
	for(int i = 0 ; i < 4 ; i++){
		int tx = dx[i] + x , ty = dy[i] + y;
		if( tx < 0 || tx >= n || ty < 0 || ty >=m )	continue;
		if( vis[tx][ty] == 0 && M[tx][ty] == c ){
			vis[tx][ty] = cnt;
			DFS(tx,ty,M[tx][ty]);
		}
	}
	return;
}
int main(){
	while(~scanf("%d%d",&n,&m)){
		
		if( n == 0 && m == 0 )	break;
		memset(vis,0,sizeof(vis));
		memset(M,0,sizeof(M));
		cnt = 0;

		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < m ; j++)
				cin>>M[i][j];
		}
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < m ; j++){
				if( vis[i][j] == 0 ){
					vis[i][j] = ++cnt;
					DFS(i,j,M[i][j]);
				}
			}
		}
		/*for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < m ; j++)	printf("%2d ",vis[i][j]);
			puts("");
		}*/
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int res = 0;
  	int input , boundry ,temp;
  	cin >> input;
  	boundry  = input - 1;
  	for(int i = 1; i <= boundry; i++)
    {
      temp =  boundry / i;
      res += temp;
    }
  cout<<res;
  	
}

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

int H1, M1, H2, M2, K;

int main(void) {
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int ans = (H2 - H1) * 60 + M2 - M1 - K;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3676