akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

struct st{
	int l, r;
} a[N];

int n, mx, fl[N], fr[N], bl[N], br[N];

bool cmp(st p, st q) {
	if (p.r != q.r) return p.r < q.r;
	else return p.l < q.l;
}

int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d %d", &a[i].l, &a[i].r);
	}
	sort(a, a + n, cmp);
	fl[0] = a[0].l; fr[0] = a[0].r;
	for (i = 1; i < n; i++) {
		fl[i] = max(fl[i - 1], a[i].l);
		fr[i] = min(fr[i - 1], a[i].r);
	}
	bl[n - 1] = a[n - 1].l; br[n - 1] = a[n - 1].r;
	for (i = n - 2; i >= 0; i--) {
		bl[i] = max(bl[i + 1], a[i].l);
		br[i] = min(br[i + 1], a[i].r);
	}
	for (i = 0; i < n; i++) {
		mx = max(mx, a[i].r - a[i].l + 1 + max(0, fr[n - 1] - fl[n - 1] + 1));
	}
	for (i = 0; i < n - 1; i++) {
		mx = max(mx, max(0, fr[i] - fl[i] + 1) + max(0, br[i + 1] - bl[i + 1] + 1));
	}
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 2560
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list,zip(*read_all))

#################

def scc(N, G, RG):
    used = [False]*N
    group = [None]*N
    order = []
    def dfs(S):
        i_order = []
        temp_order = []
        level = 0
        while S:
            v1 = S.pop()
            if used[v1[0]]:
                continue
            if v1[1]<level:
                for _ in range(len(temp_order)-v1[1]):
                    x = temp_order.pop()
                    i_order.append(x)
                level = v1[1]
            level += 1
            if not used[v1[0]]:
                for v1_to in G[v1[0]]:
                    if not used[v1_to]:
                        S.append((v1_to,level))
                temp_order.append(v1[0])
                used[v1[0]] = True
        for t in reversed(temp_order):
            i_order.append(t)
        return i_order
    for i in range(N):
        if not used[i]:
            i_order = dfs([(i,0)])
            order += i_order
    def rdfs(S,col):
        used[S[0]] = True
        while S:
            v1 = S.pop()
            for v1_to in RG[v1]:
                if not used[v1_to]:
                    used[v1_to] = True
                    S.append(v1_to)
            group[v1] = col
    used = [False]*N
    label = 0
    for s in reversed(order):
        if not used[s]:
            rdfs([s], label)
            label += 1
    return label, group

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n)]
    for i in range(len(s)):
        pt[s[i]-1].append(t[i]-1)
        if directed==False:
            pt[t[i]-1].append(s[i]-1)
    return pt

N,M = II()
if M>0:
    L,R,D = Line(M,3)
else:
    print('Yes')
    exit()

pt = edges_to_pt(L,R,N)
label,group = scc(N,pt,pt)

x = []
used = [False]*label
for i in range(N):
    if not used[group[i]]:
        x.append(i)
        used[group[i]] = True

pt_l = [[] for _ in range(N)]
for i in range(M):
    pt_l[L[i]-1].append((R[i]-1,D[i]))
    pt_l[R[i]-1].append((L[i]-1,-D[i]))

check_visited = [False]*N
l = [None]*N 
for v in x:
    check_visited[v] = True
    l[v] = 0
    S = [v]
    while S:
        v1 = S.pop()
        for i in pt_l[v1]:
            if check_visited[i[0]] == False:
                check_visited[i[0]] = True
                l[i[0]] = l[v1] + i[1]
                S.append(i[0])
            else:
                if l[i[0]] == l[v1] + i[1]:
                    continue
                else:
                    print('No')
                    exit()

print('Yes')

Measured memory_bytes: 135460
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();

		// 出力
		System.out.println(a*b);
	}

}

Measured memory_bytes: 35840
#include <stdio.h>

int main(){
    int N,M;
    scanf("%d %d",&N,&M);
    int value[N];
    int weight[N];
    for(int i=0;i<N;i++){
        scanf("%d %d",&value[i],&weight[i]);
    }
    int dp[M+1];
    dp[0]=0;
    int max=0;
    for(int i=1;i<=M;i++){
        for(int j=0;j<N;j++){
            if(i>=weight[j]){
                if(value[j]+dp[i-weight[j]]>max){
                    max=value[j]+dp[i-weight[j]];
                }
            }
        }
        dp[i]=max;
    }

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

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double real;
typedef pair<int, int> duo;

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
static inline ll mod_inv(ll a, ll p){ return pow_mod(a,p-2,p); }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
static const int Mod = 1000000000;

int main()
{
  int m;
  while (m = in()){
    int dp[2001] = {1};
    int next[2001] = {};
    vector<duo> cards;
    for (int i = 0; i < m; i++){
      int a, b;
      a = in();
      b = in();
      cards.push_back(duo(a, b));
    }
    for (int i = 0; i < cards.size(); i++){
      memcpy(next, dp, sizeof(next));
      for (int j = 1; j <= cards[i].second; j++){
        for (int k = 1000; k >= 0; k--){
          next[k + j * cards[i].first] += dp[k];
        }
      }
      memcpy(dp, next, sizeof(dp));
    }

    int g = in();
    for (int i = 0; i < g; i++){
      printf("%d\n", dp[in()]);
    }
  }

  return (0);
}

// priority_queue queue deque first second front top push pop map set stringstream max_element min_element insert count find

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int m, d; cin >> m >> d;
  int ans = 0;
  for(int M = 1; M <= m; ++M) {
    for(int D = 1; D <= d; ++D) {
      if(D/10 >= 2 && D%10 >= 2 && (D/10)*(D%10) == M) ++ans;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

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

	string pattern = "2019/04/30";
	
	for (int i = 0; i < s.length() - 1; i++)
	{
		if (s[i] > pattern[i])
		{
			cout << "TBD" << endl;
			return 0;
		}
	}

	cout << "Heisei" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    if (a >= 0 && a <= 100 &&
        b >= 0 && b <= 100 &&
        c >= 0 && c <= 100) {
        if (a < b && b < c) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}

Measured memory_bytes: 580
var
    s:string;
    i,a,b,c:longint;
begin
readln(s);
for i:= 1 to 3 do begin
    if s[i]='a' then inc(a);
    if s[i]='b' then inc(b);
    if s[i]='c' then inc(c);
end;
if (a=1) and (b=1) and (c=1) then writeln('Yes')
else writeln('No');
end.

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const int MAXN=3e5+1e1;

int a[MAXN];
bool vis[MAXN];

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	int n,m,ans=0;

	scanf("%d%d",&n,&m);

	for(int i=1;i<=n;i++) a[i]=read<int>();

	for(int i=1;i<=m;i++)
	{
		int u=read<int>();
		int v=read<int>();
		if(a[u]<a[v]) vis[u]=true;
		if(a[u]>a[v]) vis[v]=true;
		if(a[u]==a[v]) vis[u]=vis[v]=true;
	}

	for(int i=1;i<=n;i++) if(!vis[i]) ++ans;

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

	return 0;

}

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

int main(){
  string a,b;
  cin >> a >> b;
  for(int i=0;i<3;++i){
    if(a[i]!=b[2-i]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
import math
X = int(input())
b = math.floor((X / 11))*2
if((X % 11) > 0 and (X % 11) < 7):
    print(b + 1)
elif((X % 11) > 0 and X % 11 < 11):
    print(b + 2)
else:
    print(b)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int K, S;
int main()
{
    cin >> K >> S;
    int cnt= 0 ;
    for(int i=0; i<=K; ++i)
        for(int j=0; j<=K; ++j)
        {
            int k = S-i-j;
            if(0<=k && k<=K) ++cnt;
        }
    cout << cnt << endl;
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,i,j,k;
	ll temp;
	cin>>n;
	int a[n];
	REP(i,0,n-1) cin>>a[i];
	ll dp[n];
	memset(dp,0,sizeof(dp));
	dp[0]=1000;
	REP(i,1,n-1){
		REP(j,0,i-1){
			dp[i]=max(dp[i],dp[j]%a[j]+dp[j]/a[j]*a[i]);
		}
		dp[i]=max(dp[i],dp[i-1]);
	}
	// int ans=0;
	// REP(i,0,1000)
	// 	if(dp[n][i][0]) ans=i;
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N;
	cin >> N;
	vl A(N), Asum(N + 1, 0);
	rep(i, N) {
		cin >> A[i];
		Asum[i + 1] = Asum[i] + A[i];
		Asum[i + 1] %= mod;
	}
	ll ans = 0;
	rep(i, N) {
		ll anstmp = Asum[i] * A[i];
		ans += anstmp;
		ans %= mod;
	}


	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6424
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAX_N = 100;
int N, K;
int plan[MAX_N + 1];
int memo[MAX_N + 1][4][4];
int solve(int n, int b1, int b2) {
	if (n == N + 1) return 1;
	if (memo[n][b1][b2] != -1) return memo[n][b1][b2];
	if (plan[n] != 0) {
		if (b1 == b2 && b1 == plan[n])
			return 0;
		else
			return solve(n + 1, plan[n], b1) % 10000;
	}
	int t = 0;
	for (int i = 1; i <= 3; ++i) {
		if (b1 == b2 && b1 == i) continue;
		t += solve(n + 1, i, b1) % 10000;
	}
	return memo[n][b1][b2] = t % 10000;
}
int main() {
	scanf("%d %d", &N, &K);
	for (int i = 0; i < K; ++i) {
		int d, k;
		scanf("%d %d", &d, &k);
		plan[d] = k;
	}
	for (int i = 0; i <= N; ++i)
		for (int j = 0; j < 4; ++j)
			for (int k = 0; k < 4; ++k)
				memo[i][j][k] = -1;
	printf("%d\n", solve(1, 0, 0));
	return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a = n/1000;
    int b = (n%1000)/100;
    int c = (n%100)/10;
    int d = n%10;
    //cout << a << b << c << d << endl;

    if(a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    else if(a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    else if(a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int maxn = 1e5 + 100;
int n, k;
long long a[maxn], dp[maxn];
int main()
{
    cin>>n>>k;
    for(int i = 1; i <= n; i++) cin>>a[i];
    dp[1] = 0;
    for(int i = 2; i <= n; i++) {
        dp[i] = 1e18;
        for(int j = 1; j <= k && i-j >= 1; j++){
            dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  s[k-1] = s[k-1]-'A'+'a';
  cout << s << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  int count = 0;
  for(int i = 0; i < N - 1; i++) {
    if(data.at(i) != i + 1) {
      count++;
    }
  }
  if(count <= 2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {
	
	public static void main(String[] args) throws IOException {

		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));

//		ArrayList<Integer> ans = new ArrayList<Integer>();
		int[] type = new int[4];
		String[] bt = {"A","B","AB","O"};
		
		String[] msg = {"light fly","fly","bantam","feather","light","light welter",
						"welter","light middle","middle","light heavy"};
		double[] w = {48,51,54,57,60,64,69,75,81,91};
		
		while (true) {
			
			String s = br.readLine();
			if (s == null) break;
			
			StringTokenizer st = new StringTokenizer(s,",");
			st.nextToken();
			String t = st.nextToken();
			
			for (int i = 0; i < bt.length; i++) {
				if (t.equals(bt[i])) {
					type[i]++;
					continue;
				}
			}
			
		}
		
		for (int p : type) {
			System.out.println(p);
		}
		
//		for (String a : ans)
//			System.out.println(a);

	}

}

Measured memory_bytes: 9344
#include <iostream>
#include <algorithm>
//v7KÉª¯çêé
const int RANKC = 7,NA = 7;
double R_500[RANKC] = {35.5,37.5,40,43,50,55,70},
  R_1000[RANKC] = {71,77,83,89,105,116,148};

//tÍÔBmÍ0©1(»ê¼ê500,1000m)
int rcheck(double t,int m){
  double *rlist;
  (m)?rlist=R_1000:rlist=R_500;
  for(int i=0;i<RANKC;i++){
    if(t<*(rlist+i))return i;
  }
  return NA;
}

std::string res[] = {"AAA","AA","A","B","C","D","E","NA"};
int main(){
  double t_500,t_1000;
  while(std::cin>>t_500>>t_1000){
    if(std::cin.eof())break;
    //êÔá¢NðèÉüêéB
    int rank = std::max(rcheck(t_500,0),rcheck(t_1000,1));
    std::cout<<res[rank]<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
	int c1;
	int c5;
	int c10;
	int c50;
	int c100;
	int c500;
	int sum =0;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	
	sum =c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500;
	if(sum>=1000){
		printf("1\n");
	}
	else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 584
import sys
input = sys.stdin.readline
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 2* 10 ** 5+2  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def solve():
  n,k = (int(i) for i in input().split())
  mod = 10**9+7
  if n-k <= 1:
    #任意の部屋に移動可能
    comba = 1
    inva = 1
    for i in range(1,n+1):
      comba *= (n+i-1)
      inva *= i
      comba %= mod
      inva %= mod
    comba *= pow(inva,10**9+5,mod)
    comba %= mod
    print(comba)
  else:
    #n <= 2**10^5
    #k <= 2**10^5
    ans = 0
    
    
    
    for i in range(0,k+1):
      ans += cmb(n,i,mod)*cmb(n-1,i,mod)
      ans %= mod
    
    print(ans)
  
solve()

Measured memory_bytes: 81136
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      for(int k = j+1; k < n; k++){
        int Min = min({a[i], a[j], a[k]});
        int Max = max({a[i], a[j], a[k]});
        int Mid = (a[i] + a[j] + a[k]) - Min - Max;
        if(Min == Mid || Mid == Max) continue;
        if(Max < Min + Mid && Mid - Min < Max) ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int a,b;
  cin>>a>>b;

  cout<<max(a+b,max(a-b,a*b))<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
const int mod = 998244353;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
int f[4020][4020];
int n;
char s[100010];
inline int add(int a,int b){a+=b;if(a>=mod) a-=mod;return a;}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	int Sum1=0,Sum2=0;
	f[0][0]=1;
	for(rint i=0;i<2*n;++i)
	{	
		if(i+1<=n)
		{
			if(s[i+1]=='0') Sum1+=2;
			if(s[i+1]=='1') Sum1+=1,Sum2+=1;
			if(s[i+1]=='2') Sum2+=2;
		}
		for(rint j=0;j<=2*n;++j)
		{
			if(!f[i][j]) continue;
			if(Sum1-j>0)
			{
				f[i+1][j+1]=add(f[i+1][j+1],f[i][j]); 
			}
			if((Sum2-(i-j))>0)
			{
				f[i+1][j]=add(f[i+1][j],f[i][j]);
			}
		}
	}//int ans=0;
	//for(rint i=0;i<=n;++i) ans=add(ans,f[2*n][i]);
	cout<<f[2*n][Sum1];
	return 0;
}

Measured memory_bytes: 60672
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n;i>s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

ll x[50];
ll y[50];
map<pair<ll,ll>, ll> m;


int main() {
	ll n; cin >> n;
	rep(i, 0, n)cin >> x[i] >> y[i];
	ll maxV = 0;
	rep(i, 0, n) {
		rep(j, 0, n) {
			if (i != j) {
				maxV = max(maxV,++m[{x[i] - x[j],y[i] - y[j]}]);
			}
		}
	}
	cout << n- maxV << endl;

	//pair<ll,ll> pq;
	//ll maxV	 = 0;
	//for (map<pair<ll,ll>, ll>::iterator it = m.begin(); it != m.end(); it++) {
	//	maxV = max(maxV, it->second);
	//}
	//cout << n - maxV << endl;


	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
    int m,f,r;

    while(1){
    scanf("%d %d %d",&m,&f,&r);
    if(m==-1&&f==-1&&r==-1){break;}
    if(m==-1||f==-1){
        printf("F\n");
    }
       else if(m+f>=80){
            printf("A\n");
        }
          else if(m+f>=65&&m+f<80){
            printf("B\n");
           }
            else  if(m+f>=50&&m+f<65){
                printf("C\n");
              }
               else  if(m+f>=30&&m+f<50){
                    if(r>=50){printf("C\n");}  else printf("D\n");
                 }
                  else  if(m+f<30){
                        printf("F\n");
                    }
    }

return 0;}

Measured memory_bytes: 1796
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn usize() -> usize {
    read()
}

fn vec_usize(n: usize) -> Vec<usize> {
    let mut vec = Vec::new();
    for _ in 0..n {
        vec.push(usize())
    }
    vec
}

fn main() {
    let nm = vec_usize(2);
    let n = nm[0];
    let m = nm[1];

    let mut balls = vec![1usize; n];
    let mut reds: Vec<bool> = vec![false; n];
    reds[0] = true;
    for _ in 0..m {
        let xy = vec_usize(2);
        let x = xy[0] - 1;
        let y = xy[1] - 1;
        balls[x] = balls[x] - 1;
        balls[y] = balls[y] + 1;
        reds[y] = reds[y] || reds[x];
        if balls[x] == 0 {
            reds[x] = false;
        }
    }
    println!("{}",
             reds.iter().filter(|x| **x).count());
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    int n;
    Int sum = 0;
    string a,b,c;

    cin>>n;
    cin>>a>>b>>c;

    for(int i = 0;i < n;i++) {
        int ch = 0;
        if(a[i] == b[i])
            ch++;
        if(a[i] == c[i])
            ch++;
        if(b[i] == c[i])
            ch++;

        if(ch == 3)
            sum += 0;
        else if(ch == 1 || ch == 2)
            sum += 1;
        else
            sum += 2;
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
origin = []
modified = []
for i in range(n):
    tx, ty, th = map(int, input().split())
    origin.append([tx, ty, th])
    if th != 0:
        modified.append([tx, ty, th])
origin = np.array(origin).T
modified = np.array(modified).T
for cx in range(0,101):
    for cy in range(0,101):
        tmp = modified[2] + np.abs(modified[0] - cx) + np.abs(modified[1] - cy)
        if np.max(tmp) == np.min(tmp):
            height = np.max(tmp)
            # print("cx = ", cx, "cy = ", cy, "height =", height)
            # print(origin[0])
            # print(origin[1])
            # print(origin[2])
            # print(np.maximum(height - np.abs(origin[0] - cx) - np.abs(origin[1] - cy), np.zeros(origin[0].size)))
            if (origin[2] == np.maximum(height - np.abs(origin[0] - cx) - np.abs(origin[1] - cy), np.zeros(origin[0].size))).all():
                print(cx, cy, height)


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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < int(n); i++)

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int MOD = 1000000007;
ll height[200001], beauty[200001];
ll val[200001];
const int N = 500000;  // limit for array size
int n;  // array size
ll t[N];

void build() {  // build the tree
    for (int i = n - 1; i > 0; --i) t[i] = t[i << 1] + t[i << 1 | 1];
}

void modify(int p, ll value) {  // set value at position p
    for (t[p += (n + 1)] = value; p > 1; p >>= 1) t[p >> 1] = MAX(t[p], t[p ^ 1]);
}

ll query(int l, int r) {  // sum on interval [l, r)
    ll res = 0;
    for (l += (n + 1), r += (n + 1); l < r; l >>= 1, r >>= 1) {
        if (l & 1) res = max(res, t[l++]);
        if (r & 1) res = max(res, t[--r]);
    }
    return res;
}

int main() {
    IOS;
    cin >> n;
    rep(i, n) cin >> height[i];
    rep(i, n) cin >> beauty[i];
    ll ans = 0;
    rep(i, n) {
        ll maxi = query(0, height[i]);

        val[height[i]] = maxi + beauty[i];

        modify(height[i], val[height[i]]);

        ans = MAX(ans, val[height[i]]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int co[33333][288],t1[33333][260],t2[33333][260],n,m,edg[55][55];
inline int cost(int S,int T)
{return t1[T][S&255]+t2[T][S>>8];}
inline void cmin(int&a,int b) {(a>b)?(a=b):0;}
int f[33333][23];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,a,b,c;i<=m;++i)
		scanf("%d%d%d",&a,&b,&c),--a,--b,
		edg[a][b]+=c,edg[b][a]+=c;
	for(int i=0;i<n;++i)
		for(int j=0;j<(1<<n);++j)
		{
			int&s=co[j][i];
			for(int k=0;k<n;++k) if(j&(1<<k))
				s+=edg[i][k];
		}
	for(int i=0;i<(1<<n);++i)
		for(int j=0;j<(1<<8);++j)
		{
			int&s=t1[i][j];
			for(int r=0;r<8;++r) if(j&(1<<r)) s+=co[i][r];
		}
	for(int i=0;i<(1<<n);++i)
		for(int j=0;j<(1<<8);++j)
		{
			int&s=t2[i][j];
			for(int r=0;r<8;++r) if(j&(1<<r)) s+=co[i][r+8];
		}
	memset(f,127/3,sizeof f);
	f[1][0]=0;
	for(int g=1;g<(1<<n);++g)
	{
		for(int s=0;s<n;++s) if(g&(1<<s))
		{
			if(f[g][s]>5e8) continue;
			for(int r=0;r<n;++r) if((g&(1<<r))||!edg[r][s]);else
				cmin(f[g|(1<<r)][r],f[g][s]+cost(g^(1<<s),1<<r));
			int t=((1<<n)-1)^g;
			for(int p=t;p;p=(p-1)&t)
				cmin(f[g^p][s],f[g][s]+cost(g^(1<<s),p));
		}
	}
	printf("%d\n",f[(1<<n)-1][n-1]);
}


Measured memory_bytes: 107776
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <stdlib.h>
using namespace std;
typedef long long int lld;
typedef long double ld;
int arr[3333],ans;
int main(void){
	int n;
	scanf("%d",&n);
	for(int e=0;e<n;e++) scanf("%d",&arr[e]);
	sort(arr,arr+n);
	for(int e=0;e<n;e++){
		for(int p=e+1;p<n;p++){
			int a = arr[e];
			int b = arr[p];
			int wh1 = upper_bound(arr+p+1,arr+n,b-a)-arr;
			int wh2 = lower_bound(arr+p+1,arr+n,a+b)-arr;
			wh2--;
			ans += (wh2-wh1+1);
 		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
d = gets.chomp.split(" ").map(&:to_i)
mod = 998244353
dist = Array.new(n+1, 0)
ans = i = 1
d.each do |i|
    dist[i] += 1
end
if d[0] != 0 || 1 < dist[0]
    puts 0
    exit
end

d.max.times do |i|
    ans *= dist[i] ** dist[i+1]
    ans %= mod
end

puts ans

Measured memory_bytes: 9860
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  int x[100005];
  int a;
  REP(i,N){
    cin >> x[i];
    if(i == 0) a = abs(x[i] - X);
    else a = __gcd(a, abs(x[i] - X));
  }
  cout << a << endl;
  return 0;
}


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

int main()
{

    string s;
    cin >> s;


    int len = s.size();
    rep(i, len) {
        if (s.at(i) == '?') {
                 s.at(i) = 'D';
        }
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3748
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan =new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a<1){a=1;}
		if(b>100){b=100;}
		int menseki=a*b;
		int syuu=2*(a+b);
		System.out.println(menseki+" "+syuu);
	}
}

Measured memory_bytes: 26000
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	string s;
	cin >> s;
	string res = "No";
	if (s[2] == s[3] && s[4] == s[5]) res = "Yes";
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)

int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
int dxx[]={1,1,0,-1,-1,-1,0,1};
int dyy[]={0,-1,-1,-1,0,1,1,1};
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;


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

  int a,b;
  cin >>a>>b;
  if(a*b%2) cout <<"Yes\n";
  else cout <<"No\n";
  
  

  return 0;
}


Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
		long ans=(long)Math.pow(10,9);
		
  		long[] h=new long[n];
		for(int c=0;c<n;c++){
    		h[c]=sc.nextLong();
    	}
  		Arrays.sort(h);
  		
  		for(int b=0;b<n-k+1;b++){
        ans=Math.min(ans,h[b+k-1]-h[b]);
        }

    	System.out.println(ans);
    }
}

Measured memory_bytes: 59820
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int parseint(string s){
  stringstream ss(s);
  int r;
  ss >> r;
  return r;
}

int sumdiv2(vector<int> &a){
  int r=0;
  sort(a.begin(),a.end());
  for(int i=0;i<a.size()/2+1;i++){
    r+=a[i]/2+1;
  }
  return r;
}

int sum2(vector<int> &a){
  int r=0;
  sort(a.begin(),a.end());
  for(int i=0;i<a.size()/2+1;i++){
    r+=a[i];
  }
  return r;
}

int main(){
  int n;
  int stack;
  cin >> n;
  string s;

  vector<vector<int> > votes;
  while(n--){
    votes.clear();
    stack = 0;
    int max = 0;
    cin >> s;
    while(s[max]=='[')max++;
    votes.resize(max+3);
    for(int i=0;i<s.size();i++){
      if(s[i]=='[')stack++;
      else if(s[i]==']'){
        stack--;
        if(!votes[stack+2].empty()){
          if(stack+2==max){
            //cout << stack+2 << " " << sumdiv2(votes[stack+2]) << endl;
            votes[stack+1].push_back(sumdiv2(votes[stack+2]));
          }else{
            //cout << stack+2 << " " << sum2(votes[stack+2]) << endl;
            votes[stack+1].push_back(sum2(votes[stack+2]));
          }
          votes[stack+2].clear();
        }
      }else{
        //cout << stack << endl;
        int r = parseint(s.substr(i));
        //cout << r << endl;
        votes[stack].push_back(r);
        while(r/10){r/=10;i++;}
      }
    }
    cout << votes[1][0] << endl;
  }
}

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


int main()
{
  string line , ch , ch2;
  int num = 0 , j = 0;
  
  while(1)
    {
      cin >> line;

      if( line == "-" ) break;

      cin >> num;
      
      for( int i = 0; i < num; i++ )
	{  
	  cin >> j;
	  ch = line.substr( 0 , j );
	  ch2 = line.substr( j , line.size() );
	  line = ch2 + ch; 
	}
      cout << line << endl;
    }
  return 0;
}
  

Measured memory_bytes: 1216
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(sc.hasNextLine()) {
			String line = sc.nextLine();
			if(isPalindrome(line)) count++;
		}
		sc.close();
		System.out.println(count);
	}
	
	static boolean isPalindrome(String str) {
		for(int i = 0; i < str.length() / 2 + 1; i++) {
			if(str.codePointAt(i) != str.codePointAt(str.length() - i - 1)) return false;
		}
		return true;
	}
}

Measured memory_bytes: 26108
program test
implicit none
integer(8) :: n,m,a(10000),i,j,k,ans

read(*,*) n,m
read(*,*) (a(i),i=1,m)

ans = n
do i = 1,m
  ans = ans - a(i)
enddo

write(*,*) max(-1,ans)

end

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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main(){

    bool flag=true;

    ll ans=0,sum=0;
    int prebridge = -1;

    int n,m;
    cin >>n>>m;
    
    vector<pii> vs(m);

    for (int i = 0; i < m; i++){
        int a,b;
        cin >>a>>b;
        --b,--a;
        vs[i].first=b;
        vs[i].second=a;
    }
    
    sort(vs.begin(),vs.end());

    int a,b;
    for (int i = 0; i < m; i++){
        a = vs[i].second;
        b = vs[i].first;
        
        if(a >= prebridge){
            ++ans;
            prebridge = b;

            //cout << b << endl;
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

typedef long long ll;

const int LGA = 60;
const int Z = 1e9+7;

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

    int n;
    cin >> n;

    int c[LGA] = {0};
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        for (int j = 0; j < LGA; j++) {
            c[j] += a >> j & 1;
        }
    }

    int ans = 0;
    for (int i = 0, p = 1; i < LGA; i++, p = p * 2 % Z) {
        ans = (ans + 1ll * c[i] * (n - c[i]) % Z * p) % Z;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
while True:
    n = input().split()
    m = [int(i) for i in n]
    if m[0] == 0:
        break
    l = [int(input()) for k in range(m[0])]
    count = 0
    sumMoney = 0
    for count in range(m[0]):
        sumMoney += l[count]
    money = float(sumMoney * (100 - m[2]))
    try:
        pey = money / l[m[1] - 1]
        print(int(pey))
    except ZeroDivisionError :
        print('0')


Measured memory_bytes: 5624
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      
      	if(a + b >= c) {
        	System.out.println("Yes");  
        } else {
          	System.out.println("No");
        }
	}
}

Measured memory_bytes: 22996
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//228
	int n;
	cin>>n;
	vi arr(n+2,0);
	REP(i,1,n)cin>>arr[i];
	ll sum=0;
	REP(i,1,n+1){
		sum+=abs(arr[i]-arr[i-1]);
	}
	REP(i,1,n){
		cout<<sum-abs(arr[i]-arr[i+1])-abs(arr[i]-arr[i-1])+abs(arr[i-1]-arr[i+1])<<"\n";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3696
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

typedef vector<double> vd;
typedef vector<vd> vvd;

int N;
int res[4];
vector<vvd> dp;

void input_init(void) {
	cin >> N;
	for (int i = 0; i < 4; ++i)
		res[i] = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		++res[a];
	}
	dp.resize(res[1] + res[2] + res[3] + 1, vvd(res[2] + res[3] + 1, vd(res[3] + 1, -1.0)));
}

double rec(int i, int j, int k) {
	if (dp[i][j][k] >= 0) return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0) return 0.0;

	double ret = 0.0;
	if (i > 0) ret += rec(i - 1, j, k) * i;
	if (j > 0) ret += rec(i + 1, j - 1, k) * j;
	if (k > 0) ret += rec(i, j + 1, k - 1) * k;
	ret += N;
	ret *= 1.0 / (i + j + k);

	return dp[i][j][k] = ret;
}

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

	input_init();
	double ans = rec(res[1], res[2], res[3]);

	cout << fixed << setprecision(10) << ans << '\n';
	return 0;
}


Measured memory_bytes: 216960
H, W = map(int, input().split())
s = []
s.append("."*(W+2))
for _ in range(H):
    s.append("."+input()+".")
s.append("."*(W+2))


for i in range(1,H+1):
    for j in range(1,W+1):
        if s[i][j] == "#" and s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == ".":
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 3064
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int a=Integer.parseInt(sc.next());
String ans;
if(n%500<=a){ans="Yes";}else{ans="No";}
System.out.println(ans);
}}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 998244353;

int Z[120];

int main() {
	int X, N, P;
	cin >> X >> N;
	for (int i = 0;i < N;i++) {
		cin >> P;
		Z[P] = 1;
	}
	for (int i = 0;;i++) {
		if (Z[X - i] == 0) {
			cout << X - i << endl;
			return 0;
		}
		if (Z[X + i] == 0) {
			cout << X + i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3620
// Created by Tanuj Jain
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	double s;
	cin>>s;
	 // finding length 
    double length = s / 3.0; 
  
    s -= length; 
  
    // finding breadth 
    double breadth = s / 2.0; 
  
    // finding height 
    double height = s - breadth; 
  
    cout<<fixed<<setprecision(6)<<length * breadth * height; 
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int t[10][5], h;

int check() {
	int row, col, len, i;
	int score = 0;

	for (row = 0; row < h; row++) {
		for (col = 0; col <= 2; col++) {
			for (len = 1; col + len <= 4; len++) {
				if (t[row][col] != t[row][col + len]) break;
			}
			if (len <= 2) continue;
			score += t[row][col] * len;
			for (int i = 0; i < len; ++i) t[row][col + i] = 0;
		}
	}
	return score;
}

void down() {
	int col, row, min;
	for (col = 0; col < 5; ++col) {
		for (min = 1; min < h; ++min) {
			for (row = h - 1; row >= min; row--) {
				if (t[row][col] == 0) {
					t[row][col] = t[row - 1][col];
					t[row - 1][col] = 0;
				}
			}
		}
	}
}

int main() {
	int i, j;
	int score, cs;
	while (true) {
		cin >> h;
		if (h == 0) break;

		for (i = 0; i < h; ++i) {
			for (j = 0; j < 5; ++j) {
				cin >> t[i][j];
			}
		}
		score = 0;
		while (true) {
			cs = check();
			//cout << cs << endl;
			if (cs == 0) {
				cout << score << endl;
				break;
			}
			score += cs;
			down();
		}
	}
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  string S,T;
  cin >> S >> T;
  for(int i=0;i<N;i++)
  {
    cout << S.at(i) << T.at(i);
  }
  return 0;
}


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

int main(){
	
	int a[3],i;
	
	for(i=0;i<3;i++){
		
		scanf("%d",&a[i]) ;
	}
	sort(a,a+3) ;
	
	if(a[0]+a[1]==a[2]) {
		printf("Yes\n") ;
	}
	
	else {
		printf("No\n") ;
	}
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a<b){
	
	    printf("a < b\n");
	
	}else if(a>b){
	
	    printf("a > b\n");
	
	}else if("a==b\n"){
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580