akhauriyash/Code-Regression huggingface dataset:
import bisect
import numpy as np
import math
import itertools
def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    if N <= K:
        print(0)
    elif K == 0:
        print(sum(H))
    else:
        H = sorted(H)
        H = H[:-K]
        print(sum(H))


    return 0
if __name__ == '__main__':
    main()

Measured memory_bytes: 43316
/*     *******************Bismillahir Rahmanir Rahim************************
                          **************************
                          #    MD. ASFAKUL GHANI   #
                          #       *ProMAGFAT*      #
                          #         CSE-25         #
                          #JAHANGIRNAGAR UNIVERSITY#
                          #    Dhaka,Bangladesh    #
                          &&&&&&&&&&&&&&&&&&&&&&&&&#
*/

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

#define fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define Im int main(int argc, char *argv[])
#define ll long long
#define sc scanf
#define pf printf
#define rn0 return 0
#define rn return
#define f0(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define f2(i,n) for(ll i=n-1;i>=0;i--)
#define pi 2*acos(0.0)
#define modulo 1000003
#define dd double
#define PI 3.14159265358979
#define pi 2*acos(0.0)
#define p_b push_back
#define ps push

/*
ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}
*/


Im
{
    fasterIO;

    ll a,b,c;
    cin>>a>>b>>c;
    if (b-a==c-b) cout << "YES";
    else cout << "NO";
    cout << endl;

   // main();

    rn0;
}


Measured memory_bytes: 256
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N;
  string A, B, C;

  sc.scan(N, A, B, C);

  if (A == B && A == C && B == C) {
    writeln("0");
    return;
  }

  int cnt = 0;


  foreach (i; 0 .. N) {
    int num = 2;
    if (A[i] == B[i])
      num--;
    if (A[i] == C[i])
      num--;

    int tmp = 2;

    if (B[i] == A[i])
      tmp--;
    if (B[i] == C[i])
      tmp--;

    int tmp2 = 2;
    if (C[i] == A[i])
      tmp2--;
    if (B[i] == C[i])
      tmp2--;

    cnt += min(tmp, tmp2, num);
  }

  writeln(cnt);
}


Measured memory_bytes: 256
import pprint

nn, mm = map(int, input().split())
#nn, mm = 2, 3

list = []

for i in range(mm):
    p, y = map(int, input().split())
    dict = {}
    dict['i'] = i
    dict['p'] = p
    dict['y'] = y
    list.append(dict)

'''

2 3
1 32
2 63
1 12

dict = {}
dict['i']=1
dict['p']=1
dict['y']=32
list.append(dict)

dict = {}
dict['i']=2
dict['p']=2
dict['y']=63
list.append(dict)

dict = {}
dict['i']=3
dict['p']=1
dict['y']=12
list.append(dict)
'''

#pprint.pprint(list)

list.sort(key=lambda x: x['y'])

#print()
#pprint.pprint(list)


count_dict = {}

for l in list:
    if l['p'] in count_dict:
        count_dict[l['p']] += 1
    else:
        count_dict[l['p']] = 1
    l['ORDER'] = str(count_dict[l['p']]).zfill(6)

#pprint.pprint(count_dict)

list.sort(key=lambda x: x['i'])

#print()


for l in list:
    print(str(l['p']).zfill(6) + l['ORDER'])

'''
#list[0]['xx'] = 111


d = list[0]
d['xx'] = 111

pprint.pprint(list)
'''


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

int main(void) {
    int a,b, x=0,sum=0;

    cin >> a>>b;

    for(int i=1; i<(b-a); i++){
      sum += i;
    }

    cout<< sum-a << endl ;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 200000
int max(int,int);
int min(int,int);


int main(){
  int n,i,maxv,minv;
  int R[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
  }
  maxv=-2000000000;
  minv=R[0];
  for(i=1;i<n;i++){
    maxv=max(maxv,R[i]-minv);
    minv=min(minv,R[i]);
  }
  printf("%d\n",maxv);



  return 0;
}

int max(int a,int b){
  if(a>b){
    return a;
  }
  else{
    return b;
  }
}

int min(int a,int b){
  if(a>b){
    return b;
  }
  else{
    return a;
  }
}



Measured memory_bytes: 2580
N = int(input())

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

money = abs(A[0]) + abs(A[N-1])

for i in range(1,N):
  money += abs(A[i]-A[i-1])
  
print(money - abs(A[0]) - abs(A[1] - A[0]) + abs(A[1]))

for i in range(1,N-1):
  print(money - abs(A[i+1]-A[i]) - abs(A[i]-A[i-1]) + abs(A[i+1]-A[i-1]))

print(money - abs(A[N-1]-A[N-2]) - abs(A[N-1]) + abs(A[N-2]))

Measured memory_bytes: 14172
#include <iostream>

using namespace std;

int compare(const void *a, const void *b) {
  return *(int *)b - *(int *) a;
}

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

  int A[N], total = 0, tmp;
  for(int i = 0; i < N; i++) {
    cin >> tmp;
    A[i] = tmp;
    total += tmp;
  }

  qsort(A, N, sizeof(int), compare);
  if(A[M - 1] * 4 * M < total) {
    cout << "No";
  } else {
    cout << "Yes";
  }

  return 0;
}



Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i];}cout << endl;}

int main(){
    string s;
    int k;
    cin >> s >> k;
    char ans = '1';
    int cnt = 0;
    rep(i,s.size()){
        if (s[i] != '1'){ans = s[i];break;}
        else cnt++;
    }
    if (k <= cnt)cout << '1';
    else cout << ans;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
using namespace std;

class abc084a {
public:
	void solve(std::istream& in, std::ostream& out) {
        int m = 0;
        in >> m;

        out << 24 + (24 - m) << endl;

	}
};


int main() {
	abc084a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    float s ;
    cin>>s;

      double length = s / 3; 
  
    s -= length; 
  
    // finding breadth 
    double breadth = s / 2; 
  
    // finding height 
    double  height = s - breadth; 
  
    cout<<setprecision(8)<<fixed<<(length * breadth * height)<<endl; 
}


Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-08-03
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<vector<pair<long long,int>>> adj(n);
    for (int i = 0; i < n-1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        adj[u].push_back({w, v});
        adj[v].push_back({w, u});
    }
    int queries, k;
    cin >> queries >> k;
    k--;
    
    priority_queue<pair<long long,int>> q;
    vector<long long> dist(n, -1);
    q.push({0, k});
    while (!q.empty()) {
        auto node = q.top();
        q.pop();
        long long d = -node.first;
        int u = node.second;
        dist[u] = d;
        
        for (auto e : adj[u]) {
            int w = e.first, v = e.second;
            if (dist[v] != -1) continue;
            q.push({-(d + w), v});
        }
    }
    
    for (int i = 0; i < queries; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        cout << dist[u] + dist[v] << '\n';
    }
    return 0;
}

Measured memory_bytes: 13988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main(void){
    using namespace  std;
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    long length1 = SZ(A);

    sort(all(A));
    auto result = unique(all(A));
    A.erase(result, A.end());
    long length2 = SZ(A);

    cout << (length1 == length2? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
X = list(map(int,input().split()))
X.insert(0,0)
A = sorted(X[:])
a = A[N//2]
b = A[N//2+1]
for i in range(1,N+1):
    if X[i]>a:
        print(a)
    else:
        print(b)

Measured memory_bytes: 104788
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;

struct Point {
    int y, x;
};

int main(){
    int H, W, D;
    cin >> H >> W >> D;
    int n = H*W;
    vector<Point> v(n+1);
    rep(i, H){
        rep(j, W){
            int A;
            cin >> A;
            v[A] = {i, j};
        }
    }

    vector<int> dist(n+1);
    rep(i, D){
        for(int j=i+D; j<=n; j+=D){
            dist[j] = abs(v[j].x - v[j-D].x) + abs(v[j].y - v[j-D].y);
            dist[j] += dist[j-D];
        }
    }

    int Q;
    cin >> Q;
    rep(i, Q){
        int l, r;
        cin >> l >> r;
        cout << dist[r] - dist[l] << endl;
    }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

#define _ << ": " <<
#define watch1(var1) (cerr << #var1 _ var1 << '\n')
#define watch2(var1, var2) cerr << #var1 _ var1 << ", " << #var2 _ var2 << '\n';
#define watch3(var1, var2, var3) cerr << #var1 _ var1 << ", " << #var2 _ var2 << ", " << #var3 _ var3 << '\n';
#define wloop(size, arr) cerr << #arr << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size];

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ints(a...) int a; read(a)
#define longs(a...) int64_t a; read(a)

const int MAX = 5e5 + 10;
vector<int64_t> fact(MAX), ifact(MAX);
const int MOD = 1e9 + 7;

int64_t pow_n(int64_t a, int p, const int mod = MOD) {
    int64_t ans = 1;
    a %= mod;
    while(p) {
        if(p & 1) ans = ans * a % mod;
        a = a * a % mod;
        p >>= 1;
    }
    return ans;
}

int add(int64_t a, int64_t b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}

int sub(int a, int b) {
    a = a-b;
    if (a < 0) a += MOD;
    return a;
}

int mul(int64_t a, int64_t b) {
    return a * b % MOD;
}

int64_t inv(int b) {
    return pow_n(b, MOD - 2);
}

void precal() {
    fact[0] = fact[1] = 1;
    for (int i = 2; i < MAX; i++)
        fact[i] = fact[i - 1] * i % MOD;
    
    ifact[MAX - 1] = inv(fact[MAX - 1]);
    for (int i = MAX - 2; ~i; i--) ifact[i] = ifact[i + 1] * (i + 1) % MOD;
}

int ncr(int n, int r) {
    if (r > n) return 0;
    return mul(mul(fact[n], ifact[r]), ifact[n - r]);
}

int64_t sq(int64_t x) {
    return x * x % MOD;
}

void solve() {
    precal();
    longs(n, m);
    int64_t sum = 0;
    for (int k = 0; k <= n; k++) {
        int64_t c1 = ncr(n, k);
        int64_t p1 = mul(ncr(m, k), fact[k]);
        int64_t p2 = sq(mul(ncr(m - k, n - k), fact[n - k]));
        if (k%2 == 0) sum = add(sum, mul(mul(c1, p1), p2));
        else sum = sub(sum, mul(mul(c1, p1), p2));
    }
    cout << sum;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------


/*
for(int i=0;i<n;i++) {
  for(int j=i;j<n) {
    if(s.substr(0, i) + s.substr(j, n-j+1) == "keyence") {
      hoge;
    }
  }
}
*/

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

  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (s.substr(0, i) + s.substr(j, n-j+1) == "keyence") {
        puts("YES");
        return 0;
      }
    }
  }

  puts("NO");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
      map<int,vector<int> > m;
      int n;
      cin >> n;
      int a[n];
      for(int i=0;i<n;i++)
      {
            cin >> a[i];
            m[a[i]].push_back(i);
      }
      int dp[n+1]={0};

      auto it = m.find(1);
      int num=-1,ind=-1;
      if( it!=m.end() )
      {
            // num = 1;
            // ind = it->second;
            // int l = 2;
            // while(1)
            // {
            //       it = m.find(l);
            //       if( it != m.end() and it->second > ind )
            //       {
            //             l++;
            //             ind = it->second;
            //       }
            //       else
            //             break;
            // }
            // // cout << l-1 << endl;
            // cout << n - l + 1 << endl;
            dp[1] = 1;
            vector<int> t = it->second;
            int last = t[0];
            for(int i=2;i<=n;i++)
            {
                  it = m.find(i);
                  dp[i] = 0;
                  int flag = 0;
                  if( it !=m.end() )
                  {
                  		vector<int> temp1 = m.find(i-1)->second;
                        vector<int> temp2 = it->second;
                        // cout << i-1 << " : ";
                        // for(int i=0;i<temp1.size();i++)
                        // 	cout << temp1[i] << " ";
                        // cout << endl;
                        // cout << i << ": ";
                        // for(int i=0;i<temp2.size();i++)
                        // 	cout << temp2[i] << " ";
                        // cout << endl;
                        // cout << "LAST: "<< last << endl;
                        // cout << endl;
                    	for(int k=0;k<temp2.size();k++)
                    	{
                    		for(int j=0;j<temp1.size();j++)
                    		{
                    			if( temp2[k] > last and temp2[k] > temp1[j] )
                    			{

                    				dp[i] = max( dp[i],dp[i-1]+1 );
                    				flag=1;
                    			}
                    		}
                    	}
                    	for(int j=0;j<temp2.size();j++)
                    	{
                    		if(temp2[j] > last)
                    		{
                    			last = temp2[j];
                    			break;
                    		}
                    	}
                  }
                  if(flag==0)
                  	break;
            }
            // for(int i=1;i<=n;i++)
            //       cout << dp[i] << " ";
            // cout << endl;
            int m = *max_element(dp,dp+n+1);
            cout << n-m << endl;

      }
      else
            cout << "-1\n";

}


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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;

#define IOSWORK ios::sync_with_stdio(0); cin.tie(0)
#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define VAR(v, n) typeof(n) v = (n)
#define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 

int a,b,c,k;
int main(){
	
	IOSWORK;
	cin>>a>>b>>c;
	cin>>k;
	
	if(a>=b&&a>=c)
		cout<<b+c+pow(2,k)*a;
	else if(b>=c&&b>=a)
		cout<<c+a+pow(2,k)*b;
	else
		cout<<a+b+pow(2,k)*c;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll S;
  cin >> S;
  if((S/100 == 0 || S/100 > 12) && (S%100 == 0 || S%100 > 12)) cout << "NA" << rt;
  else if(S/100 == 0 || S/100 > 12) cout << "YYMM" << rt;
  else if(S%100 == 0 || S%100 > 12) cout << "MMYY" << rt;
  else cout << "AMBIGUOUS" << rt;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

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

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


template <typename T>
T gcd(T a, T b) {
    while (b != 0) {
        T c = a;
        a = b;
        b = c % b;
    }
    return a;
}

template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll v1 = (B / C) - (A - 1) / C;
    ll v2 = (B / D) - (A - 1) / D;
    ll v3 = (B / lcm(C, D)) - (A - 1) / lcm(C, D);
    cout << (B - A + 1) - (v1 + v2 - v3) << endl;
}


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

int main(){

  int d;
  while(cin >> d){
    int  S = 0;
    for(int i = 1; i < 600/d ; i++){
      S += (d*i)*(d*i);
    }
    S *= d;
    cout << S <<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n;
int main(){
	cin >> n;
	ll m,l;
	m = n;
	l = 0;

	while(m > 0) {
		l *= 10;
		l += m % 10;
		m /= 10;
	}
	if(n == l) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main()
{
    int n, m;
    std::cin >> n >> m;

    std::vector<int> a(m);
    for (int i = 0; i < m; i++) {
        std::cin >> a[i];
    }

    std::cout << std::max(n - std::accumulate(a.begin(), a.end(), 0), -1) << std::endl;
}


Measured memory_bytes: 3636
/**
 * Author: Behradm
 * Created: 19-04-2020 16:41:04
 * In the Name of God
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define LOCAL

#ifdef LOCAL
	#define debugi(x) cerr << "{" << #x << "}: " << (x) << '\n'
	#define debug(v, begin, end) cerr << "{ | "; for(auto i = begin; i < end; i++){cerr << #v << "[" << i << "]: " << v[i] << " | ";} cerr << " }\n"
	#define debugp(a, b) cerr << "\n{ " << a << " " << b << " }\n"
#else
	#define debugi(x) 42
	#define debug(v, begin, end) 42
	#define debugp(a, b) 42 
#endif

const int maxn = 2e5+1;
int cnt[maxn] = {};

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout.tie(0);
	cout.precision(6);
	int n;
	cin >> n;
	for(int i = 0; i < n-1; i++){
		int a;
		cin >> a;
		cnt[a]++;
	}	

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



Measured memory_bytes: 4320
#include <bits/stdc++.h>
using namespace std;
char a[510][510],b[510][510],c[510][510];
int h,w;
int main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		scanf("%s",c[i]);
	}
	for(int i=0;i<h;i++)
	{
		a[i][0]=b[i][w-1]='#';
		if(i%2)
		{
			for(int j=1;j<w-1;j++)
			{
				a[i][j]='#';
			}
		}
		else
		{
			for(int j=1;j<w-1;j++)
			{
				b[i][j]='#';
			}	
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			a[i][j]=((a[i][j]=='#'||c[i][j]=='#')?'#':'.');
			b[i][j]=((b[i][j]=='#'||c[i][j]=='#')?'#':'.');
		}
	}
	for(int i=0;i<h;i++)
	{
		printf("%s\n",a[i]);
	}
	printf("\n");
	for(int i=0;i<h;i++)
	{
		printf("%s\n",b[i]);
	}
	return 0;
}

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

int main()
{
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int anum = sa.size();
    int bnum = sb.size();
    int cnum = sc.size();
    string turn = "a";
    string ans;

    while (1)
    {
        if (turn == "a") {
            if (sa.size() == 0) {
                ans = "A";
                break;
            }
            turn = sa[0];
            sa.erase(sa.begin());
        } else if (turn == "b") {
            if (sb.size() == 0) {
                ans = "B";
                break;
            }
            turn = sb[0];
            sb.erase(sb.begin());
        } else {
            if (sc.size() == 0) {
                ans = "C";
                break;
            }
            turn = sc[0];
            sc.erase(sc.begin());
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,*a=`dd`.split.map &:to_i;c=0;i=g=r=1;0.upto(n-g=r=1){|i|g>a[i]?r*=i+2-c+=1:g+=2};1.upto(n-c){|i|r=r*i%(10**9+7)};p r

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;
const double    PI  = acos(-1);

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    cout << fixed << setprecision(4);

    // 入力
    // 長さ
    int a, b;
    // 角度
    double C;
    cin >> a >> b >> C;

    //周の長さ
    double L;
    // 高さ
    double h = b * sin(PI * C / 180);
    // cの長さ
    double c = sqrt(a * a + b * b - 2 * a * b * cos(PI * C / 180));
    // 周の長さ
    L = a + b + c;
    // 面積
    double S = a * h / 2;

    cout << S << "\n";
    cout << L << "\n";
    cout << h << "\n";

    return 0;
}



Measured memory_bytes: 3536
n, m = map(int, input().split())
py = [[i] + list(map(int, input().split())) for i in range(m)]
py.sort(key=lambda x:(x[1],x[2]))

city = py[0][1]
num = 0

for i in py:
    if i[1] == city:
        num += 1
    else:
        num = 1
        city = i[1]
    i.append(num)

py.sort(key=lambda x:[x[0]])

for i in py:
    print('{:06}{:06}'.format(i[1], i[3]))

Measured memory_bytes: 40444
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

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

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

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

ll f(ll N) {
  if (N <= 9) return N;
  return max(f(N / 10) + N % 10, f(N / 10 - 1) + 9);
}

void solve(ll N) {
  cout << f(N) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	solve(N);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else
        cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3092
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)
            

Measured memory_bytes: 7716
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define all(x) (x).begin(), (x).end()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N;
int O, P, Q, R, S, T, U, V, W, X, Y, Z;
string s;
int ans;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> s;

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

	return 0;
}

Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_5_D
//p177.cpp


#include<iostream>
using namespace std;

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge( int A[] , int n , int left , int mid , int right){
  int i,j,k;
  llong cnt = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  for( i = 0 ; i < n1 ; i++) L[i] = A[left + i];
  for( i = 0 ; i < n2 ; i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0 ;
  for( k = left ; k < right ; k++ ){
    if( L[i] <= R[j] ){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
      cnt += n1 - i; //= mid + j - k - 1
    }
  }
  return cnt;
}

llong mergeSort(int A[] , int n , int left , int right){
  int mid;
  llong v1 , v2 , v3;
  if( left + 1 < right ){
    mid = (left + right) / 2;
    v1 = mergeSort( A , n , left , mid );
    v2 = mergeSort( A , n , mid , right );
    v3 = merge( A , n , left , mid , right );
    return v1 + v2 + v3;
  }else return 0;
}

int main(){
  int A[MAX] , n , i;

  cin >> n;
  for( i = 0 ; i < n ; i++ ){
    cin >> A[i];
  }

  llong ans = mergeSort( A , n , 0 , n );
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 4668
from collections import deque
N,M,*L,S,T = map(int,open(0).read().split())
G = [[] for _ in range(N)]
step = [0 for _ in range(N)]
step[S-1] = 1
for u,v in zip(*[iter(L)]*2):
	G[u-1].append(v-1)
q = deque([(S-1,0)])
while q:
	cur,d = q.popleft()
	for nxt in G[cur]:
		if nxt==T-1 and (d+1)%3==0:
			print((d+1)//3)
			exit()
		if not step[nxt] & 1<<((d+1)%3):
			step[nxt] |= 1<<(d+1)%3
			q.append((nxt,d+1))
print(-1)

Measured memory_bytes: 26948
import copy

def partition(p, r):
    i = p
    for j in range(p, r):
        if A[r][1] >= A[j][1]:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[r], A[i] = A[i], A[r]
    return i

def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q-1)
        quick_sort(q+1, r)

def is_stable():
    for i in range(N-1):
        if A[i][1] == A[i+1][1]:
            small_idx, large_idx = 0, 0
            for j in range(N):
                if A[i] == orig_list[j]:
                    small_idx = j
                elif A[i+1] == orig_list[j]:
                    large_idx = j
            if small_idx > large_idx:
                return False
    return True


N = int(input())
A = []
for _ in range(N):
    suit, num = input().split()
    num = int(num)
    A.append([suit, num])
orig_list = copy.deepcopy(A)

quick_sort(0, N-1)

is_stable = is_stable()
if is_stable:
    print("Stable")
else:
    print("Not stable")

for card in A:
    print("%s %d" % (card[0], card[1]))


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

char s[1000];
char* p;

int main()
{
	cin >> s;
	p=s;
	int count = 0;
	while(*p != '\0'){
		p++;
		count++;
	}
	for(int i=0;i<count;i++){
		if(s[i]=='A' || s[i]=='B' || s[i]=='C'){
			cout << static_cast<char>(s[i]-3+26);
		}else{
			cout << static_cast<char>(s[i]-3);
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */

  NodePointer n;
  n = nil->next;

  while(n!=nil && key != n->key){
    n = n->next;
  }
  if(n == nil)return NULL;
  return n;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer n;
  n = nil->prev;
  if(n == nil)return;
  deleteNode(n);
}

void delete(int key){
  /* your code */

  NodePointer n;
  if(( n = listSearch(key)) != NULL){
      deleteNode(n);
    }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /*your code */
  x->next=nil->next;
  x->prev=nil;
  nil->next=x;
  x->next->prev=x;

}
int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
#define INF 1000000000
#define pow10 tipa_pow10
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;

int main()
{
    double n , m;
    int d;
    cin >> n >> m >> d;
    if(!d)
    {

        cout << fixed << setprecision(10) << ((n - d) * (m - 1)) / (n * n);
    }
    else
        cout << fixed << setprecision(10) << 2 * ((n - d) * (m - 1)) / (n * n);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    rep(i, M) cin >> X[i];

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

    if (N >= M) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> diff;
    rep(i, M-1) {
        diff.push_back(X[i+1] - X[i]);
    }

    sort(diff.begin(), diff.end(), greater<int>());

    int res = X.back() - X[0];
    rep(i, min((int)diff.size(), N - 1)) res -= diff[i];
    cout << res << endl;

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    string s2;
    s2=s.substr(5,2);
    int a;
    a=atoi(s2.c_str());
    if(a>=5){
        cout << "TBD" << endl;
    }
    else{
        cout << "Heisei" << endl;
    }

    

    return 0;
}

Measured memory_bytes: 3556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int ans = 0;
        int count = 0;
        int current = sc.nextInt();
        for(int i = 1; i < n; i++) {
        	int next = sc.nextInt();
        	if(current >= next) {
        		count++;
        		ans = Math.max(ans, count);
        	} else {
        		count = 0;
        	}
        	current = next;
        }
        System.out.println(ans);
	}
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K;
int L[15], R[15];
ll DP[int(5e5+5)], sum[int(5e5+5)];

int main(){
  cin >> N >> K;
  for (int i = 0; i < K; i++){
    cin >> L[i] >> R[i];
  }

  DP[1] = 1;
  for (int i = 1; i <= N; i++){
    if (i >= 2){
      sum[i] += sum[i-1]; sum[i] %= MOD2;
      DP[i] = sum[i];
    }
    for (int j = 0; j < K; j++){
      sum[i + L[j]] += DP[i];
      sum[i + R[j] + 1] -= DP[i];
    }
  }
  if (DP[N] < 0) DP[N] += MOD2;
  cout << DP[N] << endl;

  return 0;
}



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

int main() {
	int a,b;
	cin >> a >> b;
	if(a<b){
		cout << "a < b" << endl;
	}
	else if(a==b){
		cout << "a == b" << endl;
	}
	else{
		cout << "a > b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
import sys

n, we = map(int, input().split())

cf = sorted( [[int(x) for x in sys.stdin.readline().split()] for _ in range(n)] )

dp=[0]*(we+1)
cnt=0

for w,c in cf:
    cnt=cnt+w
    for j in range(min(cnt, we-w), -1, -1):
        if dp[j+w]<(dp[j] + c): dp[j+w]=dp[j] + c

print(max(dp))

Measured memory_bytes: 7736
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;

const double ESP = 1e-8;

class Point
{
public:
	double x, y;

	Point(double x = 0, double y = 0) : x(x), y(y) {}

	Point operator + (Point a) { return Point(x + a.x, y + a.y); }
	Point operator - (Point a) { return Point(x - a.x, y - a.y); }
	Point operator * (double a) { return Point(x * a,y * a); }
	Point operator / (double a) { return Point(x / a, y / a); }

	double abs() { return sqrt(norm()); }
	double norm() { return x * x + y * y; }
};

typedef Point Vector;

struct Segment
{
	Point p1, p2;
};

typedef Segment Line;

double dot(Vector a, Vector b)
{
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b)
{
	return a.x * b.y - a.y * b.x;
}

int ccw(Point p0, Point p1, Point p2)
{
	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if (cross(a, b) > ESP) return 1;
	if (cross(a, b) < -ESP) return -1;
	if (dot(a, b) < -ESP) return 2;
	if (a.norm() < b.norm()) return -2;
	return 0;
}

bool intersect(Segment a, Segment b)
{
	Point p1, p2, p3, p4;
	p1 = a.p1, p2 = a.p2;
	p3 = b.p1, p4 = b.p2;

	return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

double Distance_LP(Line l, Point p)
{
	return fabs(cross(l.p2 - l.p1, p - l.p1) / (l.p2 - l.p1).abs());
}

double Distance_SP(Segment s, Point p)
{
	if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return (p - s.p2).abs();
	if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return (p - s.p1).abs();
	return Distance_LP(s, p);
}

double Distance_SS(Segment a, Segment b)
{
	if (intersect(a, b)) return 0.0;
	return min(min(Distance_SP(a, b.p2), Distance_SP(a, b.p1)), min(Distance_SP(b, a.p2), Distance_SP(b, a.p1)));
}

void read(Point& a)
{
	scanf("%lf%lf", &a.x, &a.y);
}

int main()
{
	int q;
	scanf("%d", &q);

	while (q--)
	{
		Point p[4];
		for (int i = 0; i < 4; i++) read(p[i]);

		Segment s1, s2;
		s1.p1 = p[0], s1.p2 = p[1];
		s2.p1 = p[2], s2.p2 = p[3];

		printf("%.10lf\n", Distance_SS(s1, s2));
	}
}


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

#define MOD 1000000007

typedef long long ll;

using namespace std;

int main() {
    ll n, ans = 1;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) cin >> a.at(i);
    sort(a.begin(), a.end());
    for (ll i = n - 1; i >= 0; --i) {
        if (a.at(i) != (i + n % 2) / 2 * 2 + (n - 1) % 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    for (ll i = 0; i < n / 2; ++i) ans = ans * 2 % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll ksm(int a,int b)
{
	ll ans =1;
	while(b)
	{
		if(b&1) ans=(ll)ans*a%mod;
		b/=2;
		a=(ll)a*a%mod;
	}
	return ans%mod;
}
int main()
{
	int n,k,s[5000];
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&s[i]);
	}
	int h[5000],sum[5000];
	memset(h,0,sizeof h);
	memset(sum,0,sizeof sum);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<i;j++)
			if(s[i]>s[j])
				sum[i]++;
		for(int j=i+1;j<n;j++)
			if(s[i]>s[j])
				h[i]++;
		sum[i]+=h[i];
	//	cout<<sum[i]<<' '<<h[i]<<endl;
	}
	ll ans=0;
//	ll res=ksm(2,mod-2);
//	cout<<res<<endl;
	//cout<<(ll)k*(k-1)/2%mod<<endl; 
	for(int i=0;i<n;i++)
	{
		ans=(ans%mod+(ll)h[i]*k%mod)%mod;
		ans=(ans%mod+((((ll)k*(k-1)/2)%mod)%mod*sum[i])%mod)%mod;
	}
	cout<<ans%mod;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
//#include<array>

#define rep(i,n) for(int i=0;i<(n);i++)
#define LL long long int

using namespace std;

int main(){
    LL n,m;
    cin >> n>>m;
    vector<LL> l(m),r(m);
    rep(i,m){
        cin >> l[i]>>r[i];

    }
    LL Max=n,Min=1;
    rep(i,m){
        Max=min(Max,r[i]);
        Min=max(Min,l[i]);
    }
    cout<< max(Max-Min+1,(LL)0)<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int A[25], B[250], C[25];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> A[i];
    for(int i = 1; i <= N; i++) cin >> B[i];
    for(int i = 1; i < N; i++) cin >> C[i];
    int ans = 0;
    for(int i = 1; i <= N; i++) ans += B[i];
    for(int i = 1; i < N; i++) {
        if(A[i] + 1 == A[i+1]) {
            ans += C[A[i]];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int( input() )
alphabets = "abcdefghij"[ :N ]
types= ["a"]

for _ in range(N-1):
  for j in range(len(types)):
    target=types.pop(0)
    #print(set(target))
    for k in range(len(set(target))+1):
      types.append(target+alphabets[k])
    #print(types)
types.sort()
for each in types:
  print(each)

Measured memory_bytes: 12668
n,d = map(int,input().split())
x = [[0]]*n
for i in range(n):
  x[i] = list(map(int,input().split()))
pairs = 0
sqset = set()
for i in range(1,127):
  sqset.add(i**2)
for i in range(n-1):
  for j in range(1,n-i):
    dstsq = 0
    for k in range(d):
      dstsq += (x[i][k]-x[i+j][k])**2
    if dstsq in sqset:
      pairs += 1
print(pairs)

Measured memory_bytes: 3064