akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

bool b[114];
string nows = "zzzzzzzzzzzzzzzzz";

signed main() {
	int n, cnt = 0;
	cin >> n;
	string s[114];
	int a[114];
	rep(i, n) {
		cin >> s[i] >> a[i];
		b[i] = true;
	}
	int nowa = 0, out = -1;
	while (1) {
		nows = "zzzzzzzzzzzzzz";
		rep(i, n) {
			//ut << nows << " " << s[i] << " " << b[i] << endl;
			if (nows > s[i] && b[i]) {
				nows = s[i];
				nowa = a[i];
				out = i;
			}
			if (nows == s[i] && b[i] && a[i] > nowa) {
				nowa = a[i];
				out = i;
			}
		}
		b[out] = false;
		cout << out + 1 << endl;
		cnt++;
		if (cnt == n) break;
	}

	return 0;
}


Measured memory_bytes: 256
a, b, k = [int(i) for i in input().split()]
if k >= b-a+1:
  for i in range(a, b+1):
    print(i)
else:
  c = [i for i in range(a, a+k)]
  d = [i for i in range(b-(k-1), b+1)]
  e = sorted(list(set(c) | set(d)))
  for i in e:
    print(i)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

string s[10];
string cur[5];
int done[10];
int ans;
set<string> ans2;

int dfs2(int t){
	if( t == 5 ){
		return 1;
	}
	for(int i = 0 ; i < 10 ; i++){
		if( !done[i] ){
			int f = true;
			for(int j = 0 ; j < 5 ; j++){
				if( cur[j][t] == s[i][j] ){ f = false; break; }
			}
			if( f ){
				done[i] = true;
				int r = dfs2(t+1);
				done[i] = false;
				if( r ) return 1;
			}
			
			f = true;
			for(int j = 0 ; j < 5 ; j++){
				if( cur[j][t] == s[i][4-j] ){ f = false; break; }
			}
			if( f ){
				done[i] = true;
				int r = dfs2(t+1);
				done[i] = false;
				if( r ) return 1;
			}
		}
	}
	return 0;
}

int dfs(int t){
	if( t >= 5 ){
		if(dfs2(0))ans2.insert(cur[0]+cur[1]+cur[2]+cur[3]+cur[4]);
		return 0;
	}
	for(int i = 0 ; i < 10 ; i++){
		if( !done[i] ){
			cur[t] = s[i];
			done[i] = true;
			dfs(t+1);
			done[i] = false;
	
			reverse(s[i].begin(),s[i].end());
			cur[t] = s[i];
			done[i] = true;
			dfs(t+1);
			done[i] = false;
			reverse(s[i].begin(),s[i].end());
		}
	}
}

int main(){
	while( cin >> s[0] , s[0] != "END" ){
		int cnt = count(s[0].begin(),s[0].end(),'1');
		for(int i = 1 ; i < 10 ; i++) cin >> s[i] , cnt += count(s[i].begin(),s[i].end(),'1');
		
		if( cnt != 25 ){
			cout << 0 << endl;
		}else{
			ans2.clear();
			ans = 0;
			dfs(0);
			cout << ans2.size()/8 << endl;
		}
	}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  char s;cin>>s;
  s++;
  cout<<s<<endl;
}

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

using namespace std;

void solve() {
    string s;
    cin >> s;
    for (char c = 'a'; c <='z'; ++c) {
        bool flag = true;
        for (char si: s) {
            if (c == si) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << c;
            return;
        }
    }
    cout << "None";

}

int main() {

	solve();
    return 0;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    int a[5];
    for(int i=0;i<5;++i){
        cin>>a[i];
    }
    int k=0;
    for(int i=0;i<5;++i){
        k++;
        if(a[i]==0){cout<<k<<endl;}
    }
    
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
ll a[100005] ;
int main()
{

   ll n ;
   cin >> n ;
   memset(a,0,sizeof n);
   ll  cnt = 0 ;
   for(int i = 0 ; i < n ; i++)
   {
      cin >> a[i] ;
   }
   sort(a,a+n);
   int cn1 = 0,cn2 = 0 ;
   for(int i = 0 ; i < n ; i++)
   {
       if(a[i] != a[i+1])
       {
           cn1++ ;
           cn2 = 0;
       }
       else
       {
           cn2++ ;
           if(cn2&1)
           {
               cn1-- ;
           }
           else
           {
               cn1++;
           }
       }
   }
   cout << cn1 << endl;
   return 0;
}


Measured memory_bytes: 1024
N = int(input())
if N%2==0:
    M = (N**2-2*N)//2
    ans = []
    for i in range(1,N+1):
        for j in range(1,N+1):
            if i != j and i+j != N+1 and i < j:
                ans.append(str(i)+" "+str(j))
    print(M)
    for i in ans:
        print(i)
else:
    M = (N**2-N-(N-1))//2
    ans = []
    for i in range(1,N+1):
        for j in range(1,N+1):
            if i != j and i+j != N and i < j:
                ans.append(str(i)+" "+str(j))
    print(M)
    for i in ans:
        print(i)

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a=0;
    ll n;
    cin>>n;
    ll b[n];
    for(int x=0;x<n;x++)
        cin>>b[x];
        for(int x=0;x<n;x++)
        {
            if(b[x]==a+1)
                ++a;
        }
        if(a>0)
        cout<<n-a<<endl;
        else
            cout<<-1<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
	int  a,b;
	cin >> a>>b  ;
	if(a==b){
	cout<<	"Draw" ;
			}else if(a<b){
				if(a==1)  {
				cout <<"Alice";;
				}else {
					cout <<"Bob";
				}
			}else if(b==1){
					cout <<"Bob";
				}else{
					cout <<"Alice";
					}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++)
		ans+=s[i]-'0',ans%=9;
	if(ans==0)
		cout<<"Yes"<<endl;
	else
	 	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    Vec<int> table(32768);
    Vec<int> sq;
    for (int i = 0; i * i < 32768; i++) {
        sq.push_back(i * i);
    }

    int sq_max = (int)sq.size();
    for (int i = 0; i < sq_max; i++) {
        for (int j = i; j < sq_max; j++) {
            for (int k = j; k < sq_max; k++) {
                for (int l = k; l < sq_max; l++) {
                    int total = sq[i] + sq[j] + sq[k] + sq[l];
                    if (total < 32768) {
                        table[total]++;
                    }
                }
            }
        }
    }

    int input;
    while (1) {
        cin >> input;
        if (input == 0) {
            break;
        }
        cout << table[input] << endl;
    }
    return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in(), y = in();
  y /= 1000;

  for (int i = 0; 10 * i <= y; ++i) {
    for (int j = 0; 5 * j <= y; ++j) {
      if (10 * i + 5 * j > y) continue;
      if (y - (10 * i + 5 * j) == n - i - j) {
        cout << i << " " << j << " " << n - i - j << endl;
        return 0;
      }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
    int N, A[100], key, i, j, k;
    cin >> N;
    for (i = 0; i < N; i++)
        cin >> A[i];
    for (i = 0; i < N; i++)
    {
        cout << A[i];
        if (i < N-1)
            cout << " ";
        else
            cout << endl;
    }
    for (j = 1; j < N; j++)
    {
        key = A[j];
        i = j-1;
        while (i >= 0 && A[i] > key)
        {
            A[i+1] = A[i];
            i--;
        }
        A[i+1] = key;
        for (k = 0; k < N; k++)
        {
            cout << A[k];
            if (k < N-1)
                cout << " ";
            else
                cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n)cin >> l[i];
	sort(ALL(l));
	ll 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++)
			{
				if (l[i] + l[j] > l[k])
				{
					ans++;
				}
			}
		}
	}
	co(ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

template<typename T, typename S>
istream& operator>> (istream& in, pair<S, T>& p) {
    in >> p.fs >> p.sn;
    return in;
}
template<typename T, typename S>
ostream& operator<< (ostream& out, pair<S, T>& p) {
    out << p.fs << ' ' << p.sn << ' ';
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& v) {
    for (T& x : v) in >> x;
    return in;
}
template<typename T>
ostream& operator<< (ostream& out, vector<T>& v) {
    for (T& x : v) out << x << ' ';
    return out;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

ll sum(ll n) {
    ll ans = 0;
    while (n) {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n;
    cin >> n;
    ll ans = sum(n);
    ll nines = 1;
    n /= 10;
    while (n) {
        setmax(ans, sum(n - 1) + nines * 9);
        n /= 10;
        ++nines;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, c;
  cin >> a >> b >> c;

  cout << 10 * max({a, b, c}) + a + b + c - max({a, b, c}) << endl;
}


Measured memory_bytes: 3584
h, w = gets.split.map(&:to_i)
fld = Array.new(h){ Array.new(w) }
arr = []
h.times do |i|
   str = gets.chomp
   w.times do |j|
    if str[j] == '.'
      fld[i][j] = 0
      arr << [0, [i, j]]
    else fld[i][j] = str[j].to_i
    end
  end
end
ret = 0
until arr.empty?
  ret, pos = arr.shift
  y, x = pos
  (-1..1).each do |i|
    (-1..1).each do |j|
      p = i+y; q = j+x
      next if i == 0 && j == 0 || p < 0 || p >= h || q < 0 || q >= w || fld[p][q] <= 0
      fld[p][q] -= 1
      arr << [ret+1, [p, q]] if fld[p][q] == 0
    end
  end
end
p ret

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 10, mod = 1e9 + 7;

int n;
int s[N];
int primes[N], cnt;
bool st[N];

void init(int n)
{
	for (int i = 2; i <= n; i ++ )
	{
		if (!st[i]) primes[cnt ++ ] = i;
		for (int j = 0; primes[j] <= n / i; j ++ )
		{
			st[primes[j] * i] = true;
			if (i % primes[j] == 0) break;
		}
	}
}

int main()
{
	init(N - 1);
	
	for (int i = 2; i < N; i ++ )
		if (i % 2 && !st[i] && !st[(i + 1) / 2])
			s[i] ++ ;
			
	for (int i = 1; i < N; i ++ ) s[i] += s[i - 1];
	
	cin >> n;
	while (n -- )
	{
		int l, r;
		cin >> l >> r;
		cout << s[r] - s[l - 1] << endl;
	}
	return 0;
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i=0; i<M; ++i) {
    cin >> B[i];
  }
  vector<vector<int>> A(N, vector<int>(M));
  for (int i=0; i<N; ++i) {
    for (int j=0; j<M; ++j) {
      cin >> A[i][j];
    }
  }
  
  int var=0, ans=0;
  for (int i=0; i<N; ++i) {
    var = 0;
    for (int j=0; j<M; ++j) {
      var += A[i][j] * B[j];
    }
    if (var + C > 0) {
      ++ans;
    }
  }
  
  cout << ans << endl;
  return 0;
}









Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

long dp[110][100010];
long N, W;
vector<pair<long, long>> vec;

long rec(long i, long j) {
  if (dp[i][j] != -1) return dp[i][j];
  if (i == N) return 0;
  long ret = 0;
  if (j < vec[i].first) ret = rec(i+1, j);
  else ret = max(rec(i+1, j), rec(i+1, j-vec[i].first) + vec[i].second);
  dp[i][j] = ret;
  return ret;
}

void solve() {
  rep (i, 110) rep (j, 100010) dp[i][j] = -1;
  cin >> N >> W;
  rep (i, N) {
    long w, v;
    cin >> w >> v;
    vec.push_back(make_pair(w, v));
  }
  cout << rec(0, W) << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 86272
//cod2017_qualB_b.cpp
//Sat Nov 10 21:07:59 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	unordered_map<int, int> hash;
	for (int i=0;i<n;i++){
		int temp;
		cin >> temp;
//		auto itr = hash.find(temp);
//		if (itr != hash.end()){
			hash[temp]++;
//		}else {
//			hash[temp] = 1;
//		}
	}

	int m;
	cin >> m;

	int flag = 0;
	for (int i=0;i<m;i++){
		int temp;
		cin >> temp;
		auto itr = hash.find(temp);
		if (itr != hash.end()){
			if (hash[temp]==0){
				flag = 1;
				break;
			}else {
				hash[temp]--;
			}
		}else {
			flag = 1;
			break;
		}
	}

	if (flag == 1){
		cout << "NO" << endl;
	}else {
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 8520
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	int a,b,c;
	cin >> a >> b >> c;
	if (!cin) return false;

	if (a + b + c >= 22) cout << "bust\n";
	else cout << "win\n";

	return true;
}

int main() {
	while (res()) {}
	return 0;
}


Measured memory_bytes: 764
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inp_list(): return list(map(int, sys.stdin.readline().split()))


def lcm(x, y): return (x * y) // gcd(x, y)


X = inp()

cnt_1000 = X // 500
X -= cnt_1000 * 500

cnt_5 = X // 5
print(1000 * cnt_1000 + 5 * cnt_5)


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

int main() {
  int N, A=0;
  cin >> N;
  vector<int> V(N);
  rep(i, N) cin >> V.at(i);
  for(int i=N-1; i>0; i--){
    if(V.at(i-1)-V.at(i)>=2){
      A=1;
      break;
    }
    else if(V.at(i-1)-V.at(i)==1) V.at(i-1)--;
  }
  if(A==1) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 640
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,j,n,k,a[262144],r=0;
    scanf("%d",&n);
    //for(i=1;i<=n;i++){scanf("%d",&a[i]);}
    printf("%d\n",48-n);
    return 0;
}

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

using namespace std;

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

	int n, m; cin >> n >> m;
	vector<int> imos(n + 10,0);
	for (int i = 0; i < m; i++) {
		int c, d; cin >> c >> d;
		if (c < d) {
			imos[c]++;
			imos[d]--;
		}
	}
	for (int i = 0; i < n; i++) {
		imos[i + 1] += imos[i];
	}
	int res = n + 1;
	for (int i = 0; i < n; i++) {
		if (imos[i]) res += 2;
	}
	cout << res << endl;
}

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

using namespace std;

int n, ans, cnt, color;

int main(){
	scanf( "%d", &n );
	for( int i = 1; i <= n; ++i ){
		int x; scanf( "%d", &x );
		if( x == color ) ++cnt;
		else{
			if( cnt > 1 ) ans += cnt >> 1;
			cnt = 1; color = x;
		}
	}
	if( cnt > 1 ) ans += cnt >> 1;
	printf( "%d\n", ans );
	return 0;
}

Measured memory_bytes: 128
N = input()
Vs =  list(map(int, input().split()))
Cs =  list(map(int, input().split()))
Rs = []
for i, v in enumerate(Vs):
  Rs.append(v - Cs[i])
res = 0
for r in Rs:
  if r > 0:
    res += r
print(res)

Measured memory_bytes: 3060
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll A,B,N;
    cin >> A >> B >> N;
    ll x;
    if(N == 1) x = 1; 
    else {
        if(N < B) {
            if(N%B == 0) x = N-1;
            else x = N;
        }else x = B-1;
    }
    cout << floor(A*x/B) - A * floor(x/B) << endl;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1e9+7;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
typedef pair<ll, ll> pll;

vector<pair<ll, int>> factrized(ll num){
  vector<pair<ll, int>>  res;
 
  for(ll i = 2; i * i <= num; i++){
    if(num % i)continue;
    res.emplace_back(i, 0);
    while(num % i == 0){
      num /= i;
      res.back().second++;
    }
  }
  if(num != 1) res.emplace_back(num, 1);
  return res;
}

int main() {
  long long n, k;
  cin >> n;
  long long ans = 0;

  for (int c=1; c<n; c++){
    vector<pair<ll, int>> res = factrized(n-c);
    long long cnt = 1;
    for (auto it: res){
      cnt *= (it.second + 1);
    }
    ans += cnt;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#input
K, N = map(int, input().split())
A = list(map(int, input().split()))

#output
answer = K

for i in range(1, N):
    temp =  K + A[i-1] - A[i]
    answer = min(temp, answer)

answer = min(answer, A[N-1]-A[0])

print(answer)

Measured memory_bytes: 26548
N, C = map(int, input().split())
ch = [[False for i in range(100001)] for j in range(C+1)]

for i in range(N):
    s, t, c = map(int, input().split())
    for j in range(s, t+1):
        ch[c][j] = True
ans = 0
for i in range(100001):
    count = 0
    for j in range(1, C+1):
        if ch[j][i]:
            count += 1

    ans = max(count, ans)
print(ans)


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000
#define MAX_V 100010

struct edge{int to,cost;};
struct Dijkstra{
	int V;
	vector<edge> G[MAX_V];
	int d[MAX_V];
	void init(int v){V=v;}
	void add_edge(int from,int to,int cost){
		G[from].push_back((edge){to,cost});
	}
	void shortpath(int s){
		fill(d,d+V,INF);
		priority_queue<P, vector<P>, greater<P> > que;
		que.push(P(0,s));
		while(!que.empty()){
			P np=que.top(); que.pop();
			int v=np.second;
			if(d[v]!=INF)continue;
			d[v]=np.first;
			for(int i=0;i<G[v].size();i++){
				que.push(P(d[v]+G[v][i].cost,G[v][i].to));
			}
		}
	}
};

Dijkstra djk;
int V,E,s;

int main(){
	cin.sync_with_stdio(false);
	cin>>V>>E>>s;
	djk.init(V);
	rep(i,E){
		int a,b,c;
		cin>>a>>b>>c;
		djk.add_edge(a,b,c);
	}
	djk.shortpath(s);
	rep(i,V){
		if(djk.d[i]==INF)cout<<"INF"<<endl;
		else cout<<djk.d[i]<<endl;
	}
	return 0;
}

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

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

    vector<int> t(n+1), x(n+1), y(n+1);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for(int i=1; i<=n; i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    for(int i=1; i<=n; i++){
        if(abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) > t[i] - t[i-1]
        || (abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])) % 2 != (t[i] - t[i-1]) % 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
//hikaku site donnyoku ni otosu ippanntekina teku
#include <iostream>
using namespace std;

int n, m;
int c[500], d[500];
int imos[1002];

int main() {
	cin >> n >> m;
	int i;
	for (i = 0; i < n + 2; i++) imos[i] = 0;
	for (i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
		imos[c[i]]++;
		imos[d[i]]--;
	}
	for (i = 1; i < n + 2; i++) imos[i] += imos[i - 1];
	
	int len = 0;
	int ans = n + 1;
	for (i = 0; i < n + 2; i++) {
		if (imos[i]) {
			len++;
		}
		else {
			ans += 2 * len;
			len = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define a(x)begin(x),end(x)
using namespace std;int f,Q,T,F;char C;string S;deque<char>q;main(){for(cin>>S>>Q,q={a(S)};Q--&&cin>>T;)if(T&1)f^=1;else cin>>F>>C,F-1^f?q.push_back(C):q.push_front(C);S={a(q)};if(f)reverse(a(S));cout<<S;}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i=0; i<N; i++) {
        cin >> p[i];
    }
    int count=0;
    for (int j=0; j<N-1; j++) {
        if (p[j]!=j+1) {
            count++;
        }
    }
    if (count>2) {
        cout << "NO"<<endl;
    }else{
        cout << "YES"<<endl;
    }
    return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    char c[53][53];

    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j) cin >> c[i][j];

    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            if(c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

//100までの素数、25個
int prime[] = { 2,  3,  5,  7, 11, 13, 17, 19, 23, 29,
             31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
             73, 79, 83, 89, 97};

int main(){

    int n;
    cin >> n;

    vector<int> factor_count(25);

    for(int i = 1; i <= n; i++){
        int tmp = i;

        rep(j,25){
            while(tmp % prime[j] == 0){
                tmp = tmp / prime[j];
                factor_count[j]++;
            }
        }
    }

    int ans = 0;

    rep(i,25){
        if(factor_count[i] + 1 >= 75) ans++;
    }

    for(int i = 0; i < 24; i++){
        for(int j = i + 1; j < 25; j++){

            if(factor_count[i] + 1 >= 25 && factor_count[j] + 1 >= 3){
                //cerr << factor_count[i] << " " << factor_count[j] << endl;
                ans++;
            }

            if(factor_count[j] + 1 >= 25 && factor_count[i] + 1 >= 3){
                //cerr << factor_count[i] << " " << factor_count[j] << endl;
                ans++;
            }

            if(factor_count[i] + 1 >= 15 && factor_count[j] + 1 >= 5){
                //cerr << factor_count[i] << " " << factor_count[j] << endl;
                ans++;
            }

            if(factor_count[j] + 1 >= 15 && factor_count[i] + 1 >= 5){
                //cerr << factor_count[i] << " " << factor_count[j] << endl;
                ans++;
            }

            rep(k,25){
                if(i == k || j == k) continue;
                if(factor_count[i] + 1 >= 5 && factor_count[j] + 1 >= 5 && factor_count[k] + 1 >= 3){
                    //cerr << factor_count[i] << " " << factor_count[j] << " " << factor_count[k] << endl;
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int n,f[3][105];
int maxx(int x,int y){
	return x>y?x:y;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++){
			scanf("%d",&f[i][j]);
			f[i][j]+=maxx(f[i-1][j],f[i][j-1]);
		}
	printf("%d\n",f[2][n]);
}

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

int main()
{
	ios::sync_with_stdio(false);
	
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a+b==c||a==b+c||c+a==b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	 
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let b : f64 = a.iter().map(|&ai| 1.0 / ai as f64).sum();
    println!("{}", 1.0 / b);
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
vector<long long> v;

void prime_fac(long long n){
    long long K=n;
    for(long long i=2;i<=sqrt(K);i++){
        while(n%i==0){
            n/=i;
            v.emplace_back(i);
        }
    }
    if(n!=1)v.emplace_back(n);


    return;
}

//status unsolved
int main(){

    long long n;
    cin>>n;

    printf("%d:",n);

    prime_fac(n);

    for(int i=0;i<v.size();i++){
        cout<<" "<<v[i];
    }
    cout<<endl;
    return 0;

}
/*


*/



Measured memory_bytes: 3296
for _ in range(50):
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    else:
        if m==-1 or f==-1:
            print("F")
        elif m+f>=80:
            print("A")
        elif m+f>=65:
            print("B")
        elif m+f>=50:
            print("C")
        elif m+f>=30:
            if r>=50:
                print("C")
            else:
                print("D")
        else:
            print("F")



Measured memory_bytes: 5596
# include <stdio.h>
# include <string.h>
# include <iostream>

using namespace std;

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

const int M = 4010;
const int mod = 998244353;

inline int getint() {
  int x=0, f=1; char ch = getchar();
  while(ch < '0' || ch > '9') {
  	if(ch == '-') f = -1;
	  ch = getchar();
  }
  while(ch >= '0' && ch <= '9') {
  	x = (x<<3) + (x<<1) + ch - '0';
	  ch = getchar();
  }
  return x*f;
}

int fac[M], inv[M];
int k, n;

inline int pwr(int a, int b) {
  int ret = 1;
  while(b) {
    if(b & 1) ret = 1ll * ret * a % mod;
    a = 1ll * a * a % mod;
    b >>= 1;
  }
  return ret;
}

inline int C(int n, int k) {
  if(n < 0 || k < 0 || n < k) return 0;
  return 1ll * fac[n] * inv[k] % mod * inv[n - k] % mod;
}

int main() {
//  freopen("dice.in", "r", stdin);
//  freopen("dice.out", "w", stdout);
  ios :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  fac[0] = 1;
  for (int i = 1; i <= 4000; ++ i) fac[i] = 1ll * fac[i-1] * i % mod;
  
  inv[4000] = pwr(fac[4000], mod - 2);
  for (int i = 3999; ~i; -- i) inv[i] = 1ll * inv[i+1] * (i+1) % mod;
  
  cin >> k >> n;
  
  for (int i = 2; i <= k + k; ++ i) {
    int ans = 0, q;
    if(i > k+1) q = 2 * k + 2 - i;
    else q = i;
    int p = q/2;
    for (int j = 0, t; j <= p && j + j <= n; ++ j) {
      t = 1ll * C(p, j) * C(n - 2 * j + k - 1, k - 1) % mod;
      if(j & 1) {
        ans = ans - t;
        if(ans < 0) ans += mod;
      } else {
        ans = ans + t;
        if(ans >= mod) ans -= mod;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}




Measured memory_bytes: 384
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans=0;
    if (a<=k){
        ans+=a;
        if (c<=(k-a-b)){
            ans-=c;
        }
        else if (k-a-b>0){
            ans-=(k-a-b);
        }
    }
    else{
        ans+=k;
    }
    cout << ans;



    return 0;
}


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

int main()
{
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        if (i == A)
        {
            if (S[i] != '-')
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            if (!('0' <= S[i] && S[i] <= '9'))
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <cstdlib>
#include <iostream>
#include <vector>

#define ll long long
#define LINF LLONG_MAX

using namespace std;

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  int mx = max(H, W);
  for (int i = 1;; i++) {
    if (i * mx >= N) {
      cout << i << endl;
      return 0;
    }
  }
}

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

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

int main(void)
{
	char S0[51];
	char S[51];
	char T[51];
	cin >> S0 >> T;
	vector<string> v;

	Rep(i, strlen(S0) - strlen(T) + 1){
		strcpy(S, S0);
		bool flag = false;
		bool f = true;
		Rep(j, strlen(T)){
			if(S[i + j] != '?' && S[i + j] != T[j]) f = false;
		}
		if(f) flag = true;
		if(flag){
			Rep(j, strlen(T)){
				S[i + j] = T[j];
			}
			Rep(k, strlen(S)){
				if(S[k] == '?') S[k] = 'a';
			}
			v.push_back(S);
		}
	}

	if(v.size() == 0){
		cout << "UNRESTORABLE" << endl;
	}else{
		sort(v.begin(), v.end());
		cout << v[0] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n];
    int i,cnt=0;
    for(i=0;i<n;i++)    cin>>arr[i];
    for(i=0;i<n;i+=2)
        if(arr[i]&1)  cnt++;

    cout<<cnt<<endl;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<cstdlib>
#include<map>
#include<stack>
#include<algorithm>
using namespace std;
int n,m,gh[100001];

struct De
{
    int a,b;
}ch[100001];

bool cmp(De x,De y)
{
    return x.b<y.b;
}

int cheak(De x)
{
    for(int i=x.a+1;i<=x.b;i++)
        if(gh[i]==1) return 0;
    return 1;
}

int main()
{
    int c=0;
    scanf("%d %d",&n,&m);
    for(int i=1; i<=m; i++)
        scanf("%d %d",&ch[i].a,&ch[i].b);
    sort(ch+1,ch+m+1,cmp);
    memset(gh,0,n);
    for(int i=1; i<=m; i++)
        if(cheak(ch[i])) gh[ch[i].b]=1,c++;
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 1408
N , A, B = list(map(int, input().split()))
n = range(N+1)
list = [0]
for i in n:
  if A <= i%10+(i//10)%10+(i//100)%10+(i//1000)%10+(i//10000)%10 <= B:
    list.append(i)
print(sum(list))

Measured memory_bytes: 3292
import math

N = int(input())
x = [0] * (N)
y = [0] * (N)
for i in range(N):
    x[i], y[i] = map(int, input().split())

sum = 0

for i in range(N):
    for j in range(N):
      dx = abs(x[i]-x[j])
      dy = abs(y[i]-y[j])
      sum = sum + math.sqrt((dx*dx) + (dy*dy))

    
ave = sum/math.factorial(N)*math.factorial(N-1)

print(ave)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	int n;
	cin >> n;
	ll sum;
	for(int i=0;i<n;i++)
	{
		int k;
		cin >> k;
		sum+=k;
	}
	cout << sum/n << endl;
	return 0;
}

Measured memory_bytes: 1156
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();
        if (a <= 8 && b <= 8) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}


Measured memory_bytes: 23764
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    string s = Console.ReadLine();
    int q = int.Parse(Console.ReadLine());

    int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);

    int countD = 0;
    int countM = 0;
    long countDM = 0;
    long answer = 0;

    for(int i = 0; i < q; i++)
    {
      answer = 0;
      countD = 0;
      countM = 0;
      countDM = 0;
      for(int j = 0; j < n; j++)
      {
        if(j >= nums[i])//左から減らす
        {
          if(s[j-nums[i]] == 'D')
          {
            countDM -= countM;
            countD--;
          }
          else if(s[j-nums[i]] == 'M') countM--;
        }
      
        if(s[j] == 'D') countD++;
        else if(s[j] == 'M')
        {
          countM++;
          countDM += countD;
        }
        else if(s[j] == 'C') answer += countDM;
      }
      Console.WriteLine(answer);
    }
		
	}
}

Measured memory_bytes: 16864
#include<iostream>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c){
      cout<<"No"<<endl;
  }else if(a!=b && b!=c && c!=a){
      cout<<"No"<<endl;
  }else{
      cout<<"Yes"<<endl;
  }
//  cout<<(a==b&&b==c||a!=b&&b!=c&&c!=a?"No":"Yes")<<endl;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int R, G, B, N;
    ll cnt = 0;
    cin >> R >> G >> B >> N;
    REP(r, N+1) {
        REP(g, N+1) {
            if (N - r * R - g * G >= 0 && (N - r * R - g * G) % B == 0) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    getchar(); getchar();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	vector<ll> pref_r(1, 0), pref_g(1, 0), pref_b(1, 0);
	for(auto c:s) {
		pref_r.push_back((c == 'R') + pref_r.back());
		pref_g.push_back((c == 'G') + pref_g.back());
		pref_b.push_back((c == 'B') + pref_b.back());
	}
	ll ans = 0;
	for(int i = 0; i < sz(s); ++ i) {
		if(s[i] == 'G') {
			ans += pref_r[i] * (pref_b[sz(s)] - pref_b[i]);
			int dist = 1;
			while(i - dist >= 0 && i + dist < sz(s)) {
				if(s[i - dist] == 'R' && s[i + dist] == 'B') ans--;
				dist ++;
			}
			ans += pref_b[i] * (pref_r[sz(s)] - pref_r[i]);
			dist = 1;
			while(i - dist >= 0 && i + dist < sz(s)) {
				if(s[i - dist] == 'B' && s[i + dist] == 'R') ans--;
				dist ++;
			}
			
		}
		if(s[i] == 'B') {
			ans += pref_g[i] * (pref_r[sz(s)] - pref_r[i]);
			int dist = 1;
			while(i - dist >= 0 && i + dist < sz(s)) {
				if(s[i - dist] == 'G' && s[i + dist] == 'R') ans--;
				dist ++;
			}
			ans += pref_r[i] * (pref_g[sz(s)] - pref_g[i]);
			dist = 1;
			while(i - dist >= 0 && i + dist < sz(s)) {
				if(s[i - dist] == 'R' && s[i + dist] == 'G') ans--;
				dist ++;
			}
			
		}
		if(s[i] == 'R') {
			ans += pref_g[i] * (pref_b[sz(s)] - pref_b[i]);
			int dist = 1;
			while(i - dist >= 0 && i + dist < sz(s)) {
				if(s[i - dist] == 'G' && s[i + dist] == 'B') ans--;
				dist ++;
			}
			ans += pref_b[i] * (pref_g[sz(s)] - pref_g[i]);
			dist = 1;
			while(i - dist >= 0 && i + dist < sz(s)) {
				if(s[i - dist] == 'B' && s[i + dist] == 'G') ans--;
				dist ++;
			}
			
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3700
'use strict';
const p = s => console.log(s);

// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  let N = input[0].split(" ")[0];
  let sum = 0;

  for (let i = 1; i <= N; i++) {
    if (Math.floor(i%3) === 0 && Math.floor(i%5) === 0) {
      continue;
    } else if (Math.floor(i% 3) === 0) {
      continue;
    } else if (Math.floor(i % 5) === 0){
      continue;
    } else {
      sum += i;
    }
  }
  p(sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 36240